{"lang": "GNU C", "source_code": "#include\n#include \nint main()\n{\n\tint n,arr[100],i,j,ans[50],t=0;\n\tbool b;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i\nvoid main()\n{\nint t[4] ; \nint i,j ;\nfor(i=0;i<4;i++) scanf(\"%d\",&t[i]) ; \nfor(i=0;i<3;i++){\n\tfor(j=i+1;j<4;j++){\n\t\tif (t[i]\n\nint comp(const void *p,const void *q)\n{\n\treturn (int *)p-(int *)q;\n}\nint main()\n{\n\tint n,k;\n\tint i,j;\n\tint a[51];\n\tint flag=0;\n\tscanf(\"%d %d\",&n,&k);\n\tfor(i=0;i\n#include \nint main()\n{\n int str[999], str1[999];\n while(scanf(\"%s %s\", str, str1))\n {\n if(strcmp(str, str1)==0) printf(\"%s\\n\", str1);\n else printf(\"%s\\n\", str);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9f072c19af7c5b9944eb8e1cd5818d80", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\nint n,k,i=0,j,a[50];\nint sum=0;\nscanf(\"%d %d\",&n,&k);\nfor(j=0;j\n#include \n\nint main() {\n\tint size, i, min_v, min_p, lvl;\n\tint v[100], diff[100];\n\t\n\tscanf(\"%d\", &size);\n\t\n\tif(size < 3 || size > 1000)\n\t\treturn 1;\n\t\n\tmin_v = 1000;\n\tmin_p = -1;\n\tlvl = 0;\n\t\n\tfor(i = 0; i < size; i++) {\n\t\tscanf(\"%d\", &v[i]);\n\t\tif(i > 0) {\n\t\t\tdiff[i] = v[i] - v[i-1];\n\t\t\tif(min_v > diff[i] && i < size - 1) {\n\t\t\t\tmin_v = diff[i];\n\t\t\t\tmin_p = i;\n\t\t\t}\n\t\t\t\n\t\t\tif(lvl < diff[i])\n\t\t\t\tlvl = diff[i];\n\t\t}\n\t}\n\t\n\tv[min_p] = v[min_p - 1]; \n\tif(lvl < v[min_p+1] - v[min_p]) \n\t\tlvl = v[min_p+1] - v[min_p];\n\t\n\tprintf(\"%d\\n\", lvl);\n\n\treturn 1;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b3eaeec6c7d377f4a0eb032dabe82061", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){int count=0;\nchar s[101];\nscanf(\"%s\",s);\nint dif=s[0]-'a';\nif(dif<0){dif=dif*(-1);}\nif(dif>13){\n count=26-dif;}\n else{count=dif;}\nint i=1;\nwhile(s[i]!='\\0'){\n dif=s[i]-s[i-1];\n if(dif<0){dif=dif*(-1);}\n if(dif>13){\n count=26-dif+count;}\n else{count=dif+count;}\n}\nprintf(\"%d\",count);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4bbcfbdcfaa128a278841ab6042a1b1d", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,a,t[104],i,left,right,ans=0,flag1=0,flag2=0;\n\tscanf(\"%d%d\",&n,&a);\n\tleft=a-1;\n\tright=a-1;\n\tfor(i=0;i=0 || right0)\n\t\t{\n\t\t\tleft=left-1;\n\t\t\tflag1=1;\n\t\t}\n\t\tif(right\nint main()\n{\n while(1){\n int n,m;\n scanf(\"%d %d\",&n,&m);\n if(m==0) printf(\"1\");\n else if(n==m) printf(\"0\");\n else if(n/m==2||n/m>2) printf(\"%d\",m);\n else if(n/m<2) printf(\"%d\",(n-m));\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "5448f4b71e981e913086b8e11bdf9646", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint x,y,z,i,j,q=0,a1,a2,b1,b2,c,f1,f2;\n\tscanf(\"%d %d %d %d\",&a1,&b1,&a2,&b2);\n\tif(a1==a2 || b1==b2)\n\t\tprintf(\"1 \");\n\telse\n\t\tprintf(\"2 \");\n\tif(a1>a2)\n\t\tf1=a1-a2;\n\telse\n\t\tf1=a2-a1;\n\tif(b1>b2)\n\t\tf2=b1-b2;\n\telse\n\t\tf2=b2-b1;\n\tif(f1-f2==0)\n\t\tprintf(\"1 \");\n\telse if((f1%2+f2%2)%2==0)\n\t\tprintf(\"2 \");\n\telse\n\t\tprintf(\"0 \");\n\twhile(f1>=1 && f2>=1)\n\t{\n\t\tq++;\n\t\tf1--;\n\t\tf2--;\n\t}\n\tif(f1>0)\n\t\tq+=f1;\n\tif(f2>0)\n\t\tq+=f2;\n\tprintf(\"%d\",q);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e0624118c1b0fd96aeee2786c37dc0a5", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \nvoid main() {\nlong int n;\nlong int k;\nlong int rest;\nlong int res;\nscanf(\"%d %d\", &n, &k);\n \nrest = n % k;\nres = n - rest + k;\n \nprintf(\"%d\", &res);\n \n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "047c597a8f35f5ad32db6121f1aa66c5", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \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))\n#define inf 10000000\n\nint d[101][51][2][2];\nchar s[101];\nint n, k;\n\nint\nmain(void)\n{\n while(isalpha(s[n++] = getchar()))\n ;\n --n;\n int i, j, p, t;\n scanf(\"%d\", &k);\n for(i = 0; i < n; ++i){\n for(j = 0; j <= k; ++j){\n d[i][j][0][0] = -inf;\n d[i][j][0][1] = inf;\n d[i][j][1][0] = -inf;\n d[i][j][1][1] = inf;\n }\n }\n for(j = 0; j <= k; ++j){\n if((s[0] == 'F' && j % 2 == 0) || (s[0] == 'T' && j % 2 == 1)){\n d[0][j][0][0] = 1;\n d[0][j][0][1] = 1;\n } else {\n d[0][j][1][0] = 0;\n d[0][j][1][1] = 0;\n }\n }\n for(i = 1; i < n; ++i){\n for(j = 0; j <= k; ++j){\n for(p = 0; p <= j; ++p){\n if((s[i] == 'F' && p % 2 == 0) || (s[i] == 'T' && p % 2 == 1)){//one step\n for(t = 0; t < 2; ++t){\n if(abs(d[i - 1][j - p][0][t]) != inf){\n d[i][j][0][0] = max(d[i - 1][j - p][0][t] + 1, d[i][j][0][0]);\n d[i][j][0][1] = min(d[i - 1][j - p][0][t] + 1, d[i][j][0][1]);\n }\n if(abs(d[i - 1][j - p][1][t]) != inf){\n d[i][j][1][0] = max(d[i - 1][j - p][1][t] - 1, d[i][j][1][0]);\n d[i][j][1][1] = min(d[i - 1][j - p][1][t] - 1, d[i][j][1][1]);\n }\n }\n } else {\n for(t = 0; t < 2; ++t){\n if(abs(d[i - 1][j - p][1][t]) != inf){\n d[i][j][0][0] = max(d[i - 1][j - p][1][t], d[i][j][0][0]);\n d[i][j][0][1] = min(d[i - 1][j - p][1][t], d[i][j][0][1]);\n }\n if(abs(d[i - 1][j - p][0][t]) != inf){\n d[i][j][1][0] = max(d[i - 1][j - p][0][t], d[i][j][1][0]);\n d[i][j][1][1] = min(d[i - 1][j - p][0][t], d[i][j][1][1]);\n }\n }\n }\n }\n }\n }\n int ans = 0;\n for(i = 0; i < 2; ++i){\n for(j = 0; j < 2; ++j){\n if(abs(d[n - 1][k][i][j]) != inf)\n ans = max(ans, abs(d[n - 1][k][i][j]));\n }\n }\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0fff284d630e1fb9c2779cd8e1bf92d0", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\ntypedef long long LL_t;\n\nint GetSn(LL_t num)\n{\n\tint res=0;\n\twhile(num)\n\t{\n\t\tnum/=10;\n\t\t++res;\n\t}\n\treturn res;\n}\n\nint main()\n{\n int Sn,i,k;\n LL_t w,m,Max,Ans=0;\n scanf(\"%I64d %I64d %d\",&w,&m,&k);\n\twhile(w)\n\t{\n\t\tSn=GetSn(m);\n\t\tMax=1;\n\t\tfor(i=0;i\nint main()\n{\n int a,b,c;\n scanf(\"%d %d\",&a,&b);\n c=a/b;\n while (a>0)\n {\n\n\n if(a%b>=0 && c%2!=0) printf(\"YES\\n\");\n else if(a%b==0 && c%2==0) printf(\"NO\\n\");\n else printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a9941020590af3eaf18505efbf4ef144", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n void main()\n {\n int l,r,a,x ;\n\n\tdo{\n\t\tscanf(\"%d\",&l);\n\t\tscanf(\"%d\",&r);\n\t\tscanf(\"%d\",&a);\n\t}while(((l<0)||(l>100))||((r<0)||(r>100))||((a<0)||(a>100)));\n\n\t\t while (a>0)\n\t\t{\n\t\t\tif (l<=r) { l=l+1 ; } else { r=r+1 ;} a=a-1 ;\n\t\t}\n\tif (l<=r) { x = l*2 ;} else {x = r*2 ;}\n\tprintf(\"%d\",x);\n \n }\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3d081a08779d1cb1c8d0b2a4108469d1", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nint main()\n{\n long long n,i=0; int c=0;\n scanf(\"%l64d\",&n);\n while(n>0)\n {\n i=n%10;\n if(i==4 || i==7)\n {\n c++;\n }\n n=n/10;\n }\n if(c==4 || c==7)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n getch();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "5a87cedb32ba9f5bdb6bef6acee03def", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint *array;\n\tarray=(int*)calloc(n+1,sizeof(int));\n\tint i,j;\n\tfor(i=1;i15)\n\t\t{\n\t\t\tprintf(\"%d\",array[j-1]+15);\n\t\t\tfree(array);\n\t\t\texit(1);\n\t\t}\t\n\t}\n\t//printf(\"%d \",j);\n\tint max=90;\n\tif(array[j-1]>84)\n\t{\n\t\tprintf(\"%d\",max);\n\t}\n\telse\n\t{\n\t\tprintf(\"%d\",array[j-1]+15);\n\t}\n\tfree(array);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "399bf069cb062feaf7ecea7f89704e72", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,k,i,j=0,ch[100000000],count=0,b;\n scanf(\"%lld %lld\",&n,&k);\n for(i=1;i<=n;i++)\n {\n if(n%i==0)\n {ch[j]=i;\n j++;}\n }\n\n if(k>j)\n printf(\"-1\\n\");\n else\n printf(\"%lld\\n\",ch[k-1]);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e6cce22928575bda48c7871cca5acbd6", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nmain()\n{\n char s[101];\n gets(s);\n int capital=0,small=0,i;\n for(i=0;s[i]!='\\0';i++)\n {\n if(s[i]>=65 && s[i]<=90)\n {\n capital++;\n }\n else if(s[i]>=97 && s[i]<=122)\n {\n small++;\n }\n }\n if(capital>small)\n {\n strupr(s);\n }\n else\n {\n strlwr(s);\n }\n printf(\"%s\\n\",s);\n getch();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4bc53a35c3b455eebbf6df8f93e0fc1a", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \nvoid main()\n{\n int n,c=0;\n scanf (\"%d\",&n);\n for (int i=2;i<=n;i++)\n {\n if (n%i==0)\n {\n if(c==0)\n {\n printf(\"%d%d\",i,n/i);\n c++;\n }\n }\n }\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "28c7734ce5710fc16d22e26975386633", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint main()\n{\n long long int n,val=1000000007;\n scanf(\"%lld\",&n);\n long long int steps[10000005]={0};\n steps[1]=0;\n for(int i=2;i<=n;i++)\n {\n steps[i]=powl(3,i-1)-steps[i-1];\n }\n printf(\"%lld\",steps[n]%val);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1f940a7f450a854df0d7ac1f86cb41ea", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\nvoid main()\n{\n\tint x,y,z,t1,t2,t3,k=0,l=0,m=0,n=0;\n\tscanf(\"%d%d%d%d%d%d\",&x,&y,&z,&t1,&t2,&t3);\n\tif(x>=y)\n\t{\n\t\tk=x-y;\n\t}\n\telse\n\t{\n\t\tk=y-x;\n\t}\n\tif(z>=x)\n\t{\n\t\tn=z-x;\n\t}\n\telse\n\t{\n\t\tn=x-z;\n\t}\n\tl=(k*t1);\n\tm=(3*t3)+((n*k)*t2);\n\tif(l>m)\n\t{\n\t\tprintf(\"yes\");\n\t}\n\telse\n\t{\n\t\tprintf(\"no\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "c1f64d93428d752f9474dc334c145e4b", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int flyes[2][3];\n int i,diffs=0;\n for(i = 0; i<3; i++)\n scanf(\"%d\",&flyes[0][i]);\n for(i = 0; i<3; i++)\n scanf(\"%d\",&flyes[1][i]);\n for(i = 0; i<3; i++){\n if(flyes[0][i]!=flyes[1][i])\n\t diffs++;\n }\n if(diffs<=1)\n printf(\"YES\");\n else \n printf(\"NO\");\n\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e337567212f38e356f03f514023fdaa2", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\nvoid main()\n{\n\tint a,b,c;\n\tint t,t1,t2,t3;\n\tscanf(\"%d\",&a);\n\tscanf(\"%d\",&b);\n\tscanf(\"%d\",&c);\n\tt=a+b*c;\n\t/*printf(\"%d\\n\",t);*/\n\tt1=a*(b+c);\n\t/*printf(\"%d\\n\",t1);*/\n\tt2=a*b*c;\n\t/*printf(\"%d\\n\",t2);*/\n\tt3=(a+b)*c;\n\t/*printf(\"%d\\n\",t3);*/\n\tif(t>t1 && t>t2 && t>t3)\n\t{\n\t\tprintf(\"%d\\n\",t);\n\t}\n\telse if(t1>t && t1>t2 && t>t3)\n\t{\n\t\tprintf(\"%d\\n\",t1);\n\t}\n\telse if(t2>t && t2>t1 && t2>t3)\n\t{\n\t\tprintf(\"%d\\n\",t2);\n\t}\n\telse\n\t{\n\t\tprintf(\"%d\\n\",t3);\n\t}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "709e6751641ed8c341e2fe2d24b5f3dc", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct pair\n{\n\tint a, b;\n};\n\nint cmp ( const struct pair *a, const struct pair *b )\n{\n\tif ( a->a == b->a )\n\t\treturn a->b - b->b;\n\treturn a->a - b->a;\n}\n\nstruct pair *p, temp;\nint n, i, j;\nint a, b;\n\nint main ()\n{\n\tscanf ( \"%d\", &n );\n\tif ( n <= 2 )\n\t{\n\t\tputs ( \"no\" );\n\t\treturn 0;\n\t}\n\n\tp = (struct pair *)malloc(sizeof(struct pair)*103);\n\t\n\tscanf ( \"%d%d\", &a, &b );\n\tp[0].a = a;\n\tp[0].b = b;\n\ta = b;\n\n\tfor ( i = 2; i < n; ++ i )\n\t{\n\t\tscanf ( \"%d\", &b );\n\t\tp[i-1].a = a;\n\t\tp[i-1].b = b; a = b;\n\t\tif ( p[i-1].a > p[i-1].b )\n\t\t{\n\t\t\tp[i-1].a += p[i-1].b;\n\t\t\tp[i-1].b = p[i-1].a - p[i-1].b;\n\t\t\tp[i-1].a = p[i-1].a - p[i-1].b;\n\t\t}\n\t} -- n;\n\n\tqsort ( p, n, sizeof(struct pair), cmp );\n\n\t//for ( i = 0; i < n; ++ i )\n\t//\tprintf ( \"%d - %d\\n\", p[i].a, p[i].b );\n\n\tfor ( i = 0; i < n-1; ++ i )\n\t{\n\t//\tprintf ( \"i = %d\\n\", i );\n\t\tfor ( j = i+1; j < n; ++ j )\n\t\t{\n\t//\t\tprintf ( \" j = %d\\n\", j );\n\t\t\tif ( p[j].a > p[i].b ) break;\n\t\t\tif ( p[i].b > p[j].a && p[i].a < p[j].a && p[j].b > p[i].b )\n\t\t\t{\n\t//\t\t\tprintf ( \"%d-%d\\n\", p[i].a, p[i].b );\n\t\t\t\tputs ( \"yes\" );\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tputs ( \"no\" );\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b65b1a93baa01eb08605b1fa5a939b48", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char s[8][8];\n int i, j, count = 0, count1 = 0, c;\n for(i = 0; i < 8; i++)\n {\n gets(s[i]);\n count = 0;\n for(j = 0; s[j] != '\\0'; j++)\n {\n if(s[i][j] == 'B')\n count++;\n }\n if(count == 8)\n count1++;\n else\n c = count;\n }\n printf(\"%d\", c + count1);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "aa04ed722d5379c28675f28548e6954a", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \nint main() \n{\n\tint a,b,c,n;\n\tscanf(\"%d %d\",&a,&b);\n\tscanf(\"%d %d\",&c,&n);\n\tn=n-a-b+c;\n\tif(n>0)\n\tprintf(\"%d\",n);\n\telse\n\tprintf(-1);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "b988e26a5ae5f6994ebe62bcde68d2c8", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n long long int k,b,t;\n int i,n ,x=1,sec=0;\n scanf(\"%I64d %I64d %I64d %I64d\",&k,&b,&n,&t);\n for (i=0; xn)\n {\n printf(\"0\");\n return 0;\n }\n else if (t==x)\n {\n sec =n-i;\n printf(\"%d\",sec);\n }\n else if (x>t)\n {\n sec= n-i+1;\n printf(\"%d\\n\",sec);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e1e6fa4861e65bb25918e1a591e3653f", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{int a;\nchar b[1000];\nprintf(\"enter string\");\nscanf(\"%s\",b);\na=b[0];\nif(a>=97)\nb[0]=a-32;\nputs(b);\ngetch();\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9b3d98160f967c20898c5fe00a4b865d", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#define int long long int\nint answer(int n){\n\tif(n%2==0)\n\t\treturn n/2;\n\tfor(int i=3;i*i\nint main()\n{\n int n,k,count=0;\n scanf(\"%d%d\",&n,&k);\n\n while(k!=0)\n {\n if(n%10!=0)\n {\n n--;\n }\n else\n {\n n/=10;\n }\n count++;\n if(count==k)\n\n printf(\"%d\",n);\n}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "8a32d602214a394d7400cc5bc5eb6324", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int y=1,q=1,w=0,i,j,n,aa[1000],x,e=1;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&aa[i]);\n }\n x=aa[2]-aa[1];\n y=x;\n for(i=3;i<=n;i++)\n {\n if(x==y) q++;\n else if(x==0) y=aa[i];\n x=aa[i]-aa[i-1];\n y=x;\n }\n if(n==3&&n==q+1) printf(\"%d\\n\",aa[n]);\n else if(n==q+1) printf(\"%d\\n\",aa[n]+x);\n else printf(\"%d\\n\",y);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "f52223514357085224d19af3fb682eda", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\nint a[100100];\nint main()\n{\n int k,l,m,n,d,i,x[4],max,sum=0,temp,j=0,p,q,y;\n scanf(\"%d %d %d %d %d\",&k,&l,&m,&n,&d);\n x[0]=k;\n x[1]=l;\n x[2]=m;\n x[3]=n;\n for(i=0;i<4;i++)\n {\n for(j=i+1;j<4;j++)\n {if(x[i]>x[j])\n {\n temp=x[i];\n x[i]=x[j];\n x[j]=temp;\n }\n }\n }\n for(i=1;i<=d;i++)\n {\n a[i]=i;\n }\n if(x[0]==1)\n {\n printf(\"%d\",d);\n return 0;\n }\n else {\n for(j=1;j*x[0]<=d;j++)\n {\n a[j*x[0]]=0;\n a[j*x[1]]=0;\n a[j*x[2]]=0;\n a[j*x[3]]=0;\n }\n }\n for(i=1;i<=d;i++)\n {\n if(a[i]!=0)\n sum++;\n }\n printf(\"%d\",d-sum);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "02c63d019bf1fca0128973a899f4518b", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nvoid main()\n{ int n,i,j;n=scanf(\"%d\",&n);int s=0;\n int arr[100];s=0;\n for(i=0;i=0)&&(arr[i]>=0))\n {printf(\"%d %d\",i,j);\n arr[i]=-1;arr[j]=-1;break;\n\t }}\n }getch();\t \n\t }\n\t \n\t \n \n \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b239277ffb3f5111f587c9eb3fbc55d4", "src_uid": "6e5011801ceff9d76e33e0908b695132", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint i,s;\nscanf(\"%d\",s);\nchar s[100];\ngets(s);\n{\nif(s[i]==0)\n{\nprintf(\"EASY\");\n}\nelse if(s[i]==1)\n{\n}\nprintf(\"HARD\");\n}\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "e8e683df08b36d233e31a4772d2ac9ba", "src_uid": "060406cd57739d929f54b4518a7ba83e", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,d,i,a[1000],k=0;\n\tscanf(\"%d%d\",&n,&d);\n\tfor(i=0;id)\n\t\tprintf(\"-1\");\n\telse\n\t\tprintf(\"%d\",((d-(k+10*(n-1)))/5)+2*(n-1));\n\t\n\treturn 0;", "lang_cluster": "C", "compilation_error": true, "code_uid": "52c579f8bdf5ba63c315c378f9a6933c", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a=0,b=0,c=0;\n char ch;\n while(ch=getchar())\n {\n if(ch=='1')\n a++;\n else if(ch=='2')\n b++;\n else if(ch=='3')\n c++;\n else if(ch=='\\n')\n break;\n }\n bool first=true;\n for(int i=0;i\n#include\nint main()\n{\n\tint N,i,value,len=1,total=0,j=1;\n\tint *a,*index;\n\n\tscanf(\"%d\",&N);\n\ta=(int *)malloc(sizeof(int)*N);\n\tindex=(int *)malloc(sizeof(int)*N);\n\n\n\tfor (i = 0; i < N; ++i)\n\t{\n\t\tscanf(\"%d\",&a[i]);\n\t\ttotal+=a[i];\n\t}\n\n\tvalue=a[0];\n\tindex[0]=1;\n\tfor(i=2;value<=total/2 && i<=N;i++)\n\t{\n\t\tif(a[0]/2>=a[i-1])\n\t\t{\n\t\t\tvalue+=a[i-1];\n\t\t\tindex[j]=i;\n\t\t\tlen++;\n\t\t\tj++;\n\t\t}\n\t}\n\n\n\tif((len==1 && i!=2 )|| (value\n#include \nint main()\n{int n;\n scanf(\"%d\",&n);\n int a=n%4;\n if(a!=0)\n int b=(pow(8,a))%10;\n else\n b=6;\n printf(\"%d\",b);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "732a3974968a2760de5a769a7799da24", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main(){\n\tint x,y,y1,z,m,i,r[100][100],c[100][100],d[100][100];\n\t\tfor(i=0;i<2;i++)\t\n\t\tscanf(\"%d\",&r[0][i]);\n\t\tfor(i=0;i<2;i++)\t\n\t\tscanf(\"%d\",&c[0][i]);\n\t\tfor(i=0;i<2;i++)\t\n\t\tscanf(\"%d\",&d[0][i]);\n\t\t\n\t\ty1=(d[0][0]+r[0][0]-c[0][1])%2\n\t\ty=(d[0][0]+r[0][0]-c[0][1])/2;\n\t\tx=c[0][1]+y-d[0][0];\n\t\tz=d[0][1]+y-r[0][0];\n\t\tm=r[0][1]+y-c[0][0];\n\t//\tprintf(\"%d\",y);\n\t\n\t\tif((x+y)!=r[0][0] || (z+m)!=r[0][1] || (x+m)!=c[0][1] || (z+y)!=c[0][0] ||(m+y)!=d[0][0] || (x+z)!=d[0][1]|| y==x || y==z || y==m || x==z || x==m || z==m || y1!=0){\n\t\tprintf(\"-1\");\n\t}\n\t\telse\t{\n\t\tprintf(\"%d %d\\n\",y,x);\n\t\tprintf(\"%d %d\",z,m);\n\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t//\tsystem (\"pause\");\n\treturn 0;\n\t\t\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b57ea7082a2a3670473c8f03183b55a2", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "int main(){\n int n;\n //scanf(\"%d\",&n);\n if(n%2!=0) return 0;\n int rect=(n%4!=0)?n/4:n/4-1;\n pritnf(\"%d\\n\",rect);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0e425980e147edc35d380c332f11f4ab", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\nlong long int n,k,k1,k2;\nscanf(\"%lld\",&n);\nk=pow(5,n);\nif(k<=25)\n printf(\"%lld\\n\",(k+1);\nelse\n{\n k1=k%10;\n k=k/10;\n k2=k%10;\n k=(k2*10)+k1;\n printf(\"%lld\\n\",(k+1));\n}\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d63d14a4f05ea15f81fb29e4be3102e1", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int m,n,a,b,p;\n float d,c=0.0,e;\n scanf(\"%d %d %d %d\",&n,&m,&a,&b);\n t=n;\n d=(float)b/m;\n\n if(d<(float)a)\n {\n c=c+d;\n c*=n;\n }\n else {\n c+=a; c*=n;}\n \n \n\n e=c-(int)c;\n if(e!=0.0) c=c+1;\n \n p=(int)c;\n printf(\"%d\",p);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d3a9a6d3a46d0797169f30b0a2e74d71", "src_uid": "faa343ad6028c5a069857a38fa19bb24", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n#include\nusing namespace std;\nint judge(int a);\nint judge(int a) {\n\tint i;\n\tfor (i = 2; i <= sqrt(a); ++i)\n\t\tif (a%i == 0)\n\t\t\treturn 0;\n\treturn 1;\n}\nint main() {\n\tint n, m;\n\tchar nothing;\n\tcin>>n;\n\tfor (m = 1;; ++m)\n\t\tif (!judge(m*n + 1)) {\n\t\t\tcout << m<\nint main()\n{\n int n,s,i,j,k;\n int a[50];\n scanf(\"%d%d\",&n,&s);\n for(i=0;ia[j])\n {\n k=a[i];\n a[i]=a[j];\n a[j]=k;\n }\n }\n }\n int sum=0;\n for(i=0;is)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e1c52978e625488c739962e709a907a1", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \nint main(){double n; scanf(\"%f\",&n); double i; double s=0;\nfor(i=0; i\n#include \n#include \n\nint main(void)\n{\n char c1[101];\n char c2[101];\n int i = 0\n scanf(\"%s%s\",c1,c2);\n for(i = 0; c1[i]!= '\u00a5n'; i++){\n if(isLower(c1[i]))toLower(c1[i]);\n if(isLower(c2[i]))toLower(c2[i]);\n }\n \n for(i = 0; c1[i]!= '\u00a5n'; i++){\n if((c1[i]-c2[i])>0){\n printf(\"-1\");\n return 0;\n \n }else if((c1[i]-c2[i])<0){\n printf(\"1\");\n return 0;\n }\n }\n \n printf(\"0\")\n \n return 0;\n \n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3f85ba61bb017fde00af084d1838f069", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n char arr[100];\n int i,l,count=0;\n \n scanf(\"%s\",&arr);\n l= strlen(arr);\n \n for(i=1;i\nint main()\n{\n int i;\n char a[1000],b[1000];\n scanf(\"%s\",a);\n scanf(\"%s\",b);\n for(i=0;i\nint main()\n{\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\t//printf(\"%d %d\\n\",n,m);\n char ch[n],c;\n c=getchar();\n\tfor(int i=0;i=n-1) {x++;z=1;break;}\n }\n\t\telse if(ch[i+m]=='0'){i--;}\n\t\tif(z==1) break;\n\t}\n\tprintf(\"%d\\n\",x);\n\t\n} ", "lang_cluster": "C", "compilation_error": false, "code_uid": "18d3c855201c6af2dd0808cf89b9fd32", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint dv(int x,int n,int p){\n\tif(n==1)return (x%p);\nreturn (dv(x,n/2,p)*dv(x,n-n/2,p))%p;\n}\nint main(){\n\tint p,c=0,i;\n\tscanf(\"%d\",&p);\n\tfor(int x=1;x\n\nint main(int argc, char **argv)\n{\n\tlong long int n,x,y;\n\tunsigned long int a,b;\n\tscanf(\"%I64d\\n\",&n);\n\tscanf(\"%I64d\\t%I64d\",&x,&y);\n\ta=((x-1)+((y-1));\n\tb=((n-x)+((n-y));\n\tif(a<=b)\n\t{\n\t printf(\"White\");\n\t}\n\telse\n\t{\n\t printf(\"Black\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "702851ebb0e63397ba7bc510cbca070a", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() { \nint p,max,i,j,s,k;\np=0;\nint t[13];\nscanf (\"%d\",&k);\nfor (i=0;i<=11;i++) { scanf(\"%d\",&t[i]);\n}\n\nmax=t[0];\ns=0;\nif (k!=0){\n\nwhile (s= max) {\n\t max =t[i];\n\t j=i;\n }\n}\nt[j]=0;\ns=s+max;\np=p+1;\n}\nprintf(\"%d\",p);\nbreak ;}\nelse { printf(\"%d\",0);\n}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "345400d05751646fd4f60b36377e47c6", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,i,j,t;\n int a[8][8];\n for(i=0;i<8;i++)\n { for(j=0;j<8;j++)\n {scanf(\"%d %d\",&i,&j);\n if(c[i][j]=='Q')x=x+9;\n else if(c[i][j]=='q')y=y+9;\n else if(c[i][j]=='R')x=x+5;\n else if(c[i][j]=='r')y=y+5;\n else if(c[i][j]=='B')x=x+3;\n else if(c[i][j]=='b')y=y+3;\n else if(c[i][j]=='N')x=x+3;\n else if(c[i][j]=='n')y=y+3;\n else if(c[i][j]=='P')x=x+1;\n else if(c[i][j]=='p')y=y+1;\n else if(c[i][j]=='K')x=x+0;\n else if(c[i][j]=='k')y=y+0;\n }\n }\n if(x>y)printf(\"White\");\n else if(x\nint main()\n{\n int a,b,c,d,e,e1,f,f1,g,g1,e2,f2,g2;\n scanf(\"%d %d %d\",&a,&b,&c);\n if(a<=3 || b<=2 || c<=2){\n if(a==1 && b>=2 && c>=2)\n printf(\"5\");\n else if(a==2 && b>=2 && c>=2)\n printf(\"6\");\n else if(a==1 && b>=1 && c==0)\n printf(\"2\");\n else if(a==1 && b==0 && c>=1)\n printf(\"2\");\n else if(a==1 && b>=1 && c>=1)\n printf(\"3\");\n else if(a==3 && b==1 && c>=2)\n printf(\"6\");\n else if(a==2 && b==0 && c==0)\n printf(\"2\");\n else if(a==2 && b==1 && c==0)\n printf(\"3\");\n else if(a==2 && c==1 && b==0)\n printf(\"3\");\n else if(a==2 && c==1 && b==1)\n printf(\"4\");\n else if(a>=3 && c==1 && b==1)\n printf(\"5\");\n else if(a>=3 && c==1 && b==2)\n printf(\"6\");\n else if(a>=3 && c==2 && b==1)\n printf(\"6\");\n else if()\n else\n printf(\"7\");\n }\n else{\n e=a/3;\n e1=a%3;\n e2=e+e1;\n f=b/2;\n f1=b%2;\n f2=f+f1;\n g=c/2;\n g1=c%2;\n g2=g1+g;\n if(e<=f && e<=g){\n if(e1==0 && e==f && e==g && f1==0 && g1==0)\n printf(\"%d\",(e*7));\n else if(e1==0 && e==f && e==g && f1==1 && g1==0)\n printf(\"%d\",(e*7)+1);\n else if(e1==0 && e==f && e==g && f1==0 && g1==1)\n printf(\"%d\",(e*7)+1);\n else if(e1==0 && e==f && e==g && f1==1 && g1==1)\n printf(\"%d\",(e*7)+2);\n else if(e1==0 && f>e && g==e && g1==0)\n printf(\"%d\",(e*7)+1);\n else if(e1==0 && ee && e==f && f1==0)\n printf(\"%d\",(e*7)+1);\n else if(e1==0 && e==f && ee && g==e && g1==0)\n printf(\"%d\",(e*7)+2);\n else if(e1==1 && ee && e==f && f1==0)\n printf(\"%d\",(e*7)+2);\n else if(e1==1 && e==f && ee && g==e && g1==0)\n printf(\"%d\",(e*7)+3);\n else if(e1==2 && ee && e==f && f1==0)\n printf(\"%d\",(e*7)+3);\n else if(e1==2 && e==f && ef && f==g && g1==0)\n printf(\"%d\",(f*7)+2);\n else if(f1==0 && e>f && f==g && g1!=0)\n printf(\"%d\",(f*7)+2);\n else if(f1==0 && g>f && e==f && e1==0)\n printf(\"%d\",(f*7)+1);\n else if(f1==0 && e==f && ff && f==g && g1!=0)\n printf(\"%d\",(f*7)+5);\n else if(f1==1 && g>f && e==f && e1==0)\n printf(\"%d\",(f*7)+2);\n else if(f1==1 && e==f && f=g){\n if(g1==0 && g==f && e==g && f1==0 && e1==0)\n printf(\"%d\",(g*7));\n else if(g1==0 && g==f && e==g && f1==1 && e1==0)\n printf(\"%d\",(g*7)+1);\n else if(g1==0 && g==f && e==g && f1==0 && e1==1)\n printf(\"%d\",(g*7)+1);\n else if(g1==0 && g==f && e==g && f1==1 && e1==1)\n printf(\"%d\",(g*7)+2);\n else if(g1==0 && f>g && g==e && e1==0)\n printf(\"%d\",(g*7)+1);\n else if(g1==0 && gg && f1!=0)\n printf(\"%d\",(g*7)+2);\n else if(g1==0)\n printf(\"%d\",(g*7)+4);\n else if(g1==1 && g==f && e==g && f1==0 && e1==0)\n printf(\"%d\",(g*7)+1);\n else if(g1==1 && g==f && e==g && e1==2 && f1==0)\n printf(\"%d\",(g*7)+2);\n else if(g1==1 && g==f && e==g && f1==1 && e1==0)\n printf(\"%d\",(g*7)+2);\n else if(g1==1 && g==f && e==g && f1==0 && e1==1)\n printf(\"%d\",(g*7)+2);\n else if(g1==1 && g==f && e==g && f1==1 && e1==1)\n printf(\"%d\",(g*7)+3);\n else if(g1==1 && g==f && e==g && f1==1 && e1==2)\n printf(\"%d\",(g*7)+4);\n else if(g1==1 && f>g && g==e && e1==0)\n printf(\"%d\",(g*7)+2);\n else if(g1==1 && gg && f1!=0)\n printf(\"%d\",(g*7)+5);\n else if(g1==1)\n printf(\"%d\",(g*7)+6);\n\n }\n else if(e==f && e==g && f==g){\n if(e1==0 && f1==0 && g1==0)\n printf(\"%d\",e*7);\n else{\n if(e\nint l,r,x,y;\nint gcd(int p,int q){\n\tint r;\n\twhile(q!=0){\n\t\tr=p%q;\n\t\tp=q;\n\t\tq=r;\n\t}\n\treturn p;\n}\nvoid run(){\n\tint i,j,k,c;\n\twhile(scanf(\"%d%d%d%d\",&l,&r,&x,&y)!=EOF){\n\t\tif(y%x!=0){\n\t\t\tprintf(\"0\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\tj=y/x;\n\t\tc=0;\n\t\tfor(i=1;i<100007&&i<=j;i++){\n\t\t\tif(j%i==0){\n\t\t\t\tk=j/i;\n\t\t\t\tif(k=l&&i*x<=r&&k*x>=l&&k*x<=r){\n\t\t\t\t\tif(gcd(i,k)==1){\n\t\t\t\t\t\tc+=i==k?1:2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\",c);\n\t}\n}\nmain(){\n#ifndef\tONLINE_JUDGE\n\tfreopen(\"4892b_min.in\",\"rb\",stdin);\n\tfreopen(\"4892b_.out\",\"wb\",stdout);\n#endif\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8b58b04e34824a792aa0ee38c36bd091", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n,a=0;\n scanf(\"%d\",&n);\n int i,w;\n for(i=0;i\n#include\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n==14||n==1||n==114)\n {\n printf(\"YES\");\n exit(0);\n } \n while(n>0)\n {\n if(n%1000==144)", "lang_cluster": "C", "compilation_error": true, "code_uid": "6491f6043e6b92791541cd2c8e64b5f4", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n,m,flag=0;\n scanf(\"%d%d\",&n,&m);\n for(int i=2;i<=m/2;i++){\n if(m%i==0) {flag++;printf(\"NO\");break;}\n }\n if(flag==0){\n for(int i=n+1;i\n\nvoid main()\n{\n int x,y,max=1,i;\n int tab[100];\n scanf(\"%d\"&x);\n scanf(\"%d\"&y);\n \n for( i=0;imax)\n max=tab[i]\n \n }\n printf(\"%d\"y/max);\n \n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "4683f5e4fd2c9cef0b1b5b7d0bc256f8", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main ()\n{\n int lenght,sumdigit,sum1=1,ind1,sum2=0,ind2=0,i;\n \n \n\n scanf(\"%d %d\",&lenght,&sumdigit);\n \n if(lenght==1 && sumdigit==0)\n {printf(\"0 0\");return 0;\n \n if(lenght*90;i--)\n a1[i]=0;\n ind1=lenght-1;\n a1[0]=1;\n\n int a2[lenght];\n\n for(i=lenght;i>0;i--)\n a2[i]=0;\n\n\n while(1)\n {\n if(sum1+9<=sumdigit)\n {\n a1[ind1]=9;\n sum1+=9;\n ind1--;\n }\n else if(sum1+9>sumdigit && sum1sumdigit && sum2\n#include \ntypedef long long int ll;\nchar a[110]={'\\0'};\n\nint main(void) {\n\t// your code goes here\n\tscanf(\"%s\",a);\n\tint n = strlen(a),ts=0,flag=0,i,j,k;;\n\tif(n==3)\n\t{\n\t\tif((((a[0]-'0')*10+(a[1]-'0'))*10+(a[2]-'0'))%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(((a[0]-'0')*10+(a[1]-'0'))*10+(a[2]-'0')));\n\t\t\treturn 0;\n\t\t}\n\t if(((a[0]-'0')*10+(a[1]-'0'))%8==0)\n\t {\n\t \t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[1]-'0')));\treturn 0;\n\t }\n\t if(((a[1]-'0')*10+(a[2]-'0'))%8==0)\n\t {\n\t \t\tprintf(\"YES\\n %d\",((a[1]-'0')*10+(a[2]-'0')));\treturn 0;\n\t }\n\t if(((a[0]-'0')*10+(a[2]-'0'))%8==0)\n\t {\n\t \t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[2]-'0')));\treturn 0;\n\t }\n\t if(((a[0]-'0')*10+(a[1]='0'))%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[1]='0')));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[0]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[0]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[1]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[1]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\telse printf(\"NO\");\n\t\t\treturn 0;\n\t}\n\tif(n==2)\n\t{\n\t\tif(((a[0]-'0')*10+(a[1]='0'))%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[1]='0')));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[0]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[0]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[1]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[1]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\tif(a[0]=='8'){printf(\"YES\\n 8\");return 0;}\n\tif(a[0]=='0'){printf(\"YES\\n 0\");return 0;}\n\t\telse printf(\"NO\");\n\t\t\treturn 0;\n\t}\n\tif(n==1){\n\tif(a[0]=='8'){printf(\"YES\\n 8\");return 0;}\n\tif(a[0]=='0'){printf(\"YES\\n 0\");return 0;}\n\telse printf(\"NO\");\n\treturn 0;\n\t}\n\t\n\tint x=-1,y=-1,z=-1;\n\tfor(i = n-3;i>=0&&!flag;i--)\n\t\tfor(j = n-2;j>i&&!flag;j--)\n\t\t\tfor(k = n-1;k>j&&!flag;k--)\n\t\t\t{\n\t\t\t\tts =ts*10+(a[i]-'0');\n\t\t\t\tts = ts*10+(a[j]-'0');\n\t\t\t\tts = ts*10+(a[k]-'0');\n\t\t\t\t//printf(\"%d\\n\",ts);\n\t\t\t\tif(ts%8==0)\n\t\t\t\t{\n\t\t\t\t\tx=i;\n\t\t\t\t\ty=j;\n\t\t\t\t\tz=k;\n\t\t\t\t\tflag++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\tif(x!=-1&&y!=-1&&z!=-1){\n\t\tprintf(\"YES\\n\");\n\tfor(i=0;i\n#include \ntypedef long long int ll;\nchar a[110]={'\\0'};\n\nint main(void) {\n\t// your code goes here\n\tscanf(\"%s\",a);\n\tint n = strlen(a),ts=0,flag=0,i,j,k;;\n\tif(n==3)\n\t{\n\t\tif((((a[0]-'0')*10+(a[1]-'0'))*10+(a[2]-'0'))%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(((a[0]-'0')*10+(a[1]-'0'))*10+(a[2]-'0')));\n\t\t\treturn 0;\n\t\t}\n\t if(((a[0]-'0')*10+(a[1]-'0'))%8==0)\n\t {\n\t \t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[1]-'0')));\treturn 0;\n\t }\n\t if(((a[1]-'0')*10+(a[2]-'0'))%8==0)\n\t {\n\t \t\tprintf(\"YES\\n %d\",((a[1]-'0')*10+(a[2]-'0')));\treturn 0;\n\t }\n\t if(((a[0]-'0')*10+(a[2]-'0'))%8==0)\n\t {\n\t \t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[2]-'0')));\treturn 0;\n\t }\n\t if(((a[0]-'0')*10+(a[1]='0'))%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[1]='0')));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[0]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[0]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[1]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[1]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\telse printf(\"NO\");\n\t\t\treturn 0;\n\t}\n\tif(n==2)\n\t{\n\t\tif(((a[0]-'0')*10+(a[1]='0'))%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",((a[0]-'0')*10+(a[1]='0')));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[0]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[0]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\tif((a[1]-'0')%8==0)\n\t\t{\n\t\t\tprintf(\"YES\\n %d\",(a[1]-'0'));\n\t\t\treturn 0;\n\t\t}\n\t\tif(a[0]=='8'){printf(\"YES\\n 8\");return 0;}\n\tif(a[0]=='0'){printf(\"YES\\n 0\");return 0;}\n\t\telse printf(\"NO\");\n\t\t\treturn 0;\n\t}\n\tif(n==1){\n\tif(a[0]=='8'){printf(\"YES\\n 8\");return 0;}\n\tif(a[0]=='0'){printf(\"YES\\n 0\");return 0;}\n\telse printf(\"NO\");\n\treturn 0;\n\t}\n\t\n\tint x=-1,y=-1,z=-1;\n\tfor(i = n-3;i>=0&&!flag;i--)\n\t\tfor(j = n-2;j>i&&!flag;j--)\n\t\t\tfor(k = n-1;k>j&&!flag;k--)\n\t\t\t{\n\t\t\t\tts =ts*10+(a[i]-'0');\n\t\t\t\tts = ts*10+(a[j]-'0');\n\t\t\t\tts = ts*10+(a[k]-'0');\n\t\t\t\t//printf(\"%d\\n\",ts);\n\t\t\t\tif(ts%8==0)\n\t\t\t\t{\n\t\t\t\t\tx=i;\n\t\t\t\t\ty=j;\n\t\t\t\t\tz=k;\n\t\t\t\t\tflag++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\tif(x!=-1&&y!=-1&&z!=-1){\n\t\tprintf(\"YES\\n\");\n\tfor(i=0;i\nint main()\n{\n\tlong long int a,b,count1=0;\n\tscanf(\"%I64d %I64d\",&a,&b);\n\telse\n\t{\n\t\twhile(a!=b)\n\t\t{\n\n\t\t\t\tcount1=count1+(a/b);\n\t\t\t\ta=b;\n\t\t\t\tb=a-((a/b)*2);\n\t\t\t\tif(b<=0||a==0)\n\t\t\t\t\tbreak;\n\t\t}\n\tprintf(\"%I64d\",count1);\n\t}\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "00715addd8e24ab542c564d2d8a25996", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\n int a1,a2,a3,a4;\n scanf(\"%d %d %d %d\", &a1, &a2, &a3, &a4);\n\n if(a1+a2 == a3+a4) printf(\"YES\");\n else if(a1+a3 == a2+a4) printf(\"YES\");\n else if(a1+a4== a2+a3) printf(\"YES\");\n else if(a1+a2+a3 == a4) printf(\"YES\");\n else if(a2+a3+a4 == a1) printf(\"YES\");\n else if(a3+a4+a1 == a2) printf(\"YES\");\n else if(a1+a2+a4 == a3) printf(\"YES\");\n else printf(\"NO\");\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "27235a6117790115cf150785226bea9e", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n,a,b,i;\n\n scanf(\"%d %d %d\", &n, &a, &b);\n \n for (i=1; i<=a && i<=b && (a/i + b/i >= n); x++);\n \n printf(\"%d\",i-1);\n \n return 0;\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "a001928d3b9331723b8a2645f2b0105e", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n\ntypedef long long LL;\n\nLL GetSum(LL i,LL K)\n{\n\treturn (i+K)*(K-i+1)/2;\n}\n\nLL Binary(LL K,LL N)\n{\n\tLL Left=1,Right=K,Mid;\n\twhile(Right>Left)\n\t{\n\t\tMid=(Left+Right)/2;\n\t\tif(GetSum(Mid,K)==N)\n\t\t{\n\t\t\treturn Mid;\n\t\t}\n\t\telse if(GetSum(Mid,K)K*(K-1)/2)\n\t\t{\n\t\t\tputs(\"-1\");\n\t\t\tcontinue;\n\t\t}\n\t\tindex=Binary(K-1,N);\n\t\tif(GetSum(index,K-1)==N)\n\t\t{\n\t\t\tprintf(\"%d\\n\",K-index);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"%d\\n\",K-index+1);\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "29f4d0f0edd081b496b0fdb7d6e55d25", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint funcelias (char a);\n\nint main()\n{\n\tint i,j=0,k,f,l ;\n\tint aux[4];\n\tchar hora[6];\n\tint flag=0 ;\n\tscanf(\"%s\", hora) ;\n\t\n\n\tfor(i=0;'\\0'!=hora[i];i++){\n\t\t\n\t\tif(funcelias(hora[i])!=-1){\n\t\t\taux[j]=funcelias(hora[i]);\n\t\t\tj++;\n\t\t}\n\t}\n\tif((aux[0]*10+aux[1])<24)\n\t{\n\t\twhile(flag!=1){\n\t\t\n\t\tfor(i=aux[0] ; i<3 && flag==0; i++)\n\t\t{\n\t\t\tfor(k=aux[1] ; k<4 && flag==0; k++)\n\t\t\t{\n\t\t\t\tfor(j=aux[2] ; j<6 && flag==0; j++)\n\t\t\t\t{\t\t\t\t\n\t\t\t\t\tfor(l=aux[3]+1 ; l<10 && flag==0; l++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(i==l and k==j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tflag=1 ;\n\t\t\t\t\t\t\tprintf(\"%d%d:%d%d\",i,k,j,l) ;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\taux[3]=-1;\n\t\t\t\t}\n\t\t\t\taux[2]=0;\n\t\t\t}\n\t\t\taux[1]=0;\n\t\t\t\n\t\t}\n\t\taux[0]=0;\n\t\n\t\t}\n\t}\n\treturn 0 ;\n}\nint funcelias (char a)\n{\n\tint i;\n\t\n\tchar numero[]= {'0','1','2','3','4','5','6','7','8','9'}\t;\n\tfor(i=0; i<10; i++)\n\t{\n\t\t\n\t\tif(a==numero[i])\n\t\t{\n\t\t\treturn i;\n\t\t}\n\t\t\n\t}\n\treturn -1;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "a94c5b5844150f4ee8bdb2459b2c9730", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \nlong x ;\n\nint main()\n{\n int i=0;\n int j ;\n scanf(\" %ld\",&x);\n j = x % 8 ;\n\n switch(j) {\n case 1:case 2:case 4 :\n i=1; break ;\n case 3:case 5:case 6 :\n i=2 ; break ;\n case 7 :\n i=3; break ;\n case 0 : i=0; break ;\n\n }\n if (x >=8 ) { i= i+1 ; }\n printf(\"\\n%d\",i);\n\n\n\n\n\n\n\n return 0;", "lang_cluster": "C", "compilation_error": true, "code_uid": "674f6ffa9c86889a8ca698a29a01c19f", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "/// https://vjudge.net/contest/166123#problem/C\n/// careful! faltu code!!!\n/// but accepted :3\n#include\n#include\nint main()\n{\n long long l,r,i,j;\n int cnt2=0;\n int cnt3=0;\n int cnt5=0;\n scanf(\"%lld %lld\",&l,&r);\n if(l==r)\n {\n printf(\"%lld\",l);\n return 0;\n }\n else if ((r-l)>5)\n {\n printf(\"2\");\n return 0;\n }\n for(i=l; i<=r; i++)\n {\n if(i%2==0)\n cnt2++;\n if(i%3==0)\n cnt3++;\n }\n if(cnt2>cnt3)\n printf(\"%d\\n\",cnt2);\n else if\n printf(\"%d\",cnt3);\n else\n printf(\"2\\n\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "6ad888a23b9ce3c9fecade6504925027", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n int n;\n scanf(\"%d\", &n);\n char a[n];\n scanf(\"%s\", a);\n char b[n]=a;\n if(a==b){\n printf(\"hcyrkd\");}\n else{\n int i,j,c=0,k;\n k=n;\n while(k!=1){\n k=k/2;\n c++;\n }\n for(i=0;i<=c;i++)\n {\n k=(int)n/pow(2,c-i);\n for(j=0;j\n#include\n#define maxn 2000000000\nint not_prime[maxn],prime[100000000];\nint cnt=0;\nvoid get_prime(){\n\tnot_prime[1]=1;\n\tfor(int i=2;i<=maxn;i++){\n\t\tif(!not_prime[i]) prime[++cnt]=i;\n\t\tfor(int j=1;j<=cnt;j++){\n\t\t\tif(prime[j]*i>maxn) break;\n\t\t\tnot_prime[prime[j]*i]=1;\n\t\t\tif(i%prime[j]==0) break;\n\t\t}\n\t}\n}\nint main()\n{\n\tmemset(not_prime,0,sizeof(not_prime));\n\tint n,flag=0;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=cnt;i++)\n\t if(prime[i]==n) \n\t flag=1;\n\tif(flag==1) printf(\"1\\n\");\n\telse if(n%2==0) printf(\"2\\n\");\n\telse printf(\"3\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "adad1f5d04acd0f1270cf8b339186668", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\r\n#include\r\nint main() {\r\n int t;\r\n scanf(\"%d\", &t);\r\n while (t--) {\r\n int n, s = 0, j = 1;;\r\n scanf(\"%d\", &n);\r\n for (int i = 9;i > 0;i--) {\r\n if (n >= i) {\r\n n -= i;\r\n s += (i * j);\r\n j *= 10;\r\n }\r\n }\r\n printf(\"%d\\n\", s);\r\n }\r\n return 0;", "lang_cluster": "C", "compilation_error": true, "code_uid": "234f89a666cfbd1e60e1a5e2a2df864c", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,a,b,i;\n sacnf(\"%d %d %d\", &n,&a,&b);\n i=a+1;\n printf(\"%d\",i);\n return 0;\n\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "a72a4015c9bdb9008637d19bc1c65af7", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n char str[101];\n scanf(\"%s\",&str);\n int n=strlen(str);\n for(int i=0;i=65&&str[i]<=90){\n str[i]=str[i]+32;\n }\n }\n for(int i=0;i\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tchar num[100];\n\tscanf(\"%s\",num);\n\tchar answer[100];\n\tint result=0,count1;\n\tfor(int i=0;i\n#include\nint gcd(long long int n1,long long int n2)\n{\nreturn (n2!=0)?gcd(n2,n1%n2):n1;\n//return findgcd(n2,n1%n2);\n//else\n//return n1;\n}\nlong long lcm(long long a,long long b)\n{\n return (a/gcd(a,b))*b;\n}\nint main()\n{\nlong long n,a,b,p,q,ans=0;\nscanf(\"%lld %lld %lld %lld %lld\",&n,&a,&b,&p,&q);\nans+=(n/a)*p;\nans+=(n/b)*q;\nans-=(n/lcm(a,b))*(p>q?q:p);\nprintf(\"%lld\\n\",ans);\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "1a4e8e98e8bfd58a926b6e1668fd0911", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \n\nint main(void){\nint k;\nscanf(\"%d\", k);\nint cnt[10];\nfor (int i=0; i<10; i++)\ncnt[i] = 2 * k;\nchar c;\nwhile ((c = getchar()) != EOF)\nif (c >= '0' && (c -= '0') <= 9)\nif (!(cnt[c]--)){\nprintf(\"NO\\n\");\nreturn 0;\n}\nprintf(\"YES\\n\");\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "ab16fe389260e4dd2eb2bc00d784aee6", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int i, set[44751], n, k;\n for(i=0; i<44750; i++)\n set[i]=(i*(i+1))/2;\n scanf(\"%d\", &n);\n \n for(i=1; i<44750; i++)\n {\n if(set[i]>n)\n break;\n int j=n-set[i];\n //printf(\"j=%d\\n\", j);\n for(k=1; k<44750; k++)\n {\n //printf(\"set[k]=%d\\n\", set[k]);\n if(j==set[k])\n {\n printf(\"YES\\n\");\n return 0;\n }\n if(j\nint main(){\n\tint i,c=0,b=1,n;\n\tchar a [55];\n\t\n\tscanf(\"%s\",a);\n\tint n=strlen (a);\n\t\n\tfor(i=0;in/2){\n\t\tprintf (\"%d\\n\",n);}\n\t\telse if (c==1){\tprintf (\"%d\\n\",c);}\n\t\telse {\n\t\t\tprintf (\"%d\\n\",(2*c)-1);}\n\t\t\t\n\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2b9b725378ef8538cff629869eef54be", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint main() {\n\tint n, result = 1, s = 0;\n\tscanf_s(\"%d\", &n);\n\tn++;\n\tif (n < 10)result--;\n\telse while (!(n % 10))\n\t\tn /= 10;\n\twhile(n>100)\n\t{\n\t\ts = 10 - n % 10;\n\t\tresult += s;\n\t\tn += s;\n\t\twhile (!(n % 10))\n\t\t\tn /= 10;\n\t}\n\tprintf(\"%d\", 9 + 9*(n/10)+result);\t\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "132995da878d7d939f9a49c06959056c", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nvoid main()\n{\n int a[6],i,t,j,found=0,ans,n=0,x=0;\n printf(\"Enter the time:\");\n scanf(\"%d\",&t);\n for(i=1;i<=5;i++)\n {\n a[i]=i;\n }\n for(i=1;i<=t && found==0;)\n {\n x++;\n ans=a[x];\n for(j=1;j<=pow(2,n) && found==0;j++)\n {\n if(i\n\nint main()\n\n{\n int k,w;\n long long int sum=0;\n long long int n;\n scanf(\"%d %lli %d\",&k,&n,&w);\n for(int i=1;i<=w;i++ )\n {\n sum=sum+k;\n }\n if(sum>=n)\n {\n printf(\"%lli\\n\",sum-n);\n }\n else\n {\n printf(\"0\\n\")\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "5d0fd4cbaf0bef91dc58ddd7f2c7d3e7", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n int p1,p2,p3,p4,a,b,i,cnt=0;\n scanf(\"%d%d%d%d%d%d\",&p1,&p2,&p3,&p4,a,b);\n for(i=a;i<=b;i++)\n if(i%p1%p2%p3%p4==i)\n cnt++;\n printf(\"%d\\n\",cnt);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "8f58dbf1680f3e1289689e09c26eea4c", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\t\n\tint arr[n];\n\tint i,j,k;\n\t\n\tfor(i=0;i0)\n\t\t\t\t{\n\t\t\t\t\tarr[j]-=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tright=0;\n\t\tfor(j=0;j\n#include\n#include\n#include\n#include\n\nusing namespace std;\nint main()\n{\n\tlong a=0,b=0;\n\tscanf(\"%ld%ld\",&a,&b);\n\tif(a<10)\n\tprintf(\"%d\",a);\n\telse{\n\t\tlong number=b-a+1;\n\tlong c=a;\n\tlong flag2=0;\n\tint d[100000]={};\n\twhile(c<=b){\n\t\ta=c;\n\t\tlong f=0;\n\t\twhile(a!=0){\n\t\t\tif(a<10)\n\t\t\td[f]=a;\n\t\t\telse\n\t\t\td[f]=a-a/10*10;\n\t\t\ta=a/10;\n\t\t\tf++;\n\t\t}\n\t\tsort(d,d+f);\n\t\tlong g1=0,flag=0;\n\t\twhile(g1<=f){\n\t\t\tlong g2=g1+1;\n\t\t\twhile(g2<=f){\n\t\t\t\tif(d[g1]==d[g2]){\n\t\t\t\t\tflag++;\n\t\t\t\t\t\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tg2++;\n\t\t\t}\n\t\t\tg1++;\n\t\t}\n\t\tif(flag==0){\n\t\t\tprintf(\"%ld\\n\",c);\n\t\t\tbreak;\n\t\t\n\t\t}else\n\t\tflag2++;\n\t\t\n\t\tc++;\n\t}\n\tif(flag2==number)\n\tprintf(\"-1\\n\");\n\t}\n\treturn 0;\n\t\n\t\n\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e423554f73cb9ee568a77a98558e84c4", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nmain()\n{\n int a,b;\n scanf(\"%d %d\",&a,&b);\n int count=0;\n while(a>0&&b>0)\n { if(a==1&&b==1)\n break;\n }\n else if(a<3)\n {a=a+1;\n b=b-2;\n }\n else if(b<3)\n {a=a-2;\n b=b+1;\n \n }\n else if(a>b)\n {\n a=a+1;\n b=b-2;\n }\n else\n {\n a=a-2;\n b=b+1;\n }\n count++;\n }\n printf(\"%d\",count);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "357618a8cc4a4f7d51d7a4e6547d3973", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%c\",&a);\n if(a!='1')\n break;\n }\n if(i==n+1)\n printf(\"%d\",n);\n else\n printf\"%d\",i);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0012a16d7a48ed410fc8ee9ebebca2a7", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \nlong long int max,min,mid,ans,c[3],lol;\n#define setmax() c[0]>c[1]?(max=0,c[2]>c[max]?max=2:1):(max=1,c[2]>c[max]?max=2:1)\n#define setmin() c[0]<=c[1]?(min=0,c[2]<=c[min]?min=2:1):(min=1,c[2]<=c[min]?min=2:1)\n#define setmid() (max+min)==1?mid=2:(max+min)==2?mid=1:mid=0\n//#define setall() (setmax(),setmin(),setmid())\nint main()\n{\n\tscanf(\"%lld %lld %lld\",&c[0],&c[1],&c[2]);\t\n\tsetmax();\n\tsetmin();\n\tsetmid();\t\n\twhile(1)\n\t{\n\t\tif((c[max]-2)>=0 && (c[mid]-1)>=0)\n\t\t{\n\t\t\tc[max]-=2;\n\t\t\tc[mid]-=1;\n\t\t\tans++;\n\t\t\tsetmax();\n\t\t\tsetmin();\n\t\t\tsetmid();\t\n\t\t}\n\t\telse if(c[0]==1 && c[1]==1 && c[2]==1)\n\t\t{\n\t\t\tans++;\n\t\t\tbreak;\n\t\t}\n\t\telse break;\n\t}\t \t\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "a5c8f0dfaed58d74cc36e0675bd78217", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include\n\ntypedef unsigned long long int uint64;\ntypedef unsigned char uint8;\n\nuint8 findsum(uint64 x)\n{\n uint8 sum=0;\n uint8 temp;\n while(x!=0)\n {\n temp = x%10;\n sum += temp;\n x= x/10;\n }\n return sum;\n}\n\nint main(void)\n{\n uint64 x,maxnum,b=1;\n scanf(\"%llu\",&x);\n maxnum=x;\n while(x)\n {\n uint64 cur = (x-1)*b + (b-1);\n if(findsum(cur) > findsum(maxnum))\n maxnum = cur;\n x=x/10;\n b=b*10;\n }\n\n printf(\"%llu\",maxnum);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "032ef6255e775ff842262bd7c37538f6", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,m;\n scanf(\"%d %d\",&n,&m);\n for(int i=(n+1)/2;i<=n;i++)\n {\n if(i%m==0)\n printf(\"%d\",i);\n } \n printf(\"-1\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "9321cbd22d3706d1a6023460c8272737", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n\nint lucky(int x)\n{\n while (x) {\n\tif (x % 10 != 4 && x % 10 != 7) break;\n\n\tx /= 10;\n }\n\n if (x == 0) {\n\treturn 1;\n } else {\n\treturn 0;\n }\n}\n\nint fact(int n)\n{\n int x = 1, i;\n\n for (i = 1; i <= n; i++) x *= i;\n\n return x;\n}\n\nint main()\n{\n int n, k, p = 0, q = 2, r = 2, sum = 0, i, j;\n long long x = 1;\n int a[10000], b[100];\n\n scanf(\"%d %d\", &n, &k);\n\n a[0] = 4;\n a[1] = 7;\n\n for (i = 0; i < 8; i++) {\n\tfor (j = p; j < q; j++) {\n\t a[r++] = a[j] * 10 + 4;\n\t a[r++] = a[j] * 10 + 7;\n\t}\n\n\tp = q;\n\tq = r;\n }\n\n for (i = 1; i <= n; i++) {\n\tx *= i;\n\n\tif (x >= k) break;\n }\n\n if (i > n) {\n\tputs(\"-1\");\n\n\treturn 0;\n }\n\n for (j = 0; j < r; j++) {\n\tif (a[j] > n - i) break;\n\n\tsum++;\n }\n\n q = 0;\n\n for (j = n - i + 1; j <= n; j++) b[q++] = j;\n\n for (j = n - i + 1; j < n; j++) {\n\tp = k / fact(n - j);\n\n\tif (k % fact(n - j) == 0) p--;\n\n\tif (lucky(j) == 1 && lucky(b[p]) == 1) sum++;\n\n\tfor (i = p; i < q; i++) b[i] = b[i + 1];\n\n\tk -= p * fact(n - j);\n }\n\n if (lucky(n) == 1 && lucky(b[0]) == 1) sum++;\n\n printf(\"%d\\n\", sum);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c5d1d643c6e6c03631838f4e1de8be5b", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "66b68abd94062be793b9de12128e62fc", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#include \nusing namespace std;\n\nint main() {\n long long int n,ans,temp,k,v,l;\n scanf(\"%I64d\",&n);\n if(n<=9)\n {\n printf(\"%I64d\\n\",n);\n }\n else\n {\n ans=9;\n v=9;\n l=1;\n temp=(long long int)log10(n);\n \n for(k=0;k\n\n/* run this program using the console pauser or add your own getch, system(\"pause\") or input loop */\n#define n 6\n\nint main() {\n\t\n\tint l[6], sum = 0, yes = 0;\n\tfor(int i = 0; i < n; i++){\n\t\tscanf(\"%d\", &l[i]);\n\t\tsum += l[i];\n\t}\n\tfor(int i = 0; i < n; i++)\n\t\tfor(int j = i + 1; j < n; j++)\n\t\t\tfor(int k = j + 1; k < n; k++)\n\t\t\t\tif(sum == 2 * (l[i] + l[j] + l[k])){\n\t\t\t\t\tyes = 1; \n\t\t\t\t}\n\t\n\tif(yes) printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\t\n\treturn 0;\n}\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "7ec6afd377b4f6c1e63eeb6a8776cb9f", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint sum(int n){\n int ans=0;\n while(n){\n ans+=(n%10);\n n/=10;\n }\n return ans;\n}\nint main()\n{\n int l[10000];\n int i;\n int a,b,c,x,counter=0;\n scanf(\"%d %d %d\",&a,&b,&c);\n for(i=1;i<100;i++){\n x = b*round(pow(i,a)) + c ;\n if(sumOfDites(x)==i&&x>0&&x\nint main()\n{\n\n int a,sum=0,q,i;\n for(i=0;i<5;i++)\n {\n scanf(\"%d\",&a);\n sum=sum+a;\n a=0;\n }\n if(sum%5==0)\n {\n q=sum/5;\n printf(\"%d\",q);\n }\n else\n printf(\"-1\");\n return 0;", "lang_cluster": "C", "compilation_error": true, "code_uid": "5a42dd99ab3acc864c82b8ffe3d0d461", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n\nint main{\nchar s[20];\nint a,b;\nscanf(\"%s\",&s);\na=strlen(s);\nb=((a*25)+26);\nprintf(\"%d\",b);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "99df6b682595c0f1d04655f5c0041e2e", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int n;\n int a[100];\n scanf(\"%d\",&n);\n for(int i=0;ibig)\n {\n big=a[i];\n }\n }\n int sum=0;\n for(int i=0;ibig)\n {\n cout<\nint main()\n{\n int y,b,r,s;\n scanf(\"%d %d %d\",&y,&b,&r);\n if((b>y)&&(r>b))\n {\n s=(3*y)+3);\n printf(\"%d\",s);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2ec0de8ae8edeaddc7bc186cd7829984", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nlong mu10(int x){\n\tint i;long kq=1;\n\tfor(i=1;i<=x;i++)kq=kq*10;\n\treturn kq;\n}\nchar So_xau(char s[],long n){\n\tint i;\n\tfor(i=8;i>-1;i--){\n\t\ts[8-i]=n/mu10(i)+48;\n\t\tn=n%mu10(i);\n\t}\n\ts[9]=0;\t\n}\nint main(){\nlong a,b,mod;\nchar win;\nchar a1[10];\nscanf(\"%ld%ld%ld\",&a,&b,&mod);\nif(b>=mod-1)win=2;\nelse{\n\tlong A;\n\tif(a>=mod)A=mod-1;else A=a;\n\tlong i,S=0;\n\tfor(i=1;i<=A;i++){\n\tS=S+mu10(9)%mod;\n\twhile(S>mod)S=S-mod;\n\tif(S>0&&SA)win=2;\n\telse{\n\t\twin=1;\n\t\tSo_xau(a1,i);\n\t}\n}\nprintf(\"%d\",win);if(win==1)printf(\" %s\",a1);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "ad1a821d7a6e3fab09a4fabdd2bdab4c", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\nint main(){\nint x,y;\nscanf(\"%d %d\",&x,&y);\nif((x+y) == 3)\n else printf(\"Akshat\");\nelse if((x*y)%2 == 0)\nprintf(\"Malvika\");\nelse printf(\"Akshat\");\nreturn 0;\n \n}\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d32f0b719a1659e073db092b151c3202", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#inlude\nint main()\n{\n int a,b,c;\n scanf(\"%d %d %d\",&a,&b,&c);\n if(b>=a && c>=a)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n}\n \n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "3322dd343e190d40884dd27c594bb642", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nchar tch, ch[6], mn[6],tstr[20];\nint l1=0,l2=0,max=0,i,j,k,t;\n#define ISAL(c)(((c)>='A')&&((c)<='Z'))\nint main(){\n scanf(\"%s\", &tstr);\n l2=strlen(tstr); \n while(tstr[i]!=':'){\n\t i++;\n }\n i--;\n for(j=0; j=k){\n\t mn[j++]=tstr[l2];\n\t l2--;\n }\n l2=strlen(mn);\n //printf(\"%d %d\\n\", l1, l2);\n if(l1==1&&l2==1&&ch[0]<24){\n\t puts(\"-1\");\n\t return 0;\n } \n for(i=0; imax){\n\t\tmax=ch[i];\t\t \n\t }\n\t //printf(\"%d \", ch[i]);\n }\n //putchar('\\n');\n for(i=0; imax){\n\t\t max=mn[i];\n\t }\n\t //printf(\"%d \", mn[i]);\n }\n //printf(\"\\nMAX:%d\\n\", max);\n max++;\n k=max;\n while(1){\n\t t=0,j=1;\n\t for(i=0; i=24){\n\t\t break;\n\t }\n\t t=0; j=1;\n\t for(i=0; i=60){\n\t\t break;\n\t }\n\t printf(\"%d \", k);\n\t k++;\n }\n if(k==max){\n\t putchar('0');\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "dffaca51ebfad66d4965da739fe293c8", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n\nint main ()\n{\n\n int n,i,cont1,cont2;\n scanf(\"%d\",&n);\n char numero[(n*2)+1];\n scanf(\"\\n%s\",numero);\n cont1 = 0;\n cont2 = 0;\n if( numero [1] > numero [ (n*2)-1] && numero[n-1 > numero[n])\n {\n printf(\"YES\");\n return NULL;\n }\n if( numero [1] < numero [ (n*2)-1] && numero[n-1 < numero[n])\n {\n printf(\"YES\");\n return NULL;\n }\n printf(\"NO\");\n\n return NULL;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "ac7f40d402a6d3b5fe7bf6d1c0430acb", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n\nmain()\n{\n int n=0,a=0,b=0,res=0;\n \n scanf(\"%d %d %d\",&n,&a,&b);\n \n \n if(abs(b) >= n)\n {\n if( b%n >= 0) {\n res = abs(a + (b%n));\n }else {\n res = abs(a + n + (b%n)) ;\n }\n \n } else {\n if(b >= 0)\n res = abs(a + b));\n else\n res = abs(a + n + b);\n }\n if(res <=n )\n printf(\"%d\",res);\n else \n printf(\"%d\", res - n ); \n \n \n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "72d7865f3f22d25e9943cd5faefbc538", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int *arr, n, i, j, temp;\n scanf(\"%d\",&n);\n arr = (int*)malloc(n*sizeof(int));\n for(i = 0; i < n; i++)\n {\n scanf(\"%d\", &arr[i]);\n }\n for(i = 0; i < (n-1); i ++)\n {\n for(j = 0; j < (n-i-1) ; j++)\n {\n if(arr[j] > arr[j+1])\n {{\n temp = arr[j];\n arr[j] = arr[j+1];\n arr[j+1] = temp;\n }\n }\n }\n for(i = 0; i < n; i++)\n printf(\"%d \", arr[i]);\n return 0; \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2a3f6d09267f15c016b9942046d443a4", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0} {"lang": "GNU C", "source_code": "\n#include\nint main()\n{\n\tint i=0,j=0,n,x;\n\tscanf(\"%d%d\",&n,&x);\n\ti=n%6;\n\t if((i==1||i==0)&&x==2) \n\t printf(\"2\");\n\t else if((i==2||i==5)&&x==1)\n\t print(\"2\");\n else if((i==3||i==4)&&x==0) \n printf(\"2\");\n else if((i==1||i==4)&&x==1) \n printf(\"0\");\n else if((i==2||i==3)&&x==2) \n printf(\"0\");\n else if((i==5||i==0)&&x==0)\n printf(\"0\");\n else if((i==1||i==2)&&x==0)\n printf(\"1\");\n else if((i==3||i==0)&&x==1)\n printf(\"1\");\n else if((i==4||i==5)&&x==2)\n printf(\"1\");\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "782c7b2e3a084dd90497041c570be513", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n int i;\n char arr[201];\n scanf(\"%s\",arr);\n int len=strlen(arr);\n for(i=0;i\n#include\n\nint main()\n{\ndouble m,n,a;\ndouble a1,a2;\nscanf(\"%lf%lf%lf\",&m,&n,&a);\na1=ceil(m/a);a2=ceil(n/a);\nif(m%a==0)\ta1=ceil(m/a-1);\nif(n%a==0)\ta2=ceil(n/a-1);\t\nprintf(\"%d\",(a1+1)*(a2+1));\nreturn 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "7196f75a8ec3eb1d7bbc027b783aa2df", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "# include \n\nusing namespace std;\n\nint main(void)\n{\n int n, m;\n while(~scanf(\"%d%d\", &n, &m))\n {\n if(n % 2 == 0)\n {\n if(m > n/2)\n printf(\"%d\\n\", (m-(n/2))*2);\n else\n printf(\"%d\\n\", 2*m-1);\n }\n else\n {\n if(m > n/2+1)\n printf(\"%d\\n\", (m-(n/2+1))*2);\n else\n printf(\"%d\\n\", 2*m-1);\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "93424cf7960ec0656165e8bb5d65377f", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main() {\n int a;\n scanf (\"%d\", &a);\n printf (\"%d\", (factorial(a + 2 - 1)/factorial(a - 1)));\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3f65ae01c27de385402b5edf1efc9196", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \n\nvoid SoftDrink(int n, int k, int l, int c, int d, int p, int nl, int np);\n\nvoid SoftDrink(int n, int k, int l, int c, int d, int p, int nl, int np)\n{\n int temp1 = 0, temp2 = 0, temp3 = 0;\n int min;\n temp1 = (k*l)/nl; \n temp2 = c*d;\n temp3 = p/np;\n \n min = temp1; \n if(temp2 < min)\n {\n min = temp2;\n }\n \n if(temp3 < min)\n {\n min = temp3;\n }\n \n printf(\"%d \", min/n);\n}\nint main(void)\n{\n int N, int K, int L, int C, int D, int P, int NL, int NP; \n scanf(\"%d %d %d %d %d %d %d %d \", &N, &K, &L, &C, &D, &P, &NL, &NP);\n SoftDrink(N, K, L, C, D, P, NL, NP);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f2d9cabf5b39e750fa4187ae6c3f51c7", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a[100],b[100],c,ans,min,n,sh,m,k,i;\n scanf(\"%d%d%d\",&n,&m,&k);\n for(i=0;i0 && a[i]0)\n {\n ans=abs(((i+1)-m)*10);\n break;\n }\n }\n for(i=0;i0 && abs(((i+1)-m)*10)\n#include\nint main()\n{\n int i,j,m,k,z,o,p,n,r,s,x,y,l;\n int sum[500];\n char efa[500];\n int ok;\n scanf(\"%d\",&ok);\n for(i=0; iy) x=y;}\n k++; break;\n }\n else if(k==1){\n if(efa[j]=='C') z=0;\n else{for(l=j; efa[l]!='C'; l++) z++;\n for(l=j; efa[l]!='C'; l--) o++;\n if(z>o) z=o;}\n k++; break;\n }\n else if(k==2){\n if(efa[j]=='T') p=0;\n else{for(l=j; efa[l]!='T'; l++) p++;\n for(l=j; efa[l]!='T'; l--) n++;\n if(p>n) p=n;}\n k++; break;\n }\n else if(k==3){\n if(efa[j]=='G') r=0;\n else{for(l=j; efa[l]!='G'; l++) r++;\n for(l=j; efa[l]!='G'; l--) s++;\n if(r>s) r=s;}\n k++; break;\n }\n }\n }\n}\nsum[i]=x+z+p+r;\n}\n int min=sum[0];\n for(i=1; i<(strlen(efa)-2); i++){\n if(sum[i]\n\n \n", "lang_cluster": "C", "compilation_error": true, "code_uid": "67e5b2efc9f1603675f9b81265256622", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(){\nchar a[10],b[10];\nint c,d,k;\ngets(a);\ngets(b);\nif(strstr(a,\"ond\")!=NULL){c=1;}\nif(strstr(a,\"ues\")!=NULL){c=2;}\nif(strstr(a,\"ednes\")!=NULL){c=3;}\nif(strstr(a,\"hursd\")!=NULL){c=4;}\nif(strstr(a,\"rida\")!=NULL){c=5;}\nif(strstr(a,\"aturd\")!=NULL){c=6;}\nif(strstr(a,\"und\")!=NULL){c=7;}\nif(strstr(b,\"onda\")!=NULL){d=1;}\nif(strstr(b,\"uesd\")!=NULL){d=2;}\nif(strstr(b,\"ednesd\")!=NULL){d=3;}\nif(strstr(b,\"hursd\")!=NULL){d=4;}\nif(strstr(b,\"rida\")!=NULL){d=5;}\nif(strstr(b,\"aturd\")!=NULL){d=6;}\nif(strstr(b,\"unda\")!=NULL){d=7;}\nk=d-c;\nif(k<0){\n k+=7;\n}\nif(k=0||k=2||k=3){\n printf(\"yes\");\n}\n else printf(\"no\");\n}\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3958c829613e13a555fcc1c1d1673e0f", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "//\n// Battle.c\n// \n//\n// Created by Maris Serzans on 06.08.14.\n//\n//\n\n#include \n\nint main()\n{\n int a;\n scanf(\"%i\", &a);\n print(\"%i\", a * 3 / 2);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0944e0f6fcb26c07bb2311512660ecd7", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tchar a[51];\n\tscanf(\"%s\",a);\n\n\tint len = strlen(a);\n\tint count1 = 0 , count2 = 0;\n\tfor (int i = 0; i < len; ++i)\n\t{\n\t\tif(a[i] == 'f' && a[i+1] == 't' && a[i+2] == 'p' && count1 == 0)\n\t\t{\n\t\t\tprintf(\"%c%c%c://\",a[i],a[i+1],a[i+2]);\n\t\t\ti = i+2;\n\t\t\tcount1++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif(a[i] == 'h' && a[i+1] == 't' && a[i+2] == 't' && a[i+3] == 'p' && count1 == 0)\n\t\t{\n\t\t\tprintf(\"%c%c%c%c://\",a[i],a[i+1],a[i+2],a[i+3]);\n\t\t\tif(a[i+4] == 'r' && a[i+5] == 'u')\n\t\t\t{\n\t\t\t\tprintf(\"%c%c\",a[i+4],a[i+5]);\n\t\t\t\ti= i+2; \n\t\t\t}\n\t\t\ti = i+3;\n\t\t\tcount++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif(a[i] == 'r' && a[i+1] == 'u' && count2 == 0)\n\t\t{\n\t\t\tprintf(\".%c%c/\",a[i],a[i+1]);\n\t\t\ti = i+1;\n\t\t\tcount2++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tprintf(\"%c\",a[i]);\n\t}\n\tprintf(\"\\n\");\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "64ba65e61d3a6d67435105594ff4dff9", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint main(){\n int N;\n scanf(\"%d\", &N);\n char *s = (char*) malloc((N+1) * sizeof(char));\n scanf(\"%s\", s);\n int i, len = 0, maxLen = 0, wordCount = 0, isInsideParen = 0;\n for(i = 0; i <= N; i++){\n if(s[i] == '_' || s[i] == '(' || s[i] == ')' || s[i] == 0){\n if(!isInsideParen && len > maxLen){\n maxLen = len; \n }else if(isInsideParen){\n if(len > 0)\n wordCount+#include \n#include \nint main(){\n int N;\n scanf(\"%d\", &N);\n char *s = (char*) malloc((N+1) * sizeof(char));\n scanf(\"%s\", s);\n int i, len = 0, maxLen = 0, wordCount = 0, isInsideParen = 0;\n for(i = 0; i <= N; i++){\n if(s[i] == '_' || s[i] == '(' || s[i] == ')' || s[i] == 0){\n if(!isInsideParen && len > maxLen){\n maxLen = len; \n }\n if(isInsideParen){\n if(len > 0)\n wordCount++;\n if(s[i] == ')'){\n isInsideParen = 0;\n }\n }\n else if(s[i] == '('){\n isInsideParen = 1;\n }\n len = 0;\n }else{\n len++;\n }\n }\n printf(\"%d %d\\n\", maxLen, wordCount);\n}+;\n if(s[i] == ')'){\n isInsideParen = 0;\n }\n }else if(s[i] == '('){\n isInsideParen = 1;\n }\n len = 0;\n }else{\n len++;\n }\n }\n printf(\"%d %d\\n\", maxLen, wordCount);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3460c5512a3e18b333e39fbab5bd7459", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n void swap(int*,int*);\n int n,t;\n scanf(\"%d %d\",&n,&t);\n \n char q[100];\n scanf(\"%s\",q);\n \n int i,j;\n \n for(i=0;i\n#include \n#include \n#include \n#define MAX 100\nint main()\n{\n int i=0;\n char a[26];\n for (i=0;i<26;i++)\n a[i]=0;\n int count=0;\n int alpha;\n char str[MAX];\n gets(str);\n int l=strlen(str);\n\n for (i=0; i\n \n\nint main()\n{\n scanf(\"%d%d%d%d\",&w1,&h1,&w2,&h2);\n int result = 0;\n if(w1 > w2){\n result = (w1 + 2)*(h1 + 1) + (w2 + 2)*(h2 + 1) - w1*h1 - w2*h2 + (w1 - w2);\n } else {\n result = (w1 + 2)*(h1 + 1) + (w2 + 2)*(h2 + 1) - w1*h1 - w2*h2 + (w2 - w1);\n }\n printf(\"%d\\n\",result);\n \n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b7dbb0d93d1d0ce16c2debe85c5ddbb1", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\nint n;scanf(\"%d\",&n);getchar();\nchar a[n];int b[n];int i=0;int sum=0;\nfor(i=0;i\n#include \n\nint main() {\n\t\tint n, s;\n\t\tchar s[1000];\n\t\tscanf(\"%d\", &n);\n\t\tscanf(\"%d\", &s);\n\t\titoa(s, s, 10);\n\t\tif (n == 1) {\n\t\t\tif (s[0]=='0')\n\t\t\tprintf(\"No\");\n\t\t\telse printf(\"Yes\");\n\t\t\treturn 0;\n\t\t}\n\t\tfor (int i=1; i\n#include\n\n\nint main() {\n int n,a,b,i,l1,l2,x;\n char str1[12],str2[12],temp1[12],temp2[12];\n \n scanf(\"%d\\n\",&n);\n scanf(\"%d \",&a);\n //printf(\"%d \",a);\n for(i=0;itwo)\n {\n temp1[l1-1]=two;\n temp1[l1]=one;\n temp1[l1+1]='\\0';\n }\n else\n {\n \n temp2[l2-1]=one;\n temp2[l2]=two;\n temp2[l2+1]='\\0';\n \n }\n count++;\n }\n \n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6aeb4dae535a39c797660ec1d266cd09", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\n\nint C(int n,int p){\n if(n1) min = m*C(q,2);\n }\n else{\n min = 0;\n q = int(n/m);\n if(q>0){\n for(j=1;j<=m;j++){\n s = (q+1) * j;\n if((n-s) < q*(m-j))\n break;\n }\n min = (j-1)*C((q+1),2) + (m-j+1)*C(q,2);\n }\n }\n max = C((n-m+1),2);\n printf(\"%d %d\\n\",min,max);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e24be35577227bd6a0d851ad3af4fd45", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(int argc, char const *argv[])\n{\n int n;\n int64_t sum=0;\n\n scanf(\"%d\", &n);\n\n for(int i = 0; i < n; i++)\n sum+=n*(i+1)-i;\n \n printf(\"%ld\\n\", sum);\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "73e41a51d46b64c492de0daff2549c44", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n//using namespace std;\n\n\nint main()\n{\n\tint n , chip;\n\t//vectorv;\n\tscanf(\"%d%d\",&n,&chip);\n\tint total = 0;\n\tbool mama = false;\n\twhile(1)\n\t{\n\t\tint i;\n\t\tfor(i = 1; i <= n;i++){\n\t\t\tif((chip - i ) < 0){\n\t\t\t\tmama = true;break;\n\t\t\t}\n\t\t\telse chip -= i;\n\t\t}\n\t\tif(mama)break;\n\t}\n\n\tprintf(\"%d\\n\",chip);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "324cdb5e75e5a4f438647f0d5a5d10db", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int gl,gr,bl,br,low,high,low1,high1;\n\n scanf(\"%d %d %d %d\",&gl, &gr, &bl, &br);\n low = gl-1;\n high = g1*2+2;\n\n low1 = gr-1;\n high1 = gr*2+2;\n\n if((br>=low && br<=high) || (bl>=low1 && bl<=high1))\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "4a7e0cb3d2ff273917647d6cafcb4042", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nvoid main( ){\nint k,l,m;\nprintf(\"enter the weight of watermelon\");\nscanf(\"%d\",&k);\nprintf(\"divide the watermelon into two parts %d %d\",l,m);\nscanf(\"%d %d\",&l,&m);\nif(k=l+m&&l%2=0&&m%2=0&&w%2=0){\n printf(\"yes\");\n}\nelse\nprintf(\"no\");\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "fdd4866ea81d0e95143d482bd7f3c68e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n char ch[150];\n scanf(\"%s\",ch);\n int l=strlen(ch);\n int i,j,k;\n for(i=l-1;i>=0;i--)\n {k=0;\n if((ch[i]>=65 && ch[i]<=90) || (ch[i]>=97 && ch[i]<=122))\n {\n if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y'||ch[i]=='A'||ch[i]=='E'||ch[i]=='I'||ch[i]=='O'||ch[i]=='U'||ch[i]=='Y')\n {\n printf(\"YES\");\n k=1;\n }\n else\n {\n printf(\"NO\");k=1}\n if(k==1)break;\n }\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2adadd0d53764b45dce5a686050550c3", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n\nint main(void) {\n\tint x, y;\n\tscanf(\"%d%d\", &x, &y);\n\ty > 0 && x > y && (x - y + 1) % 2 == 0 ? cout << \"YES\" : cout << \"NO\";\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "fd9304e543f3716be6c04cee8bf1301a", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \nint main() {\n\tint n, min, max;\n\n\t//freopen(\"input.txt\", \"r\", stdin);\n\tscanf(\"%d\", &n);\n\tif (n > 7) {\n\t\tmin = n / 7 * 2;\n\t\tif (n % 7 == 0) max = min;\n\t\telse if (n % 7 == 1) max = min + 1;\n\t\telse max = min + 2;\n\t}\n\telse {\n\t\tif (n <= 5) {\n\t\t\tmin = 0;\n\t\t}\n\t\telse if (n == 6) { min = 1; }\n\t\telse { min = 0; }\n\t\tif (n >= 2) max = 2;\n\t\telse (n == 1) max = 1;\n\t}\n\tprintf(\"%d %d\", min, max);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "7c4bc0fdd5a432daeeee939193c50b41", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n ; cin>>n;\n cout<<(n*n+(n-1)*(n-1));\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "def2aaf46a834c802f23dc473d61d3aa", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0} {"lang": "GNU C", "source_code": "\n\n\t\n\t\n\t\t\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "25eac5dbf487c1793f8db103551caf37", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int count=0,ans=0,n,a[110],i;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&a[i]);\n count+=a[i];\n }\n if(count!=0)\n {\n printf(\"YES\\n1\\n1 %d\\n\",n);\n }\n else\n {\n for(i=1;i<=n;i++)\n {\n ans+=a[i];\n if(ans!=0)\n break;\n }\n if(i==n+1)\n printf(\"NO\\n\");\n else\n {\n printf(\"YES\\n2\\n1 %d\\n%d \n\n%d\\n\",i,i+1,n);\n }\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e99aa4e1d587e3684cee6df9a17607aa", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include \n\nint modMax = 1000000007;\nlong long int sumWOD[101];\nlong long int sumWD[101];\n\nint n, d, k;\n\nvoid computeSumWOD(int size) {\n sumWOD[0] = 1;\n sumWOD[1] = 1;\n for(int i = 2; i < size; i++) {\n for(int j = 0; j<=k && i-j>0; j++) {\n sumWOD[i] += sumWOD[i-j];\n sumWOD[i] %= modMax;\n }\n }\n}\n\nvoid computerSumWD(int size) {\n for(int i = 1; i < size; i++) {\n if(i >= d) \n sumWD[i] += sumWOD[i-d];\n for(int j = 1; j <=k && i-j>0; j++) {\n if(j == d)\n continue;\n sumWD[i] += sumWD[i-j];\n sumWD[i] %= modMax;\n }\n }\n}\n\nint main () {\n //get n, k, d\n int n,k,d;\n scanf(\"%d%d%d\", &n, &k, &d);\n computerSumWOD(n+1);\n computerSumWD(n+1);\n printf(\"%I64d\", sumWD[n]);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "fa2d6777ed920897bc82d0731d0bbbdd", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\n\n\nint main()\n{\n long long int n;\n scanf(\"%lld\",&n);\nchar a[n];\n\nscanf(\"%s\",a);\n//printf(\"%c\",a[n-1]);\nlong long int temp;\nlong long int f[26];\n\nfor(int i=0;i<26;i++)\n{\n f[i]=99999999999999;\n}\nfor(int i=0;imax && f[i]!=99999999999999)\n {\n\n max=f[i];\n id2=i;\n }\n\n if(f[i]\n#include \nint main(){\n int n;\n scanf(\"%d\", &n);\n int a[n];\n for(i=0;i\n#include \nlong long int (long long int ,long long int)\n{\n return a>b?a:b;\n}\nint main()\n{\n int n;\n long long int ans;\n scanf(\"%d\",&n);\n if(n==1)\n ans=1;\n else if(n==2)\n ans=2;\n else if (n==3)\n ans=6;\n else if(n%2==0)\n ans=max((n-1)*(n-2)*(n-3),n*(n-1)*(n-3));\n else\n ans=(n)*(n-1)*(n-2);\n printf(\"%lld\",ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "6b7749254bfd9cb21166f7e286aad84e", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int a,b,r;\n scanf(\"%d %d %d\",&a,&b,&r);\n if (2*r>((a\n#include \n\nint cmpfunc (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\nint main()\n{\n\tint* ar=calloc(6,sizeof(int));\n\tint* count=calloc(10,sizeof(int));\n\tint* dif=calloc(2,sizeof(int));\n\tint i=0;\n\tfor(i=0;i<6;i++)\n\t{\n\t\tscanf(\"%d\",ar+i);\n\t\tcount[ar[i]]++;\n\t}\n\tint k=0;\n\tint p=0;\n\tfor(i=1;i<=9;i++)\n\t{\n\t\tif(count[i]==4)\n\t\t\tk=1;\n\t\tif(count[i]==2)\n\t\t\tp=1;\n\t\tif(count[i]==6)\n\t\t\t{k=1;p=1}\n\t\tif(count[i]==5)\n\t\t\t{k=1;p=0}\n\t}\n\tif(k==1 && p==1)\n\t\tprintf(\"Elephant\");\n\telse if(k==1)\n\t\tprintf(\"Bear\");\n\telse\n\t\tprintf(\"Alien\");\n\t\n\treturn 0;\n\t\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a9958a7183630aaa1e2350cf982d399b", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#define matchboxes 100000000\n\nint m, containers[matchboxes][2];\nint main()\n{\n int n,i,result;\n scanf(\"%d\",&n);\n scanf(\"%d\",&m);\n for(i=0;in)\n containers[max][0]=n;\n sum = (containers[max][0]*containers[max][1]);\n containers[max][1]=0;\n return sum+a(n-containers[max][0]);\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1cfc3bd3883afc2b00491f3b6d620a3a", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "/*\n\n\nA. Nineteen\ntime limit per test\n1 second\nmemory limit per test\n256 megabytes\ninput\nstandard input\noutput\nstandard output\n\nAlice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"xiineteenppnnnewtnee\", she can get string \"xnineteenppnineteenw\", containing (the occurrences marked) two such words. More formally, word \"nineteen\" occurs in the string the number of times you can read it starting from some letter of the string. Of course, you shouldn't skip letters.\n\nHelp her to find the maximum number of \"nineteen\"s that she can get in her string.\nInput\n\nThe first line contains a non-empty string s, consisting only of lowercase English letters. The length of string s doesn't exceed 100.\nOutput\n\nPrint a single integer \u2014 the maximum number of \"nineteen\"s that she can get in her string.\nExamples\nInput\nCopy\n\nnniinneetteeeenn\n\nOutput\nCopy\n\n2\n\nInput\nCopy\n\nnneteenabcnneteenabcnneteenabcnneteenabcnneteenabcii\n\nOutput\nCopy\n\n2\n\nInput\nCopy\n\nnineteenineteen\n\nOutput\nCopy\n\n2\n\n*/\n\n\n// Code \n\n#include \n\nint main() {\n\n\tchar str[];\n\n\tgets(str);\n\n\tint iCount = 0;\n\n\tfor(int i = 0; str[i] != '\\0'; i++) {\n\t\tif(str[i] == 'i') iCount++;\n\t} \n\n\tprintf(\"%d\", iCount);\n\n\treturn 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "0070635b5eceac25945797731b01704d", "src_uid": "bb433cdb8299afcf46cb2797cbfbf724", "difficulty": null} {"lang": "GNU C11", "source_code": "#include \nint main(){\n\tlong long int k, l, i, ans = 0;\n\tscanf(\"%lld %lld\", &k, &l);\n\tans = k;\n\tfor(i = 0; ; i++){\n\t\tif(ans == b){\n\t\t\tprintf(\"YES\\n%lld\\n\", i);\n\t\t\treturn 0;\n\t\t}\n\t\tif(ans > b)\n\t\t\tbreak;\n\t\tans =* k;\n\t}\n\tprintf(\"NO\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0413c7d6e56c9f5cb5aa4953c4f80ebb", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint min(int a, int b){\n\tint m;\n\tif(ax1 && y2>y1){\n\t\ti=x1;j=y1;\n\t\twhile(min(x2,y2)!=min(i,j)){\n\t\t\tm++;\n\t\t\ti++;\n\t\t\tj++;\n\t\t}\n\t\tif(x2>i){\n\t\t\tm+=(x2-i);\n\t\t}\n\t\telse if (y2>j){\n\t\t\tm+=(y2-j);\n\t\t}\n\t}\n\n\tif(x2>x1 && y2i){\n\t\t\tm+=(x2-i);\n\t\t}\n\t\telse if (y2>j){\n\t\t\tm+=(y2+j);\n\t\t}\n\t}\n\n\tif(x2y1){\n\t\ti=x1;j=y1;\n\t\twhile(min(x2,y2)!=min(i,j)){\n\t\t\tm++;\n\t\t\ti--;\n\t\t\tj++;\n\t\t}\n\t\tif(x2>i){\n\t\t\tm+=(x2+i);\n\t\t}\n\t\telse if (y2>j){\n\t\t\tm+=(y2-j);\n\t\t}\n\t}\n\n\tif(x2y1){\n\t\ti=x1;j=y1;\n\t\twhile(min(x2,y2)!=min(i,j)){\n\t\t\tm++;\n\t\t\ti--;\n\t\t\tj--;\n\t\t}\n\t\tif(x2>i){\n\t\t\tm+=(x2+i);\n\t\t}\n\t\telse if (y2>j){\n\t\t\tm+=(y2+j);\n\t\t}\n\t}\n\tif(x2=x1 && y2!=y1){\n\t\tm=abs(y2-y1);\n\t}\n\tif(y2=y1 && x2!=x1){\n\t\tm=abs(x2-x1);\n\t}\n\tif(x2=x1 && y2=y1){\n\t\tm=0;\n\t}\n\tprintf(\"%d\\n\",m);\n\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "cd63ad282cafef1f9ab721dde37fc914", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,b,k;\n\tscanf(\"%d%d%d\",&k,&a,&b);\n\tif((ak && bk)\n\t\t\t printf(\"%d\",b/k);\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"%d\",a/k+b/k)\n\t \t } \n\t } \t\n\t}\t\n\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "c8f5a7320384bacdc45121b0bbd392ba", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,j,n;\n scanf(\"%d\",&n);\n int a[n][n];\n \n for(i=0;i\r\nint main(){\r\n int n,k;\r\n // int sum=0;\r\n int arr[3];\r\n scanf(\"%d\",&n);\r\n for(int i=0;i0&&arr[arr[arr[p-1]]]>0){\r\n printf(\"YES\\n\");\r\n }\r\n }\r\n return 0;\r\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b628ff8c9cebcf52c9de5369924af634", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#define max(x,y) x>y?(x):(y);\nint main(){\n int n,m;\n char **t={\"1/1\",\"5/6\",\"2/3\",\"1/2\",\"1/3\",\"1/6\"};\n scanf(\"%d %d\",&n,&m);\n printf(\"%s\",t[max(n,m)-1]);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2dba3f128ca07c0ed74f282281d5bd03", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\nconst int maxn = 2e5+9;\ntypedef long long ll;\n\nint score[19][19]={{3,3,0,4,4,0,3,3},{3,3,0,4,4,0,3,3},{2,2,0,3,3,0,2,2},{2,2,0,3,3,0,2,2},{1,1,0,2,2,0,1,1},{1,1,0,2,2,0,1,1}};\nchar ch[19][19];\n\nint main(){\n\tfor(int i=0;i<6;i++) scanf(\"%s\",ch[i]);\n\tint mx = 0,ii,jj;\n\tfor(int i=0;i<6;i++){\n\t\tfor(int j=0;j<8;j++){\n\t\t\tif(ch[i][j]=='-'||ch[i][j]=='*'){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(score[i][j]>mx) mx = score[i][j],ii = i,jj = j;\n\t\t}\n\t}\n\tch[ii][jj] = 'P';\n\tfor(int i=0;i<6;i++){\n\t\tprintf(\"%s\\n\",ch[i]);\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "291aeeba016fb10722f49c9892c72103", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\nint n1,n2,k1,k2;\nif(n2>n1){\nprintf(\"first\");\n}\nelse if(n2==n1);\n{printf(\"first\");\n}\nelse{\nprintf(\"second\");\n}\n\n\n\nreturn 0;\n}\n\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "32f7debf621da9007fe6cded30971f29", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n int T; scanf(\"%d\\n\", &T);\n for(int ti = 0, tn = T ; ti < tn ; ++ti) {\n int X; scanf(\"%d\\n\", &X); bool found = false;\n for(int i = 0 ; 7*i <= X && !found ; ++i)\n found = ((X - 7*) % 3 == 0);\n printf(\"%s\\n\", found ? \"YES\" : \"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "cae05cb1a46413a5c6907f268bcbdd11", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,m,x,i,k;\n scanf(\"%lld %lld %lld\",&n,&m,&x);\n if(x>n&&x>m&&n<=0&&m<=0)\n {\n printf(\"-1\\n\");\n }\n else\n {\n for(i=0;;i++)\n {\n if(n>=x||m>=x)\n {\n break;\n }\n else if(n\nint main()\n{\n\tint r,g,b;\n\tscanf(\"%d %d %d\",&r,&g,&b);\n\tprintf(\"%d\\n\",max(r/3+g/3+b/3,max((r-1)/3 + (g-1)/3 + (b-1)/3+((r<(g=1),(r-2)/3 + (g-2)/3 + (b-2)/3+2*(((r<(g=1)))) );\n\t//printf(\"%d\\n\",min(r,min(g,b)) >=2);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "428b858731938e4f810ae7c6e2d0bb46", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,i;\n\tint a[4]={};\n\tscanf(\"%d\",&n);\n\tputchar('+');\n\tfor(i=0;i<24;i++)\n\t\tputchar('-');\n\tputchar('+');\n\tputchar('\\n');\n\tif(n>=4)\n\t{\n\t\tif((n-4)%3>=1)\n\t\ta[0]=1+(n-4)/3+1;\n\t\telse\n\t\ta[0]=1+(n-4)/3;\n\t\tif((n-4)%3>=2)\n\t\ta[1]=1+(n-4)/3+1;\n\t\telse\n\t\ta[1]=1+(n-4)/3;\n\t\ta[2]=1;\n\t\ta[3]=1+(n-4)/3;\n\t}\n\telse\n\t{\n\t\ta[0]=1;\n\t\tif(n>=2)\n\t\t\ta[1]=1;\n\t\tif(n>=3)\n\t\t\ta[2]=1;\n\t}\n\tputchar('|');\n\tfor(i=0;i\n\nint main()\n {\n int n,k,i,l=0;\n scanf(\"%d%d\",&n,&k);\n for(i=1;i<=n;i++){\n minn+=i*5;\n if(l>240-k){\n printf(\"%d\\n\",i-1);\n\n }\n }\n\n return 0;\n }\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b54f579d0a34d4cfca77b77b16ebfa84", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\n\n\nusing namespace std;\nint m=1e9+7;\nlong long pow(long long a,int n){\n long long w=1;\n while(n>0){\n if(n%2==0){\n a=(a*a)%m;\n n/=2;\n }\n else{\n \n n--;\n w=(w*a)%m;\n }\n }\n return w;\n}\n\nint main(){\n int n,a=27,b=7;\n scanf(\"%d\",&n);\n printf(\"%I64d\",(m+pow(a,n)-pow(b,n))%m);\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "57556f72b9c0081803dd3ec28a5d60da", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint n, a, b, x, y;\n\tint flag = 0;\n\tscanf(\"%d %d %d %d %d\", &n, &a, &x, &b, &y);\n\ta--;\n\tb--;\n\tx--;\n\ty--;\n\tint i = a;\n\tint j = b;\n\n\tfor(int k=0; k\n#include \n\nint main ()\n{\n int n ,m ,i=0;\n scanf(\"%d%d\",&n,&m);\n int a[n] ;\n for(i=0;i\n\nint main(void) {\n\t// your code goes here\n\treturn 0;\n}\n\n#include \n\nint main(void) {\n\t// your code goes here\n\tint adult,child;\n\tint min=0,max=0,a,b,c;\n\t\n\tscanf(\"%d %d\",&adult,&child);\n\tif(adult==0&&child==0)printf(\"0 0\");\nelse if(adult==0&&child!=0)printf(\"Impossible\");\n\t\n\telse if(child==0)printf(\"%d %d\",adult,adult);\n\t\n\telse{\n\t if(adult>=child){ min=adult;max=adult+child-1; }\n\t if(adult\nint main()\n{\nint n,t,b,i;\nscanf(\"%d\",&n);\nfor(i=0;i<500;i++)\n{ b=0;\n t=i*(i+1)/2;\nif(t==n)\n{\n printf(\"YES\");\n b=1;\n break;\n}\nif(b==0)\n{\n printf(\"NO\");\n}\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b4f6c709926b9387958a1435930e1282", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include\nusing namespace std;\n\nint contains(int m){\n int r;\n while(m > 0){\n r = m % 10;\n if(r == 7)\n return 0;\n m = m /10;\n }\n return 1;\n \n}\nint main() {\n /* Enter your code here. Read input from STDIN. Print output to STDOUT */ \n int t;\n scanf(\"%d\",&t);\n int m,n;\n scanf(\"%d%d\",&m,&n);\n long long int c = 0;\n while(contains(m) && contains(n)){\n \n n = n - t;\n \n c++;\n if(n <= 0){\n m = m - 1;\n if(m == -1)\n m = 23;\n n = n + 60;\n }\n }\n printf(\"%lld\\n\",c);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "6c8b90d72e4cbc96611de5ac36e8de50", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n\n\nvoid main()\n{\n\tint a,b,c,aux,cont=0;\n\tscanf(\"%d %d %d\",&a,&b,&c);\n\t\n\tint i,j;\n\taux = a;\n\tfor(i=0;i=0)\n System.out.println(\"Yes\");\n else\n System.out.println(\"No\");\n \n return 0;\n \n }\n}\n \n\n\n ", "lang_cluster": "C", "compilation_error": true, "code_uid": "ac75882aac64b06f9be33d38bf4d38e9", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n\nusing namespace std;\n\nint gcd (int a, int b) \n{\n\tif (b == 0)\n\t\treturn a;\n\tif (a == 0)\n\t\treturn b;\n\telse\n\t\treturn gcd (b, a % b);\n}\n\nint main()\n{\n\tint n; cin>>n;\n\tint a,b;\n\ta = 0; \n\tb = 0;\n\tfor(int i = 1; i <= n/2; i++)\n\t{\n\t\tif(gcd(i,n-i) == 1)\n\t\t{\n\t\t\ta = i;\n\t\t\tb = n-i;\n\t\t}\n\t}\n\t\n\tcout<\n#include\nint main(){\n\tlong long a,b,i;\n\tlong long t[100];\n\tscanf(\"%lld %lld\",&a,&b);\n\tfor(i=0;i<3;i++){\n\t\tscanf(\"%lld\",&t[i]);\n\t\tif(i==0){\n\t\t\ta=a-2*t[i];\n\t\t}\n\t\tif(i==1){\n\t\t\ta=a-t[i];\n\t\t\tb=b-t[i];\n\t\t}\n\t\tif(i==2){\n\t\t\tb=b-3*t[i];\n\t}\n}\n if(a<0){\n\t\tif(b<0){\n\t\t\tprintf(\"%lld\",-(a+b));\n\t\t}\n\t\telse(b>=0){\n\t\t\tprintf(\"%lld\",-a);\n\t\t}\n\telse{\n\t\tif(b<0){\n\t\t\tprintf(\"%lld\",-(b));\n\t\t}\n\t\telse(b>=0){\n\t\t\tprintf(\"%d\",0);\t\n\treturn 0;}", "lang_cluster": "C", "compilation_error": true, "code_uid": "723402ae645162c1696c7bae9f28beb6", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nusing namespace std;\nint main()\n{\n char s[100];\n gets(s);\n int i,j,x,y,z=0,n,b;\n x=strlen(s);\n for(i=0; i\n#define L 8\n\nchar m[L+1][L+1];\nint a[L+1], b[L+1];\n\nint main() {\n\tint i, j, am, bm;\n\n\tfor(i=0; i=0; i--) {\n\t\t\tif(m[i][j] != '.') {\n\t\t\t\tif(m[i][j] == 'B') {\n\t\t\t\t\tb[j] = L-i-1;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor(j=0; j\n#include\nint main()\n{\n float d,L,v1,v2;\n scanf(\"%d %d %d %d\",&d,&L,&v1,&v2);\n printf(\"%f\\nL-d)/(v1+v2));\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b79741d211c217fe266da7d3619b1720", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n/* run this program using the console pauser or add your own getch, system(\"pause\") or input loop */\nint ans,i,j,i1,j1,r,c,n,s,a[11],b[11];\nint search(int x,int y,int d1,int d2)\n{\nint sum,k;sum=0;\nfor(k=1;k<=n;k++)\n{\nif(a[k]>=x&&a[k]<=x+d1-1&&b[k]>=y&&b[k]<=y+d2-1)\nsum++;\nif(sum>=s) return 1;\n}\nreturn 0;\n}\n\nint main(int argc, char *argv[]) {\n\tscanf(\"%d%d%d%d\",&r,&c,&n,&s);\n\tfor(i=1;i<=n;i++)\n\tscanf(\"%d%d\",&a[i],&b[i]);\n\tans=0;\n\tfor(i=1;i<=r;i++)\n\t for(j=1;j<=c;j++)\n\t {\n\t for(i1=1;i1<=r-i+1;i1++)\n\t for(j1=1;j1<=c-j+1;j1++)\n\t if(search(i1,j1,i,j)) ans++;\n\n\t }\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "d5c77bdc71462376437f9a60b2933f47", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n\tint h1=0,m1=0,a=0,hd=0,h2=0,m2=0,m3=0,md=0,mf=0,h3=0,hf=0,t=0,ha=0;\n\tscanf(\"%d:%d\",&h1,&m1);\n\tscanf(\"%d\",&a);\n\tif ((a==0)&&(m1<10)&&(h1>=10))\n\t{\n\t\tprintf(\"%d:0%d\",h1,m1);\n\t}\n else if ((a==0)&&(h1<10)&&(m1>=10))\n\t{\n\t\tprintf(\"0%d:%d\",h1,m1);\n\t}\n\telse if ((a==0)&&(h1>10)&&(m1>10))\n\t{\n\t\tprintf(\"%d:%d\",h1,m1);\n\t}\n\telse if ((a==0)&&(h1<10)&&(m1<10))\n\t{\n\t\tprintf(\"0%d:0%d\",h1,m1);\n\t}\n\telse\n\t{\n\thd=a/60;\n\tmd=a%60;\n\tm2=m1+md;\n\th2=h1+hd;\n\tm3=m2/60;\n\th3=h2+m3;\n\tmf=m2-60*m3;\n\t\n if (h3==24)\n {\n \thf=0;\n }\n \n else if(h3>24)\n {\n \tha=h3-24;\n \thf=ha%24;\n }\n else\n {\n \thf=h3;\n }\n\t\n\tif((mf<10)&&(hf<10))\n {\n \tprintf(\"0%d:0%d\",hf,mf);\n }\n \tif((mf<10)&&(hf>=10))\n {\n \tprintf(\"%d:0%d\",hf,mf);\n }\n \tif((mf>=10)&&(hf<10))\n {\n \tprintf(\"0%d:%d\",hf,mf);\n }\n \tif((mf>=10)&&(hf>=10))\n {\n \tprintf(\"%d:%d\",hf,mf);\n }\n\t}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f1295c94a5a232f76b90fd89a4a9ba7d", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n int t;\r\n scanf(\"%d\",&t);\r\n printf(\"%d\",t);\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "71b8d9eb0a8aad07431fad24d0ebdb27", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include\n\nint abs(int a) {\n if (n >= 0) {\n return n;\n }\n return -n;\n}\n\nchar a[201];\nint i,n,x,ans;\nmain()\n{\n scanf(\"%d %s\",&n,a);\n for(i=0;in/2&&a[i]=='X')a[i]='x',x--;\n else if(x\n\nint main()\n{\n int arr[10],i;\n for(i=0;i<10;i++)\n arr[i]=0;\n int n;\n scanf(\"%d \",&n);\n char ch='a';\n while(1)\n {\n scanf(\"%c\",&ch);\n if(ch=='\\n')\n break;\n arr[(int)ch%48]++;\n //printf(\"i:%d arr[i]:%d\",(int)ch%48,arr[(int)ch%48]);\n }\n arr[0]=-1;arr[1]=-1;\n arr[7]+=arr[9]+arr[8];\n arr[3]+=2*arr[9]+arr[6]+arr[4];\n arr[2]+=arr[9]+3*arr[8]+2*arr[4];\n arr[9]=0;arr[8]=0;\n arr[5]+=arr[6];\n arr[6]=0;arr[4]=0;\n for(i=9;i>=0;i--)\n {\n while(arr[i]>0)\n {\n printf(\"%d\",i);arr[i]--;\n }\n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "6dfa0687a814bd68c2d30f15bd2e45cd", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main()\n{\n char strtab[100][20]={\n \"zero\",\n \"one\",\n \"Two\",\n \"three\",\n \"four\",\n \"five\",\n \"six\",\n \"seven\",\n \"eight\",\n \"nine\",\n \"ten\",\n \"eleven\",\n \"twelve\",\n \"thirteen\",\n \"fourteen\",\n \"fifteen\",\n \"sixteen\",\n \"seventeen\",\n \"eighteen\",\n \"nineteen\",\n \"twenty\",\n \"twenty-one\",\n \"twenty-two\",\n \"twenty-three\",\n \"twenty-four\",\n \"twenty-five\",\n \"twenty-six\",\n \"twenty-seven\",\n \"twenty-eight\",\n \"twenty-nine\",\n \"thirty\",\n \"thirty-one\",\n \"thirty-two\",\n \"thirty-three\",\n \"thirty-four\",\n \"thirty-five\",\n \"thirty-six\",\n \"thirty-seven\",\n \"thirty-eight\",\n \"thirty-nine\",\n \"forty\",\n \"forty-one\",\n \"fourty-two\",\n \"forty-three\",\n \"fourty-four\",\n \"forty-five\",\n \"fourty-six\",\n \"forty-seven\",\n \"fourty-eight\",\n \"forty-nine\",\n \"fifty\",\n \"fifty-one\",\n \"fifty-two\",\n \"fifty-three\",\n \"fifty-four\",\n \"fifty-five\",\n \"fifty-six\",\n \"fifty-seven\",\n \"fifty-eight\",\n \"fifty-nine\",\n \"sixty\",\n \"sixty-one\",\n \"sixty-two\",\n \"sixty-three\",\n \"sixty-four\",\n \"sixty-five\",\n \"sixty-six\",\n \"sixty-seven\",\n \"sixty-eight\",\n \"sixty-nine\",\n \"seventy\",\n \"seventy-one\",\n \"seventy-two\",\n \"seventy-three\",\n \"seventy-four\",\n \"seventy-five\",\n \"seventy-six\",\n \"seventy-seven\",\n \"seventy-eight\",\n \"seventy-nine\",\n \"eighty\",\n \"eighty-one\",\n \"eighty-two\",\n \"eighty-three\",\n \"eighty-four\",\n \"eighty-five\",\n \"eighty-six\",\n \"eighty-seven\",\n \"eighty-eight\",\n \"eighty-nine\",\n \"ninety\",\n \"ninety-one\",\n \"ninety-two\",\n \"ninety-three\",\n \"ninety-four\",\n \"ninety-five\",\n \"ninety-six\",\n \"ninety-seven\",\n \"ninety-eight\",\n \"ninety-nine\"\n\n\n };\n int i, j,n;\n while(scanf(\"%d\", &n)){\n if(n>=0 && n<=99) printf(\"%s\\n\", strtab[n]);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9abfbc5f49dd53bb6a51aa644d5a1da3", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \nchar s[110],a[110],b[110];\nint main()\n{\n scanf(\"%s %s\",a,b);\n strcpy(s,a);\n int n=strlen(a),i,f=0;\n if(n==1)\n {\n if(b[0]-a[0]>1)\n s[0]++;\n printf(\"%s\",s);\n return 0;\n }\n for(i=n-1;i>=0;i--)\n {\n if(a[i]!= 'z')\n {s[i]++;break;}\n s[i]='a';\n }\n } \n for(i=0;i0)\n {\n f=1;\n break;\n }\n }\n if(!f)\n { \n if(b[n-1]-a[n-1]>1)\n printf(\"%s\",s);\n else \n printf(\"No such string\");\n \n }else\n printf(\"%s\",s);\n return 0;\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3c97b0ab4c023630e9b0bdf91edf3bd0", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \n#include \nvoid compareVal(int x, int y) \n{ \n long double a = y * log(x); \n long double b = x * log(y); \n if (a > b) \n printf( \" > \"); \n \n else if (a < b) \n printf(\" < \"); \n \n else if (a == b) \n printf(\" = \"); \n} \nint main() \n{ \n long double x = 4, y = 5; \n \n compareVal(x, y); \n \n return 0; \n} #include \n#include \nvoid compareVal(int x, int y) \n{ \n long double a = y * log(x); \n long double b = x * log(y); \n if (a > b) \n printf( \" > \"); \n \n else if (a < b) \n printf(\" < \"); \n \n else if (a == b) \n printf(\" = \"); \n} \nint main() \n{ \n long double x, y; \n scanf(\"%Lf %Lf\",&x,&y);\n compareVal(x, y); \n \n return 0; \n} ", "lang_cluster": "C", "compilation_error": true, "code_uid": "f1f311b3bccfcc9932f01519dcf64892", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n char a[20];\n int k,i,j,l,bar,temp,flag,var;\n scanf(\"%s\",a);\n scanf(\"%d\",&k);\n l=strlen(a);\n for(i=0;i=k?k:l);i++)\n {\n if(a[i]>a[j])\n {\n var=i;\n flag=1;\n }\n }\n \n if(flag)\n {\n temp=a[var];\n for(bar=var-1;bar>=j;bar--)\n a[bar+1]=a[bar];\n a[j]=temp;\n k-=(var-j);\n }\n }\n for(i=0;i", "lang_cluster": "C", "compilation_error": true, "code_uid": "bb237e95ba54ae170781617656acde7d", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std; \nint k,p; \nlong long zcy[100005]; \nvoid init() \n{ \n int cnt=0; \n for(int i=1;i<=100000;i++) \n { \n long long tmp=i; \n int p=i; \n while(p){ \n tmp=tmp*10+p%10; \n p/=10; \n } \n zcy[++cnt]=tmp; \n } \n} \nint main() \n{ \n init(); \n while(~scanf(\"%d%d\",&k,&p)) \n { \n long long sum=0; \n for(int i=1;i<=k;i++){ \n sum+=zcy[i]; \n sum%=p; \n } \n printf(\"%lld\\n\",sum); \n } \n return 0; \n} ", "lang_cluster": "C", "compilation_error": true, "code_uid": "0a83c6557b40ad101b79cc1edf43ee08", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nlong long int n,s;\nscanf(\"%I64d\",&n);\nif(n%2!=0)\ns=(n+1)/2;\nelse if (n%2=0)\ns=(n+1);\nelse\ns=0;\nprintf(\"%I64d\",s);\nreturn 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b0190995f38515a407cad472f7b15e6f", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint power(int n, int m){\n int res = 1;\n for(int i = 1; i <= m; i++){\n res = res*n;\n }\n return res;\n}\n\nint main(){\n char *n = (char *)malloc(power(10,9)*sizeof(char));\n scanf(\"%s\", n);\n int len = strlen(n), sum = 0;\n int val = power(2,len) - 1;\n for(int i = 0; i < len; i++){\n if (*(n+i) == '7')\n sum += power(2,len-i-1);\n }\n val = val + sum;\n printf(\"%d\", val);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "aaf06fc78c23ac497282b003e7aa867c", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int a,b,i,x=1,\n scanf(\"%lld%lld\",&a,&b);\n for(i=a;i<=b;i++){\n x=(x*i)%10;\n }\n printf(\"%lld\\n\",x);\n retur", "lang_cluster": "C", "compilation_error": true, "code_uid": "cdbf3d4c1faf7c812d5d2a9691157f5c", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,f,k;\n while(scanf(\"%d%d%d%d\",&a,&b,&f,&k)!=EOF)\n {\n int rb,x;\n x = 0;\n rb = b - f;\n if(rb >= 0)\n for(;k >0;)\n {\n if(2 * (a - f) > rb && k != 1)\n {\n x++;\n rb = b - 2*(a-f);\n }\n else if((a - f) > rb && k == 1)\n {\n x++;\n }\n else\n {\n rb-=2*(a-f);\n }\n if(b < 2*(a - f) && k != 1)\n {\n x = -1;\n break;\n }\n if(b < (a - f) && k == 1)\n {\n x = -1;\n break;\n }\n k--;\n if(k > 0 )\n {\n if(rb >= 2*f && k != 1)\n {\n rb-=2*f;\n }\n else if(rb >= f && k == 1)\n {\n rb-=f;\n }\n else\n {\n rb = b - 2*f;\n x++;\n }\n if(b < 2*f && k != 1)\n {\n x = -1;\n break;\n }\n if(b < f && k == 1)\n {\n x = -1;\n break;\n }\n k--;\n }\n }\n else\n x = -1;\n printf(\"%d\\n\",x);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "5f6a79662ae35a3b5765d99eab99375f", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n\tlong long m,t,c,z,i;\n\tlong long a[10000];\n\tscanf(\"%lld\",&m);\n\tt=1;\n\tc=1;\n\twhile(m>t)\n\t{\n\t\tm-=t;\n\t\tt=t*2;\n\t\tc++;\n\t}\n\tprintf(\"%lld\",c);\n\tif(m!=1)\n\t{\n\t\tm--;\n\t\tc--;\n\t\twhile(m>c)\n\t\t{\n\t\t\tprintf(\" %lld\",c);\n\t\t\tm-=c;\n\t\t\tc--;\n\t\t}\n\t\tprintf(\" %lld\",c);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "17157bf8a4caa099358644ae901bf154", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint prime_arr(int *arr)\n{\n int i,j,s,c=0;\n for(i=2;i<1000;i++)\n {\n s=sqrt(i);\n for(j=2;j<=s;j++)\n if(i%j==0)\n break;\n if(j>s)\n arr[c++]=i;\n }\n return c;\n}\nint main()\n{\n int i,j,n,k,p;\n int primes[1000];\n p=prime_arr(primes);\n scanf(\"%d %d\",&n,&k);\n for(i=5;i<=n;i++)\n {\n for(j=2;j\n\nint main() {\n\tint n;\n\tint sum;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++){\n\t\tsum+=i>(n-i+1)?(n-i+1):i;\n\t}\n\tprintf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "7ee66a09c497a7ffa65ff237b42ea183", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nint main(){\n long long n;\n scanf(\"%lld\",&n);\n printf(\"%lld\",n-n/2-n/3-n/5-n/7+n/6+n/10+n/14+n/15+n/21+n/35-n/30-n/42-n/70-n/105+n/210);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2314cf71acf285d544c9fc4dbfbe8af1", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tchar p[101],r=0;\n\tscanf(\"%s\",p);\n\tfor (int i=0;p[i]!='\\0';i++) {\n\t\tif (p[i]=='H'||p[i]='Q'||p[i]=='9'||p[i]=='+') {\n\t\t\tr=1; break;\n\t\t}\n\t}\n\tif (r==1) printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d3d8cfd0059a088f2abe1eee310887da", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n if(n==k)\n {\n printf(\"0 0\\n\");\n return 0;\n }\n else if(n>k && n/2=k)\n {\n printf(\"1 %d\\n\",k);\n }\n else\n printf(\"1 %d\\n\",k+1);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "16b7020b2894e7665da1f554470b0c52", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include\r\n#include\r\nint main()\r\n{\r\n int a, b, m, t, i, j, count = 0;\r\n scanf(\"%d %d\", &a, &b);\r\n\r\n int ar[a][b], n = 0;\r\n\r\n for(i=0; i 1){\r\n for(i=0; i\nint devide(int a, int b);\nint main()\n{\n int people, pages, notebooks, noteRed, noteGreen, noteBlue;\n scanf(\"%d %d\", &people, &pages);\n noteRed = devide(people * 2, pages);\n noteGreen = devide(people * 5, page);\n noteBlue = devide(people * 8, pages);\n notebooks = noteRed + noteGreen + noteBlue;\n printf(\"%d\", notebooks);\n return 0;\n}\nint devide(int a, int b)\n{\n if(a % b == 0) \n {\n a = a / b;\n }\n else\n {\n a = a / b + 1;\n }\n return a;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e0530a5dc02f41ab35cc6261992a6249", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int x,t,a,b,da,db,i,j,m,n;\n scanf(\"%d %d %d %d %d %d\",&x,&t,&a,&b,&da,&db);\n if(x==0) {printf(\"YES\");exit(0);}\n for(i=0;i\nint main()\n{\n long long int x1,x2,x3,y1,y2,y3,s,k,d1,d2;\n scanf(\"%lld %lld %lld %lld %lld %lld\",&x1,&y1,&x2,&y2,&x3,&y3);\n s=(x1*y2)-(x2*y1)+(x2*y3)-(x3*y2)+(x3*y1)-(x1*y3);\n d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\n d2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);\n if(s==0&&d1==d2)\n {\n printf(\"No\\n\");\n }\n else\n {\n printf(\"Yes\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "42f4c768a1fb7ece03704a198fce5e94", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n\tint n,D[101][3],i,j,k,a=0,b=0,t1=0,t2=0;\n\tscanf(\"%d\",&n);\n\tfor(i=1 ; i<=n ; i++)\n\t{\n\t\tscanf(\"%d %d\",&D[i][0],&D[i][1]);\n\t\tif((D[i][0]%2)==1) a++,t1+=D[i][0];\n\t\tif((D[i][1]%2)==1) b++,t2+=D[i][1];\n\t\tif(a!=b) t1=1;\n\t}\n\tif(a%2==0 && b%2==0) printf(\"0\");\n else if(t1) printf(\"1\")\n else printf(\"-1\")\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b6d0807f0670c7424a0d3e544ccab846", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include\nint max(int a,int b)\n{\n if(a>b)\n return a;\n else\n return b;\n}\nint main()\n{\n int a,b,c,d;\n scanf(\"%d\",&a);\n int arr[20]={};\n for(b=0;b\n\nusing namespace std;\n\nlong long mini(long long x,long long y,long long z){\n\treturn (x<=y && x<=z)?x:((y<=x && y<=z)?y:z);\n}\n\nint main(){\n\n\tlong long int a,b,c,d,e,f;long long t2,t1;\n\tcin>>a>>b>>c>>d>>e>>f;\n\tif(f>e){\n\t\tt2=mini(d,b,c);\n\t\tt1=mini(d-t2,a,100005);\n\t}\n\telse{\n\t\tt1=mini(d,a,100005);\n\t\tt2=mini(d-t1,b,c);\n\t}\n\tcout<<((t1*e)+(t2*f))<<\"\\n\";\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "38edba712bb7495ba4651621b156a1cf", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "GNU C", "source_code": "nclude\nint main()\n{\n int r,c,i,j,co,R=0,C=0,p[11]={0};\n char st[11];\n scanf(\"%d %d\",&r,&c);\n getchar();\n for(i=0;i\nint main(void)\n{\n\tlong long m, n, k, max;\n\tscanf(\"%I64d %I64d %I64d\", &m, &n, &k);\n\n\tif(m + n - 2 < k) {\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\n\tmax = m >= n ? m : n;\n\tif(k <= max - 1)\n\t\tprintf(\"%I64d\", (m / (k + 1)) * n >= (n / (k + 1)) * m) ? (m / (k + 1)) * n : (n / (k + 1)) * m);\n\telse printf(\"%I64d\", n / (k - m + 2) >= m / (k - n + 2)) ? n / (k - m + 2) : m / (k - n + 2));\n\n\treturn 0;\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2c9243bb6ccd485583c150ba68f3afa2", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \nusing namespace std;\n\nint verificaigual(float x[] , float y[]){\n if(x[0]==x[1] && y[0]==y[1]){\n return 0;\n }\n if(x[0]==x[2] && y[0]==y[2]){\n return 0;\n }\n if(x[1]==x[2] && y[1]==y[2]){\n return 0;\n }\n\n return 1;\n}\n\nint verifica(float a,float b,float c,float d,float e,float f){\n float dist1 = sqrt((a - c)*(a - c) + (b - d)*(b - d));\n float dist2 = sqrt((c - e)*(c - e) + (d - f)*(d - f));\n float dist3 = sqrt((a - e)*(a - e) + (b - f)*(b - f));\n float u , y;\n\n u = dist1*dist1;\n y = (dist2*dist2 + dist3*dist3);\n\n if(u==y)\n {\n return 0;\n }\n u = dist2*dist2;\n y = dist1*dist1 + dist3*dist3;\n\n if(u==y)\n {\n return 0;\n }\n u = dist3*dist3;\n y =(dist2*dist2 + dist1*dist1);\n if(u==y)\n {\n return 0;\n }\n\n return 1;\n}\n\nint main(){\n\n float a, b, c, d, e, f;\n cin >> a;\n cin >> b;\n cin >> c;\n cin >> d;\n cin >> e;\n cin >> f;\n\n\n if(verifica(a,b,c,d,e,f)==0){\n cout << \"RIGHT\" <\nvoid main(){\n\tint n,i,k;\n\tscanf(\"%d\",&n);\n\ti=1;\n\twhile ((n-(3*i))>=0){\n\t\tk=i;\n\t\ti++;\n\t}\n\tif (n-(3*k)==1){\n\t\tprintf(\"%d\",(3+k)*2);\n\t}\n\telse printf(\"%d\",(3+k)*2+2);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b5a597886b89b5ef31a3d9689c66f7bb", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n\nusing namespace std;\nint main()\n{\n int n,ar[3],i,p,r,q,t,j;\n scanf(\"%d\",&n);\n for(i=0;i<=2;i++)\n scanf(\"%d\",&ar[i]);\n \n for(i=0;i<3-1;i++){\n for(j=i+1;j<3;j++){\n if(ar[i]>ar[j])\n {t=ar[i];ar[i]=ar[j];ar[j]=t;}\n }\n }\n // cout<\nint main()\n{\n\tlong t,k,n;\n\twhile(~scanf(\"%ld%ld%ld\",&n,&k,&t)){\n\t\tif(t<=k){\n\t\t\tprintf(\"%ld\\n\",t);\n\t\t}\n\t\telse if(t<=n){\n\t\t\tprintf(\"%ld\\n\",k);\n\t\t}\n\t\telse{\n\t\t\tprintf(\"%ld\\n\",2*n-k-t);\n\t\t}\n\t}", "lang_cluster": "C", "compilation_error": true, "code_uid": "065531ad895a59b04fb3b74f98aec339", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n,i;\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;i\n#include \n\nint main()\n{\n int n,i;\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;ia[n-2])\n {\n if(a[n-1]==15)\n {\n printf(\"DOWN\");\n\n }\n \n else\n printf(\"UP\");\n\n }\n else if(a[n-1]\n\nint leapyear(int year){\n if((year%4==0&&year%100!=0)||year%400==0)\n return 1;\n else\n return 0;\n}\n\nint main(){\n int h1,q=1,m=13,y1,flag1,flag2;\n int h2,y2;\n scanf(\"%d\",&y1);\n h1=(q+((26*(m+1))/10)+y1+(y1/4)+(6*(y1/100))+(y1/400))%7;\n for(y2=y1; ;y2++){\n h2=(q+((26*(m+1))/10)+y2+(y2/4)+(6*(y2/100))+(y2/400))%7;\n if(h1==h2){\n flag1=leapyear(y1);\n flag2=leapyear(y2);\n if(flag1==flag2){\n printf(\"%d\",y2);\n return 0;\n }\n }\n }\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d6071699086fd165d93fd1e65b51014f", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\n\nint main()\n{\n\tlong long lInput1;\n\tlong long lInput2;\n\n\tint iCnt;\n\tlong long lTotalCnt = 0;\n\tlong long lCheck;\n\t\t\n\tlong long i;\n\t\n\tscanf(\"%lld%lld\",&lInput1,&lInput2);\n\t\n\tfor( i = lInput1 ; i <= lInput2 ; i++ )\n\t{\n\t\n\t\tlCheck = i;\n\t\tiCnt = 0;\n\t\twhile( lCheck )\n\t\t{\n\t\t\tif ( (lCheck & 0x1) == 0 )\n\t\t\t\tiCnt++;\n\t\t\tlCheck >>= 1;\t\t\n\t\t}\n\t\tif( iCnt == 1 )\t\n\t\t\tlTotalCnt++;\n\t\t\t\n\t}\n\t\n\tprintf(\"%lld\\n\",lTotalCnt);\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6d9b9c8554ecf30055c0e2f50dc92d7b", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include \n\n\nint main() {\n\tint x, y, r, a;\n\tscanf_s(\"%d\",&r);\n\tr = r - 1;\n\ty = (r - 2) / 2;\n\tx = 0;\n\twhile (++x) {\n\t\tif (x * (x + (2 * y) + 1) == r) {\n\t\t\tprintf(\"%d %d\", x, y);\n\t\t\tbreak;\n\t\t}\n\t\telse if (x * (x + (2 * y) + 1) > r) {\n\t\t\tputs(\"NO\");\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "ca0cf8aa752c1e15db40f73584c25551", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n\nusing namespace std;\nint main() {\nlong long int n,m,z=0,p,q,r;\ncin>>n;\nm=n;r=n;\nwhile(r!=0){\n r=r/10;\n z++;\n}\nwhile(1){\n n++;q=0;\n int i;p=n;\n for(i=0;i0){break;}\n}\ncout<\nint n;\nscanf(\"%d\",&n);\nint r = n % 10;\nif(r != 0){\n if(r <= 5){\n n = n - r;\n }\n else{\n n = n + 10 - r;\n }\n}\nprintf(\"%d\",n);", "lang_cluster": "C", "compilation_error": true, "code_uid": "3c39d20328adcf2a5a0e66c4629c4689", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n\nlong long int SRoot(long long int num)\n{\n long long int i;\n \n if(num == 1)\n return 1;\n else\n {\n i = 1;\n do{\n i++;\n }while(i * i < num);\n \n return i;\n }\n}\n\nint main()\n{\n long long int n, i, D[300]={0}, max, x, j, A[150], y, k, d;\n \n scanf(\"%lld\", &n);\n for(i=0;i max)\n max = D[i];\n \n x = max;\n \n //Determine all of the divisors of \"x\"\n j = 0;\n for(i=1;i<=x;i++)\n if(x % i == 0)\n {\n A[j] = i;\n j++;\n }\n \n //Multiply the divisors from D[] that are not present in A[];\n //thus we can get \"y\"\n y = 1;\n for(i=0;i\n#include \nint main()\n{int n,x,y;\n scanf(\"%d %d %d\",&n,&x,&y);\n x=int(ceil(float(n*y)/100))-x;\n if(x>0)\n printf(\"%d\",x);\n else\n printf(\"0\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "379856061ed9a3dab03ab1c605dcbad4", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#define _USE_MATH_DEFINES\n#include \n\ndouble FSimGcd(double a, double b);\n\nint main()\n{\n\tdouble x1,y1,x2,y2,x3,y3;\n\tdouble a, b, c;\n\tdouble a2, b2, c2;\n\tdouble p, q, r;\n\tdouble S, R;\n\tint n;\n\t\n\tscanf(\"%lf %lf\", &x1, &y1);\n\tscanf(\"%lf %lf\", &x2, &y2);\n\tscanf(\"%lf %lf\", &x3, &y3);\n\t\n\tS=fabs(x1*y2+x2*y3+x3*y1-x2*y1-x3*y2-x1*y3)/2;\n\t\n\ta=sqrt(a2=(x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));\n\tb=sqrt(b2=(x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));\n\tc=sqrt(c2=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));\n\t\n\tp=acos((-a2+b2+c2)/2/b/c);\n\tq=acos((-b2+c2+a2)/2/c/a);\n\tr=acos((-c2+a2+b2)/2/a/b);\n\t\n\tR=a*b*c/4/S;\n\t\n\tn=(int)floor(M_PI/FSimGcd(p,FSimGcd(q,r))+0.5);\n\t\n\tprintf(\"%.6f\", n*R*R*sin(2*M_PI/n)/2);\n}\n\ndouble FSimGcd(double a, double b)\n{\n\tif(fabs(a-b)b){\n\t\tFSimGcd(a-b, b);\n\t}\n\telse{\n\t\tFSimGcd(b-a, a);\n\t}\n}\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "ff5e663c2d4a8d609171e5ef217e62e8", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "#include \nusing namespace std;\n\nint main(){\n\n int year , n0 , n1 , n2 , n3;\n\n cin>>year;\n\n while (1==1) {\n year++;\n\n n0 = year/1000;\n n1 = (year%1000)/100;\n n2 = ((year%1000)%100)/10;\n n3 = (((year%1000)%100)%10);\n\n if (n0 != n1 && n0 != n2 && n0 != n3 && n1 != n2 && n1 != n3 && n2 != n3 ) {\n break;\n }\n }\n\n cout<\n\nint main()\n{\n\tint sum, n, k, i, temp, flag = 0;\n\tint four_set, two_set, one_set;\n\tscanf_s(\"%d %d\", &n, &k);\n\tsum = 0;\n\tfour_set = n;\n\ttwo_set = 2 * n;\n\tone_set = 0;\n\tfor (i = 0; i < k; i++) {\n\t\tscanf_s(\"%d\", &temp);\n\t\tif (temp > 4*four_set+2*two_set+one_set) {\n\t\t\tflag = 1;\n\t\t\tbreak;\n\t\t}\n\t\telse {\n\t\t\tif (four_set * 4 >= temp) {\n\t\t\t\tfour_set -= temp / 4;\n\t\t\t\ttemp = temp % 4;\n\t\t\t\tif (temp == 3) {\n\t\t\t\t\tif (one_set > 2)\n\t\t\t\t\t\tone_set -= 3;\n\t\t\t\t\telse\n\t\t\t\t\t\tfour_set--;\n\t\t\t\t}\n\t\t\t\telse if (temp == 2) {\n\t\t\t\t\tif (two_set > 0)\n\t\t\t\t\t\ttwo_set--;\n\t\t\t\t\telse if (one_set > 1)\n\t\t\t\t\t\tone_set -= 2;\n\t\t\t\t\telse {\n\t\t\t\t\t\tfour_set--;\n\t\t\t\t\t\tone_set++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (temp == 1) {\n\t\t\t\t\tif (one_set > 0)\n\t\t\t\t\t\tone_set--;\n\t\t\t\t\telse {\n\t\t\t\t\t\tfour_set--;\n\t\t\t\t\t\ttwo_set++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttemp -= four_set * 4;\n\t\t\t\tfour_set = 0;\n\t\t\t\tif (two_set * 2 >= temp) {\n\t\t\t\t\ttwo_set -= temp / 2;\n\t\t\t\t\ttemp = temp % 2;\n\t\t\t\t\tif (temp == 1) {\n\t\t\t\t\t\tif (one_set > 0)\n\t\t\t\t\t\t\tone_set--;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttwo_set--;\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttemp -= two_set * 2;\n\t\t\t\t\ttwo_set = 0;\n\t\t\t\t\tone_set -= temp;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (flag)\n\t\tprintf(\"NO\\n\");\n\telse\n\t\tprintf(\"YES\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "033549c0ea9bbde493973c7be51ce239", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint a,b;\n\tscanf(\"%d%d\",&a,&b);\n\tif(a==1 && b==1)\n\t\tprintf(\"1\\n\"),return 0;\n\tprintf(\"%d\",(b-1 >= a-b)? b-1:b+1);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "1fdb46d322e29e7956cfb8dff6e6188e", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "\n/*\n* @author : SRvSaha\n* domino_piling.c\n* 17-Jul-2016\n* Description: http://codeforces.com/problemset/problem/50/A\n*\n*/\n#include \n#define DOMINO_LEN 2\n#define DOMINO_BREADTH 1\nint main(){\n int length,breadth;\n int output;\n scanf(\"%d %d\",&length,&breadth);\n if(length >= DOMINO_LEN && breadth >= DOMINO_BREADTH){\n if(length % DOMINO_LEN == 0){\n output = length/DOMINO_LEN * breadth/DOMINO_BREADTH;\n }\n else {\n //Case when length % DOMINO_LEN = 1. Then by rotating the domino it can\n // be placed . So using the breadth at that time.\n output = (length/DOMINO_LEN * breadth/DOMINO_BREADTH) + breadth/DOMINO_LEN;\n }\n }else {\n //Case when length < DOMINO_LEN. So only the rotated part is the answer\n output = (length/DOMINO_LEN * breadth/DOMINO_BREADTH) + breadth/DOMINO_LEN;\n }\n printf(\"%d\\n\",output);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3151cc15af64f58363a2cbb7742acfaa", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \nconst int maxn = 5e4+5;\nchar S[maxn];\nint C[26], N, CNT, CNT2, ANS, STH[27], CNT3, CNT4 = 1;\nint main() {\n scanf(\"%s\", S+1);\n N = strlen(S+1);\n if(N < 26) {\n printf(\"-1\");\n return 0;\n }\n for(int i = 1; i <= 26; i++) \n if(S[i] != '?') C[S[i] - 'A']++;\n else CNT++;\n for(int i = 0; i < 26; i++) if(C[i] == 0) CNT2++;\n for(int i = 1; i <= N-25; i++) {\n if(CNT >= CNT2) {\n ANS = i;\n break;\n }\n if(S[i+26] == '?') CNT++;\n else{\n C[S[i+26] - 'A']++;\n if(C[S[i+26] - 'A'] == 1) CNT2--;\n }\n if(S[i] == '?') CNT--;\n else{\n C[S[i] - 'A']--;\n if(C[S[i] - 'A'] == 0) CNT2++;\n }\n }\n if(ANS == 0) {\n printf(\"-1\");\n return 0;\n }\n for(int i = 0; i < 26; i++) if(C[i] == 0) STH[++CNT3] = i;\n for(int i = ANS; i <= ANS+25; i++) if(S[i] == '?') {\n if(CNT4 <= CNT3) S[i] = STH[CNT4++]+'A';\n else S[i] = 'A';\n }\n for(int i = 1; i <= N; i++) if(S[i] == '?') S[i] = 'A';\n printf(\"%s\", S+1);\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "f08adffe436b5f9d8c892a0b2dc2d009", "src_uid": "a249431a4b0b1ade652997fe0b82edf3", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint i,n;\nint a[n],key=0 ;\nfor(i=0;i\nusing namespace std;\nint main()\n{\n int n,m;\n cin>>n>>m;\n long long s=n;\n while(n>=m)\n {\n s+=n/m;\n n=n%m + n/m;\n }\n cout<\n\ntypedef long long ll;\n\nll c[32];\n\nll min(ll a, ll b) {\n return a < b ? a : b;\n}\n\nll func(ll l) {\n int i;\n ll sum = 0LL;\n for (i = 31; i >= 0; i--)\n if (l >> i & 1)\n sum += c[i];\n return sum;\n}\n\nint main(int argc, char** argv) {\n int i, n;\n ll l, ans = 0LL;\n \n scanf(\"%d%I64d\", &n, &l);\n for (i = 0; i < n; i++)\n scanf(\"%I64d\", &c[i]);\n \n for (i = 1; i < n; i++)\n if (2LL * c[i-1] < c[i])\n c[i] = 2LL * c[i-1];\n for (i = n; i < 32; i++)\n c[i] = 2LL * c[i-1];\n \n ans = func(l);\n for (;;) {\n ll lower = l & -l;\n l += lower;\n ans = min(ans, func(l));\n if (l > 2147483647LL)\n break;\n }\n\n printf(\"%I64d\\n\", ans);\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9b7f9c6a94598deaf2603019cfe6962c", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n\n/* run this program using the console pauser or add your own getch, system(\"pause\") or input loop */\n\nint main() {\n\tint x,vec[101],i,vec2[101],j,soma,maxsoma;\n\tscanf(\"%d\",&x);\n\tfor(i=0;imaxsoma)\n\t\t{\n\t\t\tmaxsoma=soma;\n\t\t}\n\t\tsoma=-1;\n\t}\n\tprintf(\"%d\\n\",maxsoma);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "0436e453b742aeb6baf43a67ff0fba2f", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "\n\n\t\n\t\n\t\t\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "1a0d4c784fa9b7fc2257a770035a4ac5", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \nmain()\n{\n int i=0,n=0,m=0,k=0,b=1,t=0;\n scanf(\"%d\",&n);\n scanf(\"%d\",&m);\n scanf(\"%d\",&k);\n for(i=1;i*i<=m;i++)\n { if (i!=1)\n\t\t{\n if (m%i==0)\n {\n\t\t\t\t\tif ((m/i)>=k){\n break;\n\t\t\t\t\t\t\t\tw=1;}\n else w=0;\n\t\t\t\t\n }\n\t\t}\n }/*\n if (((i*i>m)||(m==1)) && k!=1) {\nprintf(\"Marsel\");\nreturn 0; }*/\n\nif (w=0)\n{\nif (((i*i>m)||(m==1)) && k==1) {\nprintf(\"Timur\");\nreturn 0; }\n}\nelse\n{\n /*\n for(t=0;t=k)\n {\n b[u]=a[i];\n u++;\n }\n */\n\n\n\nreturn(0);\n\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "6b94087e003611200c25648075d46033", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include \nvoid main()\n{\n int a,b,m=0,i,k;\n scanf(\"%d\",&a);\n scanf(\"%d\",&b);\n k=(a-b)/2;\n if(k<0)\n k=-k;\n for(i=1;i<=k;i++)\n m=m+i;\n if((a-b)%2==0)\n printf(\"%d\",2*m);\n else\n printf(\"%d\",2*m+k+1);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d5feb545b2fb3c491def95726ea749c6", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \nusing namespace std;\nint main(){\n ios::sync_with_stdio(0);\n cin.tie(0);\n\n stack s;\n vector v;\n string str;\n getline(cin,str);\n int length=str.length();\n //cout<\n\n#define amigos 5\n\nint main(){\n\nint arr[amigos] = {};\nint m, a, b;\n// m -> # de relaciones entre los 5 amixes\n// (a, b) relacion\n// a -> persona 1\n// b -> persona 2\n\nscanf(\"%i\", &m);\n\nint i=0;\n\n// con este do-while, vamos a contar el numero de relaciones por persona\n// con base a su n\u00famero, si sale, se le suma al arreglo en su posici\u00f3n\n\ndo {\n\tscanf(\"%i %i\", &a, &b);\n arr[a-1]++;\n //printf(\"arr[%i-1]++ %i\\n\", a, arr[a-1]++);\n arr[b-1]++;\n //printf(\"arr[%i-1]++ %i\\n\", b, arr[b-1]++);\n\ti++;\n} while (i < m);\n\ni=0;\n\n// en este do-while checamos todo el arreglo\n// si alguno tiene un valor diferente \n\ndo {\n\tif(arr[i] != 2){\n \tprintf(\"WIN\\n\");\n \treturn 0;\n }\n\ti++;\n} while (i < amigos);\n\nprintf(\"FAIL\\n\");\n\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "e2dad671dd4df8626dd5408193047655", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n;\n int f=1,g=2;\n scanf(\"%d\",&n);\n for(int i=1;i<=n;i++)\n {\n int x;\n scanf(\"%d\",&x);\n if(x==f)\n {\n g=6-f-g;\n }\n else if(x==g)\n {\n f=6-f-g;\n }\n else\n {\n printf(\"NO\");\n return 0;\n }\n }\n printf(\"YES\");\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d51bfa846532c8adba6a73801664830b", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n,i,j;\n int w=0;\n int count=0;\n \nint tab1[2000];\nint tab2[2000];\nint r;\nscanf(\"%d\",&n);\n\nfor(i=0;i\nint main()\n{\n int n;\n scanf(\"&d\",&n);\n\n char a[n];\n scanf(\"%s\",a);\n\n int p = 0;\n\n for(i=0;i0 && a[i]='-')\n {\n p--;\n }\n else if(a[i]='+')\n {\n p++;\n } \n }\n\n printf(\"%d\",p);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "33cc2008a5cabf41c103beb71572b35a", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int i,j,k,l,m,n;\n scanf(\"%I64d%I64d%I64d%I64d%I64d\",&i,&j,&m,&n,&k);\n if(n=j)\n {\n l=j-m;\n \n }\n else\n {\n l=n-m;\n }\n if(i<=m)\n {l=l+1;}\n \n if(l>0)\n {\n if(k<=j&&k>=m&&k=>i)\n l=l-1;\n \n }\n printf(\"%I64d\\n\",l);\n }\n return 0;\n\n\n}\n\n//if(m\n#include\n#include\n\n\n\nint MinX(int a,int b)\n{\n\treturn a = a>b?b:a;\n}\n\nint main()\n{\n\tint i,j,k,flag1,flag2;\n\tchar data[13][3]={\"C\",\"C#\",\"D\",\"D#\",\"E\",\"F\",\"F#\",\"G\",\"G#\",\"A\",\"B\",\"H\"};\n\tchar X[3],Y[3],Z[3];\n\tint index1,index2,len1,len2,len3,len4,len5,len6,op1,op2,op3;\n\twhile(scanf(\"%s%s%s\",X,Y,Z)!=EOF)\n\t{\n\t\tfor(i=0;i<12;i++)\n\t\t{\n\t\t\tif(!strcmp(data[i],X))\n\t\t\t{\n\t\t\t\top1 = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tindex1 = 0;index2 = 0;\n\t\tflag1 = 0; flag2 = 0;\n\t\twhile(1)\n\t\t{\n\t\t\tif(index1 == 12)\n\t\t\t\tindex1 = 0;\n\t\t\tif(index2 == 12)\n\t\t\t\tindex2 = 0;\n\t\t\tif(!strcmp(data[index1],Y))\n\t\t\t{\n\t\t\t\top2 = index1;\n\t\t\t\tflag1 = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t\tindex1++;\n\t\t\tif(!strcmp(data[index2],Z))\n\t\t\t{\n\t\t\t\top3 = index2;\n\t\t\t\tflag2 = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t\tindex2++;\n\t\t\tif(flag1 && flag2)\n\t\t\t\tbreak;\n\n\t\t}\n\t\tlen1 = MinX(abs(op1 - op2),abs(12-(op1+op2))+2);\n\t\tlen2 = MinX(abs(op2 - op3),abs(12-(op2+op3))+2);\n\t\tlen3 = MinX(abs(op2 - op1),abs(12-(op1+op2))+2);\n\t\tlen4 = MinX(abs(op1 - op3),abs(12-(op1+op3))+2);\n\t\tlen5 = MinX(abs(op2 - op3),abs(12-(op2+op3))+2);\n\t\tlen6 = MinX(abs(op3 - op1),abs(12-(op1+op3))+2);\n\t\tif( (len1 ==4 && len2 == 3) || (len3 ==4 && len4 ==4) || (len5 ==4 && len6 == 3))\n\t\t\tprintf(\"major\\n\");\n\t\telse if( (len1 ==3 && len2 == 4) || (len3 ==3 && len4 ==4) || (len5 ==3 && len6 == 4) )\n\t\t\tprintf(\"minor\\n\");\n\t\telse\n\t\t\tprintf(\"strange\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cfc9cf4561c14807c8deda97f02f13fd", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\nvoid main()\n{\n int n,m,f=0,k=0,j=0,s=0,t=0,m1=0;\n scanf(\"%d\",&n);\n while(n--)\n {\n scanf(\"%d\",&m);\n if(m==0) { k++; t=0; m1++; }\n if(m==1)\n {\n if(t==0)\n {\n if(j\n#include \n#include \n\n\nint main()\n{\n int x, y, n, i;\n double min = 9999999, c, tmpmin;\n int p, a, b;\n scanf(\"%d %d %d\", &x, &y,&n);\n for (i = 1; i <= n; i++)\n {\n c = x*i / (y*1.0);\n p = floor(c+0.499999999);\n tmpmin = fabs((x*1.0) / y - (p*1.0) / i);\n if (min > tmpmin)\n {\n min = tmpmin;\n a = p;\n b = i;\n }\n }\n printf(\"%d/%d\", a, b);\n _getch();\n return 0;\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "1c54e59c1d784b9c5b776dc560c46a28", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\n#define MOD 1000003\n\nlong long int mod(long long int p, long long int m)\n{\n\tif(p==0)\n\t\treturn 1;\n\telse if(p==1)\n\t\treturn 2;\n\telse if(p%2)\n\t\treturn (mod(1,m)*mod(p-1,m))%MOD;\n\telse\n\t\treturn (mod(p/2,m)*mod(p/2,m))%MOD;\n}\n\nint main()\n{\n\tchar p[100],s[100];\n\tscanf(\"%s\",p);\n\n\tfor(long long int i=0;p[i]!='\\0';i++)\n\t{\n\t\tif(p[i]=='>')\n\t\t{\t\n\t\t\tstrcat(s,\"1000\");\n\t\t\t\n\t\t}\n\t\telse if(p[i]=='<') \n\t\t{ \n\t\t\tstrcat(s,\"1001\");\n\t\t}\n\t\telse if(p[i]=='+')\n\t\t{ \n\t\t\tstrcat(s,\"1010\");\n\t\t}\n\t\telse if(p[i]=='-')\n\t\t{ \t\n\t\t\tstrcat(s,\"1011\");\n\t\t}\n\t\telse if(p[i]=='.') \n\t\t{\t\n\t\t\tstrcat(s,\"1100\")\n\t\t}\n\t\telse if(p[i]==',')\n\t\t{\n\t\t\tstrcat(s,\"1101\");\n\t\t}\n\t\telse if(p[i]=='[') \n\t\t{\t\n\t\t\tstrcat(s,\"1110\");\n\t\t\t//puts(s);\n\t\t}\n\t\telse \n\t\t{\n\t\t\tstrcat(s,\"1111\");\n\t\t\t//puts(s);\n\t\t}\n\t}\n\n\tlong long int ans=0,flag=0;\n\tfor(long long int i=strlen(s)-1;i>=0;i--)\n\t{\n\t\tlong long int temp=0;\n\t\tif(s[i]=='1')\n\t\t\ttemp = mod(flag,MOD);\n\t\tans = (ans+temp)%MOD;\n\t\tflag++;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d4a17665d2e52969d1e84361d4170ee5", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n char s[110];\n scanf(\"%s\",&s);\n int ans1=0,ans0=0;\n for(int i=0;i\n#include \n\nint n;\nint a[100], b[100];\nint x, k, l;\n\nint main (int argc, char *argv[])\n{\n int i;\n scanf (\"%d\", &n);\n for (i = 0; i < n; i++)\n scanf (\"%d \", &a[i]);\n for (i = 0; i < n; i++)\n scanf (\"%d \", &b[i]);\n for (i = 0; i < n; i++)\n {\n if (a[i] > b[i])\n k++;\n if (a[i] < b[i])\n l++;\n }\n if (k != 0)\n x = l / k + 1;\n else\n x = -1;\n printf (\"%d\", x);\n exit (EXIT_FAILURE);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "73d8ae7168efb46b768f35c828e4b4ac", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n\tlong long int n,k,ans,dip,deg,lul;\n\tscanf(\"%lld %lld\",&n,&k);\n\tans=0;\n\tfor(long long int i=(n/2); i>=0; i--)\n\t{\n\t\tif(i%(k+1)==0)\n\t\t{\n\t\t\tans=i/(k+1);\n\t\t\tbreak;\n\t\t}\n\t}\n\tdeg=ans;\n\tdip=k*ans;\n\tlul=n-(deg+dip);\n\n\tprintf(\"%lld %lld %lld\",deg,dip,lul);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "7e5be4ee9768a8f14886e2c7cdc1015d", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int zero=0,one=1;\n int i=0;\n char string[n];\n while(i\n#include\nmain()\n{\n int s=0,c,x,n,i,j,k;\n scanf(\"%d\",&n);\n for(i=6;i<=n;i++)\n {\n c=0;\n for(j=2;j<=i;j++)\n {\n x=0;\n if(i%j==0){\n for(k=2;k<=sqrt(j);k++)\n {\n if(j%k==0)\n {\n x=1;\n }\n }\n if(x==0)\n {\n c++;\n }\n }\n }\n if(c==2)\n s++;\n }\n printf(\"%d\",s);", "lang_cluster": "C", "compilation_error": true, "code_uid": "9f376c587a5dae7f57e3d186a8901609", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n \nint gcd(int m, int n)\n{\n int r;\n while ((r = m % n) != 0)\n {\n m = n;\n n = r;\n }\n return n;\n}\n \nint main()\n{\n int a, b, c;\n scanf(\"%d %d %d\", &a, &b, &n);\n while (true)\n {\n n -= gcd(a, n);\n if (n == 0)\n {\n printf(\"0\");\n break;\n }\n n -= gcd(b, n);\n if (n == 0)\n {\n printf(\"1\");\n break;\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "ef82151e2e6c81c92d5496010f714701", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n int x, ans;\n\n scanf(\"%d\", &x);\n\n switch (x) {\n case 1:\n ans = 1; // ok\n break;\n case 2:\n ans = 0;\n break;\n case 3:\n ans = 0; // ok\n break;\n case 4:\n ans = 0;\n break;\n case 5:\n ans = 0;\n break;\n case 6:\n ans = 0;\n break;\n case 7:\n ans = 0; // ok\n break;\n case 8:\n ans = 0;\n break;\n case 9:\n ans = 0;\n break;\n case 10:\n ans = 0;\n break;\n case 11:\n ans = 1;\n break;\n case 12:\n ans = 1;\n break;\n case 13:\n ans = 1; // ok\n break;\n case 14:\n ans = 0;\n break;\n case 15:\n ans = 0;\n break;\n case 16:\n ans = 0;\n break;\n }\n\n printf(\"%d\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "67cde4c68ff8a24206f47f21453df3d8", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nlong int i,x[8],y[8],ar1[8],ar2[8],j,t,c1=0,c2=0,p,q;\nfor(i=0;i<8;i++)\nscanf(\"%ld %ld\",&x[i],&y[i]);\nfor(i=0;i<8;i++)\n{ar1[i]=x[i];\nar2[i]=y[i];}\nfor(i=0;i<8;i++)\n{for(j=i;j<8;j++)\n{if(x[i]>x[j])\n{t=x[i];\nx[i]=x[j];\nx[j]=t;}\nif(y[i]>y[j])\n{t=y[i];\ny[i]=y[j];\ny[j]=t;}}}\nfor(i=0;i<8;i++)\n{if(i==0)\n{c1++;\nc2++;}\nelse\n{if(x[i]!=x[i-1])\n{if(c1==1)\np=i;\nc1++;}\nif(y[i]!=y[i-1])\n{if(c2==1)\nq=i;\nc2++;}}}\nif(c1!=3||c2!=3)\nprintf(\"ugly\");\nelse\n{for(i=0;i<8;i++)\n{if(ar1[i]==x[p]&&ar2[i]==y[q])\n{printf(\"ugly\");\nbreak;}}\nif(i==8)\nprintf(\"respectable\");}\nreturn(0);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "857ff8c0e4bf447f6f71853af9e4ad70", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nmain()\n{\n\tint l, d, i;\n\tscanf(\"%d%d\", &l, &d);\n\tif (l == 1)\n\t\tprintf(\"%d\\n\", d < 10 ? d : -1);\n\telse\n\t{\n\t\tprintf(\"%d\", d<10?d:1;\n\t\tfor (i = 1; i < l; i++)\n\t\t\tprintf(\"0\");\n\t\tprintf(\"\\n\");\n\t}\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "bf0b66dc8d8a010d87784e5643dc23b0", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n int n,l,r,min=0,max=1,dif=1,x=0;\n scanf(\"%d %d %d\",&n,&l,&r);\n y:{ dif=1;\n for(;x\n\nint main()\n {\n int n;\n scanf(\"%i\" , &n);\n int mod[2] , l[2];\n int i=0;\n if(n>=0 && 99>=n)\n {\n if(n==08)\n {\n printf(\"2\");\n return0;\n }\n while(i<2)\n {\n mod[i]=n%10;\n n/=10;\n i++;\n }\n\n i=0;\n while(i<2)\n {\n if(mod[i]==0 || mod[i]==6 || mod[i]==9)\n l[i]=2;\n \n if(mod[i]==1)\n l[i]=7 ;\n \n if(mod[i]==2)\n l[i]=2;\n \n if(mod[i]==3 || mod[i]==4)\n l[i]=3;\n \n if(mod[i]==5)\n l[i]=4;\n \n if(mod[i]==7)\n l[i]=5;\n \n if(mod[i]==8)\n l[i]=1;\n i++; \n }\n printf(\"%i\" , l[0]*l[1]);\n }\n else \n return 0;\n \n getche(); \n return 0;\n }\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3e73290e19dd93f2351f0c415ae8eaf0", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int l,i,j,k;\n char s[55];\n scanf(\"%s\",s);\n l=strlen(s);\n k=l;\n if(l%2==0)\n l=(l/2)-1;\n else\n l=l/2;\n int c;\n c=l;\n printf(\"%c\",s[l]);\n while(1)\n{", "lang_cluster": "C", "compilation_error": true, "code_uid": "2690219b180a6771287a96b7eefe4b2c", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\ntypedef long long Long;\n\nint main() {\n int a,c;\n scanf(\"%d%d\",&a,&c);\n int arr[100] = {0}; int cnt = 0;\n while (a > 0 || c > 0) {\n int ta = a % 3;\n int tc = c % 3;\n a /= 3;\n c /= 3;\n arr[cnt ++] = (tc - ta + 9) % 3;\n }\n Long ans = 0;\n for (int i = cnt - 1; i > -1; i--) {\n ans = ans * 3 + arr[i];\n }\n printf(\"%lld\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b0c370c8eacd486bfb7e82bb9f9d90dc", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint n,s,k;\nscanf(\"%d%I64d%d\",&n,&s,&k);\nif (s%n==0)\n {\n k==s/n\n printf(\"%d\",k);\n }\nelse\n {\n k==s/n+1\n printf(\"%d\",k);\n {\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "690cacb87a05fcdefbf063d68671389c", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,i,j,t;\n scanf(\"%d\",&n);\n int a[n];\n for(i=1;i<=n;i++)\n {\n for(j=1;j,<=n-i;j++)\n {\n if(a[j]>a[j+1])\n {\n t=a[j];\n a[j]=a[j+1];\n a[j+1]=t;\n }\n }\n }\n int count=1;\n for(i=1;i<=n;i++)\n {\n if(a[i]+1==a[i+1])\n count++;\n else\n count=1;\n if(count==3)\n {\n printf(\"YES\");\n break;\n }\n }\n if(count<3)\n printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "89d834e7978ad6e3174519f31d252962", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n\n#define hi(h) ((h%10)*10+h/10)\n\nint main(void) {\n int h, m, i;\n scanf(\"%d%*c%d\", &h, &m);\n for (i=0; i<(24*60); i++) {\n if (hi(h)==m)\n break;\n m=(m+1)%60;\n if (!m)\n h=(h+1)%24;\n }\n printf(\"%d\\n\", i);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ee92f1210671d0a57150257ceefbb615", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \nint lcm (int a, int b);\n\nint lcm ( int a, int b ) { int x=n1, y=n2; while ( n1!= n2 ) { if (n1>n2) n1=n1-n2; else n2=n2-n1; } return x*y/n1; }\n\n\nint main()\n{\n\tint n, m, z, i, count = 0;\n\tscanf (\"%d%d%d\", &n, &m, &z);\n\tprintf(\"%d\\n\", z/lcm(n,m));\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "7819e866307f4f064b7bb66da5df8999", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n\tint n,i,sum=0,c=0,k;\n\tscanf(\"%d\",&n);\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tk=(i*i+i1)/2;\n\t\tsum=sum+k;\n\t\tif(sum<=n)\n\t\tc++;\n\t}\n\tprintf(\"%d\",c);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "dd3e866981302676d11516264b0255f8", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main() {\n long long int n,m,ans;\n scanf(\"%lld %lld\",&n,&m);\n if(n>=27)\n printf(\"%lld\",m);\n else\n ans=pow(2,n)%m;\n printf(\"%lld\",ans);\n \n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "e50fadfc6b7d275f40e29311da8819dd", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{ \nlong int n;\nscanf(\"%I64d\",&n)\nif(n%2==0&&n!=0)\nprintf(\"%I64d\",n+1);\nelse\nprintf(\"%I64d\",(n+1)/2);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3ee6e93c570fd66a3e023e191a27e033", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define in(n) scanf(\"%d\",&n)\n#define ins(n) scanf(\"%s\",n)\n\nint main()\n{\n {int n,m,a,b,c=0;in(n);in(m);\n int max=n>m?n:m;\n for(a=0;a<=max;a++)for(b=0;b<=max;b++){if((a*a+b)==n&&(a+b*b)==m)c++;}\n \n printf(\"%d\\n\",c);\n\n\nreturn 0;} \n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3d469a0e7db3558836dc434734eea209", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main(){\n int i,n,prev=0,max=0;\n char s[100];\n gets(s);\n n=strlen(s);\n for(i=0;imax){\n prev=i-max;\n prev=i;}}}\n \n printf(\"%d\",&max);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f86a53085e15df409d203a80e50a3e8d", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \"stdio.h\"\n#include \"string.h\"\n\nint main()\n{\n\tchar s[100];\n\twhile (scanf_s(\"%s\",&s)!= EOF)\n\t{\n\t\tint length = strlen(s);\n\t\tfor (int i = 0; i < length; i++)\n\t\t{\n\t\t\tif (s[i] == 49)\n\t\t\t{\n\t\t\t\tint zeronum = 0;\n\t\t\t\tfor (int j = i + 1; j < length; j++)\n\t\t\t\t{\n\t\t\t\t\tif (s[j] == 48)\n\t\t\t\t\t\tzeronum++;\n\t\t\t\t}\n\t\t\t\tif (zeronum >= 6)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"YES\\n\");\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\tprintf(\"NO\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2d66894014c91494c1e3d16e84e090bf", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\nint a[18];\nint n;\nbool flag;\nvoid dfs(int sum, int step)\n{\n if (flag || step>n) \n\t\treturn ;\n if (step==n && (sum==0||sum%360==0))\n\t{\n flag=true;\n return ;\n }\n dfs(sum+a[step],step+1);\n dfs(sum-a[step],step+1);\n}\nint main()\n{\n while (scanf(\"%d\",&n)!= EOF)\n\t{\n\t\tint i;\n for (i=0;i\n#include \n#include \n\nint main()\n{\nint n,i,j;\nscanf(\"%d\",&n);\nchar t[n+1][3]; char mdp[3]; char *ch;\n\nscanf(\"%s\",mdp);\n\nfor(i=0;i\nmain()\n{int i,a=0,s=0,t=0,n,c;\nscanf(\"%d\",&n);\nfor(i=1;i<=n;i++)\n{ scanf(\"%d\",&c);\n if (c!=4 && c!=7)\n a++;\n else\n i>n/2?s+=c:t+=c;}\nputs((a==0)?((s!=t)?\"NO\":\"YES\"):\"NO\");\nreturn 0;}", "lang_cluster": "C", "compilation_error": true, "code_uid": "08bde7190d83c8d7905b8a3f2fbd640d", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define MAX 300\nint win[301][301];\nvoid solve(int a,int b){\n\tint i,j,k,l;\n\tfor(i=1;i<=a;i++){\n\t\tfor(j=1;j<=b;j++){\n\t\t\tint mink = (i>j)?j:i;\n\t\t\tfor(k=1;k<=mink;k++)\n\t\t\t\tif(win[i-k][j-k]==0){\n\t\t\t\t\twin[i][j]=1;break;}\n\t\t\tif(win[i][j]==0){\n\t\t\tfor(l=1;l<=i;l++)\n\t\t\t\tif(win[i-l][j]==0){\n\t\t\t\t\twin[i][j]=1;break;}\n\t\t\t\t\t\n\t\t\t}\n\t\t\tif(win[i][j]==0){\n\t\t\tfor(l=1;l<=j;l++)\n\t\t\t\tif(win[i][j-l]==0){\n\t\t\t\t\twin[i][j]=1;break;}\n\t\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\t\n\t}\n}\nint main(){\n\tint n,a,b,c,i,j,k;\n\twin[0][0]=0;\n\twin[1][1]=1;\n\twin[1][0]=1;\n\twin[0][1]=1;\n\twin[2][0]=1;\n\twin[0][2]=1;\n\tfor(i=1;i<=300;i++){\n\t\twin[i][0]=1;win[0][i]=1;\n\t}\n\tsolve(300,300);\n\t//for(i=0;i<=10;i++){\n\t//\tfor(j=0;j<=10;j++)\n\t//\t\tprintf(\"%d \",win[i][j]);\n\t//printf(\"\\n\");\t\n\t//}\n\tscanf(\"%d\",&n);\n\t\tif(n==1){\n\t\t\tscanf(\"%d\",&a);\n\t\t\tif(n==0)\n\t\t\t\tprintf(\"BitAryo\");\n\t\t\telse\n\t\t\t\tprintf(\"BitLGM\");\n\t\t}\n\t\telse if(n==2){\n\t\t\tscanf(\"%d %d\",&a,&b);\n\t\t\tif(win[a][b])\n\t\t\t\tprintf(\"BitLGM\");\n\t\t\telse\n\t\t\t\tprintf(\"BitAryo\");\n\t\t}\n\t\telse if(n==3){\n\t\t\tscanf(\"%d %d %d\",&a,&b,&c);\n\t\t\tif((a^b^c)!=0)printf(\"BitLGM\");\n\t\t\telse\n\t\t\t\tprintf(\"BitAryo\");\n\t\t}\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "59910e2b5a56e2b72aa508d9c72de70c", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\nint x,a,b;\nvoid dfs(int n) {\n\tfor(int i=n;;) {\n\t\tif(i/n>=x)break;\n\t\tif(i*n>x) {\n\t\t\ta=i;\n\t\t\tb=n;\n\t\t\treturn;\n\t\t}\n\t\ti+=n;\n\t}\n}\nint main() \n{\n\tscanf(\"%d\",&x);\n\tfor(int i=1;i<=x;i++)\n\t\tdfs(i);\n\tif(a==0 && b==0)printf(\"-1\");\n\telse printf(\"%d %d\",a,b);\n\treturn 0;\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "062cd68d4dc9129e3ed64babb5af97b0", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nusing namespace std;\nint cow[10010];\nint main()\n{\n\tint h1, m1, h2, m2, h3, m3, c;\n\tchar t;\n\tcin >> h1 >> t >> m1;\n\tcin >> h2 >> t >> m2;\n\tif (h2 < h1)\n\t{\n\t\th3 = h1;\n\t\tm3 = m1;\n\t\th1 = h2;\n\t\tm1 = m2;\n\t\th2 = h3;\n\t\tm2 = h3;\n\t}\n\tif (h1 == h2 && m1 > m2)\n\t{\n\t\th3 = h1;\n\t\tm3 = m1;\n\t\th1 = h2;\n\t\tm1 = m2;\n\t\th2 = h3;\n\t\tm2 = h3;\n\t}\n\tif (h2 > h1)\n\t{\n\t\tc = (h2 - h1) * 60 - m1 + m2;\n\t\tc = c / 2;\n\t\tm1 = m1 + c;\n\t\twhile (m1 >= 60)\n\t\t{\n\t\t\tm1 -= 60;\n\t\t\th1 += 1;\n\t\t}\n\t\tif (h1 < 10)\n\t\t{\n\t\t\tcout << \"0\" << h1 << t;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << h1 << t;\n\t\t}\n\t\tif (m1 < 10)\n\t\t{\n\t\t\tcout << \"0\" << m1 << endl;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << m1 << endl;\n\t\t}\n\t}\n\telse\n\t{\n\t\tc = m2 - m1;\n\t\tc = c / 2;\n\t\tm1 = c + m1;\n\t\twhile (m1 >= 60)\n\t\t{\n\t\t\tm1 -= 60;\n\t\t\th1 += 1;\n\t\t}\n\t\tif (h1 < 10)\n\t\t{\n\t\t\tcout << \"0\" << h1 << t;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << h1 << t;\n\t\t}\n\t\tif (m1 < 10)\n\t\t{\n\t\t\tcout << \"0\" << m1 << endl;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << m1 << endl;\n\t\t}\n\t}\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "128151e0fe6783acd471c3ce89dc7520", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,j,k,sum=0;\n scanf(\"%d %d\",&i,&j);\n while(1)\n {\n k=i/j;\n l=k+(i%j);\n i=l;\n sum=sum+i+k;\n if(k==0)\n break;\n }\n printf(\"%d\",sum);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "01db729fae348fac8dcdb986a8c2c5ba", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n\nstruct {\n\tchar valor, naipe;\n\tvalor = naipe = 0;\n} card ;\n\nint main(){\n\tstruct card* primeira, segunda;\n\tchar trunfo, c;\n\tprimeira = malloc (sizeof (struct card));\n\tsegunda = malloc (sizeof (struct card));\n\tscanf (\"%c\", &trunfo);\n\tscanf (\"%c\", &c); \n\tscanf (\"%c\", &c);\n\tprimeira->valor = c;\t\n\tscanf (\"%c\", &c);\n\tprimeira->naipe = c;\t\n\tscanf (\"%c\", &c);\n\tsegunda->valor = c;\t\n\tscanf (\"%c\", &c);\n\tsegunda->valor = c;\t\n\tif (primeira->naipe == trunfo){\n\t\tif (segunda->naipe != trunfo)\n\t\t\tprintf (\"YES\");\n\t\telse {\n\t\t\tif (primeira->valor > segunda->valor)\n\t\t\t\tprintf (\"YES\");\n\t\t\telse\n\t\t\t\tprintf (\"NO\");\n\t\t}\n\n\t}\n\telse {\n\t\tif (segunda->naipe == trunfo)\n\t\t\tprintf (\"NO\");\n\t\telse {\n\t\t\tif (primeira->valor > segunda->valor)\n\t\t\t\tprintf (\"YES\");\n\t\t\telse\n\t\t\t\tprintf (\"NO\");\n\t\t}\t\n\t}\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b51fa34b6715aff7fd992f21836aa959", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\nint x,y;\nint main(){\n scanf(\"%d%d\",&x,&y);\n pritnf(\"%d\\n\",x+y);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f62bc49b6a61ab1f2c05676ba7964c3e", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint deco(int x){\n int a = x;\n int n=0;\n while(a>=10){\n n+= a%10;\n a = a/10; \n }\n n+=a%10;\n return n;\n}\n\nint main(){\n long int a;\n scanf(\"%ld\",&a);\n long int max=0;\n long int x,y;\n long int b,d;\n for(long int c = 1;c<(a/2)+1;c++){\n x = deco(c);\n y = deco(a-c);\n if(x+y > max){\n\t max = x+y;\n\t b =c;\n\t d =a-c;\n\t}\n }\n printf(\"%ld\",max);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ff2f99b5902fef12508187c953655629", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main()\n{\n int n,m,k,d=0,r=0,i;\n //printf(\"Give number columns and rows \");\n scanf(\"%d %d\",&n,&m);\n // printf(\"Give number of seat:\");\n scanf(\"%d\",&k);\n for (i=2;i<=2*n*m;i+=2)\n {\n if (k<=i)\n {\n d++;\n }\n }\n // for (i=2*m;i<=2*n*m;i+=2*m)\n //{\n // if (k>=i)\n // {\n // r++;\n // }\n // }\n if (k%2)\n printf(\"%d %d L\",(int)ceil(d/n),(d%n)+1);\n else\n printf(\"%d %d R\",(int)ceil(d/n),(d%n)+1;\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "363454aab245f423cc056dbd113bdf83", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main(){\n\tchar a,b,c,d;\n\tscanf(\"%c%c\\n\",&a,&b)\n\tint i,f;\n\tf=0;\n\tfor(i=0;i<5;i++){\n\tscanf(\"%c%c \",&c,&d);\n\tif(a==c||b==d){\n\t\tf=1\n\t}\n\t}\n\tif(f==1){\n\tprintf(\"YES\");\n\t}\n\telse{\n\tprintf(\"NO\")\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "cfdb64d0733be34d1d74987f02a12fd1", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nvoid main()\n{\n int n,b, result;\n scanf(\"%d\", &n);\n\n result = 0;\n int c = 2 \n while(c <= n)\n {\n b = 1\n while(b <= sqrt(c*c/2))\n {\n if(sqrt(c*c - b*b) == (int)sqrt(c*c - b*b))\n result++;\n b++; \n }\n c++;\n }\n\n printf(\"%d\", result);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "5758469f9938147a44c757fdc72249e9", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main()\n{ int n;\n \n scanf(\"%d\",n);\n t=(1-6^n)/(1-6);\n printf(\"%d\",t);\n return 0;\n}\nS = premier terme * (1-q^nb de termes)/1-q", "lang_cluster": "C", "compilation_error": true, "code_uid": "31c609d04ab7db27fcfc9077567bcff2", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nint main()\n{\n char s[11], letter;\n gets(s);\n int i = 0, len = strlen(s), forward = 0, backward = len-1, once = 0, f = -1, pos = 0;\n for(i = 0; i < len/2; i++)\n {\n if(s[forward] != s[backward])\n {\n if(once == 1)\n {\n printf(\"NA\");\n exit(0);\n }\n once = 1;\n if(s[forward] == s[backward-1])\n {\n letter = s[backward];\n f = 1;\n pos = forward;\n forward--;\n }\n else if(s[forward+1] == s[backward])\n {\n f = 0;\n letter = s[forward];\n pos = backward;\n backward++;\n }\n else\n {\n printf(\"NA\");\n exit(0);\n }\n }\n forward++; backward--;\n }\n if(f == 0)\n {\n for(i = 0; i <= pos; i++)\n printf(\"%c\", s[i]);\n printf(\"%c\", letter);\n for(i = pos+1; i < len; i++)\n printf(\"%c\", s[i]);\n }\n else if(f == 1)\n {\n for(i = 0; i < pos; i++)\n printf(\"%c\", s[i]);\n printf(\"%c\", letter);\n for(i = pos; i < len; i++)\n printf(\"%c\", s[i]);\n }\n else\n {\n if(len % 2 == 0)\n {\n for(i = 0; i < len/2; i++)\n printf(\"%c\", s[i]);\n printf(\"%c\", 'a');\n for(i = len/2; i < len; i++)\n printf(\"%c\", s[i]);\n }\n else\n {\n for(i = 0; i <= len/2; i++)\n printf(\"%c\", s[i]);\n for(i = len/2; i < len; i++)\n printf(\"%c\", s[i]);\n }\n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "f3d44c17aa82b75c67c5d0ca2d69671e", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define P 1000000007\nint m;\nlong long f[2][300005];\nint cal2(int n)\n{\n return (n*(n+1)/2);\n}\nint main(void)\n{\n int r,g;\n int i,j;\n int p;\n long long ma,k;\n scanf(\"%d%d\",&r,&g);\n memset(f,0,sizeof(f));\n m=sqrt(2*(r+g))+1;\n p=0;\n if (r>=1)\n f[p][1]=1;\n if (g>=1)\n f[p][0]=1;\n k=1;\n for (i=2;k;i++)\n {\n k=0;\n for (j=0;j<=r;j++)\n {\n f[1-p][j]=0;\n if (j>=i)\n {\n f[1-p][j]+=f[p][j-i];\n }\n if (cal2(i)-j<=g)\n {\n f[1-p][j]+=f[p][j];\n }\n f[1-p][j]%=P;\n k=(k+f[1-p][j])%P;\n }\n p=1-p;\n // printf(\"%d\\n\",i);\n }\n ma=0;\n for (i=0;i<=r;i++)\n ma=(ma+f[1-p][i])%P;\n printf(\"%I64d\\n\",ma);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c2f9b0696a25cc7b00b76959c53ac80e", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n\nint main()\n\n{\n int a , n;\n scanf(\"%d %d\", &n, &a);\n if (a % 2 != 0 )\n {\n printf(\"%d\",(a /2 )-1);\n }\n else\n {\n printf(\"%d\",(n-a)/2 +1);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1331677cb8ed5a010d35027c52aaa159", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main() {\n\tdouble n, k;\n\tscanf(\"%f %f\", &n, &k);\n\tdouble a = (2 * n + 3 - ceil(sqrt(8 * n + 8 * k + 9))) / 2;\n\tprintf(\"%d\", int(a));\n} ", "lang_cluster": "C", "compilation_error": true, "code_uid": "e60e67e27832120185a883a8a65ca939", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\nint main(void)\n{\n int n,m,v;\n long long k;\n while(scanf(\"%d\",&n)!=EOF)\n {\n m=1;\n v=0;\n scanf(\"%d\",&k);\n if\n do\n {\n if(k%2)\n {printf(\"%d\\n\",m);v=1;}\n else\n {k=k/2;m=m+1;}\n }\n while(v==0); \n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "82c91f090cc2acbcf3f92df8ac58c28f", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "include \nint main()\n{\n\tint a,b, c=1;\n\tscanf(\"%d %d\",&a,&b);\n\twhile(a>=0&&b>=0)\n\t{\n\t a-= c++;\n\t b-=c++;\n\t}\n\tif(a<0)\n\t printf(\"Vladik\"); \n\telse\n\t printf(\"Valera\");\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "37833e22cce42e79ad68351ce15ba2f8", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n\tlong long int d1, d2, d3, min;\n\t\n\tscanf(\"%lld %lld %lld\", &d1, &d2, &d3);\n\t\n\tmin= d1+d2+d3 < (d1+d2)*2 ? d1+d2+d3:(d1+d2)*2;\n\tmin= min < (d2+d3)*2 ? min:(d2+d3)*2;\n\tmin= min<(d1+d3)*2 : min:(d1+d3)*2;\n\n\tprintf(\"%lld\", min);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "c2b59f885b4045306dfa7f2eff11e892", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int m,n,i,j,k;\n scanf(\"%d\",&m);\n k=5*m;\n int sum;\n for (i=k; i>=5 ; i-=5)\n {\n sum=0;\n for (j=5; j<=i ; j*=5)\n {\n sum=sum+ (i/j);\n }\n if (sum\nint main()\n{\n int a,b,c;\n scanf(\"%d %d %d\",&a,&b,&c);\n int i,k,j,l;\n i=sqrt(a*b*c);\n k=i/a;\n j=i/b;\n l=i/c;\n ans=4*(k+j+l);\n printf(\"%d\",ans);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "9e14457e84d35bf87fc3cf843ba4b547", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main ()\n{\n int i = 0 ,a = 0 ,b = 0; \n char s1 [100];\n char s2 [100];\n scanf(\"%s\",s1);\n scanf(\"%s\",s2);\n for ( i = 0 ; s1[i]!= '\\0' ; i++)\n {\n if (s1[i]>90)\n {\n s1[i] -= 32;\n }\n if (s2[i]>90)\n {\n s2[i] -= 32;\n }\n if (s1[i] == s2[i]) a = 0;\n else if ( s1[i]\nint main()\n{\n int c,vo,v,a,l,i=0,m=0;\n scanf(\"%d%d%d%d%d\",&c,&vo,&v,&a,&l);\n while(c>0)\n {\n if(m\nint main()\n{\nint a,b,c,time=0,r,max;\nscanf(\"%d %d %d\",&a,&b,&c);\nif (a>b && a>c)\n{\n max=a;\n}\nelse if(b>a && b>c)\n{\n max=b;\n}\nelse\n{\n max=c;\n}\nint r=(a+b+c)-max;\nwhile(max>=r)\n{\n r=r+1;\n time=time+1;\n}\nprintf(\"%d\",time)\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f81d3073c0ad8e61c66625785721afce", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define Min(a,b) a>b?b:a\nint main()\n{\n int Money,ID[5][5],i,j,a,b;\n while(scanf(\"%d\",&Money)!=EOF)\n {\n for(i=1;i<=4;i++)\n for(j=1;j<=4;j++)\n scanf(\"%d\",&ID[i][j]);\n for(i=1;i<=4;i++)\n {\n a=Min(ID[i][1],ID[i][2]);\n b=Min(ID[i][3],ID[i][4]);\n if(a+b>Money&&i==4){printf(\"-1\\n\");break;}\n if(a+b>Money)continue;\n else\n {printf(\"%d %d %d\\n\",i,a,Money-a);break;}\n }\n\n }\n\treturn 0;\n}\n\n\n ", "lang_cluster": "C", "compilation_error": false, "code_uid": "f97d53ac4e1b961bd6acaa3666858559", "src_uid": "6e7ee0da980beb99ca49a5ddd04089a5", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \nint main() {\n\tint n,min1,min2,min3,max1,max2,max3, left = 0, first = 0, second = 0, third = 0;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d\",&min1);\n\tscanf(\"%d\",&max1);\n\tscanf(\"%d\",&min2);\n\tscanf(\"%d\",&max2);\n\tscanf(\"%d\",&min3);\n\tscanf(\"%d\",&max3);\n\tleft = n;\n\tfirst = min1;second = min2;third = min3;\n\twhile(first < (left -(min2+min3)) && first <= max1) first++;\t\n\tleft -= first;\n\twhile(second < (left -min3) second <= max2) second++;\n\tleft -= second;\n\twhile(third < left && third <= max3) third++;\n\n\tprintf(\"%d %d %d\\n\", first, second, third);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "cb67d93ec1d898e1a6451e02a59e4143", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n long long int n,k,l,mod;\n scanf(\"%I64d\",&n);\n double i,j;\n i=(double)sqrt(n);\n if(i*i==n)\n {\n j=i-1;;\n }\n else \n j=i;\n while(j>0)\n {\n mod=j%10;\n k+=mod;\n j/=10;\n }\n if(i*i+k*i==n)\n printf(\"%I64d\",i);\n else \n printf(\"-1\");\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b555c23bfcdef19d67f59aef73a932dc", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\nlong long int gcd_func(long long int a, long long int b)\n{\n\tlong long int t;\n\twhile(b!=0)\n\t{\n\t\tt=b;\n\t\tb=a%b;\n\t\ta=t;\n\t}\n\treturn a;\n}\nint main()\n{\n\tlong long int t, w, b, temp;\n\tscanf(\"%lld %lld %lld\", &t, &w, &b);\n\tif(w==b)\n\t{\n\t\tprintf(\"1/1\\n\");\n\t\treturn 0;\n\t}\n\tif(w>b)\n\t{\n\t\ttemp = w;\n\t\tw = b;\n\t\tb = temp;\n\t}\n\tlong long int gcd = gcd_func(b, w), numer=w-1, denom=t, lcm;\n\tlcm = w/gcd;\n\tif(lcm<=t/b)\n\t{\n\t\tlcm = lcm*b;\n\t\ttemp = t/lcm;\n\t\tnumer += ((temp-1)*w);\n\t\ttemp = temp*lcm;\n\t\tif(temp+w-1<=t)\n\t\t\tnumer += w;\n\t\telse\n\t\t\tnumer += (t-temp+1);\n\t}\n\tif(numer == 0)\n\t{\n\t\tprintf(\"0/1\\n\");\n\t\treturn 0;\n\t}\n\tgcd = gcd_func(denom, numer);\n\tnumer /= gcd;\n\tdenom /= gcd;\n\tif(numer>denom)\n\t\tprintf(\"1/1\\n\");\n\telse\n\t\tprintf(\"%lld/%lld\\n\", numer, denom);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d95d7cb1635fba1d193dbd663fd9bf69", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\n#include\nvoid main()\n{\nint a,b,x1,y1,x2,y2;\nclrscr();\nscanf(\"%d%d%d%d%d%d\",&a,&b,&x1,&y1,&x2,&y2);\nif(((x1+x2<=a)&&(max(y1,y2)<=b))||((y1+x2<=b)&&(max(y2,x1)<=a))||((y2+x1<=b)&&(max(x2,y1)<=a))||((x1+x2<=b)&&(max(y1,y2)<=a))||((y1+y2<=b)&&(max(x1,x2)<=a))||((y1+y2<=a)&&(max(x1,x2)<=b))||((y2+x1<=a)&&(max(x2,y1)<=b))||((y1+x2<=a)&&(max(x1,y2)<=b)))\nprintf(\"YES\");\nelse\nprintf(\"NO\");\nreturn 0;\n}\nint max(int x ,int y)\n{\nint t;\nif(x>=y)\nt=x;\nelse\nt=y;\nreturn t;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "73b4ca0a500ec53c9cadea2e310761f1", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint oeration(int , int );\n\nint main()\n{\n int a , b ; \n int op ; \n scanf(\"%d %d\",&a,&b);\n \n op=operation(a,b);\n \n printf(\"%d\\n\",op)\n \n return 0;\n}\n\nint oeration(int a, int b)\n{\n int op=0 ; \n int a1=-1 , a2=-1;\n if(a==b)\n {\n return 0;\n }\n while(a!=b)\n {\n if(a>b)\n {\n if(!(a%2))\n {\n a/=2;\n op++;\n }\n else if(!(a%3))\n {\n a/=3;\n op++;\n }\n else if(!(a%5))\n {\n a/=5;\n op++;\n }\n else\n {\n a1=1;\n }\n }\n if(a\n#include \nint main()\n{\n int n ,i,m, c, min, t[101] , test = 1 ;\n do\n {\n scanf(\"%d\", &n );\n }while (( n <2) || (n>100));\n for (i=0 ; i1000) ;\n }\n c = t[0] ;\n while (test)\n {\n int x = 0 ;\n for (i=1 ; i=t[x])&&(T[i] !=1 )) { x=i;} }\n if (x==0) test =0 ;\n else { t[0]++;\n t[x]-- ; }\n }\n min= t[0]-c ;\n printf (\"%d\", min );\n return 0 ; \n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "3f10a40a1d71df68fb49ff46019ba944", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n char arr[4][4];\n int a, b, x=0, y, z=0, o=0;\n\n for(a=0 ; a<4 ; a++){\n scanf(\" %[^\\n]\",arr[a]);\n }\n\n for(a=0 ; a<4 ; a++){\n x=0;\n z=0;\n for(b=0 ; b<4 ; b++){\n if(arr[a][1] == 'o' || arr[a][2] == 'o')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.') z++;\n if(arr[a][b] == 'x')x++;\n if(z == 2)break;\n if(x > 1){printf(\"YES\\n\"); goto omar;}\n\n }\n }\n if(z == 2 || o == 2)break;\n else {\n if(x > 1){printf(\"YES\\n\",x,o); goto omar;}\n }\n x=0;\n o=0;\n for(b=0 ; b<4 ; b++){\n x=0;\n z=0;\n for(a=0 ; a<4 ; a++){\n if(arr[1][b] == 'o' || arr[2][b] == 'o')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.')z++;\n if(arr[a][b] == 'x')x++;\n\n }\n }\n if(z == 2 || o == 2)break;\n else {\n if(x > 1){printf(\"YES\\n\",x,o); goto omar;}\n }\n }\n x=0;\n y=0;\n a=1;\n b=0;\n while(y<3){\n\n if(arr[2][1] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1){printf(\"YES\\n\",x); goto omar;}\n a++;\n b++;\n y++;\n }\n }\n y=0;\n x=0;\n z=0;\n a=0;\n b=0;\n o=0;\n while(y<4){\n\n if(arr[1][1] == 'o' || arr[2][2] == 'o')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.') z++;\n if(arr[a][b] == 'x')x++;\n \n if(z == 2 || o == 2)break;\n else {\n if(x > 1 && y == 3){printf(\"YES\\n\",x,o); goto omar;}\n a++;\n b++;\n y++;\n }\n }\n y=0;\n x=0;\n a=0;\n b=1;\n while(y<3){\n\n if(arr[1][2] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1){printf(\"YES\\n\",x); goto omar;}\n a++;\n b++;\n y++;\n }\n }\n y=0;\n x=0;\n a=0;\n b=2;\n while(y<3){\n\n if(arr[1][1] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1){printf(\"YES\\n\"); goto omar;}\n a++;\n b--;\n y++;\n }\n }\n y=0;\n x=0;\n z=0;\n a=0;\n b=3;\n o=0;\n while(y<4){\n\n if(arr[1][2] == 'o' || arr[2][1] == 'o')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.')z++;\n if(arr[a][b] == 'x')x++;\n \n\n if(z == 2 || o == 2)break;\n else {\n if(x > 1 && y == 3){printf(\"YES\\n\",x,o); goto omar;}\n a++;\n b--;\n y++;\n }\n }\n y=0;\n x=0;\n a=1;\n b=3;\n while(y<3){\n\n if(arr[2][2] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1){printf(\"YES\\n\"); goto omar;}\n a++;\n b--;\n y++;\n }\n }\n printf(\"NO\\n\");\n omar:\n return 0;\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2c0e760ceda9a5f54a06a83d0ecb7889", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,j,a,b,n,m;\n scanf(\"%d%d\",&n,&m);\n int a[n],b[m];\n for(i=0;i\n#include \n#include \nint main() {\n int m, c[100], contador = 0, qwerty = 0, a, b, i;\n scanf(\"%d\", &m);\n for (i = 0; i < m; i++) {\n scanf(\"%d\", &c[i]);\n qwerty = qwerty + c[i];\n }\n scanf(\"%d %d\", &a, &b);\n for (i = 0; i < m; i++) {\n contador = contador + c[i];\n if (contador >= a && contador <= b) {\n if ((qwerty - contador) >= x && (qwerty - contador) <= y) {\n printf(\"%d\", i + 2);\n return 0;\n }\n }\n }\n printf(\"0\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d74d17692b92bdd9540c34498f2750bf", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int i,j;\n int ans[125][5]={1,2,3,4,5, 1,2,3,5,4, 1,2,4,3,5, 1,2,4,5,3, 1,2,5,3,4,\n 1,2,5,4,3, 1,3,2,4,5, 1,3,2,5,4, 1,3,4,2,5, 1,3,4,5,2,\n 1,3,5,2,4, 1,3,5,4,2, 1,4,2,3,5, 1,4,2,5,3, 1,4,3,2,5,\n 1,4,3,5,2, 1,4,5,2,3, 1,4,5,3,2, 1,5,2,3,4, 1,5,2,4,3,\n 1,5,3,2,4, 1,5,3,4,2, 1,5,4,2,3, 1,5,4,3,2, 2,1,3,4,5,\n 2,1,3,5,4, 2,1,4,3,5, 2,1,4,5,3, 2,1,5,3,4, 2,1,5,4,3,\n 2,3,1,4,5, 2,3,1,5,4, 2,3,4,1,5, 2,3,4,5,1, 2,3,5,1,4,\n 2,3,5,4,1, 2,4,1,3,5, 2,4,1,5,3, 2,4,3,1,5, 2,4,3,5,1,\n 2,4,5,1,3, 2,4,5,3,1, 2,5,1,3,4, 2,5,1,4,3, 2,5,3,1,4,\n 2,5,3,4,1, 2,5,4,1,3, 2,5,4,3,1, 3,1,2,4,5, 3,1,2,5,4,\n 3,1,4,2,5, 3,1,4,5,2, 3,1,5,2,4, 3,1,5,4,2, 3,2,1,4,5,\n 3,2,1,5,4, 3,2,4,1,5, 3,2,4,5,1, 3,2,5,1,4, 3,2,5,4,1,\n 3,4,1,2,5, 3,4,1,5,2, 3,4,5,1,2, 3,4,2,5,1, 3,4,5,1,2,\n 3,4,5,2,1, 3,5,1,2,4, 3,5,1,4,2, 3,5,2,1,4, 3,5,2,4,1,\n 3,5,4,1,2, 3,5,4,2,1, 4,1,2,3,5, 4,1,2,5,3, 4,1,3,2,5,\n 4,1,3,5,2, 4,1,5,2,3, 4,1,5,3,2, 4,2,1,3,5, 4,2,1,5,3,\n 4,2,3,1,5, 4,2,3,5,1, 4,2,5,1,3, 4,2,5,3,1, 4,3,1,2,5,\n 4,3,1,5,2, 4,3,2,1,5, 4,3,2,5,1, 4,3,5,1,2, 4,3,5,2,1,\n 4,5,1,3,2, 4,5,1,2,3, 4,5,2,1,3, 4,5,2,3,1, 4,5,3,1,2,\n 4,5,3,2,1, 5,1,2,3,4, 5,1,2,4,3, 5,1,3,2,4, 5,1,3,4,2,\n 5,1,4,2,3, 5,1,4,3,2, 5,2,1,3,4, 5,2,1,4,3, 5,2,3,1,4,\n 5,2,3,4,1, 5,2,4,1,3, 5,2,4,3,1, 5,3,1,2,4, 5,3,1,4,2,\n 5,3,2,1,4, 5,3,2,4,1, 5,3,4,1,2, 5,3,4,2,1, 5,4,1,2,3,\n 5,4,1,3,2, 5,4,2,1,3, 5,4,2,3,1, 5,4,3,1,2, 5,4,3,2,1};\n \n int g[10][10],sum,s;\n while(1)\n {\n sum=0;\n for(i=1;i<=5;i++)\n for(j=1;j<=5;j++)\n scanf(\"%d\",&g[i][j]);\n \n for(i=0;i<120;i++)\n {\n s=g[ans[i][0]][ans[i][1]]+g[ans[i][1]][ans[i][0]]+g[ans[i][2]][ans[i][3]]\n +g[ans[i][3]][ans[i][2]]+g[ans[i][1]][ans[i][2]]+g[ans[i][2]][ans[i][1]]+\n g[ans[i][3]][ans[i][4]]+g[ans[i][4]][ans[i][3]]+g[ans[i][2]][ans[i][3]]\n +g[ans[i][3]][ans[i][2]]+g[ans[i][3]][ans[i][4]]+\n g[ans[i][4]][ans[i][3]];\n if(sum\n\nint main(void) {\n\tint a, dlen, b;\n\tchar d[101];\n\n\tscanf(\"%d.\", &a);\n\tscanf(\"%[^e]%ne%d\", d, &dlen, &b);\n\n\tif (dlen == 1 && d[0] == '0' && b == 0)\n\t\tprintf(\"%d\\n\", a);\n\telse\n\t\tif (b >= dlen)\n\t\t\tprintf(\"%d%s%0.*d\\n\", a, d, b - dlen, 0);\n\t\telse\n\t\t\tprintf(\"%d%.*s.%s\\n\", a, b, d, d + b);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9796614b7a3fe8e41d9a33fac25233a0", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\n#include\nint mini(int x,int y){\n return (x>y)?y:x;\n}\nint main(){\n int n,x1,y1,x2,y2,sum=0;\n scanf(\"%d %d %d %d %d\",&n,&x1,&y1,&x2,&y2);\n\n if((x1==0 && x2==n ||x1==n && x2==0)&& (y1!=0 || y1!=n)){\n sum=(y1+y2+n);\n }\n else if((y1==0 && y2==n ||y1==n && y2==0)&& (x1!=0 ||x1!=n)){\n sum=x1+x2+n;\n }\n else{\n sum=abs(x1-x2)+abs(y1-y2);\n }\n printf(\"%d\",mini(sum,(4*n-sum)));\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "330f5239ec8f1643cba3a5c86d526212", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "\n\nint main()\n{\n typedef vector v_int;\n vector light_on(3 + 2, v_int(3 + 2, true));\n\n for(int row = 1; row <= 3; row++)\n {\n for(int column = 1; column <= 3; column++)\n {\n int no_of_toggles;\n scanf(\"%d\", &no_of_toggles);\n\n if(no_of_toggles%2 == 1)\n {\n toggle(light_on[row][column]);\n\n toggle(light_on[row][column - 1]);\n toggle(light_on[row][column + 1]);\n toggle(light_on[row + 1][column]);\n toggle(light_on[row - 1][column]);\n }\n }\n }\n\n for(int row = 1; row <= 3; row++)\n {\n for(int column = 1; column <= 3; column++)\n {\n if(light_on[row][column])\n printf(\"1\");\n else\n printf(\"0\");\n }\n printf(\"\\n\");\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "971fb624a1c8a4c21dbe95c3ecea4822", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int n,m=0,a[100],k,b=0,c[100];\n scanf(\"%d\",&n);\n scanf(\"%d\",&k);\n for(i=0;i=k)\n {\n printf(\"yes\\n\");\n for(i=0;i\nint main()\n{\n int n,i,sum=0,dg;\n scanf(\"%d\",&n);\n int x=n;\n for(i=2;i=i)\n {\n sum+=n%i;\n n/=i;\n }\n sum+=n;\n }\n printf(\"%d/%d\",sum,x-2);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "dfa914f4b8fd11fb4a5f7e38943fbb02", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{ \n int n;\n scanf(\"%d\",&n);\n printf(\"%d\",n);\n for(i=n;i>0;--i)\n {\n if(n%i==0)\n printf(\"%d \",i);\n n=n/i;\n \n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "7e2c3ad3f22f7f31cbdafa79c66d3b13", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint a , b ,c,r,m;\nbool ok(int m){\n if (b*m+b*c>=a*c) return 1;\n else return 0;\n}\nint main()\n{\n // a is l\n // b is f\n scanf(\"%i%i%i\",&a,&b,&c);\n while(a>b){\n m=(b+a)/2;\n if(ok(m)) b=m;\n else a=m-1;\n }\n printf(\"%i\",b);\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0cbb0e81e5a528edbfb01a31b7591033", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\nint mod=1000000007;\nint dp[2001][2001];\nint f(int n,int k);\nint upd[2001][2001]\nint uf(int n,int k)\n{\n\tif(udp[n][k]==0)\n\t\treturn udp[n][k];\n\telse\n\treturn f(n,k)-f(n-1,k);\n}\nint f(int n,int k)\n{\n\n\tif(dp[n][k]!=0)\n\t{\n\t\treturn dp[n][k];\n\t}\n\n\tif(n==1)\n\t\tdp[n][k]=1;\n\telse if(k==1)\n\t\tdp[n][k]=n;\n\telse{\n\tint i,p=0,j=0;\n\tint div;\n\tfor(i=n/2;i>=0;i--)\n\t{\n\t\tif(n%i==0)\n\t\t{\n\t\t\tdiv=i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tint non[div];\n\tfor(i=2;i=0;i--)\n\t{\n\t\tif(n%i==0)\n\t\t{\n\t\t\tdiv=i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%d\",div);*/\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "dd6ef9f9425fe259bc49f587b1523503", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a1,a2,a3,b1,b2,b3,n;\n scanf(\"%d %d %d\",&a1,&a2,&a3);\n scanf(\"%d %d %d\",&b1,&b2,&b3);\n scanf(\"%d\",&n);\n if(n>=2 && n<=100 && (a1+a2+a3)<=5 && (b1+b2+b3)<=10)\n printf(\"YES\");\n else if(a1==0 && a2==0 && a3==0 && b1==0 && b2==0 && b3==0)\n {\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "8188d0120340e001e76bce1c5592661b", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n & 01) printf(\"contest\")\n\telse printf(\"home\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "0bd801184518eb1f3cd518f6e6b0bda8", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n\nint main ()\n{\n \n char s[1001];\n int i, a[4] = {0};\n scanf (\"%s\", s);\n \n while (s[i] != '\\0') {\n if (s[i] > 47 && s[i] < 58)\n a[1] = 1;\n if (s[i] > 96 && s[i] < 123)\n a[2] = 1;\n if (s[i] > 64 && s[i] < 91)\n a[3] = 1;\n }\n \n if (a[1] == 1 && a[2] == 1 && a[3] == 1)\n printf (\"Correct\\n\");\n else\n printf (\"Too weak\\n\");\nreturn 0;\n} \n \n \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9ca699a03f17460894da92d8cbdeab81", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main(){\nint i,j,n1,n2;\nscanf(\"%d\",&n1);\nscanf(\"%d\",&n2);\nfor(i = 1 ;i <= n1 ; i++ ){\n for(j = 1;j <= n1; j++){\n if(i*j == n2){\n sum = sum + 1;\n }\n else\n \n }\n }\n}\nprintf(\"%d\",sum);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "da5f21e35fc0677bdca3cede06758dee", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n char s[50];\n int i=0,l,c=0,c1=0;\n scanf(\"%s\",s);\n l=strlen(s);\n for(i=0;i\nlong long int min(long long int a,long long int b)\n{\n if(a\n#include \n\nchar keyboard[100] = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n\nint main()\n{\n char way[2];\n scanf(\"%s\", way);\n\n char input[120];\n scanf(\"%s\", input);\n\n if(way[0] == 'L')\n {\n for(int i = 0; i < strlen(input); i++)\n {\n for(int j = 0; j < strlen(keyboard); j++)\n {\n if(input[i] == keyboard[j])\n {\n printf(\"%c\", keyboard[j + 1]);\n break;\n }\n }\n }\n printf(\"\\n\");\n }\n else\n {\n for(int i = 0; i < strlen(input); i++)\n {\n for(int j = 0; j < strlen(keyboard); j++)\n {\n if(input[i] == keyboard[j])\n {\n printf(\"%c\", keyboard[j - 1]);\n break;\n }\n }\n }\n printf(\"\\n\");\n }\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0a6ae476d99b20f99b3fc3a75284e8fa", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n \nint main(int argc, char* argv) {\n\tint n, counter = 0;\n\tscanf_s(\"%d\", &n);\n\tchar* k = (char*)malloc(n * sizeof(char));\n\tfor (int i = 0; i <= n; i++) {\n\t\tk[i] = getchar();\n\t}\n\t{\n\t\tfor (int i = 0; i <= n - 1; i++) {\n\t\t\tif ((k[i] == 'S') && (k[i + 1] == 'F')) {\n\t\t\t\tcounter++;\n\t\t\t}\n\t\t\telse if ((k[i] == 'F') && (k[i + 1] == 'S')) {\n\t\t\t\tcounter--;\n\t\t\t}\n\t\t}\n\t}\n\tif (counter > 0) {\n\t\tprintf(\"YES\");\n\t}\n\telse {\n\t\tprintf(\"NO\");\n\t}\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "c39ad822b4f219a5877fc46918e1fc39", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nusing namespace std;\nstring s , sl;\nlong long n , l , r , ans;\nlong long dfs(long long num) {\n if(num == 1) {\n return 1;\n }\n return 1 + 2 * dfs(num / 2);\n}\nvoid binsearch(long long le , long long ri , long long num) {\n long long mid = (le + ri) >> 1;\n if(ri < l || le > r || le > ri)\n return ;\n if(mid < l) {\n binsearch(mid + 1 , ri , num / 2);\n }\n else if(mid > r) {\n binsearch(le , mid - 1 , num / 2);\n }\n else {\n ans += num % 2;\n binsearch(le , mid - 1 , num / 2);\n binsearch(mid + 1 , ri , num / 2);\n }\n}\nint main() {\n cin >> n >> l >> r;\n if(n == 0) {\n cout << 0 << endl;\n return 0;\n }\n long long count = dfs(n);\n binsearch(1 , count , n);\n cout << ans << endl;\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a1bdbfcab1ec07a5bd1a0c801e556a15", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "a,b,c,d,l;main(x,y){scanf(\"%d%d\",&x,&y);l=abs(x)+abs(y);x<0?y<0?a=d=-l:a=-l,d=l:y<0?b=-l,c=l:(b=c=l);printf(\"%d%d%d%d\",a,b,c,d);}", "lang_cluster": "C", "compilation_error": true, "code_uid": "35df42afc37a011107c8c57612c351db", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "{\n for(i=0,j=n-1;i\n\nint main(){\n\n int n;\n scanf(\"%d\",&n);\n\n if(n%2==0){\n printf(\"Mahmoud\");\n }\n\n else(n%2){\n printf(\"Ebab\");\n }\n\n return 0;\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "c9a18cefac4e82f08f0a4450f120fd1e", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n\tint i,j,n,m,a,b;\n while(scanf(\"%d%d%d\",&n,&a,&b)!=EOF)\n\t{\n\t\tif(4*a+2*b<=n) t=1;\n\t else if(2*a+b<=n) t=2;\n\t else if(4*a<=n||(2*a<=n&&2*b<=n)||(2*a<=n&&a+b<=n)) t=3;\n\t else if(a+b<=n||2*a<=n) t=4;\n\t else if(2*b<=n) t=5;\n\t else t=6;\n\t printf(\"%d\",t);\n\t \n\t\t\n\t\t\n\t\t\n\t\t\n\t\t}\n\t}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2152bba9774a9be88ec0ee363ec6f5a7", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint deleteDuplicates(std::vector v, int n);\n\nint main()\n{\n int n = 0;\n std::cin >> n;\n std::vector vec;\n for (int a = 0; a < n; a++)\n {\n int b = 0;\n std::cin >> b;\n vec.push_back(b);\n }\n std::sort(vec.begin(), vec.end());\n int m = deleteDuplicates(vec, n);\n int l = vec[0] == 0 ? m - 1 : m;\n std::cout << l << std::endl;\n}\n\nint deleteDuplicates(std::vector v, int n)\n{\n if (n==0 || n==1)\n return n;\n std::vector temp;\n int j = 0;\n for (int i=0; i\n#include\n\nint main()\n{\n int n,dig[2]={0},phone=0;\n scanf(\"%d\",&n);\n int arr[n];\n for(int i=0;i=1 && arr[1]>=10)\n {\n while(arr[0]-1>=0 || arr[1]-10>=0)\n if(arr[0]-1>=0 && arr[1]-10>=0)\n {\n phone++;\n arr[0]-=1;\n arr[1]-=10\n }\n else if(arr[0]>0)\n {\n if(arr[0]+arr[1]>=11)\n phone++;\n }\n \n \n }\nprintf(\"%d\",phone);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2d80984a1c7ef204710508cd76789fbd", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(void)\n{\n int x,y, rad;\n \n scanf(\"%d%d\",&x,&y);\n \n rad=(int)sqrt(x*x + y*y) \n if(rad%2 && x*y>0)\n printf(\"white\");\n else\n printf(\"black\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2c8088aca8202f027df8d397dc70a10b", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n\nusing namespace std;\n\nint main(){\n long long x;\n int t=0,ans=0;\n while(~scanf(\"%lld\",&x)){\n x=x<0?-x:x;\n while(t\nint main()\n{\n int n,d=0,sum;\n scanf(\"%d\",&n);\n int arr[n];\n for(int i=0;i arr[j+1]) \n { \n int swap=arr[j+1];\n a[j+1]=a[j];\n a[j]=swap;\n swapped = 1; \n } \n }\n if (swapped == 0) \n break; \n }\n for(int i=1;i\nint main()\n{\n int k2,k3,k5,k6,min1,min2,diff,sum;\n sum=0;\n scanf(\"%d%%d%d%d\",&k2,&k3,&k5,&k6);\n min1= (k2\n#define p(x) printf(\"%c\",x);\nint i=0;\nchar a[11],b[11];\nint main()\n{\nscanf(\"%s %s\",a,b);\nwhile(a[i])\n{\nif(a[i]<=b[0])\np(a[i]);\nelse\nbreak;\ni++;\n}\nprintf(\"%c\\n\",b[0]);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "19779a8e234250d42dcee0713bc4a140", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int j,d,sumtime,summax=0,summin=0,mintime[30],maxtime[30],i;\n scanf(\"%d%d\",&d,&sumtime);\n for(i=0;i\nint main()\n{\nint i,j,n,m=0;\nscanf(\"%d\",&n);\nint arr[n];\n\tfor(i=0;im)\n \t\t{\n \t\t\tm=count;\n \t\t}\n \t}\n\t\t}\n\t\tprintf(\"%d\",max);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "5382e806672cfba8ac1b8e36a3693081", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint minimum(int x,int y)\n{\n if(x>y)\n return y;\n else\n return x;\n}\nint main()\n{\n int p1,p2,myc1,myc2,tyc;\n scanf(\"%d %d %d %d %d\",&p1,&p2,&myc1,&myc2,&tyc);\n int max,min;\n min=tyc-((myc1-1)*p1+(myc2-1)*p2);\n if(min<0)\n {\n min=0;\n }\n printf(\"%d \",min);\n min=minimum(myc1,myc2);\n if(min==myc1)\n {\n max=minimum(tyc/myc1,p1);\n tyc-=max*myc1;\n max+=minimum(tyc/myc2,p2);\n }\n else\n {\n max=minimum(tyc/myc2,p2);\n tyc-=max*myc2;\n max+=minimum(tyc/myc1,p1);\n }\n printf(\"%d\\n\",max);\n\n\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c34b27c0e5848101632afdb7ad874f1d", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int h1, h2, a, b, day = 0;\n scanf(\"%d%d%d%d\", &h1, &h2, &a, &b);\n h1 += a*8;\n if( h1>=h2 )\n printf(\"0\\n\");\n else\n {\n day++;\n while(1)\n {\n h1 -= b*12;\nh1 += a*12;\n if( h1>=h2 )\n{\n printf(\"%d\\n\", day);\n break;\n }\n if( b>=a )\n {\n printf(\"-1\\n\");\n break;\n }\n day++;\n }\n }\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f86597fd8340191bc14f2bce0acb9d94", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint main()\n{\n while(1){\nint l,i,j,position;\n char s[51],t[51];\n gets(s);\n gets(t);\n l=strlen(t);\n for(i=0,j=0;j\n#include\n\nint main()\n{\n int n;\n int i100,i20,i10,i5,i1;\n \n /* Initialize all notes to 0 */\n i100 = i20 = i10 = i5 = i1 = 0;\n //int count=0;\n\n\n /* Input amount from user */\n \n scanf(\"%d\", &n);\n\tif(n>=1&&n<=pow(10,9)\n\n\t{ \n\n \n if(n >= i100)\n {\n i100 = n/100;\n n -= i100 * 100;\n }\n \n if(n >= 20)\n {\n i20 = n/20;\n n -= i20 * 20;\n }\n if(n >= 10)\n {\n i10 = n/10;\n n -= i10 * 10;\n }\n if(n >= 5)\n {\n i5 = n/5;\n n -= i5 * 5;\n }\n \n if(n >= 1)\n {\n i1 = n;\n }\n}\n int count=i1=i5+i10+i20+i100;\n\n /* Print required notes */\n //printf(\"Total number of notes = \\n\");\n // printf(\"%d\",&count);\n printf(\"%d\",count);\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0ebd8b90e414665a9f07447805b30824", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main() {\n int res = 0;\n int aux1, aux2;\n int k;\n int n;\n\n scanf(\"%d\", &n);\n\n for (k = 1; aux1 <= n; k++) {\n aux1 = 0;\n aux2 = 0;\n aux1 = pow(2, k) - 1;\n aux2 = pow(2, k - 1);\n aux1 = aux1 * aux2;\n \n if (n % aux1 == 0)\n res = aux1;\n }\n\n printf(\"%d\\n\", res);\n}\n\n/* 1512149622788 */\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b15dd90797ef6e1da2c45232c6b908fe", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char c[2];\n int n;\n scanf(\"%d\", &n);\n scanf(\"%c %c\", &c[0],&c[1]);\n\n if((c[0]=='v'&&c[1]=='<'')||(c[0]=='<'&&c[1]=='^'')||(c[0]=='^'&&c[1]=='>'')||(c[0]=='>'&&c[1]=='v'))\n {if(n%4==1){\n printf(\"cw\");\n }\n else{\n printf(\"ccw\");\n }}\n\n if((c[0]=='v'&&c[1]=='>'')||(c[0]=='<'&&c[1]=='v')||(c[0]=='^'&&c[1]=='<'')||(c[0]=='>'&&c[1]=='^')){\n if(n%4==3){\n printf(\"cw\");\n }\n else{\n printf(\"cww\");\n }\n }\n if((c[0]=='v'&&c[1]=='^'')||(c[0]=='<'&&c[1]=='>'')||(c[0]=='>'&&c[1]=='<')){\n printf(\"undefined\");\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "11e6767b5fc1f395d5a80cf96190f8f3", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int w,h,u1,d1,u2,d2;\n scanf(\"%d %d\",&w,&h);\n scanf(\"%d %d\",&u1,&d1);\n scanf(\"%d %d\",&u2,&d2);\n if(d1!==d2){\n while(h!=0)\n {\n if(h==d1){\n w=w+h;\n w=w-u1;\n h=h-1;\n }\n else if(h==d2){\n w=w+h;\n w=w-u2;\n h=h-1;\n }\n else{\n w=w+h;\n h=h-1;\n }\n }\n }\n printf(\"%d\",w);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2c4ea821d8aa6081f742d4864fa154cb", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#define MAX 105\n\nmain()\n{\nint a[MAX],n,res =0;\nscanf (\"%d\",&n);\nfor(i=0;i\n#include \n#include \n\nchar *substring(size_t start, size_t stop, const char *src, char *dst, size_t size);\n\nint main(){\n int i, j;\n char vec[10][11];\n char dato[80];\n char parte[11];\n scanf(\"%d\", dato);\n for ( i = 0; i < 2; i++ ){\n scanf(\"%s\", vec[i] );\n }\n for( i = 0; i < 80; i = i + 10){\n substring( i, i + 11, dato, parte, sizeof parte);\n for ( j = 0; strcmp( parte, vec[ j ] ) == 0; j++);\n printf(\"%d\", j);\n }\n }\n return(0);\n}\n\nchar *substring(size_t start, size_t stop, const char *src, char *dst, size_t size)\n{\n int count = stop - start;\n if ( count >= --size )\n {\n count = size;\n }\n sprintf(dst, \"%.*s\", count, src + start);\n return dst;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "5f47fa433854e7e070f38eedfe26bf49", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint i, j, k, n, m[100], r[100];\n\tdouble s, d;\n\twhile (scanf(\"%d\", &n) == 1)\n\t{\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tscanf(\"%d\", &m[i]);\n\t\t}\n\t\tfor (j = 0; j < n; j++)\n\t\t{\n\t\t\tscanf(\"%d\", &r[j]);\n\t\t}\n\t\ts = 0;\n\t\tfor (i = 1; i <= 1000; i++)\n\t\t{\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t{\n\t\t\t\tif ((i % m[j]) == r[j])\n\n\t\t\t\t{\n\t\t\t\t\ts++;\n\t\t\t\t\td = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (s == 0)\n\t\t{\n\t\t\tprintf(\"0.0000\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"%0.5lf\\n\", s / d);\n\t\t}\n\t}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "5c1669dbd9130ab899b4da18e222b5b6", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n\nint\nmain(void)\n{\n // value of number as you input it into initNumbers -->\n int num = 0;\n // length of your array will be -->\n int length = 0;\n\n scanf(\"%d\", &length);\n\n int 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};\n\n int initNumbers[length];\n\n int divisors[length];\n\n int counter;\n\n for(int i = 0; i < length; i++)\n {\n scanf(\"%d\",&num);\n initNumbers[i] = num;\n }\n int counter3 = 0;\n for(int i = 0; i < length; i++)\n {\n counter3+=1;\n for(int j = 0; j<25;j++)\n {\n for(int k = 0; k\n\nint main()\n{\n int T, o = 0, k = 0;\n scanf(\"%d\", &T); getchar();\n while(T--)\n {\n if(getchar() == '0') printf(\"%d\", o), o = 0;\n else o++\n }\n printf(\"%d\", o);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "daa28854fb2a7357cce5c95eb1ad5967", "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nint main () { \n\tchar a,i,j,k;\n\tscanf(\"%d\",&a);\n\tk=a%10;\n\tj=f/10&10;\n\tif(a>0)\n\t\tprintf(\"%d\",a);\n\telse \n\t{\n\t\tif(k>j)\n\t\t\tprintf(\"%d\",a/100*10*k)\n\t\telse printf(\"%d\",a/10)\n\n\t}\n\treturn 0;\n}\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "94ae37e8f538f2045ded547490e6ad10", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n char a[1000];\n scanf(\"%s\",&a);\n int i,count,j,k,x,length=0;\n length=strlen(a);\n for(i=0;i\n\nint main()\n{\n int n,k,g,f=0;\n scanf(\"%d %d\",&n,&k);\n int a[n];\n for (i=0;ii;g--)\n\t{\n\t\tif (a[g]<=k)\n\t\t f++; \n\t else\n\t break;\n\t}\n\tprintf(\"%d\",f);\n\t \n\treturn 0;\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b6047377cf815061d6e1957a3f6e1195", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n for(i=n-1;i>0;i--)\n {\n if(n%i==0)\n {\n printf(\"%d\",i);\n n=n/i;\n i++;\n }\n else\n continue;\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b03d1a41b0dc0674174914865330ae18", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n \n int h,w,k,i,cells=0;\n scanf(\"%d%d%d\",&w,&h,&k);\n for (i=1;i<=k;i++)\n {\n cells = cells + 2*(h+w) - 4;\n h=h-4;\n w=w-4;\n }\n printf(\"%d\",cells);\n\t\n\treturn 0;\n}\n\u2192Judgement Protocol", "lang_cluster": "C", "compilation_error": true, "code_uid": "050671c5aae5c34f5dd58629dbf9e34c", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0} {"lang": "GNU C", "source_code": "p=b;\nq=a/b;\n\nif(a%b!=0)\n q++;\n\n if(p*q<=min)\n {\n min=p*q;\n e=p;\n f=q;\n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "7d211f4ec9449a7684a74c9cc0d9a48e", "src_uid": "6a2a584d36008151d18e5080aea5029c", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\n\nusing namespace std;\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 FORE(ii,aa,bb) for(int ii=aa;ii=bb;ii--)\n#define type(x) __typeof(x.begin())\n\n#define dbg(x) cerr << (#x) << \" --> \" << (x) << endl\n#define y1 fkfrgff\n#define int long long\n#define pii pair\n#define mod 1000000007\n#define N (int)(2e5+10)\n#define mp make_pair\n#define pb push_back\n#define sd second\n#define ft first\n#define endll puts(\"\")\n#define endl '\\n'\n#define inf mod\n#define ort ((sol+sag)/2)\n int n;\n int a[50]={ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8092, 16184, 32368, 64736, 129472, 258944, 517888, 1035776, 2071552, 4143104, 8286208, 16572416, 33144832, 66289664, 132579328, 265158656, 530317312, 1060634624, 2121269248, 4242538496, 8485076992, 16970153984, 33940307968};\n\n\nmain(){\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\",a[n]);\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "bcbc2d19d652e907a545a258d4014455", "src_uid": "76f6ebfaeea789952c931d65c6a5fdff", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "\n \n| In English \u041f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438\n1605069 | Logout\n\nHOME\nCONTESTS\nGYM\nPROBLEMSET\nGROUPS\nRATING\nAPI\nRCC \nVK CUP \nHFT BATTLE \nCALENDAR\n\nPROBLEMSSUBMITSTATUSSTANDINGSCUSTOM TEST\n friends only\n \nContest status \n \n#\tWhen\tWho\tProblem\tLang\tVerdict\tTime\tMemory\n29425650\t2017-08-13 09:36:13\tnavjotsinghcheema\t822C - Hacker, pack your bags!\tGNU C++14\tRunning on test 1\t0 ms\t0 KB\n29425649\t2017-08-13 09:36:11\tKurlyk\t45A - Codecraft III\tGNU C++14\tRunning on test 1\t0 ms\t0 KB\n29425648\t2017-08-13 09:36:09\tpaul_zrm00:03\t839C - Journey\tGNU C++11\tRunning on test 25\t0 ms\t0 KB\n29425646\t2017-08-13 09:36:05\t770780079\t839D - Winter is here\tGNU C++\tWrong answer on test 1\t15 ms\t2800 KB\n29425645\t2017-08-13 09:36:04\tnsnarender\t1A - Theatre Square\tGNU C\tCompilation error\t0 ms\t0 KB\n29425644\t2017-08-13 09:36:03\t1605069\t839A - Arya and Bran\tGNU C\tWrong answer on test 8\t15 ms\t1900 KB\n29425643\t2017-08-13 09:36:01\tlifeboat\t839C - Journey\tGNU C++14\tWrong answer on test 10\t280 ms\t9000 KB\n29425642\t2017-08-13 09:35:57\tvssm2\t832B - Petya and Exam\tGNU C++14\tAccepted\t234 ms\t2600 KB\n29425641\t2017-08-13 09:35:51\te33b54e94290cb09\t839C - Journey\tGNU C++\tAccepted\t436 ms\t7200 KB\n29425640\t2017-08-13 09:35:50\taks12331\t1A - Theatre Square\tGNU C\tWrong answer on test 9\t15 ms\t1900 KB\n29425639\t2017-08-13 09:35:39\tdrjaat00:00\t839A - Arya and Bran\tJava 8\tAccepted\t124 ms\t20400 KB\n29425638\t2017-08-13 09:35:39\takshaysharmagreek\t839A - Arya and Bran\tGNU C++11\tWrong answer on test 8\t15 ms\t2100 KB\n29425636\t2017-08-13 09:35:34\tmuseop00:50\t734C - Anton and Making Potions\tGNU C++14\tWrong answer on test 8\t202 ms\t6100 KB\n29425635\t2017-08-13 09:35:33\twenbaobao\t834C - The Meaningless Game\tGNU C++14\tAccepted\t670 ms\t51700 KB\n29425634\t2017-08-13 09:35:28\t_macros: faraday__anshul, callias, sudoBug00:43\t834B - The Festive Evening\tGNU C++14\tAccepted\t15 ms\t3900 KB\n29425633\t2017-08-13 09:35:26\tgoyaljai\t388A - Fox and Box Accumulation\tGNU C++14\tWrong answer on test 10\t15 ms\t1900 KB\n29425632\t2017-08-13 09:35:25\tsmirnov.i\t839D - Winter is here\tGNU C++14\tAccepted\t1216 ms\t21500 KB\n29425631\t2017-08-13 09:35:24\tprashantsingh\t1A - Theatre Square\tGNU C\tWrong answer on test 1\t0 ms\t1800 KB\n29425630\t2017-08-13 09:35:20\tamir.om\t71A - Way Too Long Words\tGNU C++14\tWrong answer on test 1\t30 ms\t1900 KB\n29425629\t2017-08-13 09:35:09\tTNam\t814A - An abandoned sentiment from past\tGNU C++11\tAccepted\t15 ms\t2100 KB\n29425625\t2017-08-13 09:35:05\txxtz\t839A - Arya and Bran\tGNU C++\tAccepted\t15 ms\t2100 KB\n29425624\t2017-08-13 09:35:03\tsaurabhklkr\t1A - Theatre Square\tGNU C\tCompilation error\t0 ms\t0 KB\n29425623\t2017-08-13 09:35:00\tlhclqslove\t839C - Journey\tGNU C++14\tWrong answer on test 4\t15 ms\t3300 KB\n29425622\t2017-08-13 09:34:59\tKing\t588C - Duff and Weight Lifting\tGNU C++14\tAccepted\t280 ms\t6700 KB\n29425621\t2017-08-13 09:34:53\tAKASHSANGWAN\t1A - Theatre Square\tGNU C\tWrong answer on test 9\t15 ms\t1900 KB\n29425620\t2017-08-13 09:34:51\tpaul_zrm00:03\t839C - Journey\tGNU C++14\tWrong answer on test 1\t0 ms\t3100 KB\n29425619\t2017-08-13 09:34:51\tverma_7068\t75C - Modified GCD\tGNU C++14\tAccepted\t92 ms\t2500 KB\n29425617\t2017-08-13 09:34:49\tsaloom00:05\t839A - Arya and Bran\tGNU C++14\tAccepted\t15 ms\t1900 KB\n29425616\t2017-08-13 09:34:49\tInnocent_Singh\t1A - Theatre Square\tGNU C\tWrong answer on test 9\t15 ms\t1900 KB\n29425615\t2017-08-13 09:34:48\tinterestingLSY\t225C - Barcode\tGNU C++\tWrong answer on test 3\t30 ms\t14000 KB\n29425614\t2017-08-13 09:34:46\tJust_Solve_The_Problem\t839C - Journey\tGNU C++11\tWrong answer on test 4\t15 ms\t3600 KB\n29425613\t2017-08-13 09:34:44\tmanjubala\t339A - Helpful Maths\tPyPy 2\tAccepted\t124 ms\t21400 KB\n29425612\t2017-08-13 09:34:44\ttzr000\t839C - Journey\tGNU C++\tWrong answer on test 6\t156 ms\t5800 KB\n29425611\t2017-08-13 09:34:42\tsexy_crazy01:36\t839A - Arya and Bran\tGNU C++14\tWrong answer on test 3\t15 ms\t1900 KB\n29425609\t2017-08-13 09:34:40\tmarioeid\t738A - Interview with Oleg\tGNU C++14\tWrong answer on test 2\t15 ms\t1900 KB\n29425606\t2017-08-13 09:34:28\tKing\t588C - Duff and Weight Lifting\tGNU C++14\tTime limit exceeded on test 13\t1000 ms\t6700 KB\n29425604\t2017-08-13 09:34:25\tkkw564\t839C - Journey\tGNU C++14\tAccepted\t78 ms\t7100 KB\n29425603\t2017-08-13 09:34:21\tpaul_zrm00:03\t839C - Journey\tGNU C++\tRuntime error on test 1\t0 ms\t3200 KB\n29425601\t2017-08-13 09:34:20\tDFexpress\t839A - Arya and Bran\tGNU C++\tAccepted\t15 ms\t2100 KB\n29425599\t2017-08-13 09:34:16\tarnavdodiedo\t839A - Arya and Bran\tGNU C++14\tAccepted\t15 ms\t1900 KB\n29425598\t2017-08-13 09:34:15\tashraybharambe\t839C - Journey\tJava 8\tWrong answer on test 5\t155 ms\t20600 KB\n29425597\t2017-08-13 09:34:13\tlifeboat\t839C - Journey\tGNU C++11\tWrong answer on test 1\t0 ms\t4800 KB\n29425596\t2017-08-13 09:34:12\tsam_267\t830C - Bamboo Partition\tGNU C++14\tWrong answer on test 7\t15 ms\t1900 KB\n29425595\t2017-08-13 09:34:07\tytc020306\t839B - Game of the Rows\tGNU C++\tWrong answer on test 43\t15 ms\t1900 KB\n29425592\t2017-08-13 09:34:05\tPrans\t1A - Theatre Square\tGNU C++\tAccepted\t15 ms\t2000 KB\n29425590\t2017-08-13 09:34:04\tAjmain00:11\t839A - Arya and Bran\tGNU C\tWrong answer on test 5\t0 ms\t1900 KB\n29425589\t2017-08-13 09:34:04\tcodingIsBliss\t479A - Expression\tGNU C++14\tAccepted\t15 ms\t1900 KB\n29425588\t2017-08-13 09:34:00\t5bingstar\t839C - Journey\tGNU C++11\tWrong answer on test 5\t15 ms\t19000 KB\n29425587\t2017-08-13 09:34:00\tbizaaare\t839B - Game of the Rows\tGNU C++\tWrong answer on test 7\t15 ms\t2400 KB\n29425586\t2017-08-13 09:34:00\tWackyWalrus\t158A - Next Round\tGNU C++14\tAccepted\t30 ms\t1900 KB\n\u2190 1 2 3 4 5 \u2192\n\nCodeforces (c) Copyright 2010-2017 Mike Mirzayanov\nThe only programming contests Web 2.0 platform\nServer time: Aug/13/2017 12:36:14UTC+6 (p1).\nMobile version, switch to desktop version.\nPrivacy Policy\nBy 1605069, contest: Codeforces Round #428 (Div. 2), problem: (A) Arya and Bran, Wrong answer on test 8, #\n #include\n#include\nint cmpfunc (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nmain()\n{\n int n, k, i, j;\n scanf(\"%d %d\", &n, &k);\n int sum = 0, cnt = 0;\n int a[n];\n\n for(i = 0; i=8)\n {\n cnt += 8;\n sum = sum - 8;\n }\n else\n {\n cnt += sum;\n sum = 0;\n }\n\n if(cnt>=k)\n {\n printf(\"%d\", i+1);\n return 0;\n }\n }\n\n printf(\"-1\");\n\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "c79a75d5a3940be1c1fe6c3e61ecab7a", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n#define abs(x) ((x)>0?(x):-(x))\nint main()\n{\n long long a,b,count=0,m,n;\n while(scanf(\"%lld%lld\",&a,&b)>0)\n {\n count=0;\n if(a>=b) count=a/b,a=a-b*count;\n while(a>1&&b>1)\n {\n m=abs(a-b);\n b=a;\n a=m;\n count++;\n }\n if(a==1&&b!=1) count+=b;\n if(b==1&&a!=1) count+=a;\n printf(\"%lld\\n\",count);\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "609df9228015347c2c044db0ed5fcfe4", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "GNU C", "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\n#include\n#include\n#define maxn 110\n\nint main()\n{\n char a[maxn];\n char *p;\n int n;\n int k[maxn];\n int flag;\n int i;\n while(scanf(\"%d\",&n))\n\n {\n getchar();\n memset(k,0,sizeof(k));\n gets(a);\n p=a;\n i=0;\n\n flag=0;\n while(*p)\n {\n while(*p=='B')\n { if(!flag)\n i++;\n\n flag=1;\n k[i]++;\n p++;\n }\n p++;\n flag=0;\n }\n printf(\"%d\\n\",i);\n if(i)\n\n {for(int j=1;j\n#include\n\nint main(){\n long long a[14], b[14], ans = 0;\n for(int i = 0; i < 14; i++) scanf(\"%lld\", a+i);\n for(int i = 0; i < 14; i++){\n long long t = a[i];\n memcpy(b, a, sizeof(a));\n b[i] = 0;\n for(int j = 1; t--; j++) b[(i+j)%14]++;\n t = 0;\n for(int j = 0; j < 14; j++) t += b[j] % 2 ? 0 : b[j];\n ans = ans > t ? ans : t;\n }\n printf(\"%lld\", ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "542ed54c7550563f014bda707521cc4e", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nmain ()\n{\n int m, d, x;\n scanf(\"%d %d\", &m, &d);\n if((d>5 && (m==1||m==3||m==5||m==7||m==8||m==10||m==12)) x=6;\n else if (d>6 && (m==4||m==6||m==9||m==11) x=6;\n else if (d==1 && m==2) x=4;\n else x=5;\n printf(\"%d\", x);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d2c16b4c038f354bed9bc0a489d72b21", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main (){\n int wakeh,wakem,slh,slm,wmin,smin,cevap,saat,dakika,cevap2;\n char n,n;\n scanf(\"%d%c%d\",&wakeh,&n,&wakem);\n scanf(\"%d%c%d\",&slh,&n,&slm);\n wmin=(wakeh*60)+wakem;\n smin=(slh*60)+slm;\n cevap=wmin-smin\n if(cevap>=0){\n saat=(cevap/60);\n dakika=(cevap%60);\n printf(\"%d%c%d\",saat,c,dakika);\n}\n\n\nelse {\n cevap2=24*60-(smin-wmin);\n saat=cevap2/60;\n dakika=cevap2%60;\n printf(\"%d%c%d\",saat,c,dakika);\n }\n \n return 0;\n \n }\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "fa2c216947e2dabd830daeab307f9594", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "5acffee844e50425b6b2fddd95e09b9e", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include\n#include\n\nint main()\n{\n int n,c;\n cin>>n>>c;\n int ar[n];\n for(int i=0;i>ar[i];\n }\n int large=-101;\n for(int i=1;ilarge)\n large=ar[i-1]-ar[i];\n }\n if(large<0)\n {\n cout<<0<\n#include\n#include\nvoid gen(long long int *a)\n{\n int i;\n a[2]=4;\n a[3]=7;\n for(i=2;i<=2048;i++){\n //heaps are beautiful\n a[i<<1]=a[i]*10+4;\n a[(i<<1)+1]=a[i]*10+7;\n// printf(\"%lld %lld\\n\",a[i<<1],a[(i<<1)+1]);\n }\n}\nint main()\n{\n long long int b[10000],*a;\n long long int ans,till;\n int l,r,i;\n gen(b);\n a=b+2;//the first two indices of b contain junk\n scanf(\"%d%d\",&l,&r);\n i=0;\n while(a[i]=a[i])?a[i]:r); \n ans=a[i]*(till-l+1);\n// printf(\"%lld+\",ans);\n\n for(i=i+1;a[i]<=r;i++)\n ans+=(a[i]*(a[i]-a[i-1]));\n ans+=(a[i]*(r-a[i-1]));\n // printf(\"%lld\\n\",ans);\n printf(\"%I64d\\n\",ans);\n //cout>>ans;\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "01594ff86a85cf8fd4834fb35fcec25a", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n if(n>=1&&n<=10)\n {\n cout<<0<=11&&n<=19)\n cout<<4<=22&&n<=25)\n cout<<0<\n#include\n#include\n#include\n#include\n#include\ntypedef long long int ll;\n#define INF INT_MAX\nint min(int a,int b);\nvoid swap(int *a,int *b);\nvoid swap(int *a,int *b)\n{\n\tint temp=*a;\n\t*a=*b;\n\t*b=temp;\n}\nint cmp(const void *a,const void *b)\n{\n\treturn(*(int*)a-*(int*)b);\n\n}\nint min(int a,int b)\n{\n\treturn(a>b?b:a);\n}\n\nint main()\n{\n\tint n,ans1=0,ans2=0;\n\tbool flag=false;\n\tchar a[1005],b[1005];\n\tint I[1005],II[1005],III[1005],IV[1005];\n\tscanf(\"%d%s%s\",&n,a,b);\n\tfor(int i=0;iII[j])\n\t\t\t{\n\t\t\t\tII[j]=-1;\n\t\t\tflag=true;\n\t\t\t\n\t\t}\n\t\tif(flag==false) ans1++;\n\t}\n\tfor(int i=0;iIII[i])\n\t\t\t{\n\t\t\t\tans2++;\n\t\t\t\tIV[j]=-1;\n\t\t\t}\t\n\t\t}\n\t}\n\tprintf(\"%d %d\",ans1,ans2);\n\treturn 0;\n\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b3cfe0f1f737aa3778124af5f5d5873e", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \nusing namespace std;\n\nint main() {\n char c,a[100];\n int n,i=0,j;\n scanf(\"%d %c\",&n,&c );\n while(1){\n scanf(\"%c\",&c);\n if(a[c-'0']==0) {i++;a[c-'0']++;}\n if(c=='\\n') break;\n }\n if(n<=i) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e01f888bc6061d5c3b85d1bbafee682e", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "\nIn English \u041f\u043e-\u0440\u0443\u0441\u0441\u043a\u0438\nanup.kalbalia | Logout\n\n \nHOMECONTESTSGYMPROBLEMSETGROUPSRATINGAPIHELPTESTLIB5 YEARS!\n\n\n\n \nGood Bye 2015\nContest is running\n01:34:56\nContestant\n Add to favourites\n \n\u2192 Score table\nScore\nProblem A 387\nProblem B 580\nProblem C 967\nProblem D 1354\nProblem E 1934\nProblem F 1934\nProblem G 2320\nProblem H 2707\nSuccessful hack 100\nUnsuccessful hack -50\nUnsuccessful submission -50\nResubmission -50\n* If you solve problem on 01:25 from the first attempt\nPROBLEMSSUBMIT CODEMY SUBMISSIONSSTATUSHACKSROOMSTANDINGSCUSTOM INVOCATION\n \nMy Submissions \n \n# When Who Problem Lang Verdict Time Memory\n15114549 00:57:10 anup.kalbalia A - New Year and Days GNU C Hacked 0 ms 8 KB\n\nCodeforces (c) Copyright 2010-2015 Mike Mirzayanov\nThe only programming contests Web 2.0 platform\nServer time: Dec/30/2015 22:00:01UTC+5.5 (c2).\nBy anup.kalbalia, contest: Good Bye 2015, problem: (A) New Year and Days, Hacked, #\n #include \n#include \n\nint main(void) {\n // your code goes here\n char inp[20];\n char of[10];\n char wm[10];\n int i, ans;\n \n while (scanf(\"%[^\\n]\",inp)!=-1) {\n sscanf(inp, \"%d of %s\", &i, wm);\n getchar();\n if (wm[0] == 'w') {\n if (i == 5 || i == 6)\n ans = 53;\n else \n ans = 52;\n \n } else {\n if (i<30)\n ans = 12;\n else if (i == 30) \n ans = 11;\n else if (i == 31)\n ans = 7;\n }\n printf(\"%d\\n\", ans);\n }\n return 0;\n}\nclose", "lang_cluster": "C", "compilation_error": true, "code_uid": "6e38107663808ca022e50319e75cb530", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n;\n char s[20];\n scanf(\"%d \", &n);\n for (int i = 0; i < n; i++)\n scanf(\"%c\", &s[i]);\n\n else if (n == 8)\n printf(\"vaporeon\");\n if (n == 6)\n printf(\"espeon\");\n else\n {\n if (s[0] == 'j' || s[1] == 'o' || s[3] == 't')\n printf(\"jolteon\");\n else if (s[0] == 'f' || s[3] == 'r')\n printf(\"flareon\");\n else if (s[0] == 'u' || s[1] == 'm' || s[2] == 'b' || s[3] == 'r')\n printf(\"umbreon\");\n else if (s[0] == 'l' || s[1] == 'e' || s[3] == 'f')\n printf(\"leafeon\");\n else if (s[0] == 'g' || s[3] == 'c')\n printf(\"glaceon\");\n else if (s[0] == 's' || s[1] == 'y' || s[3] == 'v')\n printf(\"sylveon\");\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a8c6ceb10bdff2caf0df00c7f033e2c9", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include \nint a,b,c,d,e,f;\nint main(void) {\n scanf(\"%d %d %d %d %d %d\",&a,&b,&c,&d,&e,&f);\n if(a*c*e 0) || (!c && d > 0)) puts(\"Ron\");\n else puts(\"Hermione\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "e671aed1a71eb6016ab157d286696e84", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int a,b,c,x,y,z;\n scanf(\"%d %d %d\",&a,&b,&c);\n\n z=a+b-c;\n x=b+c-a;\n y=a+c-b;\n if(x%2==1 || y%2==1 || z%2==1 || x<0 || y<0 ||z<0)\n {\n printf(\"Impossible\\n\");\n return 0;\n }\n else\n {\n printf(\"%d %d %d\",z/2,x/2,y/2\"\\n\");\n }\n return 0;\n\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "f2eaac053b1b7829a19183f15fd55e8f", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint main()\n{\n int n, k, d, q, i, j;\n scanf(\"%d\\n\", &q);\n while(q--)\n {\n scanf(\"%d%d%d\",&n,&k,&d);\n static int a[101], b[101];\n for(i=0; i t)\n ans = t;\n memset(b,0,sizeof(b);\n }\n printf(\"%d\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "17515e435db8b125acb209dd27e124bf", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\nint main()\n{\nint x1,y1,x2,y2;\nscanf(\"%d%d%d%d\",&x1,&y1,&x2,&y2);\nif(x1==x2)\n{\n\n\tprintf(\"%d\",2*(abs(y2-y1)));\n}\nelse if(y1==y2)\n{\n\tprintf(\"%d\",2*(abs(x2-x1)));\n}\nelse \n{\n\tprintf(\"%d\",2*((abs(x2-x1)+1)+(abs(y2-y1)+1)));\n}\ngetch();\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7844f9d3c92e3092e897a589e1f1aa17", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n\nint main(void)\n{\n\tint n;\n\tchar str[100];\n\tint i;\n\tint count;\n\tint check[100];\n\tint check1;\n\t\n\tcheck1 = 0;\n\tprintf(\"%d\", &n);\n\tprintf(\"%s\", str);\n\t\n\tfor(i = 0; i < n; i++)\n\t{\n\t\tif(str[i] == '?')\n\t\t{\n\t\t\tcheck[i] = 1;\n\t\t\tcount++;\n\t\t\tif(count == 2)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcount = 0;\n\t\t}\n\t}\n\tif(count == 2)\n\t{\n\t\tprintf(\"yes\");\n\t}\n\telse\n\t{\n\t\tif(str[0] || str[n-1])\n\t\t{\n\t\t\tprintf(\"yes\");\n\t\t}\n\t\telse if\n\t\t{\n\t\t\tfor( i = 1; i < n - 1; i++)\n\t\t\t{\n\t\t\t\tif(check[i] == 1)\n\t\t\t\t{\n\t\t\t\t\tif(str[i-1] == str[i+1])\n\t\t\t\t\t{\n\t\t\t\t\t\tprintf(\"yes\");\n\t\t\t\t\t\tcheck1 = 1;\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}\n\t\n\tif(check1 == 0)\n\t{\n\t\tprintf(\"no\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "cc1ab9a1d193c6526b7ee90b98a54ea1", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include \n#include \nvoid solve(void);\n\nint main(void)\n{\n solve();\n return 0;\n}\n\nvoid solve(void)\n{\n double n;\n scanf(\"%lf\", &n);\n\n printf(\"%u\\n\", (unsigned int)sqrt(n));\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8f2e129cc940192dedf7c3def0025caa", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\nstring s;\nint i,C=0,d=-1,c4=0,c7=0;\ncin>>s;\nC=strlen(s);\nfor(i=0;ic7)\nprintf(\"4\");\nelse if(c7>c4)\nprintf(\"7\");\nelse if(c7==1&&c4==1)\nprintf(\"4\");\nelse\nprintf(\"-1\");\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "7b07a7c4f0007420699ad035545956fb", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char s[110];\n while(1)\n {\n scanf(\"%s\",s);\n int i,len,cnt=0;\n len=strlen(s);\n for(i=0;i\n#include \nint main()\n{\n char ch[11];\n scanf(\"%s\",ch);\n int l=strlen(ch);\n int j,k,l;\n for(j=0;j\n\nint main()\n{\n\tint i, r, sum = 0, temp;\n\tlong int n;\n\tbool check = false;\n\tscanf(\"%ld\", &n);\n\ttemp = n;\n\tfor (i = 1; n!=0; i++)\n\t{\n\t\tr = n % 10;\n\t\tif (r == 0 && check == false)\n\t\t{\n\t\t\tn = n / 10;\n\t\t\ttemp = temp / 10;\n\t\t}\t\n\t\telse\n\t\t{\n\t\t\tsum = (sum * 10) + r;\n\t\t\tn = n / 10;\n\t\t\tcheck = true;\n\t\t}\n\t}\n\tif (sum == temp)\n\t\tprintf(\"YES\");\n\telse printf(\"NO\");\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "5a8d5a1d560f409b12433137f25c5323", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\ninline int abls(int x,int y)\n{\n if(x>y)\n return x-y;\n else\n return y-x;\n}\ninline int count(char *s,int len)\n{\n int i,c=0;\n for(i=0;ia-b;i--)\n m*=i;\n a=m;\n m=1;\n for(i=1;i<=b;i++)\n m*=i;\n return a/m;\n \n}\ninline int count_2(char *s,int len)\n{\n int i,c=0;\n for(i=0;in3 || (n3-z)%2)\n printf(\"%.10f\\n\",0.0);\n else\n {\n printf(\"%.10f\\n\",comb(n3,(n3-z)/2)/pow(2,n3));\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f6cabe916e06bf043c87eb24f81926d4", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n;\n int a,b;\n scanf(\"%d\",&n);\n a=n/36;\n n=n%36;\n b=n/3;\n if((n%3!=0)&&(n%3==2))\n b++;\n printf(\"%d %d\",a,b);\n getch();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b889bc761d2f044b1f817270c748d628", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,x,count=0;\n scanf(\"%d %d\",&n,&x);\n int a[n],i,j,temp,mid;\n for(i=0;ia[j])\n mid=j;\n }\n if(mid!=i)\n {\n temp=a[mid];\n a[mid]=a[i];\n a[i]=temp;}\n}\nfor(i=0;i0)\n{\n if(x-count<0)\n (count-x)=(x-count);\n\nprintf(\"%d\",x-count);}\nelse\nprintf(\"0\");\nreturn 0;\n}\n\n\n\n ", "lang_cluster": "C", "compilation_error": true, "code_uid": "c2acd1633477002e5d82a8bdde0c4cae", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint union(int e,int f);\nint min,max;\nint main()\n{\t\n\nint e,f,n,a,b,c,d;\nscanf(\"%d %d %d %d\",&a,&b,&c,&d);\nmin=1;max=n;\ne=c+1-b;f=n+c-b;\nunion( min,max, e, f);\nif(minf)\n{\nmax=f;\n}\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "6094e7884002e785f16e1455c58c7393", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n char str1[100],char str2[100],char str3[100];\n int no1[100]={-1},no2[100]={-1};\n int i;\n cin>>str1;\n cin>>str2;\n cin>>str3;\n for(int j=0;str1[j]!='\\0'||str2[j]!='\\0';j++,i++){\n no1[i]=str1[j]%65;\n no1[++i]=str2[j]%65;\n }\n for(int j=0;str3[j]!='\\0';j++){\n no2[j]=str1[j]%65;\n }\n sort(no2,no2+strlen(str3));\n sort(no1,no1+strlen(str3))\n for(int j=0;str3[j]!='\\0';j++){\n if(no[i]!=no2[i]){\n cout<<\"NO\";\n return 0;\n }\n }\n cout<<\"YES\";\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "31f96bc700fea07b6f85d66978288aee", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n\nusing namespace std;\n#define maxD 51\n\nint maxim(int a,int b)\n{\n if(a>b) return a;\n return b;\n}\n\nint main()\n{\n\n int i,n,c,p[maxD],t[maxD],L,R;\n L=R=0;\n scanf(\"%d%d\",&n,&c);\n\n for(i=0;i=0;--i)\n {\n timp+=t[i];\n R+=maxim(0,p[i]-c*timp);\n }\n\n if(L>R)\n printf(\"Limak\");\n else if(L==R)\n printf(\"Tie\");\n else\n printf(\"Radewoosh\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "bd32634404d72b1e7233442556ef95b2", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "84902135db0d8f397b1af73091e41506", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint a[100];\n\nint main() {\n int n, k;\n scanf(\"%d%d\", &n, &k);\n if (k >= 2) {\n printf(\"Yes\");\n return 0;\n }\n int zero_index;\n int sorted = 1;\n for (int i = 0; i < n; ++i) {\n scanf(\"%d\", a + i);\n if (a[i] == 0) zero_index = i;\n if (i != 0 && i != zero_index && a[i] <= a[i-1]) sorted = 0;\n }\n int b;\n scanf(\"%d\", &b);\n if (sorted) {\n if (zero_index == 0 && b < a[1] ||\n zero_index == n - 1 && a[zero_index - 1] < b ||\n zero_index != 0 && zero_index != n - 1 && a[zero_index - 1] < b && b < [zero_index + 1]) {\n printf(\"No\");\n return 0;\n }\n }\n printf(\"Yes\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "adbb7c3211f12de1cdff66e42f15950f", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \nvoid ans(int a,int b)\n{\n int a1=a%5;\n int a2=b%5;\n \n int ans=0;\n if(a1+a2>=5)\n sum+=a1+a2-4;\n \n sum+=5*(a/5)*(b/5)+a1*(b/5)+a2*(a/5);\n printf(\"%d\\n\" , sum);\n \n}\n\nint main()\n{\n int a,b;\n scanf(\"%d%d\", &a, &b);\n ans(a,b);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d1141bda745a6ce8345b10af47cf9cce", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n\nint arr[5000],brr[5000];\n\nint main(void){\n int a,b,c,d;\n scanf(\"%d %d\",&a,&b);\n scanf(\"%d %d\",&c,&d);\n arr[0]=b;brr[0]=d;\n for(int i=1;i<5000;i++){\n arr[i]=arr[i-1]+a;\n brr[i]=brr[i-1]+c;\n }\n for(int i=0;i<5000;i++)for(int j=0;j5000;j++)if(arr[i]==brr[j]){\n printf(\"%d\",arr[i]);\n return 0;\n }\n printf(\"-1\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "304ed4479b2ddcbb4b9b4397dd47e8f6", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nlong int x,y,z,sum=0;\nscanf(\"%ld %ld %ld\",&x,&y,&z);\n\nif(x==y)\nprintf(\"%ld\",(z*2)+b+a);\n\nelse if(x>y)\nprintf(\"%ld\",(z*2)+(x*2)+1);\n\nelse if(x\nint main()\n{\n \n long long int a,b,s;\n scanf(\"%lld%lld%lld\",&a,&b,&s);\n if(a<0)\n a=(0-a);\n if(b<0)\n b=(0-b);\n if((a==0 && b==0 && s==2) || (a+b==s) || ((s-(a+b))%2==0)\n printf(\"Yes\");\n else\n printf(\"No\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "24739096e815e08476a9d861382f93fb", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int n,bx,i,j;\n scanf(\"%d %d\",&n,&bx);\n int x[n];\n for(int i=0;i=0,j<=n-1;i--,j++)\n {\n s=pow(bx,j);\n s1=s1+s*x[i];\n\n }\n\n\n int m,by;\n scanf(\"%d %d\",&m,&by);\n int y[m];\n for(int i=0;i=0,j<=m-1;i--,j++)\n {\n sy=pow(by,j);\n s2=s2+sy*y[i];\n }\n\n if(s1>s2)\n {\n printf(\">\\n\");\n }\n else if(s1\n#include\nint main()\n{\n int n,bx,i,j;\n scanf(\"%d %d\",&n,&bx);\n int x[n];\n for(int i=0;i=0,j<=n-1;i--,j++)\n {\n s=pow(bx,j);\n s1=s1+s*x[i];\n\n }\n\n\n int m,by;\n scanf(\"%d %d\",&m,&by);\n int y[m];\n for(int i=0;i=0,j<=m-1;i--,j++)\n {\n sy=pow(by,j);\n s2=s2+sy*y[i];\n }\n\n if(s1>s2)\n {\n printf(\">\\n\");\n }\n else if(s1\n\nint main()\n{\n int temp, smith[30] = {4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382,\n 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648};\n\n scanf(\"%d\", &temp);\n printf(\"%d\", smith[temp-1]);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7dee5a40460c84f7dcc383f66f674d0a", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define MOD 1000000007\ntypedef long long int LLI;\n\nLLI ** expo(LLI ** mat, LLI exp, LLI mod);\nvoid dele(LLI ** a);\nLLI ** mult(LLI ** a, LLI ** b, LLI mod);\n\nint main(void) {\n LLI a, b, n;\n scanf(\"%I64d%I64d%I64d\", &a, &b, &n);\n LLI ** base = (LLI **) calloc(2, sizeof(LLI *));\n base[0] = (LLI *) calloc(2, sizeof(LLI));\n base[1] = (LLI *) calloc(2, sizeof(LLI));\n base[0][0] = 0;\n base[0][1] = 1;\n base[1][1] = 1;\n base[1][1] = (MOD - 1);\n expo(base, n - 1, MOD);\n LLI x = a * base[0][0] + b * base[0][1];\n printf(\"%I64d\", &x);\n return 0;\n}\n\nLLI ** mult(LLI ** a, LLI ** b, LLI mod) {\n int i, j, k;\n LLI ** ret = (LLI **) calloc(2, sizeof(LLI *));\n ret[0] = (LLI *) calloc(2, sizeof(LLI));\n ret[1] = (LLI *) calloc(2, sizeof(LLI));\n for (i = 0; i < 2; i++)\n for (j = 0; j < 2; j++){\n ret[i][j] = 0;\n for (k = 0; k < 2; k++)\n ret[i][j] = a[i][k] * b[k][j];\n ret[i][j] %= MOD;\n }\n return ret;\n}\n\n\nLLI ** expo(LLI ** mat, LLI exp, LLI mod) {\n int i, j;\n if (exp == 0) {\n LLI ** ret = (LLI **) calloc(2, sizeof(LLI *));\n ret[0] = (LLI *) calloc(2, sizeof(LLI));\n ret[1] = (LLI *) calloc(2, sizeof(LLI));\n ret[0][0] = (ret[1][1] = 1);\n ret[0][1] = (ret[1][0] = 0);\n return ret;\n }\n if (exp == 1) {\n LLI ** ret = (LLI **) calloc(2, sizeof(LLI *));\n ret[0] = (LLI *) calloc(2, sizeof(LLI));\n ret[1] = (LLI *) calloc(2, sizeof(LLI));\n for (i = 0; i < 2; i++)\n for (j = 0; j < 2; j++)\n ret[i][j] = mat[i][j];\n return ret;\n }\n LLI ** sq = expo(mat, exp / 2, mod);\n LLI ** tmp = mult(sq, sq, mod);\n dele(sq);\n if ((exp & 1) == 1) {\n LLI ** tmp2 = mult(sp, mat, mod);\n dele(tmp);\n tmp = tmp2;\n }\n dele(sq);\n return tmp;\n} \n\nvoid dele(LLI ** a) {\n free(a[0]);\n free(a[1]);\n free(a);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a1a61a33b1e7aa79d6149fd948c2cd8a", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint cnt1=0,cnt2=0,f,n,m,i=0,p,q;\nchar a[100001],b[100001];\nscanf(\"%d%d\",&n,&m);\np=n;q=m;\na[0]='R';n--;\n//b[0]='B';\nf=1;\nwhile(n&&m)\n{\nif(f){\nif(a[i]=='R')\n{a[i+1]='B';m--;}\nelse{\na[i+1]='R';n--;}\nf=0;\n}\nelse{\nif(a[i]=='R')\n{a[i+1]='R';n--;}\nelse\n{a[i+1]='B';m--;}\nf=1;\n}\n//n--;m--;\ni++;\n}\nwhile(n)\n{a[(i+1)]='R';n--;i++;\n}\nwhile(m)\n{a[i+1]='B';m--;i++;\n}\na[i+1]='\\0';\n//printf(\"%s\\n\",a);\ni=0;\nwhile(a[i+1]!='\\0')\n{\nif(a[i]==a[i+1])cnt1++;\nelse cnt2++;\ni++;\n}\nn=p;m=q;\na[0]='B';i=0;f=1;m--;\nwhile(n&&m)\n{\nif(f){\nif(a[i]=='R')\n{a[i+1]='B';m--;}\nelse{\na[i+1]='R';n--;}\nf=0;\n}\nelse{\nif(a[i]=='R')\n{a[i+1]='R';n--;}\nelse\n{a[i+1]='B';m--;}\nf=1;\n}\n//n--;m--;\ni++;\n}\nwhile(n)\n{a[(i+1)]='R';n--;i++;\n}\nwhile(m)\n{a[i+1]='B';m--;i++;\n}\na[i+1]='\\0';\ni=0;int cnt3=0,cnt4=0;\nwhile(a[i+1]!='\\0')\n{\nif(a[i]==a[i+1])cnt3++;\nelse cnt4++;\ni++;\n}\n//printf(\"%s\\n\",a);\nif(cnt1>cnt3)\nprintf(\"%d %d\\n\",cnt1,cnt2);\nelse\nprintf(\"%d %d\\n\",cnt3,cnt4);\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3a3af1d692aff8a19381fcef588e7a34", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,k,x,i,j,a,sum;\n scanf(\"%lld%lld%lld\",&n,&k,&x);\n int number[n];\n for(i=0;i\n\nint solve(int_t n, int_t a, int_t b, int f) {\n int_t x;\n for (x = 0; x <= a; ++x) {\n if (x*a <= n && (n - x*a) % b == 0) {\n puts(\"YES\");\n if (f) swap(&a, &b);\n printf(\"%d %d\\n\", x, (n - x*a) / b);\n return 1;\n }\n }\n return 0;\n}\n\nint_t main() {\n int_t n, a, b;\n scanf(\"%d%d%d\", &n, &a, &b);\n if (!solve(n, a, b, 0) && !solve(n, b, a, 1)) {\n puts(\"NO\");\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "63ef904412d6dde2f94b72ce6583af78", "src_uid": "b031daf3b980e03218167f40f39e7b01", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n, i;\n scanf(\"%d\", &n);\n char a[n+1] = {0};\n int b[26] = {0};\n for(i = 0; i < n; i++){\n scanf(\"%c\", &a[i]);\n if(a[i] >= 'a' && a[i] <= 'z')\n b[a[i]-'a']++;\n else if(a[i] >= 'A' && a[i] <= 'Z')\n b[a[i]-'A']++;\n }\n for(i = 0; i < 26; i++){\n if(b[i] == 0){\n printf(\"NO\\n\");\n return 0;\n }\n }\n printf(\"YES\\n\");\n return 1;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "363352e1816f26844929c3ad7af6273c", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main() \n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n int a[k],i,j;\n for(i = 1 ; i <= k; i++) {\n scanf(\"%d\",&a[i]);\n b[a[i]]++;\n }\n for(i = 1; i <= n; i++) {\n for(j = 1; j <= k; j++) {\n if(a[j] <= i) {\n printf(\"%d \",a[j]);\n break;\n }\n }\n }\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "93005be6b8e9499e481b5a5939b2ea9a", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n\nint checkshun(char word1[],char word2[],char word3[]){\n\tif(word1[1] == word2[1] && word2[1] == word3[1]){\n\t\tif(word1[0]+word2[0]+word3[0] == 3*word2[0]){\n\t\t\treturn 1;\n\t\t}else{\n\t\t\treturn 0;\n\t\t}\n\t}else{\n\t\treturn 0;\n\t}\n}\n\nint checkkou(char word1[],char word2[],char word3[]){\n\tif(word1[0] == word2[0] && word2[0] == word3[0]){\n\t\tif(word1[1] == word2[1] && word2[1] == word3[1]){\n\t\t\treturn 1;\n\t\t}else{\n\t\t\treturn 0;\n\t\t}\n\t}else{\n\t\treturn 0;\n\t}\n}\n\nint compare(const void *data1,const void *data2){\n\tchar *ptr1 = (char *)data1;\n\tchar *ptr2 = (char *)data2;\n\tif(ptr1[1] > ptr2[1]){\n\t\treturn 1;\n\t}else if(ptr1[1] < ptr2[1]){\n\t\treturn -1;\n\t}else{\n\t\tif(ptr1[0] > ptr2[0]){\n\t\t\treturn 1;\n\t\t}else if(ptr1[0] < ptr2[0]){\n\t\t\treturn -1;\n\t\t}else{\n\t\t\treturn 0;\n\t\t}\n\t}\n}\n\nint main(){\n\tchar totalword[3][3];\n\tchar word1[3] = {};\n\tchar word2[3] = {};\n\tchar word3[3] = {};\n\tscanf(\"%s%s%s\",word1,word2,word3);\n\tif(checkshun(word1,word2,word3) == 1 || checkkou(word1,word2,word3) == 1){\n\t\tprintf(\"0\\n\");\n\t}else{\n\t\ttotalword[0][0] = word1[0];\n\t\ttotalword[0][1] = word1[1];\n\t\ttotalword[0][2] = '\\0';\n\t\ttotalword[1][0] = word2[0];\n\t\ttotalword[1][1] = word2[1];\n\t\ttotalword[1][2] = '\\0';\n\t\ttotalword[2][0] = word3[0];\n\t\ttotalword[2][1] = word3[1];\n\t\ttotalword[2][2] = '\\0';\n\t\tqsort(totalword,3,sizeof(char)*3,compare);\n\t\tif(totalword[0][1] == totalword[1][1] && totalword[0][0]+1 == totalword[1][0]){\n\t\t\tprintf(\"1\\n\");\n\t\t}else if(totalword[1][1] == totalword[2][1] && totalword[1][0]+1 == totalword[2][0]){\n\t\t\tprintf(\"1\\n\");\n\t\t}else if(totalword[0][0] == totalword[1][0] && totalword[0][1] == totalword[1][1]){\n\t\t\tprintf(\"1\\n\");\n\t\t}else if(totalword[1][0] == totalword[2][0] && totalword[1][1] == totalword[2][1]){\n\t\t\tprintf(\"1\\n\");\n\t\t}else if(totalword[0][1] == totalword[1][1] && totalword[0][0]+2 == totalword[1][0]){\n\t\t\tprintf(\"1\\n\");\n\t\t}else if(totalword[1][1] == totalword[2][1] && totalwrod[1][0]+2 == totalword[2][0]){\n\t\t\tprintf(\"1\\n\");\n\t\t}else{\n\t\t\tprintf(\"2\\n\");\n\t\t}\n\t}\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "0aa100a095ecfc7a8f3d0af08ce171a0", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,ans = 1;\n scanf(\"%d\",&n);\n int m = n;\n while(m >= 10)\n ans *= 10,m /= 10;\n ans *= m % 10 + 1;\n printf(\"%d\\n\",ans - n);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "ce88a652ed0452b9c6b906527e484355", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\nint a, b, c;\n\nscanf(\"%d\", &a);\nscanf(\"%d\", &b);\nscanf(\"%d\", &c);\n\nif(c/4 > a && b/2 >a)\nprintf(\"%d\", c/4*(1+2+4);\n\nelse\nprintf(\"0\");\n\n\n\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b092afc76e73f4ef62c342f659ae1645", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n\nint main() {\n long long int n , a, b ,x, t , y;\n scanf(\"%I64d\", &t);\n while(t--){\n scanf(\"%I64d%I64d\",&a , &b);\n x = (a * a) - (b * b);\n if(x % 2 == 0) {\n printf(\"NO\\n\");\n return 0;\n }\n else {\n if(pow(3 , x-1) % x == 1){\n printf(\"YES\\n\");\n }\n else printf(\"NO\\n\");\n \n \n }\n }\n \n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d399f3cc363c3cce5fdcfd23e311b75d", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "main()\n{\nint n;\nscanf(\"%d\",&n);\nprintf(\"%d\",6n*(n\u22121)+1);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "4a874ad0def9087983d8aaef678276d7", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \nint good(unsigned k,unsigned l,char *s,unsigned n)\n{ unsigned i,j;\n//printf(\"\\n________________\\n\");\n //for(i=l,j=0;i\n#include\n\nint main(){\n int n,j,i,flag=0,c=0,m;\n scanf(\"%d %d\",&n,&m);\n if(n<1||m<1||n+m<3){printf(\"0\");return 0;}\n while(n>0&&m>0){\n if(n>=m){n=n-2;m=m-1;c++;}\n else {n=n-1;m=m-2;c++;}\n if(n+m<3)break;1\n }\n printf(\"%d\",c);\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "1148073535a2aa32412987860bbded11", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "9fb114d51c2bf98140286d80db3b3857", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\nchar s1[200]=\"312931303130313130313031312931303130313130313031312831303130313130313031312931303130313130313031\";\nchar s2[200];\nchar s3[5];\nint main()\n{\n\tint n,i,j;\n\tscanf(\"%d\",&n);\n\tgetchar();\t\n\tj=0;\n\tfor(i=0;i\nint main()\n{\n\tint a,i,j,m,n[1000],sum;\n\twhile(scanf(\"%d%d\",&sum,&m)!EOF)\n\t{\n\t\ta=0;\n\t\tfor(i=0;1;i++)\n\t\t{\n\t\t\tsum +=sum%m;\n\t\t\tn[i]=sum%m;\n\t\t\tif(sum%m==0)\n\t\t\t{\n\t\t\t\tprintf(\"YSE\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor(j=0;j\n#include \n\n\nint main() \n{\n\tint a,b,c,d;\n\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n\t\n\tif(a==d)\n\t{\n\t\tprintf(\"1\");\n\t\treturn 0;\n\t}\t\n\treturn 0;\n\telse\n\t{\n\t\tpritnf(\"0\");\n\t\treturn 0;\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3628ed815c2bd07276fd3803fda3601c", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int k;\n scanf(\"%d\",&k);\n int m=19, c=0, sum=0;\n while(true){\n int n = m;\n sum = 0;\n while(n){\n sum+=n%10;\n n=n/10;\n }\n printf(\"%d %d %d\\n\", n, sum, c);\n if(sum == 10) c++;\n if(c == k) break;\n m++;\n }\n printf(\"%d\", m);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3d584f82de3deecc815e71d032bae83a", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main (void)\n{\n char s[100];\n int len,i;\n int a,b,c,k;\n\n while (scanf (\"%s\",str) != '\\0')\n {\n len = strlen(str);\n k = 1;\n\n for (i=0; i\n\n#define wl(n) while(n--)\n#define fl(i,a,b) for(i=a; i=b; i--)\n#define scan(n) scanf(\"%d\", &n)\n#define scans(s) scanf(\"%s\", s)\n#define scanc(c) scanf(\"%c\", &c)\n#define scanp(f) scanf(\"%f\", &f)\n#define print(n) printf(\"%d\\n\", n)\n#define prints(s) printf(\"%s\\n\", s)\n#define printc(c) printf(\"%c\\n\", c)\n#define printp(f) printf(\"%f\\n\", f)\n#define nline printf(\"\\n\")\n#define mclr(strn) strn.clear()\n#define ignr cin.ignore()\n#define MOD 1000000007\n#define ll long long int\n#define u64 unsigned long long int\n\n#define PB push_back\n#define SZ size\n\ndouble dist(ll a, ll b, ll c, ll d){\n return sqrt((d-b)*(d-b)+(c-a)*(c-a));\n}\n\n\nint main()\n{\n //freopen(\"C:\\\\Users\\\\DELL\\\\Desktop\\\\input.txt\",\"r\",stdin);\n //freopen(\"C:\\\\Users\\\\DELL\\\\Desktop\\\\output.txt\",\"w\",stdout);\n int i, j, cases, k=1;\n ll x, y, nx, ny;\n ll r;\n cin>>r>>x>>y>>nx>>ny;\n cout<\n#include\nint main()\n{\n int i,j;\n int l,r,x,y;\n float k;\n scanf(\"%d %d %d %d %f\",&l,&r,&x,&y,&k);\n for(i=l;i<=r;i++)\n {\n if((i*k<=y&&i*k>=x)\n {\n printf(\"YES\");\n exit(0);\n }\n }\n printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b290b605bc8e5b7bef0582d1823ffe47", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include \n#include\nint compute(char a[],int n,int bb){\n\tint hor=0,vert=0,count=0,i;\n\tfor(i=bb;i!=n;i++)\n\t{\n\t\tif(a[i]=='U')\n\t\t\thor++;\n\t\telse if(a[i]=='D')\n\t\t\thor--;\n\t\telse if(a[i]=='L')\n\t\t\tvert++;\t\n\t\telse if(a[i]=='R')\n\t\t\tvert--;\n\tif(hor==0&&vert==0)\n\t\tcount++;\n\t}\n\treturn count;\n}\nint main() {\n\t// your code goes here\n\tint n,i,ways;\n\tchar a[300];\t\n\tscanf(\"%d\",&n);\n\t\n\t\tscanf(\"%s\",&a);\n\t\n\tfor(i=0;i\n#include\n#include\nint debug=0;\ntypedef long long int lld;\nint kb,nb,pb,ks,ns,ps,kc,nc,pc;\nlld r;\nlld getCost(lld n){\n lld ab=(n*kb-nb);ab=ab>0?ab:0;\n lld as=(n*ks-ns);as=as>0?as:0;\n lld ac=(n*kc-nc);ac=ac>0?ac:0;\n if(debug){\n printf(\"cost for : n=%lld \\n\",n);\n printf(\"cost of b : %lld\\n\",ab*pb);\n printf(\"cost of s : %lld\\n\",as*ps);\n printf(\"cost of c : %lld\\n\",ac*pc);\n printf(\"\\n\\n\");\n }\n return ab*pb+as*ps+ac*pc;\n}\nint main(int argc , char **argv)\n{\n if(argc>1 && strcmp(argv[1],\"DEBUG\")==0) debug=1;\n char str[101];\n scanf(\"%s\",str);\n int i;\n kb=0;ks=0;kc=0;\n for(i=0;i1){\n cost=getCost(mid);\n if(debug)printf(\"start=%lld , end=%lld , cost=%lld\\n\",start,end,cost);\n if(cost>r)end=mid;\n else if(cost\n#include\n#include\nint debug=0;\ntypedef long long int lld;\nint kb,nb,pb,ks,ns,ps,kc,nc,pc;\nlld r;\nlld getCost(lld n){\n lld ab=(n*kb-nb);ab=ab>0?ab:0;\n lld as=(n*ks-ns);as=as>0?as:0;\n lld ac=(n*kc-nc);ac=ac>0?ac:0;\n if(debug){\n printf(\"cost for : n=%lld \\n\",n);\n printf(\"cost of b : %lld\\n\",ab*pb);\n printf(\"cost of s : %lld\\n\",as*ps);\n printf(\"cost of c : %lld\\n\",ac*pc);\n printf(\"\\n\\n\");\n }\n return ab*pb+as*ps+ac*pc;\n}\nint main(int argc , char **argv)\n{\n if(argc>1 && strcmp(argv[1],\"DEBUG\")==0) debug=1;\n char str[101];\n scanf(\"%s\",str);\n int i;\n kb=0;ks=0;kc=0;\n for(i=0;i1){\n cost=getCost(mid);\n if(debug)printf(\"start=%lld , end=%lld , cost=%lld\\n\",start,end,cost);\n if(cost>r)end=mid;\n else if(cost\n\nint main()\n{\n\tint n,p,q,r,b,c,s=0,a,i,j,k;\n\tdouble u,m,w,l,t;\n\tscanf(\"%d %d %d %d\",&n,&p,&q,&r);\n\tfor (i=0;i<=p;i++){\n\t\tfor (j=0;j<=q;j++){\n\t\t\tfor (k=0;k<=r;k++){\n\t\t\t\tm=(0.5*i)+j+(k*2.0);\n\t\t\t\tif (m==n){\n\t\t\t\t\ts=s+1;\n\t\t\t\t}\n\t\t\t\telse if (m>n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\",s);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2fc140e0bebd593a14d7ac645c98b3d1", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,x1,x2,x3,x4,y1,y2,y3,y4,a,b,c,d,e,f,g,h,area;\n scanf(\"%d\",&n);\n\n\n if(n==1)\n {\n scanf(\"%d %d\",&x1,&y1);\n if(x1<0)\n {\n x1=-x1;\n }\n else if(y1<0)\n {\n y1=-y1;\n }\n printf(\"-1\");\n\n }\n else if(n==2)\n {\n scanf(\"%d %d %d %d\",&x1,&y1,&x2,&y2);\n area=(x1-x2)*(y1-y2);\n if(area<0)\n {\n area=-area;\n\n }\n printf(\"%d\",area);\n else if(area==0)\n {\n printf(\"-1\");\n }\n }\n else if(n==3)\n {\n scanf(\"%d %d %d %d %d %d\",&x1,&y1,&x2,&y2,&x3,&y3);\n if(x1<0)\n {\n x1=-x1;\n }\n else if(y1<0)\n {\n y1=-y1;\n }\n else if(x2<0)\n {\n x2=-x2;\n }\n else if(y2<0)\n {\n y2=-y2;\n }\n else if(x3<0)\n {\n x3=-x3;\n }\n else if(y3==0)\n {\n y3=-y3;\n }\n\n\n else if(x1==y1 && x2==y2 && x3==y3)\n {\n printf(\"1\");\n }\n else\n {\n printf(\"-1\");\n }\n }\n\n else if(n==4)\n {\n scanf(\"%d %d %d %d %d %d %d %d\",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);\n\n area=(y1-y2)*(x1-x4);\n if(area<0)\n {\n area=-area;\n }\n printf(\"%d\",area);\n }\n\n\n\n\n }\n\n\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "df62e362921f9064efe1e8f3147c7bc3", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int i,j,a[n][n];\n for(i=0;i\n#include \n#include \nint Gcd(int a,int b)\n{\n return b==0?a:Gcd(b,a%b);\n}\nint main()\n{\n int a,b,sign,Time,num,sum,A,B,Begin_Time;\n scanf(\"%d%d\",&a,&b);\n Time=0;num=0;sum=0;A=1;B=1;Begin_Time=0;\n sign=a>b?a/Gcd(a,b)*b:a/Gcd(b,a)*b;\n while(1)\n {\n Time=A*a>B*b?B*b:A*a;\n if(Time==A*a)A++;\n if(Time==B*b)B++;\n if(Time==sign)\n {\n if(num>sum)\n sum+=sign-Begin_Time;\n else\n num+=sign-Begin_Time;\n break;\n }\n if(Time%a==0) \n num+=Time-Begin_Time;\n if(Time%b==0) \n sum+=Time-Begin_Time;\n Begin_Time=Time;\n }\n if(num>sum)\n printf(\"Dasha\\n\");\n else if(num>a>>b;\n __int64 lcm=a>b?a/gcd(a,b)*b:a/gcd(b,a)*b;\n __int64 t=0,sum=0,sud=0,n1=1,n2=1,Min=0;\n while(1)\n {\n t=min(n1*a,n2*b);\n if(t==n1*a) n1++;if(t==n2*b) n2++;\n if(t==lcm){\n if(sum>sud) sud+=lcm-Min;\n else sum+=lcm-Min;\n break;\n }\n if(t%a==0) sum+=t-Min;\n if(t%b==0) sud+=t-Min;\n Min=t;\n }\n if(sum==sud) cout<<\"Equal\";\n else if(sum>sud) cout<<\"Dasha\";\n else cout<<\"Masha\";\n return 0;\n}\n\n ", "lang_cluster": "C", "compilation_error": true, "code_uid": "ec9e9dfeb337709079c5c3b388cea634", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n int c,a,b,n;\n scanf(\"%d %d\",&c,&n);\n if(n>=0&&n<=99){\n a=(n%10)*10;\n b=n/10;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n>=100&&n<=999){\n a=(n%100)*10;\n b=n/100;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n>=1000&&n<=9999){\n a=(n%1000)*10;\n b=n/1000;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n>=10000&&n<=99999){\n a=(n%10000)*10;\n b=n/10000;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n>=100000&&n<=999999){\n a=(n%100000)*10;\n b=n/100000;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n>=1000000&&n<=9999999){\n a=(n%1000000)*10;\n b=n/1000000;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n>=10000000&&n<=99999999){\n a=(n%10000000)*10;\n b=n/10000000;\n printf(\"%d\\n\",c+a+b);\n }\n else if(n==100000000){\n a=(n%100000000)*10;\n b=n/100000000;\n printf(\"%d\\n\",c+a+b);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2b58d9c55bdd955bdd849951d0759579", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "main(a,b)\n{\nchar c=' ',d;\nwhile((d=getchar())\n{\nif(d==c) a++;\nif(a==5 || t!=d){b++;a=0;c=d;}\n}\nprintf(\"%d\",b);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d851c7f7695661bc8c5c0324cab01ba9", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,k,total,median,median1;\n\tscanf(\"%d %d\",&n,&k);\n\ttotal = (n - 1) * 2 + 3;\n\t(n % 2 == 0) ? median = n / 2 : median = n/2+1;\n\tif(k == 1 || k == n)\n\t{\n\t\tprintf(\"%d\\n\",total + n - 1);\t\n\t} \n\telse{\n\t\tif(n % 2 == 0)\n\t\t{\n\t\t\tif(k == median || k == median + 1)\n\t\t\t{\n\t\t\t\tk = (median - 1) * 2 + n/2;\n\t\t\t\tprintf(\"%d\\n\",total+ k);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tint temp = median + (median+1);\n\t\t\t\tif(k < median)\n\t\t\t\t{\n\t\t\t\t\ttotal += (k-1) * 2 + (n - k);\n\t\t\t\t\tprintf(\"%d\\n\",total);\n\t\t\t\t}\n\t\t\t\telse if(k > median)\n\t\t\t\t{\n\t\t\t\t\tk = temp % k;\n\t\t\t\t\ttotal += (k-1) * 2 + (n - k);\n\t\t\t\t\tprintf(\"%d\\n\",total);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(n % 2 != 0)\n\t\t{\n\t\t\tif(k == median)\n\t\t\t{\n\t\t\t\tk = n-1;\n\t\t\t\tprintf(\"%d\\n\",total + k + n/2);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(k < median)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%d\\n\",total + (k-1) * 2 + (n - k));\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tk = k % (median * 2);\n\t\t\t\t\tprintf(\"%d\\n\",total + (k-1) * 2 + (n-k));\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "fd2d87fe086bf6d0de291094a6dbfcfb", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef long long int int64;\n\nstatic void printInt(int64 n){\n if(n<0){putchar('-');n=-n;}\n if(n==0){putchar('0');return;}\n int s[20];int len=0;\n while(n>0){s[len++]=n%10+'0';n/=10;}\n while(len>0){putchar(s[--len]);}\n}\nstatic int64 readInt(void){\n int prev='\\0';int c=getchar();\n while(!('0'<=c && c<='9')){prev=c;c=getchar();}\n int64 res=0;\n while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}\n return prev=='-'?-res:res;\n}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n#define ABS(a) ((a)>(0)?(a):-(a))\n\nint64 func(int64 n,int64 b){\n int64 res=0;\n while(n>0){\n res+=n/b;\n n/=b;\n }\n return res;\n}\n\nvoid run(void){\n int64 n=readInt();\n int64 b=readInt();\n int64 ans=n;\n for(int64 k=2;k*k<=b;k++){\n if(b%k!=0) continue;\n int cnt=0;\n do{\n b/=k;\n cnt++;\n } while(b%k==0);\n int64 f=func(n,k)/cnt;\n ans=MIN(ans,f);\n }\n if(b>1){\n ans=MIN(ans,func(n,b));\n }\n printInt(ans);\n putchar('\\n');\n}\n\nint main(void){\n run();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b1db141a6445f8465e199842f51babd4", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int a[3],n,temp;\n scanf(\"%d\",&n);\n scanf(\"%d\",&a[0]);\n scanf(\"%d\",&a[1]);\n scanf(\"%d\",&a[2]);\n for(int i=0;i<=2;i++)\n {\n for(int j=i;j<=2;j++)\n {\n if(a[i]>a[j])\n {\n temp=a[i];\n a[i]=a[j];\n a[j]=temp;\n }\n }\n }\n int sum=0;\n n--;\n while(n!=0)\n {\n if(n%2==0) sum+=a[1];\n else if(n%2==1) sum+=a[0];\n n--;\n }\n printf(\"%d\",sum);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "6244c0dd91bc409966944e77da1e549b", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b)\n{\n int c = a % b;\n while(c != 0)\n {\n a = b;\n b = c;\n c = a % b;\n }\n return b;\n}\n\nint main()\n{\n int a, b, c, d;\n scanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\n int ansa, ansb;\n if(b*c >= a*d)\n {\n ansa = b*c - a*d;\n ansb = b*c;\n }\n else\n {\n ansa = a*d - b*c;\n ansb = a*d;\n }\n\n int ansc = gcd(ansa, ansb);\n\n printf(\"%d/%d\\n\", ansa/ansc, ansb/ansc);\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "1d47408c7451d549dbac5ecf7c4785a9", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nusing namespace std ;\nstruct node{\n int a , i ;\n} p[110];\nint cmp(node x,node y)\n{\n return x.a < y.a ;\n}\nint main()\n{\n int n , k , num ;\n while( scanf(\"%d %d\", &n, &k) != EOF )\n {\n num = 0 ;\n int i ;\n for(i = 0 ; i < n ; i++)\n {\n scanf(\"%d\", &p[i].a) ;\n p[i].i = i+1 ;\n }\n sort(p,p+n,cmp) ;\n for(i = 0 ; i < n ; i++)\n if( k >= p[i].a )\n {\n k -= p[i].a ;\n }\n else\n break ;\n num = i ;\n printf(\"%d\\n\", num) ;\n if( num == 0 ) continue ;\n for(i = 0 ; i < num-1 ; i++)\n {\n printf(\"%d \", p[i].i) ;\n }\n printf(\"%d\\n\", p[i].i) ;\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "60dd81964b51960de4d565c57ab11881", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#define N 1000000000\n#define M 100000000\nint main() {\n int n;\n scanf(\"%d\",&n);\n int p[N];\n int i,j;\n for(i=2; i=M){\n printf(\"\u5185\u5b58\u4e0d\u591f\\n\");\n break;\n }\n }\n }\n if(p[n]==1){\n printf(\"1\\n%d\\n\",n);\n }else{\n int find=0;\n //printf(\"%d\\n\",np);\n int p1,p2,p3;\n for(i=0;!find && prime[i]<=n && i\n\n\nint main()\n{\n\n int n,i,max,min,j,k,c=0,a,b;\n\n scanf(\"%d\",&n);\n\n int x[n],y[n];\n\n for(i=0;ic) printf(\"%d\",y[0]);\n else printf(\"%d\",c);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d916a5f08984fd7764ebf0424a100fb8", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \r\nint main(){\r\n int a,b;\r\n scanf(\"%d\",&a);\r\n if(a == 2999){\r\n b = a + 1;\r\n }\r\n else if(a == -45){\r\n b = a - 1;\r\n }\r\n else{\r\n b = a\r\n }\r\n printf(\"%d\\n\",b);\r\n return 0;\r\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "49cd2ebe7f232f74ef53ef7eadf9eb5a", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n\n\nint main()\n{\n int da , db ,a,x,b;\n scanf(\"%d\",&da) ;\n scanf(\"%d\",&db) ;\n if ((abs(db-da)>=2)||(da>db))\n printf(\"-1\") ;\n\n else\n {\n a=da*10;\n b=db*10;\n x=abs(a-b+1);\n printf(\"%d %d\",a+x,a+x+1);\n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "b4b14385bbae6c9d8c5da67290f5a49c", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int a['z']={0},n,k;\n scanf(\"%d %d\",&n,&k);\n char s[1000];\n scanf(\"%s\",&s);\n int i;\n for(i=0;s[i]!='\\0';i++)\n {\n char z=s[i];\n a[z]++;\n }\n char d;\n for(d='a';d<='z';d++)\n {\n if(y[d]\n\nint main() {\n\tint xx1[4], yy1[4], xx2[4], yy2[4], tmp, i;\n\tint h1 = -1, h2 = -1, v1 = -1, v2 = -1, rect;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tint x1, y1, x2, y2;\n\n\t\tscanf(\"%d%d%d%d\", &x1, &y1, &x2, &y2);\n\t\tif (x1 == x2 && y1 != y2) {\n\t\t\tif (y1 > y2)\n\t\t\t\ttmp = y1, y1 = y2, y2 = tmp;\n\t\t\tif (v1 == -1)\n\t\t\t\tv1 = i;\n\t\t\telse\n\t\t\t\tv2 = i;\n\t\t} else if (x1 != x2 && y1 == y2) {\n\t\t\tif (x1 > x2)\n\t\t\t\ttmp = x1, x1 = x2, x2 = tmp;\n\t\t\tif (h1 == -1)\n\t\t\t\th1 = i;\n\t\t\telse\n\t\t\t\th2 = i;\n\t\t}\n\t\txx1[i] = x1;\n\t\tyy1[i] = y1;\n\t\txx2[i] = x2;\n\t\tyy2[i] = y2;\n\t}\n\n\trect = 0;\n\tif (h1 != -1 && h2 != -1 && v1 != -1 && v2 != -1) {\n\t\tif (yy1[h1] > yy2[h2])\n\t\t\ttmp = h1, h1 = h2, h2 = tmp;\n\t\tif (xx1[v1] > xx2[v2])\n\t\t\ttmp = v1, v1 = v2, v2 = tmp;\n\t\tif (xx1[h1] == xx1[v1] && yy1[h1] == yy1[v1]\n\t\t\t\t&& xx2[h1] == xx1[v2] && yy2[h1] == yy1[v2]\n\t\t\t\t&& xx1[h2] == xx2[v1] && yy1[h2] == yy2[v1]\n\t\t\t\t&& xx2[h2] == xx2[v2] && yy2[h2] == yy2[v2])\n\t\t\trect = 1;\n\t}\n\tprintf(rect ? \"YES\\n\" : \"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "f02b1498c57c3b45a64cbf498c73abb9", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,i,j,x,y,z,temp;\n\tscanf(\"%d\",&n);\n\tint A[4];\n\tfor(i=0;iA[j])\n\t\t\t\t{\n\t\t\t\t\ttemp=A[i];\n\t\t\t\t\tA[i]=A[j];\n\t\t\t\t\tA[j]=temp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tx=A[0],y=A[1],z=A[3];\n\t\tif(3*x>z)\n\t\t\tprintf(\"NO\\n\");\n\t\telse\n\t\t\tprintf(\"YES\\n%d\\n\",3*x);\n\t}\n\telse\n\t\tprintf(\"YES\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "989a485400536997426fd99f1d8711bd", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n\n#define MOD 1000000007\n\nlong long binpow(long long a, long long k)\n{\n long long ans = 1;\n if(a == 0) return 0;\n while(k)\n {\n if(k & 1) \n {\n ans *= a;\n ans %= MOD;\n }\n a *= a;\n a %= MOD;\n k >>= 1;\n }\n return ans;\n}\n\nint main()\n{\n long long n, k; \n scanf(\"%lld %lld\", &n, &k);\n printf(\"%lld\", binpow(k, k - 1) * binpow(n - k, n - k) % MOD);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "1d909392b5ef6892a3458dd793153669", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n, i=0, nule=0, neg=0, poz=0;\n cin>>n;\n int niz1[n];\n while(i>niz1[i];\n\n if(niz1[i]==0)\n {\n nule++;\n i++;\n }\n else if(niz1[i]<0)\n {\n neg++;\n i++;\n }\n else if(niz1[i]>0)\n {\n poz++;\n i++;\n }\n }\n if(poz>=(n+1)/2)\n {\n cout<<1;\n }\n else if(neg>=(n+1)/2)\n {\n cout<<-1;\n }\n else cout<<0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "39e94ef91f19bc33c4c33ac3204aa83b", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nint main(void)\n{\n\tchar k[3],t[3];\n\tscanf(\"%s %s\",k,t);\n\n\tint hor=abs(k[0]-t[0]),ver=abs(k[1]-[1]);\n\n\tif(hor>=ver) printf(\"%d\\n\",hor);\n\telse printf(\"%d\\n\",ver);\n\n\tfor(;strcmp(k,t);)\n\t{\n\t\tif(k[0]t[0])\n\t\t{\n\t\t\tprintf(\"L\");\n\t\t\tk[0]-=1;\n\t\t}\n\n\t\tif(k[1]\nint main()\n{\n int a[5],temp,i,j;\n scanf(\"%d%d%d\",&a[0],&a[1],&a[2]);\n for(i=0;i<2;i++)\n {\n for(j=0;j<2-i;j++)\n {\n if(a[j]>a[j+1])\n {\n temp=a[j];a[j]=a[j+1];a[j+1]=temp;\n }\n }\n }\n printf(\"%d\\n\",(a[2]-a[0]);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "bac56067ddb85ecf466c289a7a2790c8", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint requires_substitute(char string[], int index1, int index2) {\n if (index1 != 0 && index2 != 0) return 0;\n if (index1 == 1 || index2 == 1) {\n if (string[2] == '0') return 1;\n } if (string[1] == '0') return 1;\n}\nint requires_substitute_fifty(char string[], int index1, int index2) {\n if (index1 == 0 && index2 != 1 && string[1] == '0') return 1;\n else return 0;\n}\nint substitute(char string[], int index1, int index2, int size) {\n int res = -1;\n for (int i = 0; i < size; i++) {\n if (i != index1 && i != index2 && string[i] != '0') {\n res = i;\n break;\n }\n }\n return res;\n}\n\nint main() {\n char string[20];\n scanf(\"%s\", string);\n int nums[5];\n for (int i = 0; i < 5; i++) {\n nums[i] = -1;\n }\n int switchZero = 1;\n int size = strlen(string);\n for (int i = 0; i < size; i++) {\n if (string[i] == '2') {\n nums[0] = i;\n } else if (string[i] == '5') {\n nums[1] = i;\n } else if (string[i] == '7') {\n nums[2] = i;\n } else if (string [i] == '0') {\n if (switchZero) {\n nums[3] = i;\n switchZero = 0;\n } else {\n nums[4] = i;\n switchZero = 1;\n }\n }\n }\n\n if (nums[3] > nums[4] || nums[4] == -1) {\n int tmp = nums[3];\n nums[3] = nums[4];\n nums[4] = tmp;\n }\n int steps[4];\n for (int i = 0; i < 4; i++) \n steps[i] = -1;\n if (nums[1] != -1) {\n if (nums[0] != -1) {\n int step_count = 0;\n if (size > 2 && requires_substitute(string, nums[1], nums[0])) {\n int sub = substitute(string, nums[1], nums[0], size);\n if (sub != -1) {\n step_count += sub;\n if (sub > nums[0] && sub > nums[1]) \n step_count --;\n }\n }\n if (nums[1] < nums[0]) {\n step_count ++;\n }\n step_count += size - nums[1] - 1;\n step_count += size - nums[0] - 2;\n steps[0] = step_count;\n } if (nums[2] != -1) {\n int step_count = 0;\n if (size > 2 && requires_substitute(string, nums[1], nums[2])) {\n int sub = substitute(string, nums[1], nums[2], size);\n if (sub != -1) {\n step_count += sub;\n if (sub > nums[2] && sub > nums[1]) \n step_count --;\n }\n }\n if (nums[1] < nums[2]) {\n step_count ++;\n }\n step_count += size - nums[1] - 1;\n step_count += size - nums[2] - 2;\n steps[1] = step_count;\n } if (nums[4] != -1) {\n int step_count = 0;\n if (size > 2 && requires_substitute_fifty(string, nums[1], nums[4])) {\n int sub = substitute(string, nums[1], nums[4], size);\n if (sub != -1) {\n step_count += sub;\n }\n }\n if (nums[1] > nums[4]) {\n step_count ++;\n }\n step_count += size - nums[1] - 1;\n step_count += size - nums[4] - 2;\n steps[2] = step_count;\n }\n } if (nums[3] != -1 && nums[4] != -1) {\n int step_count = 0;\n step_count += size - nums[3] - 1;\n step_count += size - nums[4] - 2;\n steps[3] = step_count;\n }\n int min = -1;\n for (int i = 0; i < 4; i ++) {\n \n if (steps[i] != -1) {\n if (min == -1 || steps[i] < min) {\n min = steps[i];\n }\n }\n }\n printf(\"%d\", min);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "75087461eed1341902de99a67046eeae", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint c,d,n,m,k,prob,target,compare;\n\twhile((scanf(\"%d %d %d %d %d\",&c,&d,&n,&m,&k)) != EOF) {\n\t\tprob = 0;\n\t\ttarget = n*m;\n\t\tif(target <=k) printf(\"0\\n\");\n\t\telse {\n\t\t\ttarget -= k;\n\t\t\twhile(target > 0) {\n\t\t\t\tif(target >= n) {\n\t\t\t\t\tcompare = d * n;\n\t\t\t\t\tif(compare < c) {\n\t\t\t\t\t\ttarget -= n;\n\t\t\t\t\t\tprob += compare;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\ttarget -= n;\n\t\t\t\t\t\tprob += c;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcompare = d * target;\n\t\t\t\t\tif(compare < c) {\n\t\t\t\t\t\ttarget = 0;\n\t\t\t\t\t\tprob += compare;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\ttarget = 0;\n\t\t\t\t\t\tprob += c;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tprintf(\"%d\\n\",prob);\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6d7e3da4c37a408fbf7b14580b8f0cfa", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\tint a, b, c, d;\n\tint prirastaj;\n\tfloat koeficijent, next;\n\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\n\tprirastaj=b-a;\n\tkoeficijent=(float)b/a;\n\n\tif(c==b+prirastaj && d==c+prirastaj)\n\t\tprintf(\"%d\", d+prirastaj);\n\telse if(c==koeficijent*b && d==koeficijent*c)\n\t{\n\t\tnext=koeficijent*d;\n\t\tif(next==(int)next)\n\t\t\tprintf(\"%d\", (int)next);\n\t\telse printf(\"42\");\n\t}\n\telse printf(\"42\");\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "fbdc97ee2b9f92370abb72efa697790a", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,b,c,d,e,f;\n\tscanf(\"%d%d%d%d%d%d\",&a,&b,&c,&d,&e,&f);\n\ta\n\nint ans;\nint students[5][105];\nint n;\n\nint main()\n{\n scanf(\"%d\", &n);\n for (int i = 0; i < 2; i++)\n {\n for (int j = 0; j < n; j++)\n {\n scanf(\"%d\", &a);\n students[i][a]++;\n }\n }\n for (int i = 1; i < 6; i++)\n {\n if ((students[0][i]+students[1][i])%2 == 1)\n {\n printf(\"-1\");\n return 0;\n }\n if (students[0][i] > students[1][i])\n {\n ans += students[0][i]-students[1][i];\n }\n }\n \n printf(\"%d\", ans/2);\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "54aa6b5d4b809b59d999054f355b893c", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include \nusing namespace std;\n\n\nint32_t main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr), cout.tie(nullptr);\n \n int n, v;\n cin >> n >> v;\n if (n-1 <= v) {\n cout << n-1 << endl;\n return 0;\n }\n int result = v - 1;\n for(int i = 1; i <= n - v; ++i) {\n result += i;\n }\n cout << result << endl;\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "1a0567a8cbd1fb723ab95815cb46509a", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\n#include\nint arr[360];\nvoid doiChoTrucTiep(int &n)\n{\n\tfor(int i=0;i\n#include \n#include \n#include \n void main()\n{\n\tchar str[200];\n\tscanf(\"%s\", str);\n\tint len = strlen(str);\n\tint x = 0;\n\tif (len % 2 == 1)\n\t{\n\t\tfor (int i = 1; i < strlen(str); i++)\n\t\t{\n\t\t\tint t = str[i] - '0';\n\t\t\tx = x + t;\n\t\t}\n\t}\n\tif (x > 0)\n\t{\n\t\tx = 1;\n\t}\n\tint sol = len / 2 + m;\n\tprintf(\"%d\\n\", sol);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "dcf8d5dc92e0e1469a8f2140459bd6a7", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint n, m, k, s=0;\n\tscanf_s(\"%d\", &n);\n\tscanf_s(\"%d\", &m);\n\n\tif (m%n != 0)\n\t\tprintf(\"-1\\n\");\n\telse if (m == n)\n\t\tprintf(\"0\\n\");\n\telse\n\t{\n\n\t\tk = m / n;\n\t\twhile (k != 0)\n\t\t{\n\t\t\tif (k % 6 == 0)\n\t\t\t{\n\t\t\t\ts += 2;\n\t\t\t\tk /= 6;\n\t\t\t}\n\n\t\t\tif (k % 2 == 0)\n\t\t\t{\n\t\t\t\ts += 1;\n\t\t\t\tk /= 2;\n\t\t\t}\n\t\t\tif (k % 3 == 0)\n\t\t\t{\n\t\t\t\ts += 1;\n\t\t\t\tk /= 3;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\", s);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "9b9b821a196d41f78b9c04395e90c015", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n\nint solution[40];\nint n,m;\nint used[40]={0};\nint sum=0;\nint c=0;\nint ans=0;\n\nvoid backtrack(int x)\n{\n\tvoid minmin(int);\n\tif(x==n+1)\n\t{\n\t\tint i;\n\t\tsum=0;\n\t\tminmin(1);\n\t\tif(c==m)\n\t\t{\tint i;\n\t\t\tfor(i=1;i<=n;i++)\n\t\t\t\tprintf(\"%d \",solution[i]);\n\t\t}\n\t\treturn;\n\t}\n\t\n\tint i;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tif(used[i]==0)\n\t\t{\n\t\t\tsolution[x]=i;\n\t\t\tused[i]=1;\n\t\t\tbacktrack(x+1);\n\t\t\tif(c==m)\n\t\t\treturn;\n\t\t\tused[i]=0;\n\t\t}\n\t}\n\treturn;\n}\n\n\nvoid minmin(int x)\n{\n\tif(x==n+1)\n\t{\n\t\tif(sum==ans)\n\t\tc++;\n\t\treturn;\n\t}\n\t\n\tint i,j;\n\tfor(i=x;i<=n;i++)\n\t{\t\n\t\tint MIN=100;\n\t\tfor(j=x;j<=i;j++)\n\t\t{\n\t\t\tif(MIN>solution[j])\n\t\t\t\tMIN=solution[j];\n\t\t}\n\t\tsum+=MIN;\n\t}\n\tminmin(x+1);\n\treturn;\n}\n\nint main()\n{\n\tscanf(\"%d %d\",&n,&m);\n\tans=n*(n+1)*(n+2)/6;\n\tbacktrack(1);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ff9006d0624ed0ca7b5ec1c56a016b05", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n long long a, b, x1, y1, x2, y2, x3, y3, x4, y4, p, q, ans;\n\n scanf(\"%I64d %I64d %I64d %I64d %I64d %I64d\", &a, &b, &x1, &y1, &x2, &y2);\n\n a *= 2;\n b *= 2;\n\n x3 = x1; y3 = y1;\n x4 = x2; y4 = y2;\n\n p = (x3 + y3) % a;\n q = (x4 + y4) % a;\n\n y3 -= p;\n y4 -= q;\n\n if (x3 > x4) {\n\t y3 += (x3 - x4);\n } else {\n\t y4 += (x4 - x3);\n }\n\n ans = abs(y3 - y4) / a;\n\n x3 = x1; y3 = y1;\n x4 = x2; y4 = y2;\n\n p = abs(x3 - y3) % b;\n q = abs(x4 - y4) % b;\n\n if (x3 > y3) p = b - p;\n if (x4 > y4) q = b - q;\n\n y3 -= p;\n y4 -= q;\n\n if (x3 > x4) {\n\t y3 -= (x3 - x4);\n } else {\n\t y4 -= (x4 - x3);\n }\n\n if (abs(y3 - y4) / b > ans) ans = abs(y3 - y4) / b;\n\n printf(\"%I64d\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7ada10611008e3ec554ab90e83b99a49", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "# include\n\nint main()\n{\nint n,a,x;\nscanf(\"%d\",&n);\nn=(n*(n+1))/2;\nif(n%2==0)\n{\nprintf(\"0\");\nelse\n{\nprintf(\"1\");\n}\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d2793c4e7a70e54db8007b49f5ab808f", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint main(void) {\r\n int t,k;\r\n scanf(\"%d\", &t);\r\n int answers[t];\r\n for(int i = 0; i < t; i++) {\r\n scanf(\"%d\", &k);\r\n if((100 - k) > k) {\r\n min = k;\r\n max = 100 - k;\r\n }\r\n else {\r\n max= k;\r\n min = 100 - k; \r\n }\r\n if(k == 100 || k == 0) {\r\n answers[i] = 1\r\n }\r\n else if(max % min== 0) {\r\n answers[i] = 100 / min;\r\n }\r\n else {\r\n for(int j = min / 2;j >= 1;j--) {\r\n if(max % j == 0 && min % j == 0) {\r\n answers[i] = 100 / j;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n \r\n for(int i = 0; i < t; i++) {\r\n printf(\"%d\\n\",answers[i]);\r\n }\r\n\treturn 0;\r\n}\r\n ", "lang_cluster": "C", "compilation_error": true, "code_uid": "c2bd401f08852298fac13632ab73dabe", "src_uid": "19a2bcb727510c729efe442a13c2ff7c", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \"stdafx.h\"\n#include \n#include \n\nint main()\n{\n\t\tdouble h, m, s, t1, t2, collisionForward = 0, collisionBackward = 0;\n\t\tscanf(\"%lf %lf %lf %lf %lf\", &h, &m, &s, &t1, &t2);\n\t\tm += s / 12;\n\t\th = h * 5 + m / 12;\n\t\tt1 *= 5;\n\t\tt2 *= 5;\n\t\tif (t1 > t2) {\n\t\t\tt1 = t1 + t2;\n\t\t\tt2 = t1 - t2;\n\t\t\tt1 = t1 - t2;\n\t\t}\n\t\tif (h >= t1 && h <= t2 || m >= t1 && m <= t2 || s >= t1 && s <= t2) {\n\t\t\tcollisionForward = 1;\n\t\t}\n\t\tt1 += 60;\n\t h += 60;\n\t m += 60;\n\t s += 60;\n\t\tif (h <= t1 && h >= t2 || m <= t1 && m >= t2 || s <= t1 && s >= t2) {\n\t\t\tcollisionBackward = 1;\n\t\t}\n\t\tif (collisionBackward && collisionForward) {\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t\tprintf(\"YES\");\n\t\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "407737642cd24ef9c1ed0c71b120d2d7", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "GNU C", "source_code": " \nint main(){\n char a[30]=\"\";\n char b[30]=\"\";\n int i,t1=0,t2=0;\n scanf(\"%s%s\",a,b);\n for(i=0;a[i]!=0;i+=2){\n switch(a[i]){\n case '8':\n switch(b[i]){\n case '[':t1++;break;\n case '(':t2++;break;\n default:;\n }break;\n case '[':\n switch(b[i]){\n case '8':t2++;break;\n case '(':t1++;break;\n default:;\n }break;\n case '(':\n switch(b[i]){\n case '[':t2++;break;\n case '8':t1++;break;\n default:;\n }break;\n }\n } \n if(t1>t2)\n printf(\"TEAM 1 WINS\\n\");\n else if(t1\n#include \nint main(void){\nunsigned long long int x,a;\nint t[18];\nint n,i,j;\nchar s[18];\nscanf(\"%lld\",&x);\nsprintf(s, \"%lld\", x);\nn=strlen(s);\n\nfor(i=0;i4){\n t[0]=9-t[0];}\nfor(i=1;i4){\n t[i]=9-t[i];\n }\n}\nj=0;\nfor(i=n-1;i>-1;i--){\n if(t[i]==0){\n j++;}else {break;}\n }\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2f8475df9c2ec9457484f31e11441853", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \nusing namespace std;\n\nint main() {\n long long int l,r,m;\n scanf(\"%lld%lld\",&l,&r);\n int i;\n int a[]={3,5,7,11,13,17,19,23,29,31,37,41,43,47};\n if(r-l<2){\n printf(\"-1\\n\");\n return 0;\n }\n if(l%2==0){\n printf(\"%lld %lld %lld\\n\",l,l+1,l+2);\n return 0;\n }\n if(l%2!=0){\n m=l;\n i=0;\n while(i<16){\n if(l%a[i]!=0 && (l+a[i])<=r){\n printf(\"%lld %lld %lld\\n\",m,m+1,(l+a[i]));\n break;\n }\n else if(l%a[i]==0 && (l+a[i])<=r) i++;\n else if((l+a[i])>r) printf(\"-1\\n\");\n }\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "74a49ba8535ad22476a9c6afd097a395", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n\n\nint main(int argc, const char* argv[]){\n int n,k, partial,i;\n int count = 0;\n int a[100];\n \n scanf(\"%d %d\",&n, &k);\n for(i=0; i\n\n\ntypedef long long ll;\n\nint main(){\n\nll n,m ;\nint i,j,k;\nchar * a;\n\nscanf(\"%\",&);\n\n\nfor (i=0;i\n#include\nint main()\n{\n int n,arr[100],i;\n scanf(\"%d\",&n);\n \n int pos;\n for(i=0;iwhite)?printf(\"%d\",black):printf(\"%d\",white);\n \n return 0;\n}\nint black(int *arr,int n)\n{\n int i=n-1,j=n-2,steps=0;\n while(i>=0 &&j>=0)\n {\n if(arr[i]==1 && i/%2==1)\n {\n if(arr[j]==0)\n {\n arr[j]=1;\n arr[i]=0;\n \n steps+=abs(j-i);\n i--;\n j-=2;\n }\n else\n {\n while(arr[j]!=0)\n j-=2;\n \n arr[j]=1;\n arr[i]=0;\n \n steps+=abs(j-i);\n i--;\n j-=2;\n \n }\n }\n else if(arr[i]==1 && i%2==0)\n i--; \n }\n}\nint white(int *arr,int n)\n{\n int i=n-1,j=n-1,steps=0;\n while(i>=0 && j>=1)\n {\n if(arr[i]==1 && i/%2==1)\n {\n if(arr[j]==0)\n {\n arr[j]=1;\n arr[i]=0;\n \n steps+=abs(j-i);\n i--;\n j-=2;\n }\n else\n {\n while(arr[j]!=0)\n j-=2;\n \n arr[j]=1;\n arr[i]=0;\n \n steps+=abs(j-i);\n i--;\n j-=2;\n \n }\n }\n else if(arr[i]==1 && i%2==0)\n i--; \n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "33b60bc1f0beba136720e93e0e011df5", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint n, t;\n\nint greatestdivisor(int n)\n{\n for (int i = 2; i <= sqrt(n); i++)\n if (n % i == 0) return n / i;\n return 1;\n}\nint main()\n{\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++)\n {\n scanf(\"%d\", &t);\n gd = greatestdivisor(n);\n printf(\"%d %d\\n\", gd, n - gd);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a301080f5d0607af54d2732fdaf732b0", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\nint main(){\nlong long int n;\nscanf(\"%lld\",&n);\nif(n==1){\nprintf(\"1\");}else{\nif(n%2==0)\n{printf(\"1\");\n}else{\nprintf(\"0\");\n}\n}\nretur", "lang_cluster": "C", "compilation_error": true, "code_uid": "dd04e6f5f126048b5e1ebe89c4603fed", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#define win(c) (a[0]==c &&a[1]==c && a[2]==c || a[3]==c && a[4]==c && a[5]==c ||a[6]==c && a[7]==c && a[8]==c || a[0]==c && a[4]==c && a[8]==c || a[2]==c && a[4]==c && a[6]==c || a[0]==c && a[3]==c && a[6]==c || a[1]==c && a[4]==c && a[7]==c || a[2]==c && a[5]==c && a[8]==c)\n\nchar a[9];\nint main(){\n for (int i=0; i<9; i++) scanf(\" %c\", &a[i]);\n\n int p1=0, p2=0;\n for (int i=0; i<9; i++){\n if (a[i]=='X') p1++;\n else if (a[i]=='0') p2++;\n }\n\n if (p2>p1 || p1>p2+1) printf(\"illegal\\n\");\n else if (win('X')){\n if (p1<=p2) printf(\"illegal\\n\");\n else printf(\"the first player won\\n\");\n }\n else if (win('0')) {\n if (p1>p2) printf(\"illegal\\n\");\n else printf(\"the second player won\\n\");\n }\n }\n else{\n if (p1+p2==9) printf(\"draw\\n\");\n else if (p1>p2) printf(\"second\\n\");\n else printf(\"first\\n\");\n }\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "8af7f4a093bebbc1db3f1bf91c7d71fa", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include \n#include\n#include\n#include\nlong long cmpfunc (const void * a, const void * b) {\n return ( *(long long*)a - *(long long*)b );\n}\n\nint main(void){\n \nlong long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,k,r,o,sum1,sum=0,y,count1=0,a[100000];\n\nscanf(\"%lld\",&n);\n\nfor(i=0;i){\n \n sum+=a[i];\n \n }else{\n sum+=(-1)*a[i];\n count++;\n }\n}\nqsort(a,n,sizeof(long long int),cmpfunc);\nif(count!=0){\n if(count%2==0){\n sum+=a[0];\n }\n}\nprintf(\"%lld\\n\",sum);\n\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "bd540aaa1502058e6d699890294f7275", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n/* maximum factors count, 10 must be enough. I take few more ) */\nconst int64_t cnt = 1000; \n\nint64_t\ndecompose(int64_t x, int64_t *p)\n{\n /* factors counter */\n int64_t c = 0;\n for (int64_t d = 2, b = x; x*x >= b; ++d)\n {\n if (x % d == 0)\n p[c++] = d;\n while (x % d == 0)\n x /= d;\n }\n if (x != 1) {\n p[c++] = x;\n }\n return c;\n}\n\nint\nmain()\n{\n int64_t x;\n int64_t p[cnt];\n scanf(\"%\"SCNd64, &x);\n\n int64_t c = decompose(x, p);\n\n int64_t max_f = x;\n int64_t min_f = x - p[c-1] + 1;\n int64_t min = min_f;\n for (int64_t f = min_f; f < max_f; ++f) {\n c = decompose(f, p);\n if ((c != 1 || p[0] != f) && f - p[c-1] + 1 < min)\n min = f - p[c-1] + 1;\n }\n printf(\"%\"PRId64\"\\n\", min);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "5aeb1563c24f25f638c0fb138ac5c255", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n\nint main() {\nint n, k;\nscanf(\"%d %d\", &n, &k);\nprintf(\"%d\\n\", 3n - k);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d79fa7745376a7cd1987df0bc573fcc0", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint go[2] = {0}; // 0 shangxia 1 zuoyou\nint main()\n{\n int T;\n scanf(\"%d\", &T);\n int flag = 1;\n for(int i = 1; i <= T; i++)\n {\n int a;\n char b[10]; // 1 is north, 0 is s\n scanf(\"%d %s\", &a, b);\n if(strstr(b, \"East\") && flag == -1)\n {\n go[1] = fabs((go[1] + a) % 40000);\n continue;\n }\n else if(strstr(b,\"South\") && flag != 0)\n {\n go[0] = fabs((go[0] + a) % 40000);\n if(go[0] == 20000)\n flag = 0;\n if(go[0] == 0)\n flag = 1;\n else\n flag = -1;\n continue;\n }\n else if(strstr(b, \"North\") && flag != 1)\n {\n go[0] = fabs((go[0] - a) % 40000);\n if(go[0] == 20000)\n flag = 0;\n if(go[0] == 0)\n flag = 1;\n else\n flag = -1;\n continue;\n }\n else if(strstr(b, \"West\") && flag == -1)\n {\n go[1] = fabs((go[1] - a) % 40000);\n continue;\n }\n else\n {\n printf(\"NO\\n\");\n return 0;\n }\n }\n if(go[0] == 0)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "760a247e4daa423129fc12a989a0a9df", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int a[100]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, \n 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1\n , 4, 1, 51, 1, 2\n , 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2\n , 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267,\n 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15,\n 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2}\n int n;\n scanf(\"%d\",&n);\n peintf(\"%d\",&a[n]);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "752be6a5abb4a12de1e80ba76cce1742", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \nint temp[26];\nint main()\n{\n char s[52];\n int i, j, k;\n gets(s);\n if(s[0] != 'a'){ printf(\"NO\\n\"); return 0;}\n else temp[0] = 1;\n for(i = 1; s[i] != '\\0'; i++){\n j = s[i] - 97;\n if((s[i] - s[i-1]) ==1 || temp[j] != 0){\n temp[j] = 1;\n }\n else{\n printf(\"NO\\n\"); return 0;\n }\n }\n printf(\"YES\\n\");\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "74d4de76efebe42094ced4b7bd8e8443", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nint main() \n{\nint x,y,z;\nint x1,yy,z1;\nint a[7];\nint i;\n scanf(\"%d%d%d\",&x,&y,&z);\n scanf(\"%d%d%d\",&x1,&yy,&z1);\n for i=1;i<=6;i++) scanf(\"%d\",&a[i]);\n\n int ans=0;\n if (y<0) ans+=a[1];\n if (y>yy) ans+=a[2];\n if (z<0) ans+=a[3];\n if (z>z1) ans+=a[4];\n if (x<0) ans+=a[5];\n if (x>x1) ans+=a[6];\n printf(\"%d\\n\",ans);\n\n\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "5adda86df27216744f95ed8d39b9316d", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int x,y,z;\n scanf(\"%d%d%d\",&x,&y,&z);\n\n if(x>y)\n printf(\"+\\n\");\n else if(x\n#include\nint main()\n{\n int x,a;\n scanf(\"%d\",&x);\n a=(x-1)/2;\n print(\"%d\",a);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d1c43a5ec397441df94654e887f2e0a3", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "/* http://codeforces.com/problemset/problem/1243/C */\n/* If n = r*s where gcd(r,s) = 1, return 1. \nIf n = p^k, return p. */\n\n#include \n#include \n\nint main(){\n int i, n;\n scanf(\"%d\",&n);\n if(n == 1) return 1;\n for(i = 2; i <= n/2; i++){\n if(n % i == 0) break;\n }\n while(n % i == 0) n = n/i;\n if(n == 1){printf(\"%d\\n\",i);}\n else{printf(\"%d\\n\",n);}\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "3b541895f103ebb44dc6747c99fe5beb", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\n\nlong long int fact(long long int x)\n{\n\tlong long int p=1;\n\tfor(int i=1;i<=x;i++)\n p=p*i;\n return p;\n}\nint main()\n{\n\t#ifndef ONLINE_JUDGE\n // for getting input from input.txt\n freopen(\"input.txt\", \"r\", stdin);\n // for writing output to output.txt\n freopen(\"output.txt\", \"w\", stdout);\n \t#endif\n\tlong long int b,b1, a1,a;int m;\n\tscanf(\"%lld %lld\",&a,&b);\n a1=fact(a);\n b1=fact(b);\n m=min(a1,b1);\n printf(\"%d\",m);\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b6c89a476e478841a8bd5446623625e1", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nvoid solution()\n{\n int n,i=0;\n scanf(\"%d\",&n);\n\n if(n==1||n==2)\n printf(\"-1\");\n else\n {\n for(i=n;i>0;i--)\n printf(\"%d\",i );\n\n }\n\nint main()\n{\n\n solution();\n\n\n\n return 0;\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f63e5d0536add65d4e11c5f285639902", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include \n\n#define M\t1000000007\n\nint factorial(int n) {\n\treturn n == 0 ? 1 : (long long) factorial(n - 1) * n % M;\n}\n\nint main() {\n\tint i, n, f, g;\n\n\tscanf(\"%d\", &n);\n\tf = factorial(n);\n\tif (n % 2 == 0)\n\t\tprintf(\"0\\n\");\n\telse {\n\t\tg = 1;\n\t\tfor (i = 1; i <= n; i += 2)\n\t\t\tg = (long long) g * i % M;\n\t\tf = f * g % M;\n\t\tprintf(\"%d\\n\", f);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cdaea1304452daa22edaf3617fa0a5c9", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n, m,no=1;\n scanf(\"%d %d\", &n,&m);\n int a[n];\n int b[m];\n int i,nn=9,mm=9;\n for(i=0;imm)\n printf(\"%d%d\", mm, nn);\n else\n printf(\"%d%d\", nn, mm);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "c3aa55673a633f9f2c55bb99939ba96d", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n\n char str[100];\n int count=0,i,n;\n scanf(\"%d\",&n);\n scanf(\"%s\",str);\n for(i=0;i\nmain()\n{\n\tint a1,b1,a,b;\n\tchar s;\n\tfor(;;)\n\t{\n\tscanf(\"%d%c%d\",&a1,&s,&b1);\n\tif(a1<12)\n\t{a=(a1+1.0*b1/60)*30;\n\tb=b1*6;\n if(b1%2==1)\n\t{\n\t\tprintf(\"%d\",a);\n\t\tprintf(\".5\");\n\t\tprintf(\" %d\\n\",b);\n\t}\n\telse printf(\"%d %d\\n\",a,b);\n\t}\n\t\n\telse if(a1<=23)\n\t{a1-=12;a=(a1+1.0*b1/60)*30;\n\tb=b1*6;\n if(b1%2==1)\n\t{\n\t\tprintf(\"%d\",a);\n\t\tprintf(\".5\");\n\t\tprintf(\" %d\\n\",b);\n\t}\n\telse printf(\"%d %d\\n\",a,b);}\n\t\n\telse\n\t{\n\t\ta=1.0*b1/60*30;\n\t\tif(b1%2==1)\n\t\t{\n\t\t\tprintf(\"%d\",a);\n\t\t\tprintf(\".5\");\n\t\t\tprintf(\" %d\\n\",b);\n\t\t}\n\t\telse \n\t\t\tprintf(\"%d %d\\n\",a,b);\n\t}\n\t}\n}\n\t\t\t\t\t\t \t \t\t \t\t \t \t \t", "lang_cluster": "C", "compilation_error": false, "code_uid": "2935b2b3f6d9a0cfe0cbfeea4f7317ad", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "\n#include \n#define LL long long\n#define ULL unsigned long long\nint main()\n{\n char square[3][3];\n for(int i=0;i<3;i++) for(int j=0;j<3;j++) scanf(\"%c\",&square[i][j);\n bool flag=true;\n if(square[0][0]!=square[2][2]) flag=false;\n else if(square[0][1]!=square[2][1]) flag=false;\n else if(square[0][2]!=square[2][0]) flag=false;\n else if(square[1][0]!=square[1][2]) flag=false;\n if(flag) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "6f2c58f337ae4e3851622137528896b8", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n\nint main(void) {\n\tint n = 0;\n\tscanf(\"%d\", &n);\n\tif(n%2 != 0 || n==0)\n\t printf(\"%d\", 0);\n\telse\n\t printf(\"%d\", 2^(n\\2));\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "df5b6c2886b01b3013468a8b46c8e806", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\n#define vutka long long int\n\nvutka check[1000005];\nvectorprime;\nint main()\n{\n for(vutka i=2;i<=1000;i++)\n {\n if(!check[i])\n {\n for(vutka j=2*i;j<=1000000;j+=i)\n check[j]=1;\n }\n }\n for(vutka i=2;i<=1000000;i++)\n if(!check[i])\n prime.push_back(i);\n vutka b,r;\n cin>>b;\n vutka n=b;\nr=1;\n for(vutka i=0;i\nint main(){\nint a,b,c;\nwhile(~scanf(\"%d%d%d\",&a,&b,&c)){\nint x,y,z;\nscanf(\"%d%d%d\",&x,&y,&z);\nint x1,y1,z1,tmp;\nif(a>=x) x1=(a-x)/2;\nelse x1=a-x;\nif(b>=y) y1=(b-y)/2;\nelse y1=b-y;\nif(c>=z) z1=(c-z)/2;\nelse z1=c-z;\ntmp=x1+y1+z1;\n//printf(\"000 tmp=%d\\n\",tmp);\nif(tmp>=0) printf(\"Yes\\n\");\nelse printf(\"No\\n\");\n}\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "a8395c3283c90599f4dd1e33e49a61ae", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n\tint i, n, k, flag, Gpos, Tpos;\n\tchar field[101];\n\t\n\tscanf(\"%d %d %s\", &n, &k, field);\n\t\n\tfor(i=0; field[i]!='\\0'; i++)\n\t{\n\t\tif(field[i]=='G')\n\t\t\tGpos=i;\n\t\telse if(field[i]=='T')\n\t\t\tTpos=i;\n\t}\n\t\n\tif(Gpos>Tpos)\n\t\tk*=-1;\n\t\n\twhile(1)\n\t{\n\t\tif(Gpos+k>=n)\n\t\t{\n\t\t\tflag=0;\n\t\t\tbreak;\n\t\t}\n\t\telse if(field[Gpos+k]=='#')\n\t\t{\n\t\t\tflag=0;\n\t\t\tbreak;\n\t\t}\n\t\telse if(field[Gpos+k]=='.')\n\t\t\tGpos+=k;\n\t\telse if(field[Gpos+k]=='T')\n\t\t{\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tif(flag==1)\n\t\tprintf(\"YES\");\n\telse\n\t\tprintf(\"NO\");\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b018c32b9299c8fca2672ce3aa7db153", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n\nint main(void)\n{\nunsigned x, y, result = 0;\nscanf(\u201c%u\u201d, &x);\ndo {\ny = x & 15;\nx >>= 4;\nif (y == 0 || y == 4 || y == 6 || y == 9 || y == 10 || y == 13){\nresult++;\n}\nif (y == 8 || y == 11){\nresult += 2;\n}\n} while (x);\nprintf(\u201c%d\u201d, result);\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b02eb77c925407c8e27ea42830c74998", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{int i,j,k[100005]={0},m,a,b,r;\nscanf(\"%d %d %d %d\",&a,&b,&m,&r);\nk[r]=1;j=1;\nfor(i=0;i<=m;i++)\n{r=(a*r+b)%m;\nk[r]++;j++;\nif(k[r]>1)\n{\n printf(\"%d\",j-1);\n break;\n}\n\n}\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "daa8baf0958279156caff6c0e64efde4", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint arr[10]={6,2,5,5,4,5,6,3,7,6};\n \tlong long int a,b,sum=0,i,temp;\n\tscanf(\"%I64d %I64d\",&a,&b);\n\tfor(i=a;i<=b;i++)\n\t{\n\t\ttemp = i;\n\t\twhile(temp!=0)\n\t\t{\n\t\t\tsum=sum+arr[temp%10];\n\t\t\ttemp = temp/10;\n\t\t}\n\t\t\n\tprintf(\"%I64d\\n\",sum);\nreturn 0;\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f1ee0a3d5ecc97d02cc7e7ee88b5f813", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "\n#include\n#include\n\nint main()\n{\n\tlong int n,lf;\n\n\tscanf(\"%d\",&n);\n\n\tlf=n%2;\n\n\nif(lf==1 ||lf==-1)printf(\"%d\",1);\nelse printf(\"%d\",2);\n\ngetch();\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "d00d77a823708d9e3add5ce7d117edb5", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(){\n\t\n\tint grid[300][300];\n\tint r=105, c=105, i, j;\n\tmemset(grid, 0, sizeof grid);\n\tgrid[r][c]=1;\n\tchar cad[200];\n\tgets(cad);\n\tfor( i=0;i1 ) {printf(\"BUG\\n\") return 0;}\n\t}\n\tprintf(\"OK\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "f3619d22d5246ff327dbbd18ae9b31f1", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int n;\n scanf(\"%d\", &n);\n printf(\"%s\", n&(n-1) ? : \"YES\" ? \"NO\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "82158c4c93cb7cf36a3deb0f9ca4d669", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\nint h, r, ans;\nscanf(\"%d\",&r);\nscanf(\"%d\",&h);\nans = 2*h/r;\nans += ((2*m>=r)?2:1)\nans += ((2.0*m>=(sqrt(3.0)*r))?1:0);\nprintf(\"%d\",ans);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "56a678471776eb83f4e7c8be7b4e0e2b", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{int n,i,c=0;\n scanf(\"%d\",&n);\n for(i=0;i<=(n/2);i++)\n {\n if(pow(2,i)==n)\n c++;\n if(pow(2,i)\n#include \n\nchar C[205];\n\nint main()\n{\n int N,B,G,R,i;\n B = G = R = 0\uff1b\n scanf(\"%d\",&N);\n scanf(\"%s\",C);\n \n for(i = 0;i < N;i++)\n {\n switch(C[i])\n {\n case 'B':B++;break;\n case 'G':G++;break;\n case 'R':R++;break;\n }\n }\n \n if(0);\n else if(B == 0&&G == 0)printf(\"R\\n\");\n else if(R == 0&&G == 0)printf(\"B\\n\");\n else if(B == 0&&R == 0)printf(\"G\\n\");\n else if(B == 0&&G == 1||G == 0&&B == 1)printf(\"BG\\n\"); \n else if(R == 0&&B == 1||B == 0&&R == 1)printf(\"BR\\n\"); \n else if(R == 0&&G == 1||G == 0&&R == 1)printf(\"GR\\n\"); \n else if(R+G+B < 4&&R == 2)printf(\"BG\\n\");\n else if(R+B+G < 4&&G == 2)printf(\"BR\\n\"); \n else if(R+G+B < 4&&B == 2)printf(\"GR\\n\"); \n else if(R == 0&&B == 1&&G == 1)printf(\"R\\n\"); \n else if(G == 0&&B == 1&&R == 1)printf(\"G\\n\"); \n else if(B == 0&&G == 1&&R == 1)printf(\"B\\n\"); \n else printf(\"BGR\\n\"); \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "da2cfaa33fdfe53901a1cddd832b670e", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint compare (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint mask(int x){\n int k = 0, t = 1;\n\twhile (x > 0) {\n\t if (x % 10 == 7 || x % 10 == 4) {\n\t\t k += x%10*t;\n\t\t\tt *= 10;\n\t\t}\n\t\tx = x/10;\n\t}\n\treturn(k);\n}\n\nint main() {\n int a, b, i;\n\tscanf(\"%d %d\",&a,&b);\n\tfor (i = a;mask(i) != b;i++);\n\tprintf(\"%d\\n\",i);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7413141d5f5ccb3e5707ef7a6ef922ef", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n\nusing namespace std;\n\nint map[101];\nint main() {\n\tint num[5];\n\tscanf(\"%d %d %d %d %d\", &num[0], &num[1], &num[2], &num[3], &num[4]);\n\tmap[num[0]]++;\n\tmap[num[1]]++;\n\tmap[num[2]]++;\n\tmap[num[3]]++;\n\tmap[num[4]]++;\n\tint sum, min;\n\tint i;\n\tfor(i = 0; i < 5; i++) sum += num[i];\n\tmin = sum;\n\tfor(i = 0; i < 5; i++) {\n\t\tif(map[num[i]] > 1) {\n\t\t\tint delta, new_min;\n\t\t\tdelta = map[num[i]] == 2 ? 2 : 3;\n\t\t\tmap[num[i]] = 0;\n\t\t\tnew_min = sum - delta * num[i];\n\t\t\tif(min > new_min) {\n\t\t\t\tmin = new_min;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", min);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "5341980e719752b4c5e296e63ca95885", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \"stdio.h\"\n#include \"stdlib.h\"\n#include \"string.h\"\n\nint main(int argc, char const *argv[]) {\n int p,d,i,x,continuer = 1,y,a=0,b=1 ;\n char str[50],temp ;\n scanf(\"%d%d\",&p,&d );\n x = p-d ;\n\n while(continuer)\n {\n sprintf(str, \"%d\", p);\n str[a]-- ;\n for(i=b;i=x)\n continuer = 0 ;\n else\n {\n str[a]++ ;\n a++;\n b++;\n }\n if(b==strlen(str) && str[b-1]-1 != 9)\n {printf(\"%d\\n\",p );\n return 0 ;}\n }\n printf(\"%d\\n\",y );\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "59153c68eec33c4332a026be1d40e563", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nlonglong int a,b;\nscanf(\"%lld%lld\",&a,&b);\nwhile((a!=0)&&(b!=0))\n{\n if(a>=2*b)\n {\n a=a%2*b;\n }\n else if(b>=2*a)\n {\n b=b%2*a;\n }\n else\n {\n break;\n }\n }\n printf(\"%lld%lld\",a,b);\n return 0;\n } \n", "lang_cluster": "C", "compilation_error": true, "code_uid": "1722ecd3fbf7f462b288a60eb3f16b6e", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\nlong long int n,c;\nvoid do(long long int i, int l);\nint main (){\n scanf(\"%I64d\",&n);\n do(2520,1);\n printf(\"%I64d\",c);\n}\nvoid do(long long int i,int l){\n i*=l;\n if(i<=n){\n c++;\n do(i,2);\n do(i,3);\n do(i,5);\n do(i,7);\n if(l!=2){\n do(i,4);\n if(l!=3){\n do(i,6);\n do(i,9);\n }\n if(l!=4){\n do(i,8);\n }\n if(l!=5){\n do(i,10);\n }\n }\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "ff7004f6df6f0cb51e2e436c39f53a7e", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n, t, k, d;\n scanf_f(\"%d%d%d%d\", &n, &t, &k, &d);\n\n\n int time1 = ceil((float)n / k) * t;\n int time2 = d + t;\n if (time1 > time2)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "fb0f8ff49acc831169a0f49286a5a47c", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,j,k,a,arr[3];\n scanf(\"%d\",&a);\n while(1)\n {\n if(a%4==0)\n {\n printf(\"%d\",a);\n break;\n }\n else\n {\n arr[0]=a%10;\n a=a-arr[0];\n arr[1]=a%10;\n arr[2]=a-arr[1];\n sum=arr[0]+arr[1]+arr[2];\n if(sum%4==0)\n printf(\"%d\",sum);\n else\n sum++;\n \n }\n return 0;\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "55be98b568cf72119f7d64f5066c9bd3", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint k,i;\nchar s[50],c[12][50]={\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\nbool check(char *a,char *b)\n{\n if(strlen(a)-strlen(b))return 0;\n for(int i=0;a[i];i++)if(a[i]-b[i])return 0;\n return 1;\n}\nint main()\n{\n scanf(\"%s%d\",s,&k);\n for(;i<12;i++)if(check(s,c[i]))break;\n printf(\"%s\",c[(i+k)%12]);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "4e2653e8bd13a531a6731acbe01834e4", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\r\n#include\r\nint main(){\r\n int t;\r\n for(int i=0;i\n#include \n\nint main()\n{\n int x,y,result;\n scanf(\"%d %d\",&x,&y);\n if(x==0 && y==0)result=0;\n else if(x==1 && y==0)result=0;\n else if(x==0 && y==1)result=2;\n else if(x==0 && y==-1)result=4;\n else if(x==-1 && y==0)result=3;\n else if(x=>0 && y=>0)\n {\n if(x0 && y<0)\n {\n if(x>abs(y))\n {\n if(x-abs(y)==1)\n result=(4*abs(y));\n else\n result=(3*x)+(x-3);\n }\n else result=(4*abs(y));\n }\n else if(x<0 && y=>0)\n {\n if(abs(x)>y)\n result=(3*abs(x))+(abs(x)-1);\n else result=(3*y)+(y-2);\n }\n printf(\"%d\",result);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0194df46e4f6ea5cd12fec1ae5d6be37", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint a,b,x,y;\nscanf(\"%d%d\",&a,&b);\nif(a>b)\n {x=b;\n y=((a-x)/2);}\nelse if (b>a)\n {x=a;\ny=((b-x)/2);}\nprintf(\"%d %d\", x,y);\n \n \n \n \n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "80d877f6407a2f3bf7db97ffe0f91d96", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nvoid main()\n{\n int n,p,s,i;\n scanf(\"%d%d%d\",&n,&p,&s);\n if((p-s)!=1)\n { printf(\"<<\");\n }\n for(i=p-s;i<=p+s;i++)\n {\n if(i==p) \n { printf(\"(%d)\",i);\n }else\n {printf(\"%d\",i);\n }if(i==n)\n {\n break;\n }\n }\n if(i>\");\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "8d070500e2a243b26cc9cd2b8a237cd0", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\t\n int a;\n\tscanf(\"%d\",&a);\n\tint x;\n\tfor(int n=1;;n++){\n\t\tif(a%n==0){\n\t\t\tif(a/n\nmain(){\n\tint y,z,i,j,si,n,m,x,bo,k,s=0;\n\tscanf(\"%d %d %d %d\",&k,&n,&bo,&si);\n\twhile(n>0){s++;y=(k\nint b[51];\nvoid merge(int a[], int k,int l);\nvoid merge_sort(int a[], int n);\n\nint main()\n{\n int n,m,k,i,s,flag,a[51];\n scanf(\"%d%d%d\",&n,&m,&k);\n for(i=0;i=m) {flag=1;break;}\n }\n if(flag) printf(\"%d\\n\",i);\n else printf(\"-1\\n\");getch();\n return;\n}\nvoid merge_sort(int a[], int n)\n{\nif(n==1||n==0) return;\nmerge_sort(a, n/2);\nmerge_sort(a+n/2, n-n/2);\nmerge(a,n/2, n-n/2);\n}\n\nvoid merge(int a[], int k,int l)\n{\n int i,j=k,c=0;\nfor(i=0;i=a[j]&&j\nint main()\n{\nint a,b,c,d,e;\nscanf(\"%d%d%d\",&a,&b,&c);\nfor(d==0;d<=10000;d++)\n{\nfor(e==0;e<=10000;e++)\n{\nif((d*a+e*b)==c){printf(\"yes\");return 0;}\n}\n}\nelse printf(\"no\");\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "fec90040caaa8707bf6931dcbe755566", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main(void)\n{\n int s, x1, x2, p, d1, t1, t2, ans = 0;\n scanf(\"%d%d%d%d%d%d%d\", &s, &x1, &x2, &t1, &t2, &p, &d1);\n int t_ig = abs(x1 - x2) * t2;\n int t_tr;\n if ((x2 - p) * d1 > 0) {\n t_tr = abs(x2 - p) * t1;\n }\n else{\n if (x2 < p){\n t_tr = (2 * s - p - x2) * t1;\n }\n else{\n t_tr = (p + x2) * t1;\n }\n }\n if (t_tr >= t_ig)\n ans = t_ig;\n else\n ans = t_tr;\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4095b510039f0fea9096cae27efdf8c7", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main()\n{\n int i,j,k,l,m,temp,res=0,max=0;\n char s[300],in[10];\n scanf(\"%s\",s);\n scanf(\"%d\",&k);\n l=strlen(s);\n if(k>=l)\n printf(\u201c%d\\n\u201d,(((k+l)/2))*2);\n else\n {\n for(i=0;i=1;j--)\n {\n temp=0;\n for(m=i;m=l)\n break;\n if(s[i]!=s[m+j])\n {temp=-1;break;}\n }\n if(temp==0 && j>max)\n max=j;\n }\n }\n if(max>k)\n printf(\"%d\\n\",2*max);\n else\n printf(\"%d\\n\",2*k);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "9c60d6d84905d00086cd3514ae001b04", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include\nint main(){\nconst int x;\nint n=0;\nchar s[x];\nscanf (\"%d\",&x);\nscanf (\"%s\",&s);\nfor(inti=0;i\nmain()\n{\n int small,c,w=1,j,k,n,m,i,bench[100];\n scanf(\"%d\",&n);\n scanf(\"%d\",&m);\n\n for(i=1;i<=n;i++) scanf(\"%d\",&bench[i]);\n c=bench[1];\n for(i=2;i<=n;i++){if(c>bench[i]) c=c;else c=bench[i];}\n\n\n x : small=bench[1];\n j=1;\n\n for(i=2;i<=n;i++)\n {\n if(smallbench[i] k=k;else k=bench[i];}\n\n\n\n printf(\"%d\\n\",k);\n printf(\"%d\",m+c);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "bb48ca2a874265a70506ddfb89c493ec", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int p,y,i,j;\n scanf(\"%d%d\",&p,&y);\n int b[y];\n b[0]=-1;\n b[1]=-1;\n for(i=2;i<=y;i++)\n b[i]=i;\n for(i=2;i<=p;i++)\n {\n for(j=2;j<=y;j++)\n {\n if(j%i==0)\n b[j]=-1;\n }\n }\n int max=-1;\n for(i=y;i>=0;i--)\n {\n if(b[i]!=-1)\n {\n max=i;\n break;\n }\n }\n printf(\"%d\",max);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "38180bf5838dd40f7a3495dc0583b013", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint x[5];\nint y[5];\n\nmain(){\n int i;\n for(i = 0; i < 3; i++){\n scanf(\"%d %d\", x+i, y+i);\n }\n if((x[0] == x[1] && x[1] == x[2]) || (y[0] == y[1] && y[1] == y[2])){\n printf(\"1\");\n return 0;\n }\n if(x[0] == x[1] && (y[0] == y[2] || y[1] == y[2])){\n printf(\"2\");\n return 0;\n }\n if(x[2] == x[1] && (y[0] == y[2] || y[1] == y[0])){\n printf(\"2\");\n return 0;\n }\n if(x[0] == x[2] && (y[1] == y[2] || y[1] == y[0])){\n printf(\"2\");\n return 0;\n }\n printf(\"3\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2df6aada727a6ce787b316dbf91a649d", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int a,b,c,d,e,f,n,m;\n scanf(\"%d%d%d%d%d%d\",&a,&b,&c,&d,&e,&f);\n int x=a;\n int y=b;\n if(a>=0 && c>=0)|| (a<0 && c<0))\n {\n a=abs(a-c);\n }\n else\n {\n a=abs(a+c);\n }\n if(b>=0 && d>=0)|| (b<0 && d<0))\n {\n b=abs(b-d);\n }\n else\n {\n b=abs(b+d);;\n }\n n=a/e;\n m=b/f;\n if(n!=m && (x!=c && y!=d))\n{\n printf(\"NO\");\n }\n else\n {\n if(a>b)\n {\n if(a%e==0 && b%f==0 && a%b==0)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n }\n else\n {\n if(a%e==0 && b%f==0 && a%b==0)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n }\n }\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "c02c4830019050f4834174982aa7ca72", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#define ll long long\nusing namespace std;\n\nll pw2[40],pw3[40];\nint calc(ll k)\n{\n\n int ret = 0 ;\n for (int i = 0 ; i <= 32 ; i ++)\n for (int j = 0 ; j <= 32 ; j ++)\n if (k * 1.0 / pw3[j] >= pw2[i]) ret ++ ;\n return ret;\n}\nint main()\n{\n pw2[0] = pw3[0] = 1;\n for (int i = 1 ; i <= 32 ; i++ ) pw2[i] = pw2[i-1] * 2;\n for (int i = 1 ; i <= 32 ; i++ ) pw3[i] = pw3[i-1] * 3;\n\n int x , y;\n\n cin >> x >> y;\n cout<< calc(y) - calc(x-1) << endl;\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "5511c0011496e527f01e6d53eb195a06", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \nchar a[30], b[30];\n\nint main ()\n{\n\tint n, m, i, ans = 1;\n\tscanf (\"%d %d\\n\", &n, &m);\n\tfor (i = 1; i <= n; i++)\n\t\tscanf (\"%c\", &a[i]);\n\tfor (i = 1; i <= m; i++)\n\t\tscanf (\"%c\", &b[i]);\n\tif ((a[1] == '>' && b[1] == 'v') || (a[1] == '<' && b[1] == '^')) ans = 0;\n\telse if ((a[n] == '>' && b[1] == '^') || (a[n] == '<' && b[1] == 'v')) ans = 0;\n\telse if ((a[1] == '>' && b[m] == '^') || (a[1] == '<' && b[m] == 'v')) ans = 0;\n\telse if ((a[n] == '>' && b[m] == 'v') || (a[n] == '<' && b[m] == '^')) ans = 0;\n\tif (ans) printf (\"YES\");\n\telse printf (\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7e833a099daf30150730e665aa56b0f2", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main(void)\n{\n int len,i;\n long long num;\n char str[105];\n gets(str);\n len=strlen(str);\n if(len==19)\n {\n if(str[0]<='9'){if(str[1]<='2')if(str[2]<='2')if(str[3]<='3')if(str[4]<='3')if(str[5]<='7')if(str[6]<='2')if(str[7]<='0')if(str[8]<='3')if(str[9]<='6')if(str[10]<='8')if(str[11]<='5')if(str[12]<='4')if(str[13]<='7')if(str[14]<='7')if(str[15]<='5')if(str[16]<='8')if(str[17]<='0')if(str[18]<='7')}\n printf(\"long\\n\");\n else\n printf(\"BigInteger\\n\");\n }\n else if(len>19)\n printf(\"BigInteger\\n\");\n else\n {\n sprintf(num,\"%s\",str);\n if(num<=127)\n printf(\"byte\\n\");\n else if(num<=32767)\n printf(\"short\\n\");\n else if(num<=2147483647)\n printf(\"int\\n\");\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "00cf3e3c83d16ad7620d2a152491ed02", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include \ntypedef long long unsigned int u64;\nu64 dp[1<<24];\nu64 solve(const u64 n, const u64 x, const u64 y) {\n dp[1] = x;\n for(int i = 1; i <= n; i++)\n if(i & 1) dp[i] = dp[i - 1] + x;\n else dp[i] = dp[i >> 1] + y < dp[i - 1] + x ? dp[i >> 1] + y : dp[i - 1] + x;\n return dp[n];\n}\n\nint main(void) {\n int n, x, y;\n scanf(\"%d%d%d\", &n, &x, &y);\n printf(\"%llu\", solve(n, x, y));\n return 0;", "lang_cluster": "C", "compilation_error": true, "code_uid": "ba45e18d2be96b03b74af92828963a5f", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\nint main(){\nint x,y,a,b,i,min,count = 0;\nif (x>y) min = y else min = x;\nscanf (\"%d %d %d %d\",&x,&y,&a,&b);\nfor (i=a;i\n\nint main(void) {\n\t// your code goes here\n\tchar st1[1000000], st2[1000000];\n\tint count_a = 0, count_b = 0;\n\tchar ch=getchar_unlocked();\n\twhile(ch!='|')\n\t\tst1[count_a++] = ch, ch = getchar_unlocked();\n\t\n\tch = getchar_unlocked();\n\twhile(ch!='\\n')\n\t\tst2[count_b++] = ch, ch = getchar_unlocked();\n\tch = getchar_unlocked();\n\twhile(ch>=65 && ch <= 90)\n\t{\n\t\tif(count_a <= count_b)\n\t\t\tst1[count_a++]=ch;\n\t\telse\n\t\t\tst2[count_b++]=ch;\n\t\tch = getchar_unlocked();\n\t}\n\n\t\n\tif(count_a != count_b)\n\t{\n\t\tprintf(\"Impossible\\n\");\n\t}\n\telse\n\t{\n\t\tst1[count_a] = '\\0';\n\t\tst2[count_b] = '\\0';\n\t\tprintf(\"%s|%s\\n\", st1, st2);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "436f2e693d0834070aa713360532414d", "src_uid": "917f173b8523ddd38925238e5d2089b9", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\n\nint main()\n{\n\n long long int w,h,ans;\n\n scanf(\"%lld%lld\",&w,&h);\n\n\n long long int t=w+h;\n ans=pow(2,t);\n\n printf(\"%lld\\n\",ans%998244353 );\n\n\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9089b5ada66d5db80f2ba4def5f10f35", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\n int a,i;\n int tc,t;\n scanf(\"%d\",&tc);\n for(i=0; i0)\n {\n\n if(a>=7)\n a=a-7;\n else if(a>=6)\n a=a-6;\n else if(a>=5)\n a=a-5;\n else if(a>=4)\n a=a-4;\n else if(a>=3)\n a=a-3;\n else if(a>=2)\n a=a-2;\n t++;\n\n }\n printf(\"%d\\n\",t);\n\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "1fea2b6521ecebd13cbb8b85c01c42c9", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint n,k,i;\nscanf(\"%d%d\",&n,&k);\nfor(i=0;i<=n-n%k;i++)\n printf(\"%d \",n/k);\nfor(i=0;i\n#include\n#include\n#include\n#define N 205\nint main(void)\n{\n int i,j,print,star=0,count1=0,count2=0,length;\n bool yn[N];\n char line[N];\n gets(line);\n scanf(\"%d\",&length);\n for(i=0; icount1&&!star)\n printf(\"Impossible\\n\");\n else\n {\n if(length>count1)\n {\n print=length-count1;\n for(i=0; i\n#include \n#include \n\nint tab [110];\n\nint main(){\n\tint n;\n\tscanf (\"%d\",&n);\n\tfor (int i = 0; i < n; i++){\n\t\tscanf (\"%d\",&tab[i]);\n\t}\n\n\tint vsota = 0;\n\tint je = 1;\n\n\tint a;\n\tint b;\n\n\tfor (int i = 1; i < n; i++){\n\t\ta = tab[i-1];\n\t\tb = tab[i];\n\t\t\n\t\tif ((a == 1 && b == 2)||\n\t\t\t(a == 2 && b ==1)){\n\t\t\tvsota += 3;\n\t\t}\n\t\telse if ((a == 1 && b == 3)||\n\t\t\t\t(a == 3 && b == 1)){\n\t\t\tvsota += 4;\n\t\t}\n\t\telse{\n\t\t\tje = 0;\n\t\t\tbreak;\n\n\t\t}\n\n\n\n\n\n\t\t/*\n\t\tif (tab [i] == 1 || tab[i-1] == 1){\n\t\t\tif (tab[i] == 2 || tab [i-1] == 2){\n\t\t\t\tvsota = vsota + 3;\n\t\t\t}\n\t\t\telse if ( tab[i] == 3 || tab [i-1] == 3){\n\t\t\t\tvsota = vsota + 4;\n\t\t\t}\n\n\t\t}\n\n\t\tif((tab[i] == 2 && tab [i-1] == 3 )||\n\t\t\ttab [i-1]== 2&& tab [i] == 3){\n\t\t\tje = 0;\n\t\t\tbreak;\n\t\t}\n\t\t*/\n\n\t}\n\n\tif (je == 1){\n\t\tprintf(\"Finite\\n\");\n\t\tprintf(\"%d\\n\",vsota );\n\t}\n\telse{\n\t\tprintf(\"Infinite\\n\");\n\n\t}\n\n\n\n\n\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "85b2c4de6e093ec115c69c1e01070da0", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \n\nint Win(int a, int b)\n{\n return b == (a + 1) % 3;\n}\n\nint main()\n{\n char ans[4] = \"FMS\";\n int choice[3];\n char str[15];\n for(int i = 0; i < 3; ++i) {\n scanf(\"%s\", str);\n if(str[0] == 'r') {\n choice[i] = 0;\n } else if(str[i] == 's') {\n choice[i] = 1;\n } else if(str[i] == 'p') {\n choice[i] = 2;\n }\n }\n for(int i = 0; i < 3; ++i) {\n char allWin = 1;\n for(int j = 0; j < 3; ++j) {\n if(i != j && !Win(choice[i], choice[j])) {\n allWin = 0;\n break;\n }\n }\n if(allWin) {\n putchar(ans[i]);\n return 0;\n }\n }\n puts(\"?\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e0a65a281fd087aa906f41bccc15fd4e", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \nint a[1000];\nint main()\n{\n//\tfreopen(\"datain.txt\",\"r\",stdin);\n//\tfreopen(\"datain.txt\",\"w\",stdout);\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i=1;\n\tint len;\n\tint cnt=0;\n\twhile(n>0)\n {\n a[i]=n%8;\n n /=8;\n i++;\n len = i;\n }\n for(i=1;i<=len;i++)\n {\n if(a[i]==1) cnt++;\n }\n printf(\"%d\",cnt);\n//\tfclose(stdin);\n//\tfclose(stdout);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "d4852a57cfb717006b180bddef20f015", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\t// your code goes here\n\t\n\tint n,q,w,e,r,t,a,b,c,d,i,j,k;\n\tscanf(\"%d\",&n);\n\tint act;\n\t\n\te=n%10;\n\tn=n/10;\n\td=n%10;\n\tn=n/10;\n\tc=n%10;\n\tn=n/10;\n\tb=n%10;\n\tn=n/10;\n\ta=n;\n\t\n\tn=a*10000 + c*1000 +e*100+d*10+b;\n\tact=n;\n\t\n\tfor(i=0;i<4;i++)\n\t{n=n*act;\n\t \te=n%10;\n\tn=n/10;\n\td=n%10;\n\tn=n/10;\n\tc=n%10;\n\tn=n/10;\n\tb=n%10;\n\tn=n/10;\n\ta=n%10; \n\t \n\t n=a*10000 + b*1000 +c*100+d*10+e;\n\t \n\t \n\t} printf(\"%d \",n);\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "41d209dd72c7213dafefd66b8b2466c0", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(){\n int n,pos,l,r,sec=0;\n scanf(\" %d %d %d %d\",&n,&pos,&l,&r);\n if(pos>=l%%pos<=r){\n if(l==1&&r==n){\n sec=0;\n }else if(l==1&&r!=n){\n sec=r-pos+1;\n }else if(l!=1&&r==n){\n sec=pos-l+1;\n }else if(l!=1&&r!=n){\n if(pos-l<=r-pos){\n sec+=pos-l+1;\n sec+=r-l+1;\n }else if(pos-l>r-pos){\n sec+=r-pos+1;\n sec+=r-l+1;\n } \n }\n }else if(pos>r){\n if(l==1&&r!=n){\n sec=pos-r+1;\n }else if(l!=1&&r!=n){\n sec+=pos-r+1;\n sec+=r-l+1;\n }\n }else if(pos\nint main()\n{\n int w,h,i,T=0;\n scanf(\"%d %d\",&w,&h);\n for(i=2; ;i=i*2){\n if(w>=i&&h>=i){\n T=(w-i+1)*(h-i+1)+T;\n }\n else break;\n }\n printf(\"%d\",T);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a85cd71825e5689e292369d1fb24e334", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int k,i;\n cin>>k;\n if(k<2*1000000000000000000)\n {\n if(k%2==0)\n {\n for(i=0;i\nint main()\n{\n\tint len,array[105],last=4,count=0,i;\n\tscanf(\"%d\",&len);\n\tfor(i=1;i<=len;i++)\n\t\tscanf(\"%d\",&array[i]);\n\tfor(i=1;i<=len;i++)\n\t{\n\t\tif(array[i]==0)\n\t\t{\n\t\t\tcount++;\n\t\t}\n\t\telse if(array[i]==1)\n\t\t{\n\t\t\tif(last==1)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t\tlast=4;\n\t\t\t}\n\t\t\telse\n\t\t\t\tlast=1;\n\t\t}\n\t\telse if(array[i]==2)\n\t\t{\n\t\t\tif(last==2)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t\tlast=4;\n\t\t\t}\n\t\t\telse\n\t\t\t\tlast=2;\n\t\t}\n\t\telse\n\t\t{\n if(last==1)\n\t\t\tlast=2;\n else if(last==2)\n last=1;\n else\n last=4;\n\t\t}\n\t}\n printf(\"%d\\n\",count);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0295fcfb55976b63dd307448364415d5", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int x,y,a; \n scanf(\"%d %d %d\",&x,&y,&z);\n float a2=float(a)/2; \n if(y%a==0)\n {\n printf(\"-1\");\n retrun 0;\n }\n int ya=y/a+1;\n float xa=x/a2;\n int num=ya+(ya-1)/2;\n if(ya==1||ya%2==0)\n { \n if(xa!=0)\n printf(\"-1\");\n else\n printf(\"%d\",num);\n return 0;\n }\n else\n {\n if(xa>=2||xa<=-2||xa==0)\n {\n printf(\"-1\");\n return 0;\n }\n else \n { \n if(xa>0)\n num++;\n printf(\"%d\",num);\n }\n return 0;\n }\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "040fd10bc4be5c1fea1917c56e92a0a7", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n char A[100];\n int n,i,j,k=0,m,l,r;\n\n scanf(\"%d\",&n);\n scanf(\"%s\",A);\n\n r=n;\n\n for(i=n;i>=0;i--)\n {\n l=0;\n m=j;\n if(i%2==0)\n {\n j=i/2;\n m=j;\n for(k=0;k\n#include \n\nint comp(const void * elem1, const void * elem2)\n{\n\tint f = *((int*) elem1);\n\tint g = *((int*) elem2);\n\tif(f > g) return 1;\n\tif(f < g) return -1;\n\treturn 0;\n}\n\nint main()\n{\n\tlong long int n, w;\n\tscanf(\"%lld %lld\", &n, &w);\n\tlong long int total_volume, a[n], b[n];\n\tfor(int i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%lld\", &a[i]);\n\t\ttotal_volume += a[i];\n\t\tb[i] = a[i]/2 + a[i]%2;\n\t\tw -= b[i];\n\t}\n\tif(w < 0 || total_volume < w)\n\t{\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t} \n\telse\n\t{\n\t\tint max_index = -1, max_volume = -1;\n\t\twhile(w > 0)\n\t\t{\n\t\t\tfor(int i = 0; i < n; i++)\n\t\t\t{\n\t\t\t\tif(a[i] > max_volume)\n\t\t\t\t{\n\t\t\t\t\tmax_volume = a[i];\n\t\t\t\t\tmax_index = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(b[max_index] == a[max_index])\n\t\t\t{\n\t\t\t\ta[max_index] = -1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tint volume = w - (a[max_index] - b[max_index]) < 0 ? w : a[max_index] - b[max_index];\n\t\t\t\tb[max_index] += volume;\n\t\t\t\tw -= volume;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0; i < n; i++)\n\t{\n\t\tprintf(\"%lld \", b[i]);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "f0f3118f8577c214199a13a7a8ca6d0e", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\nint n,p,ans,tot;\nchar a[45][10];\nint main() {\n\tscanf(\"%d%d\",&n,&p);\n\tfor(int i=1; i<=n; i++)scanf(\"%s\",a[i]+1);\n\tfor(int i=n; i>=1; i--) {\n\t\tif(a[i][5]=='p')tot=tot*2+1,ans+=tot*p/2;\n\t\telse tot*=2,ans+=tot*p/2;\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "7a293864ec1ca61c05d9d393c6f75072", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "// DHUOJ solution #297163 @ 2018-05-07 12:08:53.031\n\n#include \n#include \n#include\n#include \n#include\nusing namespace std;\nint num[105];\nsetcards;\nset::iterator it;\nint main()\n{\n int T,N,temp;\n while(~scanf(\"%d\",&N))\n {\n memset(num,0,sizeof num);\n cards.clear();\n for(int i=0;i\n#include \n\nint main()\n{\n int n,k,dem,max=0,z=0,i;\n scanf(\"%d%d\",&n,&k);\n if (n==0)\n printf(\"%d\",k);\n int a[n],b[n];\n for(i=0;imax)\n max=dem;\n }\n int kq,c,sodoi,sopt=1;\n for (i=0;i=k)\n {\n c=max/k;\n if ((float)max/k>0)\n {\n c++;\n kq=sopt*c*k-n;\n }\n kq=0;\n }\n printf(\"%d\",kq);\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2cbae077948db8e3debe823637a2a398", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint is_big(char a)\n{\n\tif(a>='A'&&a<='Z')\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\nint main()\n{\n\tint n;\n\twhile(scanf(\"%d\",&n)!=EOF)\n\t{\n\t\tgetchar();\n\t\tchar a[220];\n\t\tint max=0,sum=0,abc[27];\n\t\tfor(int i=0;imax)\n\t\t\t\t\tmax = sum;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\",max);\n\t}\n\treturn 0;\n } ", "lang_cluster": "C", "compilation_error": false, "code_uid": "ead4be6e0dba089b1941037b86f62dfd", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \nint main(void){\n\tint s,v1,v2,t1,t2;\n\tscanf(\"%d%d%d%d%d\",&s,&v1,&v2,&t1,&t2);\n\tint p1,p2;\n\tif(v1==v2&&t1==t2)\n\t\tprintf(\"Friendship\");\n else{\n\tp1=s/(s*v1-2t1);\n\tp2=s/(s*v2-2t2);\n\tif(p1==p2)\n\t\tprintf(\"Friendship\");\n\tif(p1>p2)\n\t\tprintf(\"First\");\n\tif(p2>p1)\n\t\tprintf(\"Second\");\n}}", "lang_cluster": "C", "compilation_error": true, "code_uid": "979264c0587d9bc71b1d103484f8d8a8", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define REP(i,n) for(int i=0;i<(int)n;++i)\ntypedef long long ll;\n\nconst int dy[] = {1,0,-1,0};\nconst int dx[] = {0,1,0,-1};\n\nint d[100];\nchar s[105];\nint vx[105], vy[105];\nint ix, iy;\nint main() {\n int a,b;\n while(scanf(\"%d%d\", &a, &b) == 2) {\n scanf(\"%s\",s);\n ll y=0,x=0;\n int n = strlen(s);\n REP(i,n) {\n d[i] = strchr(\"URDL\", s[i]) - s;\n }\n\tix = 0;\n\tiy = 0;\n vx[ix++] = 0;\n\tvy[iy++] = 0;\n REP(i,n) {\n y += dy[d[i]];\n x += dx[d[i]];\n\t vy[iy++] = y;\n vx[ix++] = x;\n }\n ll Y = y;\n ll X = x;\n bool ok = 0;\n REP(i,n) {\n REP(j,n) {\n ll yy = vy[j];\n ll xx = vx[j];\n ll y = b-yy;\n ll x = a-xx;\n if (Y && y % Y == 0) {\n if (X*(y/Y) == x) {\n ok = 1;\n }\n }\n if (Y == 0 && y == 0) {\n if (x == 0 || (X && x % X == 0)) {\n ok = 1;\n }\n }\n }\n }\n printf(\"%s\\n\",ok?\"Yes\":\"No\");\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0d31f993ac581f3ac6e61b4171609c15", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\nint main(){\n int n,x,y;\n scanf(\"%d%d%d\",&n,&x,&y);\n if(n==2||((x==n/2 && y==n/2)||(x==n/2 && y==(n/2)+1)(x==(n/2)+1 && y==n/2))){\n printf(\"NO\");\n return 0;\n }\n else {\n printf(\"YES\");\n return 0;\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "7bc812be713261255dbfd07b16c8e0c9", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;\nchar s[233333];\n\nint comp(const void* a,const void* b) {\n\tint arg1=*(int*)(a);\n\tint arg2=*(int*)(b);\n\tif(arg1 < arg2) return -1;\n\tif(arg1 > arg2) return 1;\n return 0;\n}\n\nint main() {\n\t//freopen(\"in.txt\",\"r\",stdin);\n\t//freopen(\"out.txt\",\"w\",stdout);\n\t\n\tscanf(\"%d%d\",&n,&k);\n\tfor(int i=1;i<=n;++i) {\n\t\tscanf(\"%d\",&b[i]);\n\t}\n\tscanf(\"%s\",s+1);\n\tfor(int i=1;i<=n;++i) {\n\t\tif(s[i]=='R') r[++rn]=b[i];\n\t\telse if(s[i]=='O') o[++on]=b[i];\n\t\telse if(s[i]=='W') w[++wn]=b[i];\n\t}\n\tif(on==0) {\n\t\tputs(\"-1\");\n\t\treturn 0;\n\t}\n\tif(rn==0&&wn==0) {\n\t\tputs(\"-1\");\n\t\treturn 0;\n\t}\n\tqsort(r,rn,sizeof(int),comp);\n\tqsort(o,on,sizeof(int),comp);\n\tqsort(w,wn,sizeof(int),comp);\n\tint ans=0,tmp=0,oo=on;\n\tif((rn+oo=k) {\n\t\tfor(int cnt=1;cnt<=k;++cnt) {\n\t\t\tif(r[rn]>o[on]&&rn) ans+=r[rn--];\n\t\t\telse ans+=o[on--];\n\t\t}\n\t}\n\tif(wn+oo>=k) {\n\t\ton=oo;\n\t\tfor(int cnt=1;cnt<=k;++cnt) {\n\t\t\tif(w[wn]>o[on]&&wn) tmp+=w[wn--];\n\t\t\telse tmp+=o[on--];\n\t\t}\n\t}\n\tif(tmp>ans) ans=tmp;\n\tprintf(\"%d\\n\",ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9f97b3a7a9fb48b84683f5fea81b426b", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n cout << (n-2)*(n-2) <\n#include\nint main()\n{\n\tchar box[8][8],ch='B',temp;\n\tint i,j,k,FLAG=0;\n\tfor(i=0;i<8;i++)\n\t{\n\t\tfor(j=0;j<8;j++)\n\t\t{\n\t\t\tscanf(\"%c\",&box[i][j]);\n\t\t\tif(box[i][j-1]==box[i][j]&&J!=0)\n\t\t\tFLAG=1;\t\n\t\t}\t\n\t}\n\t\n\tif(FLAG==1)\n\t{\n\t printf(\"NO\");\n\t exit(0);\n\t}\n\telse\n\t{\n\t\t\n\tj=0;\t\n\t for(i=1;i<8;i++)\n\t {\n\t\n\t\t\n\t\tif(box[i-1][j]==box[i][j])\n\t\t\t{\n\t\t\t\ttemp=box[i][7];\n\t\t\t\tfor(k=7;k>0;k--)\n\t\t\t\t{\n\t\t\t\t\tbox[i][k]=box[i][k-1];\t\n\t\t\t\t}\n\t\t\t\tbox[i][0]=temp;\n \t\t}\n\t\t\t\n\t } \n\t}\n\tprintf(\"YES\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "00b5ec01e0bf171aaa3b9e6942a3b702", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n\n#define ll long long\n\nint main(){\n long long int n, m, s, x ,y;\n\n scanf(\"%lld %lld %lld\", &n, &m, &s);\n\n if (n <= s)\n x = n;\n else\n x = (n-1)/s + 1;\n\n if (m <= s)\n y = m;\n else\n y = (m-1)/s + 1;\n \n if(s < n)\n x *= ((n - 1) %s) + 1;\n\n if(s < m)\n y *= ((m - 1) %s) + 1;\n \n printf(\"I64d\\n\", x*y);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cf972f3ec83a596feb3442ecd36c4168", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\nlong long int a[30000001];\nint main()\n{\n long long int n;\n int i,index;\n\n\n scanf(\"%lld\",&n);\n for(i=1;i<=30000000;i++)\n {\n \ta[i]=i*(i+1LL)/2;\n }\n //for(i=1;i<=10000000;i++)\n // printf(\"%lld\\n\",a[i]);\n for(i=1;1<2;i++)\n {\n \tif(a[i]>=n)\n \t{\n \t\tindex=i;\n \t\tbreak;\n \t}\n }\n index--;\n // printf(\"\\nloda=%lld\\n\",a[index]);\n printf(\"%lld\\n\",n-a[index]);\n\n return 0;\n}\nclose", "lang_cluster": "C", "compilation_error": true, "code_uid": "96030d83efd4dd9aeef2b31ca40a249a", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\nlong long int a[1000000];\nmain()\n{\n\tlong long int temp,j,n,m,b;\n\tint i=0;\n\tscanf(\"%lld%lld\",&n,&m);\n\ttemp=m;\n\twhile(m>n)\n\t{\n\t\tif(m%2==0)\n\t\t{m/=2;\n\t\ta[i]=m;}\n\t\telse if((m-1)%10)==0)\n\t\t{m=(m-1)/10;\n\t\ta[i]=m;}\n\t\ti++;\n\t}\n\tif(m!=n)\n\tprintf(\"NO\");\n\telse\n\t{\n\t\tprintf(\"YES\\n\");\n\t\tprintf(\"%d\\n\",i+1);\n\t\tfor(j=i-1;j>=0;j--)\n\t\tprintf(\"%d \",a[j]);\n\t\tprintf(\"%d\",temp);\n\t}\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3cc417f358f7f3f47c23a327e76363f5", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\nint main(){\nchar c;int l;\n scanf(\"%c%d\",&c,&l);\nif(c=='a'||c=='h'){\n if(l==1||l==8)\n printf ('3');\nelse printf('5');\n \n}\nelse printf('8');\n\nreturn 0;\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "cb4df3709856dfc88a01a004690b43c9", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \nmain() {printf(\"INTERCAL\");}", "lang_cluster": "C", "compilation_error": false, "code_uid": "4cb23ae0b78e15a510d1b1ec67277f0b", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define N 111111\n#define M 1000000007\ntypedef long long ll;\nint n, dp[N], ind, ans[N], first[N];\nint strint(char *a){\n int len=strlen(a), tmp=0;\n for (int i=len-1, j=1; i>=0; i--, j*=10)\n tmp+=(a[i]-'0')*j;\n return tmp;\n}\nvoid solve(char *a){\n int len=strlen(a);\n if (len>6)\n return ;\n dp[ind]=strint(a);\n ind++;\n char *tmp=(char *) malloc((len*2)*sizeof(char));\n for (int i=0; ib?a:b;}\nint min(int a, int b) {return abb?1:0;\n}\nint main(){\n scanf(\"%d\", &n);\n char *tmp=(char *) malloc(2*sizeof(char));\n tmp[0]='1', tmp[1]='\\0';\n solve(tmp);\n qsort(dp, ind, sizeof(int), comp);\n ans[0]=0;\n for (int i=1; i<=n; i++){\n ans[i]=INT_MAX;\n for (int j=0; j=0&&ans[i-dp[j]]+10){\n printf(\"%d \", first[n]);\n n-=first[n];\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0786d927b763f36ff8ea438eed8bf06b", "src_uid": "033068c5e16d25f09039e29c88474275", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\nlong long int cal[5001][5001];\nint main()\n{\nlong long int n,a,b,k,prev[5001],cur[5001],i,j,dist,count[5001],c1,h,ans;\nscanf(\"%lld %lld %lld %lld\",&n,&a,&b,&k);\nfor(i=1;i<=n;i++)\n prev[i]=0;\nprev[a]=1;\nfor(i=1;i<=5000;i++)\n count[i]=0;\nfor(i=1;i<=n;i++)\n{\n for(j=1;j<=n;j++)\n {c1=b-j;\nif(c1<0)\n c1=-c1;\n dist=j-i;\n if(dist<0)\n dist=-dist;\n if(i!=j&&dist\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n int ans = 0;\n for(int i = 2; i < n; ++i) {\n ans += i * (i + 1);\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0d24174088717e3b6cfcb799157ddd30", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "\n#include \n\n#include \n\nint main() \n\n{\n \n int n , k ;\n \n scanf(\"%d %d\",&n,&k) ; \n \n char lotus[100] , eater[100] ;\n \n scanf(\"%s\",lotus) ; // char paie = getchar() ;\n \n char swap ;\n \n for( int a = 0 ; a < (n-1) ; a++ ) {\n \n for( int b = a+1 ; b < n ; b++ ) {\n \n if( lotus[a] > lotus[b] ) {\n \n swap = lotus[b] ;\n \n lotus[b] = lotus[a] ;\n \n lotus[a] = swap ;\n \n }\n \n }\n \n }\n /*\n //puts(lotus) ;\n \n strcpy(eater,lotus) ;\n \n // puts(eater) ;\n \n int d ;\n \n n = strlen(eater) ;\n \n for( int c = 0 ; c < (n-1) ; c++ ) {\n \n int x = (eater[c+1] - eater[c] ) ;\n \n if( x == 1 ) {\n \n for( d = c+1 ; d < n ; d++ ) {\n \n eater[d] = eater[d+1] ;\n \n } \n \n }\n \n n-- ;\n \n }\n puts(eater) ; */\n /*int sum = lotus[0] - 96 ;\n for( int e = 0 ; e 1 ) {\n \n sum = sum + lotus[e+1] - 96 ;\n \n }\n \n }\n if(sum==1 && sum= 2 ) {\n \n sum = sum + lotus[i] - 96 ;\n \n count++ ;\n \n x = lotus[i] ;\n \n if(count==k) \n \n { break ; }\n \n \n \n }\n \n }\n \n if( count > k ) {\n \n printf(\"-1\\n\") ;\n \n }\n \n \n else {\n \n printf(\"%d\\n\",sum) ;\n \n }\n \n return 0 ;\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e4fe1d15aabd7093b75e54ec1c166b4e", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\nlong long a[1005];\nint main()\n{\n\tlong long n,k,x;\n\tint i,j=0; \n\tscanf(\"%lld %lld\",&n,&k);\n\tfor(i=1;i\n\nint main()\n{\n\tint arr[3][3];\n\tint x,y;\n\t\n\tfor(x=0;x<3;x++)\n\t{\n\t\tfor(y=0;y<3;y++)\n\t\t{\n\t\t\tscanf(\"%d\",&arr[x][y]);\n\t\t}\n\t}\n\t\n\tint a,f,b,c,d,e;\n\ta=arr[0][1];\n\tb=arr[0][2];\n\tc=arr[1][2];\n\td=arr[1][0];\n\te=arr[2][0];\n\tf=arr[2][1];\n\t\n\tarr[0][0] = (a+f+b+c-d-e)/2;\n\tarr[1][1] = (-a-f+b+c+d+e)/2;\n\tarr[2][2] = (a+f-b-c+d+e)/2;\n\t\n\tfor(x=0;x<3;x++)\n\t{\n\t\tfor(y=0;y<3;y++)\n\t\t{\n\t\t\tprintf(\"%d \",arr[x][y]);\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "98c0720bd2f832be07b6968592e8fa92", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\nchar min(char a,char b)\n{\n\treturn a>b?b:a;\n}\nint main()\n{\n\tchar str1[102];\n\tchar str2[102];\n\twhile(gets(str1))\n\t{\n\t\tchar str[102];\n\t gets(str2);\n\t bool temp=false;\n\t for(int i=0;istr1[i])\n\t \t{\n\t \t\ttemp=true;\n\t\t }\n\t\t if(temp)break;\n\t\t str[i]=min(str2[i],str1[i]);\n\t }\n\t if(temp)printf(\"-1\\n\");\n\t else puts(str);\n\t}\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "80987edc2c3d1f6e6fb738c7e9acad4e", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "GNU C", "source_code": "#include\nint a,b,c,d,n;\nint main()\n{\n scanf(\"%d %d %d\",&a,&b,&c);\n for(d=0;d\n#include \nusing namespace std;\n\n/**\n * http://codeforces.com/contest/861/problem/A\n * */\nlong gcd(long a, long b) {\n long mod = a % b;\n while(mod > 0) {\n a = b;\n b = mod;\n mod = a % b;\n }\n return b;\n}\n\nlong round(long n, long k) {\n long kk = 1;\n while(k > 0) {\n kk *= 10;\n k--;\n }\n long g = gcd(n, kk);\n return n * kk / g;\n}\n\nint main() {\n long n, k;\n scanf(\"%ld %ld\", &n, &k);\n// printf(\"%ld\\n\", round(n, k));\n cout << round(n, k);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2b1bd6a7add2dea0abb44e0405e1c95e", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n//long long int asd( long long int r);\n\nint main()\n{\n int n, b, p, m, r;\n scanf(\"%d %d %d\", &n, &b, &p);\n r=n;\n int ans=0;\n while(r>1)\n {\n m=(r)/2; ans+=m; //r+=m-pow(2,m);\n r+=m-m*2;\n }\n b=ans*(b*2+1);\n p=p*n;\n printf(\"%d %d\\n\", b, p);\n}\n\n\n/*long long int asd( long long int r)\n{\n long long int m=0; while(r>0)\n {\n r/=2;\n m++;\n }\n return m-1;\n}*/\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2f22978e1b33ef462e621dcb4ae15f07", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\nint main()\n{\n\tlong long int k,i,j,a,b,l,flag=0;\n\tscanf(\"%lld\",&k);\n\tchar arr[15] =\"codeforces\";\n\t// for(i=0;i<10;i++)\n\t// {\n\t// \tprintf(\"%c-%lld\\n\",arr[i],i);\n\t// }\n\ta=1,b=2;\n\twhile(1)\n\t{\n\t\tfor(i=0;i<=10;i++)\n\t\t{\n\t\t\tif(int(pow(b,i)*pow(a,10-i))>=k)\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==1)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\ta++;\n\t\tb++;\n\t}\n\tfor(j=1;j<=i;j++)\n\t{\n\t\tfor(l=1;l<=b;l++)\n\t\t{\n\t\t\tprintf(\"%c\",arr[j-1]);\n\t\t}\n\t}\n\tfor(j=i+1;j<=10;j++)\n\t{\n\t\tfor(l=1;l<=a;l++)\n\t\t{\n\t\t\tprintf(\"%c\",arr[j-1]);\n\t\t}\n\t}\n\tprintf(\"\\n\");\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "b4f33c37b14bbcafd9925e07832561db", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n;\n scanf(\"%d\", &n);\n int count=0;\n int i,k,z,j=0;\n if(n>100)\n z=n-100;\n else\n z=1;\n int b[n/2];\n for(i=z;i0)\n {\n j=j+(k%10);\n k=k/10;\n }\n j=j+i;\n if(j==n)\n {\n b[count]=i;\n count++;\n }\n }\n printf(\"%d\\n\", count);\n for(i=0;i\nint comp(const void* a, const void* b)\n{\n return *(int *)a - *(int *)b;\n}\nint main()\n{\n int n,d;\n scanf(\"%d %d\",&n,&d);\n int *arr=(int *)malloc(sizeof(int)*n);\n int i;\n int sum=0;\n for(i=0;in)\n ans=sum-((m-n)*d);\n else\n {\n for(i=0;i\n#include \n#include \n#include \n\nint a, b;\nint abs(int p, int q){\n return (p-q)>0 ? (p-q) : (q-p);\n}\n\nint win(int num){\n if(abs(num,a) < abs(num,b)){\n return -1;\n }else if(abs(num,a) > abs(num,b)){\n return 1;\n }else{\n return 0;\n }\n}\n\nint main(){\n int aw = 0, d = 0, bw = 0;\n scanf(\"%d %d\",&a,&b);\n for(int i=1; i<=6; i++){\n if(win(i) == -1){\n aw++;\n }else if(win(i) == 1){\n bw++;\n }else{\n d++;\n }\n }\n printf(\"%d %d %d\\n\",aw,d,bw);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "eef4c11a63e67ecb4c7377aa24f8b651", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n\n\nvoid sort(int* seg,int x);\nvoid judge(int* seg,int x);\n\nint main() {\n\tint seg[100001] = { '\\0' };\n\tint numOfLine,temp;\n\tscanf_s(\"%d\", &numOfLine);\n\tfor (int i = 0; i < numOfLine; i++) {\n\t\tscanf_s(\"%d\", &temp);\n\t\tseg[i] = temp;\n\t}\n\tsort(seg, numOfLine);\n\tjudge(seg,numOfLine);\n\n}\n\nvoid sort(int* seg,int x) {\n\tint isChanged = 0;\n\tfor (int i = 0; i < x; i++) {\n\t\tisChanged = 0;\n\t\tfor (int j = 0; j < x-1; j++) {\n\t\t\tif (seg[j] > seg[j + 1]) {\n\t\t\t\tint temp = seg[j];\n\t\t\t\tseg[j] = seg[j + 1];\n\t\t\t\tseg[j + 1] = temp;\n\t\t\t\tisChanged = 1;\n\t\t\t}\n\t\t}\n\t\tif (!isChanged)\n\t\t\tbreak;\n\t}\n\t\n}\n\nvoid judge(int* seg,int x) {\n\tint pd = 1;\n\tfor (int i = 1; i < x - 1; i++) {\n\t\tif (seg[i - 1] + seg[i] > seg[i + 1]) {\n\t\t\tpd = 1;\n\t\t\tbreak;\n\t\t}\n\t\telse {\n\t\t\tpd = 0;\n\t\t}\n\t}\n\tif (pd)\n\t\tprintf(\"yes\");\n\telse\n\t\tprintf(\"no\");\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "81d5e5bbb44b46e0f6f6d93fc424737f", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint cmp(const void *a,const void *b) {\n\treturn strcmp(*(char **)a,*(char **)b);\n}\n\nint main() {\n\tchar s[101];\n\tscanf(\"%s\\n\",s);\n\tint i,m,l=strlen(s);\n\tchar *x[l],*p,*q;\n\tp=s;\n\twhile (*p) {\n\t\tx[p-s]=p;\n\t\tp++;\n\t}\n\tqsort(x,l+1,sizeof *x,cmp);\n\tm=0;\n\tfor (i=1;im) m=p-x[i];\n\t}\n\tprintf(\"%d\\n\",m);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "644171b035836b3a1f2bfbbb266cc513", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n {\n int m,n,count=0;\n char ch;\n scanf(\"%d %d\",&m,&n);\n int grid[m][n];\n char line[n];\n fflush(stdin);\n for(int i=0;i\n\nchar vec[101];\n\nint main() {\n\tint n, x = 0, y = 0;\n\tscanf(\"%d\", &n);\n\t\n\tscanf(\"%s\", vec);\n\n\tfor (int i = 0; i <= n; i++) {\n\t\tif (vec[i] == 'L') x--;\n\t\tif (vec[i] == 'R') x++;\n\t\tif (vec[i] == 'D') y--;\n\t\tif (vec[i] == 'U') y++;\n\t\n\t\tif (x == 0 && y == 0) { printf(\"%d\", i + 1); \tgetch(); return 0; }\n\t}\n\tprintf(\"0\");\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "2445eaee96932f375931fdb67c009bb6", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint Destroy(int *Data, int Len)\n{\n int i, j;\n int Pre = Data[0];\n int Con = 1;\n for(i=1; i 2)\n {\n for(j=i-Con; j 2)\n {\n return Con + Destroy(Data, Len-Con);\n }\n return 0;\n}\n\nint Fun(int *Data, int Len, int idx)\n{\n int Array[101];\n memcpy(Array, Data, idx*sizeof(int));\n Array[idx] = Data[idx - 1];\n memcpy(Array+idx+1, Data+idx, (Len-idx)*sizeof(int));\n return Destroy(Array, Len+1);\n}\n\nint main()\n{\n int N, K, X, i, Max, Sum;\n int Data[101];\n scanf(\"%d %d %d\", &N, &K, &X);\n for(i=0; i0 && Data[i-1]==X)\n {\n Sum = Fun(Data, N, i+1)-1;\n if(Sum > Max)\n {\n Max = Sum;\n }\n }\n }\n printf(\"%d\\n\", Max);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8ac3eaf3fde10b8df4ce09a7ac598d22", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int d,k,a,b,t,s1,s2,s3,s4,s,x,y,z;\n scanf(\"%lld %lld %lld %lld %lld\",&d,&k,&a,&b,&t);\n if(d<=k)\n {\n printf(\"%lld\\n\",a*d);\n }\n else if(d%k==0)\n {\n if(a*k+t>=b*k)\n {\n s=a*k+(d-k)*b;\n }\n else\n {\n s=((d/k)-1)*t+d*a;\n }\n printf(\"%lld\\n\",s);\n }\n else\n {\n x=d/k;\n z=d%k;\n y=x*k;\n if(a*k+t>=b*k)\n {\n s=a*k+(y-k)*b;\n }\n else\n {\n s=(x-1)*t+y*a;\n }\n if(t+z*a>=b*z)\n {\n s=s+b*z;\n }\n else\n {\n s=s+t+z*a;\n }\n printf(\"%lld\\n\",s);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3b09f7c6ef61962dfe0f4b8f51b6fd32", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n\tint n, y;\n\tint i, x;\n\tint a;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 1; i <= n; i++)\n\t{\n\t\tscanf_s(\"%d\", &x);\n\t\tfor (y = 0; x >= 10; y++)\n\t\t\tx /= 10;\n\t\ty += 1;\n\t\tfor (a = 0; y > 0; y--)\n\t\t\ta += y;\n\t\ta += ((x - 1) * 10);\n\t\tprintf(\"%d\\n\", a);\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e7d890291d62a9b7425c0299ca0e862b", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#define INF ~0ULL\n#define ULL unsigned long long\nULL p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};\nULL n, ans;\nvoid dfs(ULL depth, ULL temp, ULL num, ULL up)\n{\n if (num == n && temp < ans) ans = temp;\n if (num >= n || depth == 16) return;\n for (int i = 1; i <= up; ++i)\n {\n if (temp * p[depth] >= ans) return;\n else dfs(depth + 1, temp = temp * p[depth], num * (i + 1), i);\n }\n}\nint main()\n{\n while (scanf(\"%llu\", &n) != EOF)\n {\n ans = INF;\n dfs(0, 1, 1, 64);\n printf(\"%llu\\n\", ans);\n }\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "2742fc47bfd983f8cfac9986fa6a345f", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "/*\nID: mohamma73\nLANG: C\nTASK: crypt1\n*/\n\n#include\"stdio.h\"\n#include\"stdlib.h\"\n#include\"ctype.h\"\n#include\"math.h\"\n#include\"string.h\"\nstruct card{\n\tint val;\n\tchar suit;\n\tint id;\n};\nstruct point{\n\tint x;\n\tint y;\n\tint visit;\n};\nstruct node{\n\tint id;\n\tint n;\n\tint nei[102];\n};\nstruct person{\n\tint id;\n\tint nd;\n\tint nl;\n\tint like[2004];\n\tint dis[2004];\n\tint visit;\n};\nstruct farmer{\n\tint p;\n\tint c;\n};\nvoid inc(int *a,int n){\n\tint i;\n\tif(a[0]!=2){\n\t\ta[0]++;\n\t\treturn;\n\t}\n\tfor(i=0;it[j])\n\t\treturn 1;\n\telse if(s[i]0 && a[j]0 && a[j-1]>a[j];j--){\n\t\t\t\ttemp=a[j];\n\t\t\t\ta[j]=a[j-1];\n\t\t\t\ta[j-1]=temp;\n\t\t\t\n\t\t}\n}\nvoid fun(int n,char *s){\n\tint i=0;\n\tfor(i=0;n/10!=0;i++,n/=10)\n\t\ts[i]=n%10+'0';\n\ts[i++]=n+'0';\n\ts[i]='\\0';\n}\nvoid sortIn(int *a,int *indx,int n){\n\tint t1;\n\tint i,j;\n\tfor(i=1;i0 && a[j-1]>a[j];j--){\n\t\t\tt1=a[j-1];\n\t\t\ta[j-1]=a[j];\n\t\t\ta[j]=t1;\n\t\t\tt1=indx[j-1];\n\t\t\tindx[j-1]=indx[j];\n\t\t\tindx[j]=t1;\n\t\t}\n}\nint valid(int *a,int l,int r,int n){\n\tint f=0;\n\tif(l>0 && a[l-1]>a[r])\n\t\tf=1;\n\tif(a[l+1]a[l])\n\t\tf=1;\n\tif(r0)\n\t\t\tstripe[0]=colors[stripe[0]-'A'-1];\n\t\telse\n\t\t\tstripe[0]=colors[stripe[0]-'A'+1];\n\t\treturn ;\n\t}\n\tfor(j=0;j0){\n\t\t\tif(stripe[j]==stripe[j+1])\n\t\t\t\tstripe[j]=colors[stripe[j]-'A'-1];\n\t\t\telse if(stripe[j+1]!=colors[stripe[j]-'A'-1])\n\t\t\t\tstripe[j]=colors[stripe[j]-'A'-1];\n\t\t\telse if(stripe[j]-'A'x==pts[j]->x || nom[i]->y==pts[j]->y){\n\t\t\t\tif(pts[j]->visit==0){\n\t\t\t\t\tinvite[idx++]=pts[j];\n\t\t\t\t\tpts[j]->visit=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\t\n\t}\n\treturn idx;\n}\nint feasible(struct person *a[],int n){\n\tint i,j,k;\n\tint flag=1;\n\tfor(i=0;flag && ind;j++)\n\t\t\tfor(k=0;flag &&kid==a[i]->dis[j]){\n\t\t\t\t\tflag=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\tif(i==n)\n\t\treturn 1;\n\treturn 0;\n}\nint find(struct node *p,struct node *node[]){\n\tint i,j,k;\n\tint count=0;\n\tfor(i=0;in;i++){\n\t\tif(p->nei[i]==-1)\n\t\t\tcontinue;\n\t\tfor(j=0;jnei[i]]->n;j++){\n\t\t\tif(node[p->nei[i]]->nei[j]==-1)\n\t\t\t\tcontinue;\n\t\t\tfor(k=0;kn;k++){\n\t\t\t\tif(p->nei[k]==-1)\n\t\t\t\t\tcontinue;\n\t\t\t\tif(node[p->nei[i]]->nei[j]==p->nei[k])\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\t\t\n\treturn count;\n}\nvoid rem(struct node *p,struct node *nodes[],int n){\n\tint i,j;\n\tfor(i=0;in;j++)\n\t\t\tif(nodes[i]->nei[j]==p->id)\n\t\t\t\tnodes[i]->nei[j]=-1;\n\t}\n}\nint dfs3(struct card piles[],int n,int a[55][55][55][55]){\n\tint dfs1(struct card[],int,int [][][][]);\n\tif(n<=3)\n\t\treturn 0;\n\tif(a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]!=-1)\n\t\treturn a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id];\n\tif(piles[n-1].suit==piles[n-4].suit || piles[n-1].val==piles[n-4].val){\n\t\tstruct card p[n];\n\t\tint i;\n\t\tfor(i=0;i2)\n\t\tif(a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]!=-1)\n\t\t\t\t\treturn a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id];\n\tif(piles[n-1].val==piles[n-2].val || piles[n-1].suit==piles[n-2].suit){\n\t\tstruct card p[n-1];\n\t\tint i;\n\t\tfor(i=0;i\n#include\nusing namespace std;\n\n \nint main () \n{\n \nstring arr;\n \ncin >> arr;\n \nint x, y, z, i = 0;\n \n \nx = arr.find ('+'); //sticks before plus\n \ny = arr.find ('=') - x - 1; //sticks btw plus and equal\n \nz = arr.length () - y - x - 2; //sticks after equal\n \n \n \nif ((x + y) == z)\n \n {\n \ncout << arr << \"\\n\";\n \n}\n \n else if ((x + y + 1) == (z - 1))\n \n {\n \nfor (i = 0; i < x + 1; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \ncout << '+';\n \nfor (i = 0; i < y; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \ncout << '=';\n \nfor (i = 0; i < z - 1; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \n}\n \n \n else if ((x > 1) && ((x + y - 1) == (z + 1)))\n \n {\n \nfor (i = 0; i < x - 1; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \ncout << '+';\n \nfor (i = 0; i < y; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \ncout << '=';\n \nfor (i = 0; i < z + 1; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \n}\n \n \n else if ((y > 1) && ((x + y - 1) == (z + 1)))\n \n {\n \nfor (i = 0; i < x; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \ncout << '+';\n \nfor (i = 0; i < y - 1; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \ncout << '=';\n \nfor (i = 0; i < z + 1; i++)\n\t\n\t{\n\t \ncout << '|';\n\t\n}\n \n}\n \n else\n \ncout << \"Impossible\";\n \n \nreturn 0;\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e4f8f404a23448986b9d7dc391b32c83", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6", "difficulty": null} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main()\n{\n long long int i,n,m,k,l,r,cnt,mid;\n scanf(\"%I64d%I64d%I64d\",&n,&m,&k);\n left=1;\n right=n*m+1;\n while (l\n\nint\nmain() {\n int n, a = 1, b = 1, c, k = 0;\n scanf(\"%d\", &n);\n while (a + b <= n) {\n k++;\n c = a + b; a = b; b = c;\n }\n printf(\"%d\\n\", k);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e00967b637a943a9ba4e9393dd984eed", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b10171098c1d405b617ada6824695d8e", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include\r\nint main(){\r\n int t;\r\n scanf(\"%d\",&t);\r\n \r\n while(t--){\r\n int n,k;\r\n int max=1e9+7;\r\n scanf(\"%d%d\",&n,&k);\r\n long long int ans=1;\r\n for(int i=1;i<=n;i++){\r\n ans=(ans*i)%max;\r\n }\r\n printf(\"%lld\",ans)\r\n }\r\n return 0;\r\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "28098e1dc1b64370dde2bfb03ec908df", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{\n int n;\n scanf(\"%d\",&n);\n char s1[n+1],s2[n+1];\n int i;\n gets(s1);\n gets(s1);\n for (i=0;i\n#include \n\nint main()\n{\n int i, j, len, flag=0;\n char s[105];\n\n scanf(\"%s\", s);\n len=strlen(s);\n\n for(i=0;i\n#include\n#include\nlong long int mod = 1000000007;\nlong long int add(long long int a, long long int b)\n{\n\tlong long temp = a + b;\n\treturn (temp%mod);\n}\nlong long int mult(long long int a, long long int b)\n{\n\tlong long temp=a*b;\n\treturn (temp%mod);\n}\nlong long int f[500001];\nint main()\n{\n\tlong long int l, r, t,i;\n\tscanf_s(\"%I64d %I64d %I64d\", &t, &l, &r);\n\tfor (i = 0; i <= r; i++)\n\t\tf[i] = 1e18;\n\tlong long int ans=0,power=1,j,temp,g;\n\tf[1] = 0;\n\tfor (i = 1; i <= r; i++)\n\t{\n\t\tfor (j = 2 * i; j <= r; j += i)\n\t\t{\n\t\t\tg = j / i;\n\t\t\ttemp = add(mult(((g*(g - 1)) / 2), i), f[i]);\n\t\t\tif (f[j] > temp)\n\t\t\t\tf[j] = temp;\n\t\t}\n\t}\n\tfor (i = l; i <= r; i++)\n\t{\n\t\tans = add(ans, mult(power, f[i]));\n\t\tpower *= t;\n\t}\n\tprintf(\"%I64d\\n\", ans);\n\tfflush(stdin);\n\tgetchar();\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "bbe786957ec6a5fe93aa2ec3371bdc56", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\nchar s[30];\nint a[30];\nint main()\n{\n scanf(\"%s\",s);\n int target=s[0]-'A'+1;\n int last=target;\n a[0]=target;\n for(int i=1;s[i]!='\\0';i++)\n {\n int temp=s[i]-'A'+1;\n a[i]=temp;\n if(temp==last)\n {\n printf(\"Impossible\\n\");\n return 0;\n }\n last=temp;\n }\n for(int i=0;i<=26;i++)\n {\n for(int j=i+1;j<=26;j++)\n if(a[i]==a[j])\n target=a[i];\n }\n int flag=0;\n int start,end;\n start=end=0;\n for(int i=0;i<=27;i++)\n {\n if(a[i]==target&&flag==0)\n start=i,flag=1;\n else if(a[i]==target&&flag!=0)\n end=i;\n }\n int mid=(end-start-1)/2+start;\n //printf(\"%d\\n\",mid);\n if(mid>13){\n for(int i=mid-13;i=0;i--)\n printf(\"%c\",a[i]+'A'-1);\n for(int i=26;i>=mid;i--)\n {\n if(i==end) continue;\n printf(\"%c\",a[i]+'A'-1);\n }\n printf(\"\\n\");\n } else\n {\n for(int i=mid+1;i<=mid+13;i++)\n printf(\"%c\",a[i]+'A'-1);\n printf(\"\\n\");\n for(int i=mid;i>=0;i--)\n {\n if(i==start) continue;\n printf(\"%c\",a[i]+'A'-1);\n }\n for(int i=26;i>=mid+14;i--)\n printf(\"%c\",a[i]+'A'-1);\n printf(\"\\n\");\n }\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "55f9a61f021447ca51da81ca4bf2aad1", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#define ll long long int \nint main()\n{\n\tll a,b;\n\tscanf(\"%I64d%I64d\",&a,&b);\n\tif(a==b)\n\t{\n\t\tprintf(\"infinity\\n\");\n\t}\n\telse\n\t{\n\t\tll i,num=a-b;\n\t\tll ans=1;\n\t\tfor(i=2;i<=sqrt(num);i++)\n\t\t{\n\t\t\tif(num%i==0)\n\t\t\t{\n\t\t\t\tif(a%i==b)\n\t\t\t\t{\n\t\t\t\t\tans+=1;\n\t\t\t\t}\n\t\t\t\tif(i!=num/i)\n\t\t\t\t{\n\t\t\t\t\tif(a%(num/i)==b)\n\t\t\t\t\t\tans+=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintf(\"%I64d\\n\"ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "1adebbbb09dabc7ea6b1d335d5c0d58b", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \nusing namespace std; \nint jl[100]; \nint main() \n{ \n \n int n,k,c=0; \n cin>>n>>k; \n if(k==1) \n { \n cout<\n\nint lTime(int h, int a, int d) {\n int i=-1;\n if(d>=a) return 999999999;\n while(h>0){\n h=h-(a-d);\n i++;\n }\n return i;\n}\nint main() {\n int yh,ya,yd;\n int mh,ma,md;\n int h,a,d;\n int lh,la,ld=1000;\n int i,j,k,cost,min=999999999,yaa=0;\n scanf(\"%d %d %d\",&yh,&ya,&yd);\n scanf(\"%d %d %d\",&mh,&ma,&md);\n scanf(\"%d %d %d\",&h,&a,&d);\n/*\n for(i=0;i<10000;i++)\n if(lTime(yh+i,ma,yd)>lTime(mh,ya,md)) \n break;\n lh=i;\n for(i=0;i<10000;i++)\n if(lTime(yh,ma,yd)>lTime(mh,ya+i,md)) \n break;\n la=i;\n for(i=0;i<10000;i++)\n if(lTime(yh,ma,yd+i)>lTime(mh,ya,md)) \n break;\n ld=i;\n*/\n lh=(h>10)?10000/h:1000;\n la=(a>10)?10000/a:1000;\n ld=(d>10)?10000/d:1000;\n if(ya<=md) yaa=md-ya+1;\n// printf(\"%d %d %d\\n\",lh,la,ld);\n for(i=0;ilTime(mh,ya+j,md)) {\n cost=i*h+j*a+k*d;\n if(cost\n#include \n\nint main()\n{\n\n char arr[100];\n int i,c=0,o=0,d=0,f=0,r=0,e=0,s=0;\n gets(arr);\n for(i=0;arr[i]!='\\0';i++)\n {\n if(arr[i]=='C')\n {\n for(c=i+1;arr[c]!='\\0';c++)\n {\n if(arr[c]=='O')\n {\n for(o=c+1;arr[o]!='\\0';o++)\n {\n if(arr[o]=='D')\n {\n for(d=o+1;arr[d]!='\\0';d++)\n {\n if(arr[d]=='F')\n {\n for(f=d+1;arr[f]!='\\0';f++)\n {\n if(arr[f]=='O')\n {\n for(o2=f+1;arr[o2]!='\\0'o2++)\n {\n if(arr[o2]=='R')\n {\n for(r=o2+1;arr[r]!='\\0';r++)\n {\n if(arr[r]=='C')\n {\n for(c2=r+1;arr[c2]!='\\0';c2++)\n {\n if(arr[c2]=='E')\n {\n for(e=c2+1;arr[e]!='\\0';e++)\n {\n if(arr[e]=='S')\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n else\n printf(\"NO\\n\");\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n }\n else\n printf(\"NO\\n\");\n }\n return 0;\n}\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "91334a427b229c6b5c409688022e4b14", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nusing namespace std;\n\nint main()\n{\n char s[100], r[100], back[100];\n int ch[26] = {0};\n cin>>s;\n sort(s, s+strlen(s));\n //cout<=0 && ch[i]==0; i--){\n\n }\n int k=0;\n for(int j=0; j\n#include\n#define MAX 100\nvoid nhapmang(int a[], int n)\n{\n\tfor (int i = 0; i\nint i, n, c;\nint main() {\n scanf(\"%d\", &n);\n while (n) {\n i++;\n if (i & 1) {\n if (n > 0) n--;\n else break;\n c++;\n } else {\n if (n > 1) n -= 2;\n else break;\n c++;\n }\n }\n print(\"%d\", c);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "eace78369ed29d67672f5f9f4445fb57", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n long long int xa,xb,xc,ya,yb,yc ;\n scanf(\"%I64d%I64d\",&xa,&ya);\n scanf(\"%I64d%I64d\",&xb,&yb);\n scanf(\"%I64d%I64d\",&xc,&yc);\n double m1 , m2 ;\n if(xb!=xa)\n m1=atanf((yb-ya)/(xb-xa));\n else\n m1=asinf(1);\n if(xc!=xb)\n m2=atanf((yc-yb)/(xc-xb));\n else\n m2=asinf(1);\n if(m1==m2)\n printf(\"TOWARDS\");\n else if(m2>m1)\n printf(\"LEFT\");\n else\n printf(\"RIGHT\");\n getch();\n }\n \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cb2692b3bb1efb7adbe9d8d62da384b2", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint a,b,c;\n\tint two = 0,three = 0,four = 0;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tint miny = 2000;\n\tif (a < miny) miny = a;\n\tif (b < miny) miny = b;\n\tif (c < miny) miny = c;\n\t\n\tif (a == 2) two++;\n\tif (b == 2) two++;\n\tif (c == 2) two++;\n\t\n\tif (a == 3) three++;\n\tif (b == 3) three++;\n\tif (c == 3) three++;\n\t\n\tif (a == 4) four++;\n\tif (b == 4) four++;\n\tif (c == 4) four++;\n\t\n\tif (miny > 3) printf(\"NO\\n\");\n\telse\n\t{\n\t\tif (miny == 1) printf(\"YES\\n\");\n\t\telse if (three == 3) printf(\"YES\\n\");\n\t\telse\n\t\t{\n\t\t\tif (two == 2 || two == 3) printf(\"YES\\n\");\n\t\t\telse if (two == 1 && three == 2) printf(\"YES\\n\");\n\t\t\telse if (four == 2 && two == 1) printf(\"YES\\n\");\n\t\t\telse printf(\"NO\\n\");\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "74259c0557e6ff59ae864ce9077a631d", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \nint n, m, tz, a[11], h = 0, i = 0, j, zero = 0, z = 0;\nint main()\n{\n scanf(\"%d\",&n);\n scanf(\"%d\",&m);\n int g = n;\n // printf(\"%d\\n\", n);\n while(g > 0)\n {\n a[z] = g % 10;\n g = g / 10;\n // printf(\"%d\\n\", a[z]);\n z++;\n //printf(\"%d\", z);\n }\n for(i = 0; i a[j + 1]){\n tz = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tz;\n }\n //for(j = 0; j < z; j++)\n //printf(\"%d, %d\\n\", a[j], j);\n \n for(i = 0; i <=z; i++)\n {\n if(h > 0 && h < 10 )\n for(j = 1; j < zero; j++) h = h * 10;\n \n \n if(h == 0 && a[i] == 0 ) zero++;\n else\n {\n h = h * 10;\n h += a[i];\n }\n p//rintf(\"%d\\n\", zero);\n }\n //printf(\"%d\", h);\n if(h == m)printf(\"OK\");\n else\n printf(\"WRONG_ANSWER\");\n return 0;\n}\n\n\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "28554a3497425f5d2941b9d2ad881c81", "src_uid": "d1e381b72a6c09a0723cfe72c0917372", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\ntypedef long long int lli;\n\nlli FindFor(lli X)\n{\n\t lli ans=1;\n\n\tif(X%2==0)\n\t{\n\t\t ans=2;\n\t\t while(X%2==0)\n\t\t\tX>>=1;\n\t}\n\n\tfor(lli i=3;i<=sqrt(X);i+=2)\n\t{\n\t\tif(X%i==0)\n\t\t{\n\t\t\tans=ans*i;\n\t\t\twhile(X%i==0)\n\t\t\t\tX=X/i;\n\t\t}\n\t}\n\n\t if(X>2)\n\t\tans=ans*X;\n\n\treturn ans;\n}\n\nint main()\n{\n lli N;\n\n scanf(\"%I64d\",&N);\n printf(\"%I64d\",FindFor(N));\n\n \n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "8bf9c02d6942ed230cc1a89914b55d81", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "// In the name of **** God ****\n\n/*\n\nCopyright (C) oofMan\n\n Morocco\n\ncreated : 30/3/2019\n\t\n*/\n#include \n#include \n\nusing namespace std;\n\ninline void oofMan() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL); cout.tie(NULL);\n}\n\nchar m[4][4];\nint main(void) {\n\t//oofMan();\n\tbool flag=false;\n\tint xc[3]={1,0,1};\n\tint yc[3]={0,1,1};\n\tfor(int i=0 ;i<4 ;i++)\n\t\tfor(int j=0 ; j<4 ;j++)\n\t\t\tscanf(\"%c\",&m[i][j]);\n\n\tfor(int i=0 ;i<3 ;i++)\n\t\tfor(int j=0 ; j<3 ;j++){\n\t\t\tint counter=0;\n\t\t\tfor(int k=0;k<3;k++){\n\t\t\t\tif(i+xc[k]<4 && j+yc[k]<4)\n\t\t\t\t\tif(m[i][j]!=m[i+xc[k]][j+yc[k]])\n\t\t\t\t\t\tcounter++;\n\t\t\t}\n\t\t\tif(counter==3 || counter<=1){\n\t\t\t\tflag=true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\n\tprintf(\"%s\",(flag?\"YES\":\"NO\"));\n\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "ba872bce74402e372a33444af2217f56", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint f(int n,int v,int k)\n{\n int s=0,m;\n for(m=1;(int)(v/m)>0;m=m*k)\n {\n s+=(int)(v/m);\n }\n if(s==n||s>n)\n {\n f(n,v-1,k);\n }\n else\n return v+1;\n}\n\nint main()\n{\n int m,n,i,k,s;\n scanf(\"%d %d\",&n,&k);\n m=n;\n i=f(n,m,k);\n printf(\"%d\",i);\n // getch();\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9816a1c697311b0aa54cadf65e1e0aa3", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n int n,j,i,flag=0,c1=0,c3=0,c7=0,c9=0;\n scanf(\"%d \",&n);\n char a[n];\n gets(a);\n for(i=0;i\n\n#define F(I) for(int i=0;i\nint main(void) {\n int l, r, s, p;\n bool res = false;\n for(int i = 0; i < 4; i++) {\n scanf(\"%d%d%d%d\", &l, &r, &s, &p);\n if(p == 0) continue;\n else if(l | r | s == 1) res = true;\n }\n puts(res ? \"YES\" : \"NO\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f644cdcc65ac17fc4da7da337aa57a5a", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint dp[21][11][10][5][5];\n\nvoid func(int n, int t)\n{\n int i, j, k, g, h, f, ans = 0;\n memset(dp, 0, sizeof(dp));\n for (i = 1; i <= 4; i ++)\n {\n for (j = 1; j <= 4; j ++)\n {\n if (i != j)\n {\n dp[2][0][0][i][j] = 1;\n }\n }\n }\n for (i = 3; i <= n; i ++)\n {\n for (j = 0; j <= t; j ++)\n {\n for (k = 0; k <= t - 1; k ++)\n {\n for (g = 1; g <= 4; g ++)\n {\n for (h = 1; h <= 4; h ++)\n {\n if (g != h)\n {\n for (f = 1; f <= 4; f ++)\n {\n if (f != h)\n {\n if (g < h && h > f)\n {\n if (j < t)\n {\n dp[i][j + 1][k][h][f] += dp[i - 1][j][k][g][h];\n }\n }\n else if (g > h && h < f)\n {\n if (k < t - 1)\n {\n dp[i][j][k + 1][h][f] += dp[i - 1][j][k][g][h];\n }\n }\n else\n {\n dp[i][j][k][h][f] += dp[i - 1][j][k][g][h];\n }\n }\n }\n }\n }\n }\n }\n }\n }\n for (i = 1; i <= 4; i ++)\n {\n for (j = 1; j <= 4; j ++)\n {\n if (i != j)\n {\n ans += dp[n][t][t - 1][i][j];\n }\n }\n }\n printf(\"%d\\n\", ans);\n}\n\nint main()\n{\n int n, t;\n while (scanf(\"%d%d\", &n, &t) == 2)\n {\n func(n, t);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "7bdc5098b6f9a3cbbc11b9d0559447b6", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint arr[101];\nint n,dis;\nint min(int x,int y)\n{\n\treturn xarr[n-1])\n\t printf(\"%d\\n\",n-1);\n\telse\n\tprintf(\"%d\\n\",recur(0,n-1));\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "48fa6ef4147864e9df83b317251b610a", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\nint s,i,j,n,k,L[50];\nprintf(\"entrez n ;\");\nscanf('%d',&n);\n\nwhile (s<=n){\ns=s+i;\nL[i-1]=i;\ni=i+1;\n}\nif(s-i-1!=n){\n int j=n-s+i+1;\n for(i=0;i!=j;i++){\n L[i]+=1;\n }\n}\n\n\n\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "44e92c6fddd0b584766b63952da835dd", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nint main(int argc, char *argv[]) \n{\n\tint i,cnt=0,a,b,c,d;\n\tscanf(\"%d %d %d %d\",&a,&b,&c,&d);\n\tif(a!=b)\n\t\tcnt++;\n\tif(c!=b&&c!=a)\n\t\tcnt++;\n\tif(d!=c&&d!=v&&d!=a)\n\t\tcnt++;\n\tprintf(\"%d\",cnt);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "25b86cc4435714d8a598de2e63cc81bf", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0} {"lang": "GNU C", "source_code": "int main(void)\n{\n char a[9][9];\n int i,j,x,y,flag=1;\n for(i=0;i<9;i++)\n scanf(\"%s%s%s\",&a[i][0],&a[i][3],&a[i][6]);\n scanf(\"%d%d\",&x,&y);\n \n while(x>3) x-=3;\n while(y>3) y-=3;\n if(x==1&&y==1)\n for(i=0;i<3;i++)\n for(j=0;j<3;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0; }\n if(x==2&&y==1)\n for(i=3;i<6;i++)\n for(j=0;j<3;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==3&&y==1)\n for(i=6;i<9;i++)\n for(j=0;j<3;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==1&&y==2)\n for(i=0;i<3;i++)\n for(j=3;j<6;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==2&&y==2)\n for(i=3;i<6;i++)\n for(j=3;j<6;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==3&&y==2)\n for(i=6;i<9;i++)\n for(j=3;j<6;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==1&&y==3)\n for(i=0;i<3;i++)\n for(j=6;j<9;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==2&&y==3)\n for(i=3;i<6;i++)\n for(j=6;j<9;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(x==3&&y==3)\n for(i=6;i<9;i++)\n for(j=6;j<9;j++)\n if(a[i][j]=='.') {a[i][j]='!';flag=0;}\n if(flag)\n {for(i=0;i<9;i++)\n for(j=0;j<9;j++)\n if(a[i][j]=='.') a[i][j]='!';\n }\n for(i=0;i<9;i++)\n {\n if(i%3==0&&i) printf(\"\\n\");\n for(j=0;j<9;j++)\n {\n if(j%3==0&&j) printf(\" \");\n printf(\"%c\",a[i][j]);\n }\n printf(\"\\n\");\n }\n return 0;", "lang_cluster": "C", "compilation_error": true, "code_uid": "d28ce24acc2e29791abbcde674a1ef26", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n#define MD 1000000009\n\nint main()\n{\n int nn, mm, kk, aa;\n long long int n, m, k, l, p, q, qq, r, rr, s, t, i, a;\n\n scanf(\"%d%d%d\", &nn, &mm, &kk);\n\n n = nn; m = mm; k = kk;\n\n l = (n+1)/k;\n p = (n+1)%k;\n if(p==0)\n {\n q = l*(k-1);\n }\n else\n {\n q = l*(k-1)+p-1;\n }\n\n if(q>=m)\n {\n a = m;\n }\n else\n {\n if(p==0)\n {\n qq = (m-q+1)*k-1;\n r = qq/k;\n rr = qq%k;\n t = 1;\n s = 0;\n for(i=0; i\nmain()\n{\n\tint a,b,c,p,q,r,i=0,j=0,k=0,t;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\t\n\t\n\t\n\tif(a >= b && a >= c)\n\t{\n\t\tfor(p=a;p >2;p=p-2)\n\t\tj++;\n\t\tt=30 + (j*3);\n\t}\n\tif((b >= c && b >= a) || ((a-b)==1 && b>2))\n\t{\n\t\tfor(p=b;p >2;p=p-2)\n\t\tk++;\n\t\tt=31 + (k*3);\n\t}\n\tif((c >= a && c >= b) || ((a-c)==1 && c>2) || ((b-c)==1 && c>2))\n\t{\n\t\tfor(p=c;p >2;p=p-2)\n\t\ti++;\n\t\tt=32 + (i*3);\n\t}\n\tprintf(\"%d\",t);\n}\n\t\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e6688d2e6e47454011f989aa7172a004", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \nusing namespace std;\nint s[2501][15]={0};\nint s1[15]={0};\nvoid bit(int a)\n{ int t=0;\n int b=a;\n while(a!=0)\n {\n s[b][t]=a%2;\n a=a/2;\n t++;\n }\n // for(int i=0;i<13;i++)\n // printf(\"%d \",s[b][i]);\n // printf(\"\\n\");\n}\nlong long int f(int i,int j)\n{\n int sign=1;\n for(int a=13;a>=0;a--)\n {\n if(s[i][a]==s[j][a]&&sign==1&&s[i][a]==0)\n continue;\n else\n sign=0;\n if(s[i][a]==s[j][a])\n s1[a]=1;\n else\n s1[a]=0;}\n int c =0;\n for(int a=0;a<13;a++)\n {\n c=c+pow(2,a)*s1[a];\n }\n if(i==c||j==c)\n return 0;\n if(i+j<=c||j+c<=i||i+c<=j)\n return 0;\n else\n {\n // printf(\"%d %d %d\\n\",i,j,c);\n return 1;\n }\n\n\n}\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n for(int i=1;i<=n;i++)\n {\n bit(i);\n }\n int sum=0;\n for(int i=1;i<=n;i++)\n {\n for(int j=1;j<=n;j++)\n {\n if(i==j)\n continue;\n if(f(i,j))\n sum++;\n }\n }\n printf(\"%d\",sum/6);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "032ffe6af82a0a632f1c1097fafbaff4", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include \n \nint main () \n{\n int x;\n\tscanf(\"%d\", &x);\n\tprintf(\"%d 0 0\\n\", x);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2e992618270e5a670949f5788dcfa2ad", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "GNU C11", "source_code": "#include \n#include \nint compare(const void *data1,const void *data2){\n\tint *ptr1 = (int *)data1;\n\tint *ptr2 = (int *)data2;\n\treturn (data1 > data2)? 1 : -1;\n}\nint main(){\n\tint n;\n\tint arr[100];\n\tscanf(\"%d\",&n);\n\tfor(int i = 0;i\n#include \n#include \n#define EPS 1e-11\n#define SQ(x) ((x)*(x))\n#define EQ(x,y) (fabs((x)-(y))EPS){\n bllg=(blg*19+brg)/20; brrg=(blg+brg*19)/20;\n bld=hh(th,bllg); brd=hh(th,brrg);\n bld>brd?blg=bllg:(brg=brrg);\n }\n return la+bld;\n}\n\ndouble f(double th){\n double tx=r*cos(th),ty=r*sin(th),lr,lb;\n lr=hypot(ax-tx,ay-ty);\n th=acos((tx*bx+ty*by)/(r*hb));\n lb=sqrt(SQ(d)+SQ(bd)-2*d*bd*cos(th*r/d));\n return lr+lb;\n}\n\nmain(){\n int i,j;\n double ans=1e9,alg,arg,allg,arrg,ald,ard;\n\n scanf(\"%d%d%lf%lf%lf%lf%lf%lf\",&r,&h,&ax,&ay,&az,&bx,&by,&bz);\n if(EQ(ax,bx)&&EQ(ay,by)&&EQ(az,bz)) print(.0);\n if(azEPS){\n allg=(alg*19+arg)/20; arrg=(alg+arg*19)/20;\n ald=f(allg); ard=f(arrg);\n ald>ard?alg=allg:(arg=arrg);\n }\n print(ald);\n }\n if(EQ(bz,h)) print(ad);\n temp1=sqrt(SQ(ad)+SQ(bd)-2*ad*bd*cos(th*r/d));\n alg=0; arg=2*M_PI;\n while(arg-alg>EPS){\n allg=(alg*19+arg)/20; arrg=(alg+arg*19)/20;\n ald=g(allg); ard=g(arrg);\n ald>ard?alg=allg:(arg=arrg);\n }\n temp2=ald;\n print(temp1\n#include\nint main()\n{\n\tint i,j,l[4];\n\tchar a[4];\n int n1=n2=0;\n\tint f,c=0;\n\tfor(i=1;i<=4;i++)\n\t\tscanf(\"%c\",a[i]);\n\tfor(i=1;i<=4;i++)\n l[i]=strlen(a[i])-2;\n\tfor(i=1;i<=4;i++)\n\t{\n\t\tfor(j=1;j<=4;j++)\n\t\t{\n\t\t\tif(i!=j)\n\t\t\t\t{\n\t\t\t\t\tif(l[i]>=2*l[j])\n\t\t\t\t\t\tn1++;\n\t\t\t\t\telse\n\t\t\t\t\t\tn2++;\n\t\t\t\t}\n\t\t}\n\t\tif(n1==3||n2==3)\n\t\t{\n\t\t\tc++;\n\t\t\tf=i-1;\n\t\t}\n\t}\n\tif(c==1)\n\t\tprintf(\"%c\\n\",'A'+f);\n\telse\n\t\tprintf(\"C\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "0a72f8e2d6cba95bca374a68f7eae3c7", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n while(1)\n {\n long long int a,b,c,n,A1=0,A2=0;;\n scanf(\"%lld\\n%lld\\n%lld\\n%lld\",&n,&a,&b,&c);\n if(n>=b) A1=1+(n-b)/(b-c)+((n-b)%(b-c)+c)/a;\n if(n>=a) A2=1+n/a+max((n%a-b)/(b-c),(long long int)0);\n printf(\"%lld\\n\",max(A1,A2));\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "4a99e555977e474b2519c0e0b749a2bc", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \nunsigned int a,b;\nchar c;\nint main()\n{\n\tfloat f,l;\n\tint k,i=0;\n\tbool key=false;\n\tscanf(\"%d %d %d\",&a,&b,&c);\n\tf=(float)a/b*10;\n\tk=(int)f;\n\t\n\twhile (i<1000 && key==false)\n\t{\n\t\tk=k%10;\n\t\tif (k==c) key=true;\n\t\tl=(a-k*0.1*b)*10;\n\t\ta=(int)l;\n\t\tf=(float)a/b*10;\n\t\tk=(int)f;\n\t\ti++;\n\t}\n\tif (key==true) printf(\"%d\",i);\n\telse printf(\"-1\");\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "3ecd92bf0e3e178ba52ddacf70027589", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tlong long x;\n\tint cnt;\n\n\tscanf(\"%lld\", &x);\n\tif (x > 0)\n\t\tx %= 360;\n\telse\n\t\tx = (360 - (-x % 360)) % 360;\n\tcnt = 0;\n\tif ((x >= 315 && x < 360) || (x >= 0 && x <= 45))\n\t\tcnt = 0;\n\telse if (x >= 46 && x <= 135)\n\t\tcnt = 1;\n\telse if (x >= 136 && x <= 225)\n\t\tcnt = 2;\n\telse if (x >= 225 && x <= 315)\n\t\tcnt = 3;\n\tprintf(\"%d\\n\", cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "05c52e91f7166ed977d4f0b64219df98", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\n\nlong long perm(int n, int i) {\n\tlong long sum = 1;\n\twhile (i--) sum = sum * n--;\n\treturn sum;\n}\n\nlong long comb(int n, int i) {\n\treturn perm(n, i) / perm(i, i);\n}\n\nint main() {\n\tint n, k, temp;\n\tscanf(\"%d %d\", &n, &k);\n\tlong long dp[5], sum, tt;\n\tdp[0] = 1;\n\tdp[1] = 1;\n\n\tfor (int i = 2; i <= k; i++) {\n\t\tsum = comb(n, i) * perm(i, i);\n\t\ttemp = 0;\n\t\tfor (int j = i - 1; j >= 0; j--) {\n\t\t\ttt = comb(n - j, n - i) - 1;\n\t\t\tsum -= (tt - temp) * dp[j];\n\t\t\ttemp += tt - temp;\n\t\t}\n\t\tdp[i] = sum;\n\t}\n\n\tprintf(\"%lld\", dp[k]);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "b8a5fec7779e8b3b037f80af5572dab2", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i=0) ok_g = 1;\n if(r>=0) ok_r = 1;\n }\n continue;\n }\n if(r+1==g || r-1==g); else cnt++;\n if(r > g-2 || g > r-2) ok_v=1;\n }\n\n if(ok_g && ok_r){\n puts(\"Draw\"); continue;\n }\n if(ok_g){\n puts(\"First\"); continue;\n }\n if(ok_r){\n puts(\"Second\"); continue;\n }\n\n if(cnt % (k+1) || ok_v){\n puts(\"First\");\n } else {\n puts(\"Second\");\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "63b56c50091e630d560ad4bbcd3b76b1", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "#include\r\nusing namespace std;\r\nint main(){\r\n int t;\r\n cin>>t;\r\n while(t--){\r\n int n;\r\n cin>>n;\r\n if(n==1){\r\n cout<<1<\n#include \n\nint main()\n{\n char str[102];\n while ((scanf(\"%s\", str)))\n {\n int length = strlen(str);\n int count = 0;\n int i = 0;\n while (i < length)\n {\n int j = i + 1;\n while (j < length && str[j] == str[j - 1])\n j++;\n\n int diff = j - i;\n if (diff && diff % 2 == 0)\n count++;\n\n i = j;\n }\n print(\"%d\\n\", count);\n }\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "25d73d83ee76c6f5b5ad75ab0ed0d647", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n\n#define mset(a) memset(a,0,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n#define mcmp(a,b,n) memcmp(a,b,n)\n#define maxint 2147483647\n#define pi 3.14159265358979323846\n\nlong long n,t,ans=0,k;\nlong long a[111],cnk[111][111];\n\nlong long turn(long long t)\n{\n long long i=0;\n \n if(t&(t-1))\n return -1;\n \n while(t>>=1)\n i++;\n return i;\n}\n\nint main()\n{\n int i,j,l;\n \n a[0]=1;\n for(i=1;i<63;i++)\n a[i]=a[i-1]<<1;\n mset(cnk);\n for(i=0;i<111;i++)\n {\n cnk[i][0]=1;\n for(j=1;j<=i;j++)\n cnk[i][j]=cnk[i-1][j-1]+cnk[i-1][j];\n }\n \n scanf(\"%I64d%I64d\",&n,&t);\n \n k=turn(t);\n if(k==-1)\n {\n printf(\"0\\n\");\n return 0;\n }\n \n for(i=1;n>a[i];i++)\n {\n ans+=cnk[i][k];\n n-=a[i];\n }\n for(i=62;i>=0;i--)\n if((~k)&&(n>>i&1))\n {\n ans+=cnk[i][k];\n k--;\n }\n \n printf(\"%I64d\\n\",ans);\n \n //system(\"pause\");\n return 0;\n}\n\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d0c24cef063c373d694485f48f77a29a", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "include\nint main()\n{\n int a;\n scanf(\"%d\",&a);\n \n if(a%2==0)\n printf(\"0\");\nelse\n printf(\"1\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "8ac686687493dbb802f4da192b8f9a09", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\n int n, a[7], i;\n\n scanf(\"%d\", &n);\n for(i=0; i<7; i++)\n scanf(\"%d\", &a[i]);\n\n i=-1;\n while(n>0){\n i=(i+1)%7;\n n-=d[i];\n }\n\n printf(\"%d\",i+1);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d63f1a88974d1710bc31d27e21ea1bfb", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nmain()\n{\n\n long int n,i,p,b[10]={0},t,flag=0,m,j=0,count=0,c[10]={0};\n char a[10];\n scanf(\"%s\",a);\n t=atoi(a);\n if(t==1){printf(\"1\");goto x;}\n for(i=0;i\r\n#include \r\n#include \r\n#include \r\n\r\nint64_t x, y;\r\nint n_0, n_1, m;\r\nint s_0[100], s_1[100], t[100];\r\n\r\nvoid build(int64_t value, int* buffer, int* size, bool keep_trailing_zero) {\r\n *size = 0;\r\n if (!keep_trailing_zero)\r\n while (value % 2 == 0) value /= 2;\r\n while (value > 0) {\r\n buffer[(*size)++] = value % 2;\r\n value /= 2;\r\n }\r\n}\r\n\r\nvoid reverse(int* a, int size) {\r\n for (int i = 0, j = size - 1; i < j; i++, j--) {\r\n a[i] ^= a[j];\r\n a[j] ^= a[i];\r\n a[i] ^= a[j];\r\n }\r\n}\r\n\r\nbool try_match(int* s, int n, int* t, int m) {\r\n for (int i = 0; i + n <= m; i++) {\r\n if (t[i] == 0) break;\r\n bool good = true;\r\n for (int j = 0; j < n; j++) {\r\n if (t[i + j] != s[j]) {\r\n good = false;\r\n break;\r\n }\r\n }\r\n if (!good) continue;\r\n for (int j = i + n; j < m; j++) {\r\n if (t[j] == 0) {\r\n good = false;\r\n break;\r\n }\r\n }\r\n if (good) return true;\r\n }\r\n return false;\r\n}\r\n\r\nvoid solve() {\r\n scanf(\"%lld %lld\", &x, &y);\r\n if (x == y) {\r\n printf(\"YES\\n\");\r\n return;\r\n }\r\n build(x, s_0, &n_0, false);\r\n build(x * 2 + 1, s_1, &n_1, true);\r\n build(y, t, &m, true);\r\n if (try_match(s_0, n_0, t, m)) {\r\n printf(\"YES\\n\");\r\n return;\r\n }\r\n reverse(s_0, n_0);\r\n if (try_match(s_0, n_0, t, m)) {\r\n printf(\"YES\\n\");\r\n return;\r\n }\r\n\r\n if (try_match(s_1, n_1, t, m)) {\r\n printf(\"YES\\n\");\r\n return;\r\n }\r\n reverse(s_1, n_1);\r\n if (try_match(s_1, n_1, t, m)) {\r\n printf(\"YES\\n\");\r\n return;\r\n }\r\n\r\n printf(\"NO\\n\");\r\n}\r\n\r\nint main() {\r\n int t = 1;\r\n // scanf(\"%d\", &t);\r\n while (t--) solve();\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "7a53d3ae611a033e17853b61c942bbb2", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include\n#include\n\nint decode(char a){\n\tif(a=='P')return 1;\n\telse if(a=='W')return -1;\n\telse return 0;\n}\n\nint hantei(int a[10][10],int n,int m){\n\tint max=0,tmp;\n\tint b[10][10];\n\tint i,j;\n\tfor(i=0;i0&&(a[i-1][j]==1)){\n\t\t\t\t\t\tb[i][j]=0;\n\t\t\t\t\t\tb[i-1][j]=0;\n\t\t\t\t\t\ttmp=hantei(b,n,m);\n\t\t\t\t\t\tb[i][j]=-1;\n\t\t\t\t\t\tb[i-1][j]=1;\n\t\t\t\t\t\tif(max0&&(a[i][j-1]==1)){\n\t\t\t\t\t\tb[i][j]=0;\n\t\t\t\t\t\tb[i][j-1]=0;\n\t\t\t\t\t\ttmp=hantei(b,n,m);\n\t\t\t\t\t\tb[i][j]=-1;\n\t\t\t\t\t\tb[i][j-1]=1;\n\t\t\t\t\t\tif(max\n#include\nint main() {\n char s[100+1];\n char t[100+1];\n scanf(\"%s\",s);\n scanf(\"%s\",t);\n int s_count[256];\n int t_count[256];\n int i;\n for(i=0;i<256;i++){\n s_count[i]=0;\n t_count[i]=0;\n }\n for(i=0;it_count[i]) more=1;\n }\n int within=0;\n int j;\n while(i\n#include \nint main(){\n long int n, i, a, b, c;\n scanf(\"%ld\", &n);\n\n a = sqrt(n)/1;\n if(n > a*a && n <= a*(a+1)) printf(\"%ld\", 2*a+1);\n if(n > a(a+1)) printf(\"%ld\", 2*a+2);\n if(n == a*a)printf(\"%ld\", 2*a);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "420f7cf842cc9923dc6c2dde0f36c0b2", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\ncmpfun(const void*a,const void*b)\n{\n\treturn(*(int*)a-*(int*)b);\n}\nint main()\n{\n\tint i,j,k,l,m,z=0,w=0,n;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tfor(i=0;i\nint main()\n{\nint n;\nscanf(\"%d\",&n);\nprintf(\"%d\", (n/2)+1);", "lang_cluster": "C", "compilation_error": true, "code_uid": "73a6f81789eae762dfd9432a6e57eaca", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \nint main(){\n\tlong long a,b,x,y,count=0,m,n,l,k,gcd;\n\tscanf(\"%I64d %I64d %I64d %I64d\",&a,&b,&x,&y);\n\tm=x;n=y;\n\twhile(m!=n)\n\t{\n\t\tif(m>n)\n\t\tm=m-n;\n\t\t\n\t\tif(n>m)\n\t\tn=n-m;\n\t}\n\tgcd=m;\n\ty=y/m;\n\tx=x/m;\n\ta=a/x;\n\tb=b/y;\n\tif(a>b)\n\tprintf(\"%I64d\",b);\n\telse if\n\tprintf(\"%I64d\",a);\n\t\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "1ffa1d7934a4485cebef5ac3189fc244", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n\nint n,ans,D[35];\n\nint q[6400010][5],head,tail;\nshort vis[410][410][8][5];\nshort MAP[410][410];\n\nshort dir[8][2] = {-1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};\n\nvoid add(int i,int j,int k,int d,int now)\n{\n if(vis[i][j][k][d]) return;\n vis[i][j][k][d] = 1; MAP[i][j] = 1;\n q[tail][0] = i; q[tail][1] = j; q[tail][2] = k; q[tail][3] = d; q[tail++][4] = now;\n}\n\nvoid bfs(int SI,int SJ)\n{\n int i,j,k,d,now;\n int ii,jj,kk,dd;\n head = 1; tail = 1;\n add(SI,SJ,0,D[1]-1,1);\n \n while(head != tail)\n {\n i = q[head][0]; j = q[head][1]; k = q[head][2];\n d = q[head][3] - 1; now = q[head++][4];\n if(d >= 0)\n {\n ii = i+dir[k][0]; jj = j+dir[k][1]; dd = d;\n add(ii,jj,k,dd,now);\n }\n else\n {\n if(now == n) continue;\n dd = D[now+1] - 1;\n kk = (k+7)%8; ii = i+dir[kk][0]; jj = j+dir[kk][1];\n add(ii,jj,kk,dd,now+1);\n kk = (k+1)%8; ii = i+dir[kk][0]; jj = j+dir[kk][1];\n add(ii,jj,kk,dd,now+1);\n }\n }\n}\n\nint main()\n{\n int i,j;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++) scanf(\"%d\",&D[i]);\n \n bfs(200,200);\n for(i=1;i<=400;i++) for(j=1;j<=400;j++) if(MAP[i][j]) ans++;\n printf(\"%d\",ans);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9c7e88354517e93d3f7a08cc63c7173e", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int c,b;\n scanf(\"%c%d\",&a,&c);\n \n b=c%2;\n if(b!=0){printf(\"1\");\n \n }\n else\n printf(\"%d\",b);\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "73ff660b8220afc64bfd86e183d70f4e", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null} {"lang": "GNU C", "source_code": "#include \n#define MIN(A,B) ((A) < (B)) ? (A) : (B)\n#define MAX(A,B) ((A) > (B)) ? (A) : (B)\n\nint main(void) {\n int f[2][2];\n int s[2][2];\n int a1, d1;\n int a2, d2;\n int maxa1, maxa2, maxd1, maxd2;\n int i, j;\n int score;\n\n for (i = 0; i < 2; i++) {\n for (j = 1; j >= 0; j--) {\n scanf(\" %d\", &f[i][j]);\n }\n }\n for (i = 0; i < 2; i++) {\n for (j = 1; j >= 0; j--) {\n scanf(\" %d\", &s[i][j]);\n }\n }\n\n maxa1 = MAX(f[0][0], f[1][0]);\n maxd1 = MAX(f[0][1], f[1][1]);\n maxa2 = MAX(s[0][0], s[1][0]);\n maxd2 = MAX(s[0][1], s[1][1]);\n\n if (f[0][0] > maxd2 && f[1][0] > maxd2) {\n d1 = maxd1;\n a1 = maxd2 + 1;\n } else if (f[0][0] > maxd2) {\n d1 = f[1][1];\n a1 = f[0][0];\n } else if (f[1][0] > maxd2) {\n d1 = f[0][1];\n a1 = f[1][0];\n } else if (maxa1 == maxd2) {\n a1 = maxa1;\n d1 = -1;\n } else {\n d1 = maxd1;\n if (f[0][1] == d1 && f[1][1] == d1) {\n a1 = maxa1;\n } else if (f[0][1] == d1) {\n a1 = f[1][0];\n } else {\n a1 = f[0][0];\n }\n }\n\n\n if (s[0][0] > d1 && s[1][0] > d1) {\n d2 = maxd2;\n a2 = d1 + 1;\n } else if (s[0][0] > d1) {\n a2 = s[0][0];\n d2 = s[1][1];\n } else if (s[1][0] > d1) {\n a2 = s[1][0];\n d2 = s[0][1];\n } else if (maxa2 == d1) {\n a2 = maxa2;\n d2 = -1;\n } else {\n d2 = maxd2;\n if (s[0][1] == d2 && s[1][1] == d2) {\n a2 = maxa2;\n } else if (s[0][1] == d2) {\n a2 = s[1][0];\n } else {\n a2 = s[0][0];\n }\n }\n\n /*printf(\"a1 = %d, d1 = %d\\n\", a1, d1);\n printf(\"a2 = %d, d2 = %d\\n\", a2, d2); */\n\n score = 0;\n if (a1 > d2) {\n score++;\n } else if (d2 > a1) {\n score--;\n }\n\n if (d1 > a2) {\n score++;\n } else if (a2 > d1) {\n score--;\n }\n\n if (score == 2) {\n printf(\"Team 1\\n\");\n } else if (score == -2) {\n printf(\"Team 2\\n\");\n } else {\n printf(\"Draw\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "08a657731ff8b65dcb27a59dd3347e82", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "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\n\nint main()\n{\n int count[2000] ={0};\n int arr[1000] ={0}; \n int n,m,i;\n scanf(\"%d %d\",&n,&m);\n for(i=0;i0){\n brr[b]=i;\n b++;\n }\n }\n \n while(max>=0){\n int f = 0;\n for(i=0;i=n){\n printf(\"%d\\n\",max);\n return 0;\n break;\n }\n max = max - 1;\n }\n \n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "595fff41d099d3dae19578d33a463dfa", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n\n#define mod 1000000007\nlong long dp[55][55][205]={};\nlong long c[55][55]={};\nint n,lim,A=0,B=0,i,j,k,ii,jj;\nint min(int a,int b){return a=0;i--){\n\t\t\tfor(j=B;j>=0;j--){\n\t\t\t\tint s=k%2;\n\t\t\t\tdp[i][j][s]=0;\n\t\t\t\tif(s){\n\t\t\t\t\tfor(ii=i;ii<=A;ii++){\n\t\t\t\t\t\tint f=lim-(ii-i)*50;\n\t\t\t\t\t\tif(f>=0){\n\t\t\t\t\t\t\tf/=100;\n\t\t\t\t\t\t\tf+=j; f=min(f,B);\n\t\t\t\t\t\t\tfor(jj=j;jj<=f;jj++){\n\t\t\t\t\t\t\t\tif((i!=ii || j!=jj)){\n\t\t\t\t\t\t\t\t\tdp[i][j][s]+=(dp[ii][jj][1-s]*c[ii][ii-i]*c[jj][jj-j])%mod;\n\t\t\t\t\t\t\t\t\tdp[i][j][s]%=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}else{\n\t\t\t\t\tfor(ii=0;ii<=i;ii++){\n\t\t\t\t\t\tint f=lim-(i-ii)*50;\n\t\t\t\t\t\tif(f>=0){\n\t\t\t\t\t\t\tf/=100; f=max(j-f,0);\n\t\t\t\t\t\t\tfor(jj=f;jj<=j;jj++){\n\t\t\t\t\t\t\t\tif((i!=ii || j!=jj)){\n\t\t\t\t\t\t\t\t\tdp[i][j][s]+=(dp[ii][jj][1-s]*c[A-ii][i-ii]*c[B-jj][j-jj])%mod;\n\t\t\t\t\t\t\t\t\tdp[i][j][s]%=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\tif(dp[0][0][s]){\n\t\t\t\t\tprintf(\"%d\\n\",k);\n\t\t\t\t\tprintf(\"%lld\\n\",dp[0][0][s]);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tputs(\"-1\\n0\");\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// \n// \n// \n// \n// \n// ", "lang_cluster": "C", "compilation_error": false, "code_uid": "781d4510bf3783ff91e5373c55c38ba5", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint t,x,y,k,q,l;\n\tint sv[2000000];\n\tint i,j=0;\n\tfor(i=2;i<1000000;i++)\n\tfor(j=2;j*i<2000000;j++)\n\t\tsv[i*j]=1;\n\tsv[0]=7;sv[1]=9;\n//\tscanf(\"%d\",&t);\n\tfor(i=0;i<1000;i++);\n\t//\tprintf(\"%d\",sv[i]);\n//\twhile(t-->0)\n\t\tint c=0;\n\t\tscanf(\"%d %d %d\",&x,&y,&k);j=y-x+2;\n\t\tint mid,low=1,high=(y-x+1);\n\t\tmid=(low+high)/2;\n\t\twhile(low<=high)\n\t\t{\tl=mid;\n\t\t//\tprintf(\"%d\",sv[i]);\n\t\t\tfor(q=(y-l+1);q>=x;q--)\n\t\t{\tc=0;\n\t\t\tfor(i=q;i<(q+l);i++)\n\t\t\t\tif(sv[i]==0)\n\t\t\t\t\tc++;\n\t\t\tif(c\nint main()\n{\n x,y,z,a,b,c;\n scanf(\"%d %d %d\",&x,&y,&z);\n scanf(\"%d %d %d\",&a,&b,&c);\n if(a>=x && a-x+b && (c>=z || (a+b)-(x+y)+c>=z))\n printf(\"YES\");\n else\n printf(\"NO\");\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d9422cbdb0428e6dcce16b045abb4349", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, i, j, k;\n int g[100010];\n\n scanf(\"%d\", &n);\n\n for (i = 0; i <= n; i++) g[i] = -1;\n\n for (i = 1; i <= (n + 1) / 2; i++) {\n\t int c[1000] = {0};\n\n\t for (j = (i + 1) / 2; j > 0; j--) {\n\t int sum = 0, f = 0, num = 0;\n\n\t for (k = j; k > 0; k--) {\n\t\t sum += k;\n\t\t num++;\n\n\t\t f ^= g[k];\n\n\t\t if (sum >= i) break;\n\t }\n\n\t if (sum < i) break;\n\n\t if (sum == i && num > 1) {\n\t\t if (f < 1000) c[f] = 1;\n\t }\n\t }\n\n\t for (j = 0; j < 1000; j++) {\n\t if (c[j] == 0) break;\n\t }\n\n\t g[i] = j;\n }\n\n for (i = (n + 1) / 2; i > 0; i--) {\n\t int sum = 0, f = 0, num = 0;\n\n\t for (j = i; j > 0; j--) {\n\t sum += j;\n\t num++;\n\n\t f ^= g[j];\n\n\t if (sum >= n) break;\n\t }\n\n\t if (sum < n) break;\n\n\t if (sum == n && num > 1 && f == 0) {\n\t printf(\"%d\\n\", num);\n\n\t return 0;\n\t }\n }\n\n puts(\"-1\");\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a174ac48d523dba4b786456cd6e30855", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n\nvoid caballo (int m[][9], int f, int c)\n{\n/*8 mov tiene el caballo*/\n\n /*derecha 1 cuadro*/\n if(c+2<9 && f-1>0)/*9 final del tablero, arriba derecha columna+2*/\n {\n m[f-1][c+2]=1;\n\n }\n if(c+1<9 && f-2>0)/*9 final del tablero, arriba derecha columna+1*/\n {\n m[f-2][c+1]=1;\n }\n\n /*abajo derecha*/\n if(c+1<9 && f+2<9)/*9 final del tablero, arriba derecha colu+1*/\n {\n m[f+2][c+1]=1;\n }\n if(c+2<9 && f+1<9)/*9 final del tablero, arriba derecha colu+2*/\n {\n m[f+1][c+2]=1;\n }\n\n\n /*izquierda arriba*/\n if(c-1>0 && f-2>0)/* arriba del tablero, arriba izquierda fi-2*/\n {\n m[f-2][c-1]=1;\n }\n if(c-2>0 && f-1>0)/*arriba del tablero, arriba derecha fi-1*/\n {\n m[f-1][c-2]=1;\n }\n\n /*izquierda abajo*/\n if(c-1>0 && f+2<9)/*9 final del tablero, arriba derecha fi+2*/\n {\n m[f+2][c-1]=1;\n }\n if(c-2>0 && f+1<9)/*9 final del tablero, arriba derecha co+1*/\n {\n m[f+1][c-2]=1;\n }\n /*fin funcion*/\n\n}\n\nvoid torre (int m[][9], int f,int c)\n{\n int aux;\n\n /*fila torre llenar de 1s*/\n for(aux=1; aux<=8; aux++)\n {\n m[f][aux]=1;\n }\n\n /*fila torre llenar de 1s*/\n for(aux=1; aux<=8; aux++)\n {\n m[aux][c]=1;\n }\n\n}\n\nvoid inici (int m[][9])\n{\n int i,j;\n /*imprimir matriz*/\n for(i=1; i<9; i++){\n for(j=1; j<9; j++)\n m[i][j]=0;\n\n }\n}\n\nvoid resultado(int m[][9])\n{\n int i,j,con=0;\n /*imprimir matriz*/\n for(i=1; i<9; i++){\n for(j=1; j<9; j++)\n if(m[i][j]==0)\n con++;\n }\n\n printf(\"%d\",con);\n}\n\n\nmain()\n{\n\nint ma[9][9]={0};\nint i,j,i2;\nchar c;\n\n\n\n/*primera linea entra torre*/\nscanf(\"%c %d\",&c,&i);\nj=(int)c-'a';\nj++; /*se pasa la letra a numero +1*/\ni=9-i;/*posicion de fila invertida*/\n\ninici(ma);\nma[i][j]=1;/*primera linea*/\n\n/*se colocan 1s para la posicion del caballo y torre*/\ncaballo (ma,i,j);\ntorre (ma,i,j);\n\n/*segunda linea*/\nscanf(\"%1s %d\",&c,&i2); /*guarda un solo caracter en la variable*/\n\nj=(int)c-'a';\nj++; /*se pasa la letra a numero +1*/\ni2=9-i2;/*posicion de fila invertida*/\nma[i2][j]=1;/*primera linea*/\n\n/*se colocan 1s para la posicion del caballo y torre*/\ncaballo (ma,i2,j);\n\n\nresultado(ma);\n\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2079ae76112106f2064623f45f8b2288", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\nint n, cube[3][6],v[3];\n\nint dfs(int num){\n\tif (num == 0)return 1;\n\tfor (int i = 0; i < n; i++){\n\t\tif (v[i])continue;\n\t\tint f = 0;\n\t\tfor (int j = 0; j < 6; j++)\n\t\t\tif (num % 10 == cube[i][j])f = 1;\n\t\tif (!f)continue;\n\t\tv[i] = 1;\n\t\tif (dfs(num / 10))return 1;\n\t\tv[i] = 0;\n\t}\n\treturn 0;\n}\nvoid main(){\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++)\n\t\tfor (int j = 0; j < 6; j++)scanf(\"%d\", &cube[i][j]);\n\n\tfor (int i = 0; i < 1000; i++){\n\t\tfor (int j = 0; j < n; j++)v[j] = 0;\n\t\tif (!dfs(i)){\n\t\t\tprintf(\"%d\\n\", i - 1);\n\t\t\treturn;\n\t\t}\n\t}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "f6fd068c2f52ca31fff1fb1372b66367", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\nlong long product(char *ch){\n long long pr=1;\n if(ch[0]=='0')ch[0]='1';\n for(int i=0;ch[i]!='\\0'; i++){\n pr=pr*(ch[i]-48);\n }\nreturn pr;\n}\n\n\n\nint main(){\n\n char inp[12];\n long long in,pr,maxpr=0;\n gets(inp);\n pr=product(inp);\n if(pr>maxpr)maxpr=pr;\n int len=strlen(inp);\n for(int i=len-1;i>0; i--){\n if(inp[i]!='9'){\n inp[i]='9';\n if(inp[i-1]=='0'){\n inp[i-1]='9';\n if(inp[i-2]!='0')inp[i-2]--;\n }\n else inp[i-1]--;\n }\n pr=product(inp);\n if(pr>maxpr)maxpr=pr;\n }\n\nprintf(\"%ld\",maxpr);\n\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6ff81f4951cafbd9a7fed8e30d405b08", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int A1,B1,C1,A2,B2,C2;\n int ans;\n scanf(\"%d %d %d\",&A1,&B1,&C1);\n scanf(\"%d %d %d\",&A2,&B2,&C2);\n if((A1 == 0 && B1 == 0) && (A2 == 0 && B2 == 0) && (C1 != C2))\n {\n /*ans = 0;\n printf(\"%d\\n\",ans);*/\n return 0;\n }\n if ((A1 == 0 && B1 == 0 && C1 == 0) || (A2 == 0 && B2 == 0 && C2 == 0))\n {\n ans = -1;\n printf(\"%d\\n\",ans);\n else if(A1*B2 == B1*A2 && B2*C1 == C2*B1 && C1*A2 == C2*A1)\n {\n ans = -1;\n printf(\"%d\\n\",ans);\n \n }\n else if(((A1*B2) - (A2*B1)) == 0)\n { \n ans = 0;\n printf(\"%d\\n\",ans);\n \n }\n else\n {\n ans = 1;\n printf(\"%d\\n\",ans);\n } \n \n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "655d4f06d23ec0659bf9852232e4c1cb", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint c,ha,hb,wa,wb;\nint max1(int i)\n{\n\tint k,j,count = 0;\n\tfor(j = 0;j<=(c-i*wa)/wb;j++)\n\t{\n\t\tk = i*ha+j*hb;\n\t\tif(count < k)\n\t\t\tcount = k;\n\t}\n\treturn count;\n}\nint main()\n{\n\tint ans = 0,i,j,k;\n\tfloat xa,xb,yw,yh,m = 3.3333*pow(10,4);\n\tscanf(\"%d%d%d%d%d\",&c,&ha,&hb,&wa,&wb);\n\tif(wa=m)\n\t{\n\t\tfor(i = 0;ixb)\n\t{\n\t\tyw = wa;\n\t\twa = wb;\n\t\twb = yw;\n\t\tyh = ha;\n\t\tha = hb;\n\t\thb = yh;\n\t}\n\tfor(i = 0;i<=c/wb;i++)\n\t{\n\t\tk = max1(i);\n\t\tif(ans < k)\n\t\t\tans = k;\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}\n\n ", "lang_cluster": "C", "compilation_error": false, "code_uid": "67cdd8bb6ddbe258fe31e304e615725d", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include \n\nint main(void) \n{\n long long int n;\n long long int original_m;\n scanf(\"%ld\", &n);\n scanf(\"%ld\", &original_m);\n\n\tlong long int m = original_m;\n\n\tlong long int r = 1;\n\tlong long int t = 1;\n\n\twhile( m >= 1) {\n\t\tr = 1;\n\t\twhile (r < t && t <= n) {\n\t\t\tm--;\n\t\t\tr++;\n\t\t}\n\t\tt++;\n\t}\n\tlong long int count = n - r;\n\n\n\tlong long int tempo = 1;\n\tlong long int i = 2;\n\tm = original_m;\n\tlong long int count_max = 1;\n\n\twhile (m>= 1) {\n\t\tif (i>n) {\n\t\t\tcount_max = 0;\n\t\t\tbreak;\n\t\t}\n\t\tm--;\n\t\ttempo+=2;\n\t\ti+=2;\n\t}\n\tif (count_max != 0) {\n\t\tcount_max = n - tempo + 1;\n\t}\n\n\tprintf(\"%ld \", count_max);\n\tprintf(\"%ld\\n\", count);\n\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "b06eeeaee3b50c650cf56f9f6da0590c", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n, m, x1, y1, x2, y2;\n\n scanf(\"%d %d %d %d %d %d\", &n, &m, &x1, &y1, &x2, &y2);\n\n if (abs(x1 - x2) > abs(y1 - y2)) {\n int aux = abs(x1 - x2);\n abs(x1 - x2) = abs(y1 - y2);\n abs(y1 - y2) = aux;\n }\n\n if ((abs(x1 - x2) <= 2 && abs(y1 - y2) <= 4) || (abs(x1 - x2) == 3 && abs(y1 - y2) == 3)) {\n puts(\"First\");\n } else {\n puts(\"Second\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "14a342e6f7ba8443b82caf54cebd5a2f", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "//set many funcs template\n//Ver.20190820\n#include\n#include\n#include\n#include\n#include\n#include\n#define inf 1072114514\n#define llinf 4154118101919364364\n#define mod 1000000007\n#define pi 3.1415926535897932384\n\nint max(int a,int b){if(a>b){return a;}return b;}\nint min(int a,int b){if(a= b){return (a/b)+1;}return a/b;}\nint ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}\nint gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}\nint lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}\nint nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}\nint nHr(int a,int b){return nCr(a+b-1,b);}\nint fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}\nint pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}\nint dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}\nint dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}\nint sankaku(int x){return ((1+x)*x)/2;}\nvoid swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}\nlong long llmax(long long a,long long b){if(a>b){return a;}return b;}\nlong long llmin(long long a,long long b){if(a= b){return (a/b)+1;}return a/b;}\nlong long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}\nlong long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}\nlong long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}\nlong long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}\nlong long llnHr(long long a,long long b){return llnCr(a+b-1,b);}\nlong long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}\nlong long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}\nlong long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}\nlong long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}\nlong long llsankaku(long long x){return ((1+x)*x)/2;}\nvoid llswap(long long *a,long long *b){long long c;c=(*a);(*a)=(*b);(*b)=c;}\ndouble dbmax(double a,double b){if(a>b){return a;}return b;}\ndouble dbmin(double a,double b){if(a*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}\nint sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}\nint llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}\nint llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}\nint dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}\nint dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}\nint strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}\nint strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}\nint chsortfncsj(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}\nint chsortfnckj(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}\n\nvoid shuffledget(int x[],int n){\n int i,b[524288],p,c;\n for(i=0;i=1;i--){\n p=rand()%i;\n c=b[i-1];b[i-1]=b[p];b[p]=c;\n }\n for(i=0;i=1;i--){\n p=rand()%(i+1);\n swap(&a[p],&a[i]);\n }\n}\n\ntypedef struct{\nint val;\nint node;\n}sd;\n\nint sdsortfnc(const void *a,const void *b){\nif(((sd*)a)->val < ((sd*)b)->val){return -1;}\nif(((sd*)a)->val > ((sd*)b)->val){return 1;}\nreturn 0;\n}\n\nvoid coordinate_comp(int a[],int n){\n int i,c=0;\n sd dat[524288];\n for(i=0;i\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n==1)\n printf(\"Washington\\n\");\n else if(n==2||n==6)\n printf(\"Adams\\n\");\n else if(n==3)\n printf(\"Jefferson\\n\");\n else if(n==4)\n printf(\"Madison\\n\");\n else if(n==5)\n printf(\"Monroe\\n\");\n else if(n==7)\n printf(\"Jackson\\n\");\n else if(n==8)\n printf(\"Van Buren\\n\");\n else if(n==9||n==23)\n printf(\"Harrison\\n\");\n else if(n==10)\n printf(\"Tyler\\n\");\n else if(n==11)\n printf(\"Polk\\n\");\n else if(n==12)\n printf(\"Taylor\\n\");\n else if(n==13)\n printf(\"Fillmore\\n\");\n else if(n==14)\n printf(\"Pierce\\n\");\n else if(n==15)\n printf(\"Buchanan\\n\");\n else if(n==16)\n printf(\"Lincoln\\n\");\n else if(n==17)\n printf(\"Johnson\\n\");\n else if(n==18)\n printf(\"Grant\\n\");\n else if(n==19)\n printf(\"Hayes\\n\");\n else if(n==20)\n printf(\"Garfield\\n\");\n else if(n==21)\n printf(\"Arthur\\n\");\n else if(n==22||n==24)\n printf(\"Cleveland\\n\");\n else if(n==25)\n printf(\"McKinley\\n\");\n else if(n==26)\n printf(\"Roosevelt\\n\");\n else if(n==27)\n printf(\"Taft\\n\");\n else if(n==28)\n printf(\"Wilson\\n\");\n else if(n==29)\n printf(\"Harding\\n\");\n else if(n==30)\n printf(\"Coolidge\\n\");\n else if(n==31)\n \n else if(n==32)\n \n else if(n==33)\n \n else if(n==34)\n \n else if(n==35)\n \n else if(n==36)\n \n else if(n==37)\n \n else if(n==38)\n \n else if(n==39)\n \n else if(n==40)\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "a8bf9e3f57c5992cffd47f805d7ee584", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n\n#define N\t100\n\nint main() {\n\tstatic int aa[N];\n\tint n, a, b, i;\n\n\tscanf(\"%d%d%d\", &n, &a, &b);\n\twhile (a-- > 0) {\n\t\tscanf(\"%d\", &i);\n\t\ti--;\n\t\taa[i] = 1;\n\t}\n\twhile (b-- > 0) {\n\t\tscanf(\"%d\", &i);\n\t\ti--;\n\t\tif (aa[i] == 0)\n\t\t\taa[i] = 2;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tprintf(\"%d \", aa[i]);\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "44c59801d45862da8db67c9ed114f3c6", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "\n#include\n#include\n#include\n\nint main()\n{\n long long int a,b,c;\n long long int n=1000000,q,e;\n long long int d[n];\n int i,j;\n for(i=1; i<=n; i++) {\n for(j=i; j<=n; j+=i) {\n d[j]++;\n }\n }\n scanf(\"%lld %lld %lld\",&a,&b,&c);\n {\n long long int p=0;\n for(i=1; i<=a; i++) {\n for(j=1; j<=b; j++) {\n for(int k=1; k<=c; k++) {\n \n p=p+d[i*j*k];\n e=p%1073741824;\n }\n }\n }\n printf(\"%lld\\n\",e);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "a4a55acdff4e3370c3b483b4334aead7", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main()\n{\n\tlong long int m,b,t,ans=0;\n\tscanf(\"%lld %lld\",&m,&b);\n\tint i;\n\tfor(i=0;i<=m*b;i++)\n\t{\n\t\tif(i%m==0)\n\t\t\tt=((-1*i)/m+b);\n\t\telse\n\t\t\tt=((-1*i)/m)+b-1;\n\t\tlong long int temp1=(i+1)*(t+1)*(i+t)/2;\n\t\tif(temp1>ans)\n\t\t\tans=temp1;\n\t}\t\n\tprintf(\"%lld\\n\",ans);\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "079bde4ce4dd2d19c28230094da7332d", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n\tint a,b,x,n;\n\tscanf(\"%d%d%d\",&a,&b,&x);\n\tn=a+b;\n\tchar u,v;\n\tif(a>b){\n\t\tu='0';v='1';\n\t}\n\telse{\n\t\tv='0';u='1';\n\t\tint temp=a;a=b;b=temp;\n\t}\n\tfor(int i=0;i\nint a[60], b[60];\nint n, l;\n\nvoid arrange(){\n\tint x1, y1, x2, y2;\n\tx1 = a[n-1], y1 = a[0];\n\tx2 = b[n-1], y2 = b[0];\n\tfor(int i=0; i\nint main()\n{long long x=0,a=0;\nscanf(\"%I64d\",&x);\na=x%3+x/3;\nprintf(\"%I64d\",&a)\n return 0;\n }", "lang_cluster": "C", "compilation_error": true, "code_uid": "90284b101a0b6cd3b762db988c85e3ff", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \nlong long fact(long long int n)\n{\n long long int ans = 1;\n for (long long int i = 2; i<=n; i++)\n ans*=i;\n return ans;\n}\n\nint main()\n{\n int h[10] = {},f[10] = {},p,f0,fn0;\n long long int n,temp,ctr = 0;\n scanf(\"%I64d\",&n);\n while(n>0)\n {\n h[n%10]++;\n n/=10;\n }\n outer :while(1)\n {\n f0 = 0, fn0 = 0,p = 9;\n f[9]++;\n while(f[p] > h[p] && p>0)\n {\n f[p] = 0;\n f[--p]++;\n }\n printf(\"\\n\");\n if (f[0] > h[0])\n break;\n f0 = f[0];\n for (int i = 1; i<10; i++)\n fn0+=f[i];\n temp = fn0 * fact(fn0 + f0 -1);\n for (int i = 0; i<10; i++)\n {\n if (f[i] == 0 && h[i]!=0)\n {\n temp = 0;\n break;\n }\n temp/=(f[i] > 0)?fact(f[i]) : 1;\n }\n ctr+=temp;\n }\n printf(\"%I64d\",ctr);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "499cc90607ae62b30392ff33316e4e66", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include \nint min(int a, int b){if(ab) ? ( (a>c)? a : c ) :( (b>c)? b : c );\n mn = (a= 2*d){\n int t=min(mx-s,s-mn);\n if(t>=d)\n printf(\"0\");\n else\n printf(\"%i\",d-t );\n }\n else{\n int t = (mx-s > s - mn)? mx-s : s - mn ;\n if(t>d)\n t -= d\n printf(\"%i\", 2*d-(mx-mn) +t );\n }\n \n return 0-0-0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "36ff75a8e24b8a7241bf312207bdd6fc", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0} {"lang": "GNU C", "source_code": "#include\n\n#define lli long long int\n\nlli boy,girl,num,i,j,top;\n\nlli C(lli x,lli y){\n \n long long int s = 1,son = x-y+1,t = 1;\n for(int i = x; i >= son; i--){\n s *= i;\n s /= t++;\n }\n return s;\n}\n\nvoid coz(){\n\n for(i = 4; i < num; i++)\n top += C(boy,i)*C(girl,num-i);\n \n printf(\"%lld\\n\",top);\n}\n\nint main(){\n\n scanf(\"%lld %lld %lld\",&boy,&girl,&num);\n coz();\n \n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "fa517c28a96c0df988935400c6b71bb2", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nlong long getpath(long long pos, int h, int origh, int n, int indi, int *found)\n{\n long long x = 0;\n if (h == 0 && n == pos) { *found = 1; return 0; }\n else if (h == 0) return 1;\n int tmp = n;\n \n tmp = tmp>>(h);\n if (tmp != pos) return (1<<(h + 1)) - 1;\n \n x = getpath(pos * 2 + indi, h - 1, h, n, !indi, found);\n if (!*found) x += getpath(pos * 2 + !indi, h - 1, h, n, indi, found);\n \n return x + 1;\n \n}\nint main(int argc, char **argv)\n{\n int h, n;\n scanf(\"%d%d\", &h, &n);\n n--;\n long long x = 0;\n int found = 0;\n x = getpath(0, h, h, n, 0, &found);\n printf(\"%I64d\\n\", x);\n system(\"pause\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "f3b83cee05d9ba2e3c0b8193abbf2ccf", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nmain()\n{\n char a[55];\n scanf(\"%s\", a);\n int x=strlen(a), y=strspn(a, &a[x-1]);\n if(x==y)\n {printf(\"1\");}\n else\n {\n for(int i=x-1; i>1;)\n {\n if(x%i==0)\n {\n int z=x/i, w=z;\n while(z\nint main()\n{long long int a[3]={0},b,c,y,x,i,j,k=0,t;\nscanf(\"%I64d %I64d %I64d\",&a[0],&a[1],&a[2]);\nfor(i=0;i<3;i++)\nfor(j=0;j<3-i-1;j++)\nif(a[j]=0;i--)\n{ if(a[i]-a[i+1]==0)\n {\n k+=a[i];\n goto flag;\n }\n}if(a[1]-a[2]==1)\n{k+=a[0]-a[1];a[0]=a[1];}\nelse\n{\n x=(a[1]+a[2])/2;\n y=x-a[2];\n a[2]=x;\n a[1]-=y;\n a[0]-=y;\n k+=y;\n}\n\nif(a[1]\nchar mark[100000];\nlong long PN[100000];\nint pC = 0;\nlong long PS[100000];\nint sC = 0;\nlong long BP(long long a, long long b, long long p)\n{\n long long r = 1;\n while (b)\n {\n if (b & 1)\n {\n r *= a;\n r %= p;\n }\n a *= a;\n a %= p;\n b >>= 1;\n }\n return r;\n}\nvoid PG()\n{\n int i;\n long long t;\n for (t = 1; t < 100000; t++)\n {\n mark[t] = 1;\n }\n for (t = 2; t < 100000; t++)\n {\n if (mark[t])\n {\n PN[pC] = t;\n pC++;\n }\n for (i = 0; i < pC; i++)\n {\n if (t * PN[i] >= 100000)\n {\n break;\n }\n mark[t * PN[i]] = 0;\n if (t % PN[i] == 0)\n {\n break;\n }\n }\n }\n}\nint main()\n{\n int i;\n long long x, n;\n long long temp;\n long long t;\n long long R = 1;\n PG();\n scanf(\"%I64d %I64d\", &x, &n);\n temp = x;\n for (i = 0; i < pC; i++)\n {\n if (temp % PN[i] == 0)\n {\n PS[sC] = PN[i];\n sC++;\n temp /= PN[i];\n while (temp % PN[i] == 0)\n {\n temp /= PN[i];\n }\n }\n if (temp == 1)\n {\n break;\n }\n }\n if (temp > 1)\n {\n PS[sC] = temp;\n sC++;\n }\n for (i = 0; i < sC; i++)\n {\n t = PS[i];\n while (64)\n {\n R *= BP(PS[i], n / t, 1000000007);\n R %= 1000000007;\n if (n / t < PS[i])\n {\n break;\n }\n else\n {\n t *= PS[i];\n }\n }\n }\n printf(\"%I64d\", R);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "04b4d0d6716468fa27cf6a675f528527", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n//int a[1000000001];\n//int count(int n,int x)\n//{\n//\tif(n==1)return 2;\n//\tif(a[n])return a[n];\n//\t a[n]=(3*count(n-1,x)%x+2)%x;\n//\t return a[n];\n//}\nint main()\n{\n\tint n,x,i;\n\tint ans=2;\n\tscanf(\"%d%d\",&n,&x);\n\tfor(i=1;i\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tif(n%2 == 0) printf(\"white\\n1 2\\n\");\n\telse printf(\"black\\n\");\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "54a7c40a201eacb66ab7916aeec6f10b", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.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 \nint n,m,i,j,k,min,ans[25],f[25],s,l,t[25];\nstruct u\n{\n\tint a,b;\n}a[25],b[25];\n\n\nint main()\n{\n\tscanf(\"%d %d\",&n,&m);\n\tfor (i=1;i<=n;i++) scanf(\"%d %d\",&a[i].a,&a[i].b);\n\tfor (i=1;i<=m;i++) scanf(\"%d %d\",&b[i].a,&b[i].b);\n\tmemset(ans,0,sizeof(ans));\n\tfor (i=1;i<=n;i++) \n\t{\n\t\tfor (j=1;j<=9;j++) t[j]=ans[j];\n\t\tfor (j=1;j<=m;j++)\n\t\t{\n\t\t\tmemset(f,0,sizeof(f));\n\t\t\tf[a[i].a]++;\n\t\t\tf[a[i].b]++;\n\t\t\tf[b[j].a]++;\n\t\t\tf[b[j].b]++;\n\t\t\tfor (l=1,s=0;l<=9;l++)\n\t\t\tif (f[l]) \n\t\t\t{\n\t\t\t\ts++;\n\t\t\t\tif (f[l]==2) k=l;\n\t\t\t}\n\t\t\tif (s==3) ans[k]++;\n\t\t}\n\t\tmemset(f,0,sizeof(f));\n\t\tfor (j=1,s=0;j<=9;j++) \n\t\tif (t[j]1) \n\t\t{\n\t\t\tputs(\"-1\");\n\t\t\texit(0);\n\t\t}\n\t}\n\tmemset(ans,0,sizeof(ans));\n\tfor (i=1;i<=m;i++) \n\t{\n\t\tfor (j=1;j<=9;j++) t[j]=ans[j];\n\t\tfor (j=1;j<=n;j++)\n\t\t{\n\t\t\tmemset(f,0,sizeof(f));\n\t\t\tf[a[j].a]++;\n\t\t\tf[a[j].b]++;\n\t\t\tf[b[i].a]++;\n\t\t\tf[b[i].b]++;\n\t\t\tfor (l=1,s=0;l<=9;l++)\n\t\t\tif (f[l]) \n\t\t\t{\n\t\t\t\ts++;\n\t\t\t\tif (f[l]==2) k=l;\n\t\t\t}\n\t\t\tif (s==3) ans[k]++;\n\t\t}\n\t\tfor (j=1,s=0;j<=9;j++) \n\t\tif (t[j]1) \n\t\t{\n\t\t\tputs(\"-1\");\n\t\t\texit(0);\n\t\t}\n\t}\n\tmemset(f,0,sizeof(f));\n\tfor (i=1,s=0;i<=9;i++) \n\tif (ans[i]) \n\t{\n\t\ts++;\n\t\tk=i;\n\t}\n\tif (s==0) puts(\"-1\");\n\telse if (s==1) printf(\"%d\\n\",k);\n\telse puts(\"0\");\n\treturn 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "bfb5875390bbdae08c790e535788b21c", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "// sigma0(Prod[pi^ai]) = Prod(ai+1)\n// hence to have 4 divisors we need to consider numbers in the form: p^3, pq\n\n#include \n#include \n#include \n\n#include \n#define __STDC_FORMAT_MACROS\n#include \n\n#define IMPL_LOWER_BOUND_VTYPE(T, VT, NAME, CMP) \\\n static inline int NAME(int n, const T elem[const static n], VT v) { \\\n int low = 0, high = n; /* start with whole array */ \\\n while(high > low) { /* more than one candidate */ \\\n const int mid = low + (high - low) / 2; /* pick middle */ \\\n if(CMP(elem[mid], v)) low = mid + 1; /* a[mid] < v: no need to consider mid */ \\\n else high = mid; /* a[mid] >= v: pick first half */ \\\n } \\\n return low; \\\n }\n\n#define LESS(a,b) ((a)<(b))\nIMPL_LOWER_BOUND_VTYPE(int64_t, int64_t, lower_bound, LESS)\n\n#define SIEVE_MAX_PRIME 99999989\n#define SIEVE_PRIME_COUNT 5761455\n\nstatic bool _sieve_is_composite[SIEVE_MAX_PRIME/2+1] = {}; // 2*i+1\nstatic int64_t _sieve_prime[SIEVE_PRIME_COUNT];\n\nstatic void generate_primes() {\n // sieve\n _sieve_is_composite[0] = true;\n for(int64_t i = 1, j = 3 ; j*j <= SIEVE_MAX_PRIME ; ++i, j+= 2) {\n if(_sieve_is_composite[i]) continue;\n for(int64_t jj = j*j, ii = (jj-1)/2 ; jj <= SIEVE_MAX_PRIME ; jj += 2*j, ii += j)\n _sieve_is_composite[ii] = true;\n }\n\n // collect primes\n _sieve_prime[0] = 2;\n for(int64_t i = 0, in = (SIEVE_MAX_PRIME-1)/2, pi = 1 ; i <= in ; ++i) {\n if(_sieve_is_composite[i]) continue;\n assert(pi < SIEVE_PRIME_COUNT); _sieve_prime[pi++] = 2*i+1;\n }\n}\n\nstatic uint64_t isqrt(uint64_t n) {\n uint64_t bit_place = 1ULL << 31;\n while(bit_place > n) bit_place >>= 1;\n\n uint64_t root = 0; while(bit_place) {\n const uint64_t root_cand = root | bit_place, square_cand = root_cand*root_cand;\n if(square_cand <= n) root = root_cand;\n bit_place >>= 1;\n }\n return root;\n}\n\nstatic uint64_t icbrt(uint64_t n) {\n // modified code from hacker's delight, applying 64-bit specific fixes\n int64_t y = 0;\n for(int s = 63 ; s >= 0 ; s -= 3) {\n y = 2*y;\n int64_t b = 3*y*(y+1) + 1;\n if((n >> s) >= b) {\n n -= (b << s); ++y;\n }\n }\n return y;\n}\n\n// we need to memoize only lower levels of the tree\n#define LPHI_MEMO_X 100000LL\n#define LPHI_MEMO_A 100LL\nstatic int64_t _lphi_memo[LPHI_MEMO_X+1][LPHI_MEMO_A+1] = {};\n\nstatic int64_t legendre_phi(int64_t x, int64_t a) { assert(a < SIEVE_PRIME_COUNT);\n if(a == 1) return (x+1)/2; // odd numbers\n\n const bool should_memo = x <= LPHI_MEMO_X && a <= LPHI_MEMO_A;\n if(should_memo && _lphi_memo[x][a]) return _lphi_memo[x][a];\n\n // do not forget that in math we count primes from 1, but in prime array we count from 0\n const int64_t p = _sieve_prime[a-1];\n const int64_t t1 = legendre_phi(x, a-1); // not using p[1],...,p[a-1]\n const int64_t t2 = x >= p ? legendre_phi(x/p, a-1) : 0; // not using p[1],...,p[a-1], but uses p[a]\n const int64_t phi = t1 - t2; if(should_memo) _lphi_memo[x][a] = phi;\n\n return phi;\n}\n\nstatic int64_t prime_pi_lehmer(int64_t N) {\n if(N <= SIEVE_MAX_PRIME) {\n const int idx = lower_bound(SIEVE_PRIME_COUNT, _sieve_prime, N); assert(idx < SIEVE_PRIME_COUNT);\n return idx + (_sieve_prime[idx] == N ? 1 : 0);\n }\n const int64_t N_2 = isqrt(N), a = prime_pi_lehmer(isqrt(N_2)), b = prime_pi_lehmer(N_2), c = prime_pi_lehmer(icbrt(N));\n int64_t ret = legendre_phi(N,a) + ((b+a-2)*(b-a+1)) / 2;\n for(int64_t i = a+1 ; i <= b ; ++i)\n ret -= prime_pi_lehmer(N/_sieve_prime[i-1]);\n for(int64_t i = a+1 ; i <= c ; ++i) {\n const int64_t pi = _sieve_prime[i-1], bi = prime_pi_lehmer(isqrt(N/pi));\n for(int64_t j = i ; j <= bi ; ++j)\n ret -= (prime_pi_lehmer(N/(pi*_sieve_prime[j-1])) - (j-1));\n }\n return ret;\n}\n\n\nint main() {\n generate_primes();\n\n int64_t N; scanf(\"%\" PRId64 \"\\n\", &N);\n\n int64_t count = 0;\n\n for(int i = 0 ; i < SIEVE_PRIME_COUNT ; ++i) {\n const int64_t p = _sieve_prime[i]; if(p*p*p > N) break;\n ++count;\n }\n\n for(int i = 0 ; i < SIEVE_PRIME_COUNT ; ++i) {\n const int64_t p = _sieve_prime[i]; if(p*p > N) break;\n const int64_t ppi = prime_pi_lehmer(N/p);\n if(ppi <= (i+1)) break;\n count += ppi - (i+1); // do not forget that in math we count primes from 1, but in prime array we count from 0\n }\n\n printf(\"%\" PRId64 \"\\n\", count);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "5b693aedccf9877ef3075641aa779025", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "difficulty": 2400.0} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tdouble n,t;\n\tdouble arr[11][11];\n\tint i,j;\n\tscanf(\"%lf %lf\",&n,&t);\n\tfor(i=1;i<=n;i++)\n\t\tfor(j=1;j<=i;j++)\n\t\t\tarr[i][j] = 0;\n\tint flag = 0;\n\tif(t >= 1)\n\t\tarr[1][1] = 1;\n\telse\n\t{\n\t\tflag = 1;\n\t}\n\tdouble over = t;\n\tarr[1][1] = 1;\n\ti = 1;\n\tover = (over-1)/2;\n\twhile(i<=n)\n\t{\n\t\tfor(j=1;j<=i;j++)\n\t\t{\n\t\t\tarr[i+1][j] += over;\n\t\t\tarr[i+1][j+1] += over;\n\t\t}\n\t\tover = (over-1)/2;\n\t\tif(over > 0)\n\t\t{\n\t\t\tfor(j=1;j<=i;j++)\n\t\t\t\tarr[i][j] = 1;\n\t\t}\n\t\tif(over < 0)\n\t\t\tbreak;\n\t\ti = i + 1;\n\t}\n\tint k,ans=0;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tfor(j=1;j<=i;j++)\n\t\t{\n\t\t\tif(arr[i][j] >= 1)\n\t\t\t\tans = ans + 1;\n\t\t}\n\t}\n\tif(flag == 0)\n\t\tprintf(\"%d\\n\",ans);\n\telse\n\t\tprintf(\"0\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a0520b304893ec08231890a9275fe42a", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n if(k<=n/2)\n {\n printf(\"%d\",k*(2*n-2*k-1));\n }\n else printf(\"%d\",(n/2)*n);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "119fcb9dce0879c399f6297ff5c2316b", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n#include\nusing namespace std;\n\nint c1, c2, x, y, ans;\nint main()\n{\n scanf(\"%d%d%d%d\", &c1, &c2, &x, &y);\n\n ans = c1+c2;\n while(ans - ans/x < c1)\n {\n ans += c1 - (ans - ans/x);\n }\n while(ans - ans/y < c2)\n {\n ans += c2 - (ans - ans/y);\n }\n while(ans - ans/(x*y) < c1+c2)\n {\n ans += (c1+c2) - (ans - ans/(x*y));\n }\n printf(\"%d\\n\", ans);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a99b72f3f57b1533153b5d03274e1efb", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,n2;\n\tscanf(\"%d\",&n);\n\tn2=n;\n\tint max,max2;\n\tscanf(\"%d\",&max);\n\tn--;\n\tmax2=0;\n\twhile(n--)\n\t{\n\t\tint k;\n\t\tscanf(\"%d\",&k);\n\t\tif(k>max)\n\t\t{\n\t\t\tint temp=max;\n\t\t\tmax=k;\n\t\t\tmax2=temp;\n\t\t}\n\t\telse if(kmax2)\n\t\t\t\tmax2=k;\n\t\t}\n\t}\n\tif(n2==7)\n\t\tprintf(\"YES\\n\");\n\telse\n\t{\n\tif(max2*2 <= max)\n\t\tprintf(\"NO\\n\");\n\telse\n\t\tprintf(\"YES\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "eb987ba2ba978bd95e3ec08b48243405", "src_uid": "ab003ab094931fc105384df9d144131e", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint result(int n)\n{\n int t=0;\n while(n)\n {\n if((n%10!=0)&&(n%10!=1))\n t++;\n n=n/10;\n }\n if(t)\n return 0;\n return 1;\n}\nint cmpfunc(const void*a,const void*b)\n{\n return (*(int*)a - *(int*)b);\n}\nint main()\n{\n int n,m,i,j,sum=1,chk=0,k=0,c=0,max=0,min=0,d=0;\n int a[2000005]={0},b[5]={0};\n char ch[101];\n scanf(\"%s\",ch);\n d=strlen(ch);\n k=d-1;\n while(k--)\n {\n sum*=2\n }\n sum--;\n n=atoi(ch);\n d--;\n m=1;\n while(d--)\n {\n m=m*10;\n }\n //printf(\"%d\\n\",m);\n for(i=m;i<=(m*2);i++)\n {\n c=result(i);\n sum+=c;\n if(i>n)\n break;\n //printf(\"%d\\n\",c);\n }\n printf(\"%d\",sum);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "a0fba080ba4b3366e487cd5428292bd7", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define MAX 100000\n\nint main()\n{\n\tchar hint[MAX], c ;\n\tint let_flag[10] = {0}, i, pos ;\n\tlong long int n ;\n\t\n\tscanf(\" %s\",hint) ;\n\n\tn = 1 ;\n\tpos = 10 ;\n\n\tfor(i=0;i='A')&&(c<='J'))\n\t\t{\n\t\t\tif(let_flag[c-65]==0)\n\t\t\t{\n\t\t\t\tlet_flag[c-65] = 1 ;\n\t\t\t\tif(i==0)\n\t\t\t\t\tn *= 9 ;\n\t\t\t\telse\n\t\t\t\t\tn *= pos ;\n\t\t\t\tpos-- ;\n\t\t\t}\n\t\t}\n\t\telse if(c=='?')\n\t\t{\n\t\t\tif(i==0)\n\t\t\t\tn *= 9 ;\n\t\t\telse\n\t\t\t\tn *= 10 ;\n\t\t}\n\t}\n\n\tprintf(\"%I64d \\n\",n) ;\n}\n\n\t\t\t\t\nvoid dec_pos(int *pos)\n{\n\tif(*pos != 1)\n\t\t(*pos)-- ;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b3cc1b8e8c5a8ad98960c322d64ee2ac", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "import java.util.*;\n\npublic class BabyEhabPrtnAgain{\n static ArrayList freq[]=new ArrayList[11];\n \n static void findPos(int n,int j){\n int pos=0;\n while(n!=0){\n int rem=n%2;\n if(rem==1)\n freq[pos].add(j+1);\n pos++;\n n/=2;\n }\n }\n \n public static void main(String args[]){\n Scanner Sc=new Scanner (System.in);\n \n int n=Sc.nextInt();\n int arr[]=new int[n];\n \n \n for(int j=0;j<11;j++)\n freq[j]=new ArrayList<>();\n \n for(int j=0;j\n#include\n#include\n#include\n#include\n#include\n\n\n#define KONTROL(x,y,t) (!mariaMove[x][y][t] && x >= 0 && x < n && y >= 0 && y < n)\n\n#define Max(a,b) (((a) > (b)) ? (a) : (b))\n#define Min(a,b) (((a) < (b)) ? (a) : (b))\n\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\n#define SWAP(a,b) {t = a; a = b; b = t;}\n\n#define lli long long int\n\n#define endl puts(\"\")\n\n#define MAX 1e5 + 9\n\ntypedef struct pair{\n\tint x, y;\n}pair;\n\nint const N = 1e4 + 5;\n\nint n = 8;\n\npair sMatrix[N], sac[N];\n\nchar matrix[N][N], mariaMove[10][10][10];\n\npair anna, maria;\n\nint i, j, k, s, m, h, t;\n\nint kontrol(int x, int y){\n\tint i, j;\n\tfor(i = 0; i < s; i++) {\n\t\tif(sMatrix[i].x == x && sMatrix[i].y == y)\n\t\t\treturn 0;\n\t}\n\treturn 1;\n}\n\nvoid sDown(int add) {\n\tint i;\n\tfor(i = 0; i < s; i++) {\n\t\tsMatrix[i].x += add;\n\t}\n}\n\t\nvoid dfs(int x, int y, int t) {\n\tint i, j, k;\n\t\n\tif(x == anna.x && y == anna.y) {\n\t\tprintf(\"WIN\"), endl;\n\t\texit(0);\n\t}\n\n\tif(!KONTROL(x,y,t) || !kontrol(x,y)) return ;\n\t\n\tsDown(1);\n\n\tif(!kontrol(x,y)){ sDown(-1); return ; }\n\n\tmariaMove[x][y][t] = 1;\n\t\n\tfor(i = -1, k = 0; i <= 1; i++) {\n\t\tfor(j = -1; j <= 1; j++, k++) {\n\t\t\tdfs(x+i,y+j, k);\n\t\t}\n\t}\n\tsDown(-1);\n}\n\nvoid clearMariaMove() {\n\tint i, j, k;\n\tfor(i = 0; i < 10; i++) {\n\t\tfor(j = 0; j < 10; j++) {\n\t\t\tfor(k = 0; k < 100; k++) {\n\t\t\t\tmariaMove[i][j][k] = 0;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid clear_sMatrix() {\n\tint i;\n\tfor(i = 0; i < s; i++) {\n\t\tsMatrix[i].x = sac[i].x;\n\t\tsMatrix[i].y = sac[i].y;\n\t}\n}\n\nint main() {\n\t\n\tfor(i = 0; i < n; i++) {\t\n\t\tscanf(\"%s\", matrix[i]);\n\t\tfor(j = 0; j < n; j++) {\n\t\t\tif(matrix[i][j] == 'S') {\n\t\t\t\tsMatrix[s].x = i, sMatrix[s].y = j;\n\t\t\t\tsac[s].x = i, sac[s].y = j;\n\t\t\t\ts++;\n\t\t\t}\n\t\t}\n\t}\n\n\tmaria.x = 7, maria.y = 0;\n\tanna.x = 0, anna.y = 7;\n\n\tfor(i = -1; i <= 0; i++) {\n\t\tfor(j = 0; j <= 1; j++) {\n\t\t\tdfs(maria.x+i, maria.y+j, 0);\n\t\t\tclearMariaMove();\n\t\t\tclear_sMatrix();\n\t\t}\n\t}\t\n\n\tputs(\"LOSE\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "127621ad9c52a952f228008326f67fe9", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include \nstruct point {\n int x;\n int y;\n};\nstruct point point_subtract(struct point a, struct point b) {\n return {.x = a.x - b.x, .y = a.y - b.y};\n}\nstruct point point_add(struct point a, struct point b) {\n return {.x = a.x + b.x, .y = a.y + b.y};\n}\nvoid print_point(struct point a) {\n printf(\"%d %d\", a.x, a.y);\n}\nint main(void) {\n struct point a, b, c;\n struct point d[3];\n scanf(\"%d %d\\n%d %d\\n%d %d\", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y);\n d[0] = point_add(point_subtract(a, c), b);\n d[1] = point_add(point_subtract(b, a), c);\n d[2] = point_add(point_subtract(a, b), c);\n printf(\"3\");\n for(int i = 0; i < 3; i++) {\n printf(\"\\n\");\n print_point(d[i]);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "e9d051547fb2ac985447b65aa23175bb", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main()\n{\n\t//freopen(\"program.txt\",\"r\",stdin);\n\tlong long int n,k,a,b;\n\tlong long int i,j;\n\tscanf(\"%I64d %I64d %I64d %I64d\",&n,&k,&a,&b);\n\tlong long int ans=0;\n\twhile(n!=1)\n\t{\n\t\tlogn long int rem=n%k;\n\t\tif(rem!=0)\n\t\t{\n\t\t\tif(n\n#include\ntypedef long long (ll);\nint main()\n{\n\tll a,b,c,d,e,f,g,h,i,j,k,l,o,p,q;\n\tscanf(\"%lli\",&a);\n\tfor(b=c=1;b\nint main()\n{\n\tlong long int a,b,c,d,i;\n\tlong long int ans=0;\n\tscanf(\"%lld%lld%lld%lld\",&a,&b,&c,&d);\n\tfor(i=c;i<=d;i++)\n\t{\n\t\tif(i+2>=a+b)\n\t\t\tans+=((i-a-b+2)*(i-a-b+1))/2;\n\t\tif(i+2>=2*b+1)\n\t\t\tans-=((i-2*b+1)*(i-2*b))/2;\n\t\tif(i+2>=a+c+1)\n\t\t\tans-=((i-a-c+1)*(i-a-c))/2;\n\t\tif(i-b-c>=0)\n\t\t\tans+=((i-b-c)*(i-b-c-1))/2;\n\t}\n\tans=(b-a+1)*(c-b+1)*(d-c+1)-ans;\n\tprintf(\"%lld\\n\",ans);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1f1f0b7b0f911f61016d8fae21c4ec4c", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nlong long arr[60000005];\nchar str[2000001];\nchar s1[2000001];\nint func(const void *a, const void *b)\n{\n\treturn (*(int*)a-*(int*)b);\n}\nlong long max(long long a, long long b)\n{\n\treturn (a>b)?a:b;\n}\nlong long min(long long a, long long b)\n{\n\treturn (a>b)?b:a;\n}\nlong long power(long long x, long long int y, long long p)\n{\n\tlong long int res = 1;\n\tx = x % p; \n\twhile (y > 0)\n\t{\n\t\tif (y & 1)\n\t\t\tres = (res*x) % p;\n\t\ty = y>>1; // y = y/2\n\t\tx = (x*x) % p; \n\t}\n\treturn res;\n}\nlong long isPrime(long long int n)\n{\n\tif (n <= 1) return 0;\n\tif (n <= 3) return 1;\n\tif (n%2 == 0 || n%3 == 0) return 0;\n\n\tfor (long long int i=5; i*i<=n; i=i+6)\n\t\tif (n%i == 0 || n%(i+2) == 0)\n\t\t\treturn 0;\n\treturn 1;\n}\nint main()\n{\n\tlong long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;\n\tscanf(\"%lld\", &n);\n\tif(n==1 || isPrime(n)==1)\n\t{\n\t\tprintf(\"1\\n\");\n\t\tprintf(\"0\\n\");\n\t}\n\telse\n\t{\n\t\tfor(i=0;i<=60000005;i++)\n\t\t\tarr[i]=i;\n\t\tfor(i=2;i*i<=60000005;i++)\n\t\t\tif(arr[i]!=0)\n\t\t\t\tfor(j=0;j*i+i*i<=60000005;j++)\n\t\t\t\t\tarr[i*i+j*i]=0;\n\t\tfor(i=2;i<=60000005;i++)\n\t\t\tif(n%i==0 && arr[i]==0 && i!=n)\n\t\t\t{flag=1;break;}\n\t\t\t\n\t\tif(flag)\n\t\t{printf(\"1\\n\");printf(\"%lld\\n\",i);}\n\t\telse\n\t\t\tprintf(\"2\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "06f6af0be23b1b6106f08021f047e522", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\n\ntypedef struct{\n\tint l, r, cont;\n} Range;\n\nchar string[300001];\n\nint main(){\n\tint i, n, worst=1, off=0, curr=0, num=0;\n\tscanf(\"%d %s\", &n, string);\n\tfor(i=0;ibest.cont){\n\t\t\t\t\tbest=dve;\n\t\t\t\t\tbest.r=i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(curr==0){\n\t\t\t\tif(ena.cont>best.cont){\n\t\t\t\t\tbest=ena;\n\t\t\t\t\tbest.r=i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n%d %d\\n\", best.cont, (best.l+off)%n+1, (best.r+off)%n+1);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4961b6e27a9cfd588bf71a40352daba8", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n long long int l,r,i,n,x;\n scanf(\"%I64d%I64d\",&l,&r);\n n=r;\n x=0;\n while(n!=0)\n { x=x*10+9;\n n=n/10;\n }\n if(l<=x/2&&r>=x/2)\n printf(\"%I64d\",(x+1)/2*((x+1)/2-1));\n\n if(rx/2)\n printf(\"%I64d\",l*(x-l));\n\n return 0;\n }\n\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "398d3bd733360cf55468e755a419a4bb", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \nint main() {\n\tint inp;\n\tint output;\n\tscanf(\"%d\",&inp);\n\toutput = sqrt(inp);\n\tprintf(\"%d\", output);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "95c7cfb88d37ad9d2e2cfe1faf276c48", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n char a[100];\n int b[]={0,0,0,0};\n int c[]={0,0,0,0};\n int r,b,y,g;\n scanf(\"%d\",&a);\n int i,j;\n for(i=0;a[i]!='\\0';++i)\n if(a[i]=='!')\n b[i%4]++;\n else \n c[i%4]=i;\n \n kr,kb,ky,kg\n for(i=0;i<4;++i)\n {\n for(j=0;j<4;++j)\n {\n if(a[c[j]]=='R')\n r=b[c[j]%4];\n else if(a[c[j]]=='B')\n b=b[c[j]%4];\n else if(a[c[j]]=='Y')\n y=b[c[j]%4];\n else if(a[c[j]]=='G')\n g=b[c[j]%4];\n }\n }\n printf(\"%d %d %d %d\",r,b,y,g);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "d4fb83e9c0a39f1a662a5c0c23672790", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nusing namespace std;\nint big[3][3];\nbool cmp(int a,int b){\n\treturn !big[a][b];\n}\nint main(){\n\tchar s[20];\n\tint qq=3;\n\tmemset(big,-1,sizeof(big));\n\twhile(qq--){\n\t\tscanf(\"%s\",s);\n\t\tif(s[1]=='<'){\n\t\t\t\tbig[s[2]-'A'][s[0]-'A']=1;\n\t\t\t\tbig[s[0]-'A'][s[2]-'A']=0;\n\t\t}else{\n\t\t\t\tbig[s[0]-'A'][s[2]-'A']=1;\n\t\t\t\tbig[s[2]-'A'][s[0]-'A']=0;\n\t\t}\n\t}\n\tif(big[0][1]&&big[1][2]&&big[2][0]||!big[0][1]&&!big[1][2]&&!big[2][0])printf(\"Impossible\\n\");\n\telse{\n\t\tint i,num[3];\n\t\tfor(i=0;i<3;i++)num[i]=i;\n\t\tsort(num,num+3,cmp);\n\t\tfor(i=0;i<3;i++)printf(\"%c\",num[i]+'A');\n\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "27f960c7541b4f6fead9550091950cb4", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "include\nint main(){\n long long a,b=0,c,d,i,j,level,x,cards,n,t;\n scanf(\"%lld\",&n);\n for(level=1000000;level>0;level--){\n x=(level*(level+1))/2-level;\n cards=(3*x+2*level);\n if(cards<=n){\n b=level;\n break;\n }\n }\n// printf(\"%lld\\n\",b);\n if(n%3==2){\n a=(b+2)/3;\n }else if(n%3==1){\n a=(b+1)/3;\n }else{\n a=b/3;\n }\n printf(\"%lld\\n\",a);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "d44d7fc26b2763bbe5bec4bbcfbce9e8", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\nint main(){\n int n;\n scanf(\"%d\",&n);\n int ar[n];\n float sum=0.0;\n for(int i=0;i=4.5){\n count++;\n break;\n }\n else{\n if(ar[i]!=5){\n sum=sum-ar[i]+5;\n ar[i]=5;\n }\n }\n }while(i\n#include \n#include \n\n#define MAX 2000010\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nshort len[MAX];\nchar mu[MAX], flag[MAX];\nint prime[MAX], dp[MAX], sum[MAX], power[MAX], L[MAX], *divisors[MAX];\n\nint expo(int a, int b){\n int res = 1;\n\n while (b){\n if (b & 1) res = (long long)res * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return res;\n}\n\nvoid mobius(){\n mu[1] = 1;\n int i, j, k, p = 0;\n\n for (i = 2; i < MAX; i++){\n if (!flag[i]) mu[i] = -1, prime[p++] = i;\n for (j = 0; j < p && (k = i * prime[j]) < MAX; j++){\n\n flag[k] = true;\n if (!(i % prime[j])){\n mu[k] = 0;\n break;\n }\n else mu[k] -= mu[i];\n }\n }\n for (i = 1; i < MAX; i++) sum[i] = sum[i - 1] + mu[i];\n}\n\nvoid generate(){\n mobius();\n int i, j, k, c, d, x;\n\n len[0] = len[1] = L[0] = L[1] = 1;\n for (i = 4; i < MAX; i++, i++) len[i] = 2;\n\n for (i = 3; (i * i) < MAX; i += 2){\n if (!len[i]){\n for (j = (i * i), d = i << 1; j < MAX; j += d){\n if (!len[j]) len[j] = i;\n }\n }\n }\n\n for (i = 2; i < MAX; i++){\n if (!len[i]) L[i] = i;\n else{\n L[i] = len[i];\n x = L[i /len[i]];\n if (x > L[i]) L[i] = x;\n }\n }\n\n divisors[1] = (int *) malloc(sizeof(int));\n divisors[1][0] = 1, len[1] = 1;\n\n for (i = 2; i < MAX; i++){\n c = 0, k = i;\n while (k > 1 && L[k] == L[i]){\n c++;\n k /= L[k];\n }\n\n len[i] = (c + 1) * len[k];\n divisors[i] = (int *) malloc(sizeof(int) * len[i]);\n\n for (x = 1, j = 0, len[i] = 0; j <= c; j++, x *= L[i]){\n for (d = 0; d < len[k]; d++){\n divisors[i][len[i]++] = divisors[k][d] * x;\n }\n }\n }\n}\n\nint count(int n, int m){\n int z, y, x = m;\n long long v, res = 0;\n\n while (x >= 1){\n y = m / x, z = m / (y + 1);\n v = (long long)power[y] * (sum[x] - sum[z]);\n x = z, res += v;\n }\n\n res = (res % MOD + MOD) % MOD;\n return res;\n}\n\nint solve(int n, int k){\n long long res = 0;\n int i, j, v, m, x, y, z;\n for (i = 0; i < MAX; i++) power[i] = expo(i, n);\n\n dp[1] = count(n, 1);\n for (m = 2; m <= k; m++){\n res = dp[m - 1];\n for (j = 0; j < len[m]; j++){\n x = 0, y = 0, z = 0;\n x = divisors[m][j], v = m / x;\n y = power[v] * mu[x];\n z = power[v - 1] * mu[x];\n res = res + y - z;\n }\n dp[m] = ((res % MOD) + MOD) % MOD;\n }\n\n for (m = 1, res = 0; m <= k; m++) res += (m ^ dp[m]);\n return res % MOD;\n}\n\nint main(){\n generate();\n int n, k, res;\n\n while (scanf(\"%d %d\", &n, &k) != EOF){\n printf(\"%d\\n\", solve(n, k));\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "03ee6d48332a5036cae4ce347db65572", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "GNU C11", "source_code": "#\n\n#include \n#include \n#include \n\n\nint f_max(int x, int y)\n{\n return x > y ? x : y;\n}\n\nint f_min(int x, int y)\n{\n return x > y ? y : x;\n}\nint main(void)\n{\n char tmp[100];\n int i = 0;\n while (i < 100) \n tmp[i++] = 0;\n int b = atoi(gets(tmp));\n i = 0;\n while (i < 100) \n tmp[i++] = 0;\n int g = atoi(gets(tmp));\n i = 0;\n while (i < 100) \n tmp[i++] = 0;\n int p = atoi(gets(tmp));\n\n int max = f_max(b, g);\n int min = f_min(b, g);\n if (p == 0)\n {\n printf(\"%d\", 0);\n return (0);\n }\n if (p <= min)\n {\n int b = p + 1;\n printf(\"%d\", b);\n return (0);\n }\n else if (p > min && p <= max)\n {\n int b = min + 1;\n printf(\"%d\", b);\n }\n else if (p > max && max + min >= p)\n {\n int ans = 0;\n int max1 = max;\n int min1 = 0;\n while (max1 + min1 < p && min1 < min)\n {\n ++min1;\n }\n while (min1 <= min)\n {\n ++ans;\n --max;\n ++min1;\n }\n printf(\"%d\", ans);\n return (0);\n }\n else \n {\n return (0);\n }\n\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4d72eb13842b17ed8b75bdbd348d8dbb", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "GNU C11", "source_code": "\n#include \n#include\n\nint lcm(int n1,int n2){\n int min;\n min = (n1 > n2) ? n1 : n2;\n while (1) {\n if (min % n1 == 0 && min % n2 == 0) {\n \n break;\n }\n ++min;\n }\n return min;\n} \nint main()\n{int n,k,x,y,m,p,t;\n scanf(\"%d\",&n);\n k=sqrt(n);\n for(t=k;t>0;t--){\n if(n%t==0 && lcm(t,n/t)==n){\n x=k-t;\n m=t;\n \n break;\n }\n }\nfor(t=k;t<=n;t++){\n if(n%t==0 && lcm(t,n/t)==n){\n y=t-k;\n p=t;\n break;\n }\n}\nif(x>y){\n \n printf(\"%d %d\",m,n/m);\n\n \n}\nelse{\n \n printf(\"%d %d\",p,n/p);\n \n}\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "22d0c1d531e8e9b62801322de8c63d4e", "src_uid": "e504a04cefef3da093573f9df711bcea", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include\n\n \nint main ()\n{\n \n int i, j, k, l;\n int a[100];\n scanf(\"%d\",&l);\n for(i=0; i\n#include \nint main()\n{\n\tint i,w,cnt,g,e,c,f,h,r;\n\tchar str[101];\n\tscanf(\"%s\",str);\n\tw=strlen(str);\n\tcnt=0;\n\tfor (i=0;i='A' && str[i]<='Z') || (str[i]>='a' && str[i]<='z')|| (str[i]>='0' && str[i]<='9') || str[i]=='_'){\n\t\t\tcnt++;\n\t\t\tif (cnt==0 || cnt>16){\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\telse if (str[i]=='@'){\n\t\t\tif (cnt==0 || cnt>16){\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tr=i;\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tc=0;\n\tg=0;\n\tf=0;\n\tfor (i=r+1;i='A' && str[i]<='Z') || (str[i]>='a' && str[i]<='z') || (str[i]>='0' && str[i]<='9') || str[i]=='_'){\n\t\t\tc++;\n\t\t\tg++;\n\t\t\tif (c==0 || c>16){\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif (g==0 || g>32){\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\telse if (str[i]=='.'){\n\t\t\t\n\t\t\t\n\t\t\tif (c==0 || g==0 || g>32){\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tc=0;\n\t\t\tg++;\n\t\t}\n\t\telse if (str[i]=='/'){\n\t\t\tf=1;\n\t\t\th=i;\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (c==0){\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t}\n\tif (f==0){\n\t\t\n\t\t\n\t\tprintf(\"YES\");\n\t\treturn 0;\n\t\t\n\t}\n\te=0;\n\tfor (i=h+1;i='A' && str[i]<='Z') || (str[i]>='a' && str[i]<='z')|| (str[i]>='0' && str[i]<='9') || str[i]=='_'){\n\t\t\te++;\n\t\t\tif (e==0 || e>16){\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\t\n\t\telse{\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (e==0){\n\t\tprintf(\"NO\");\n\t\treturn 0;\n\t}\n\tprintf(\"YES\");\n\treturn 0;\n\t\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "66045a06272d868ec5970334fd897022", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n\ntypedef long long int ll;\nconst ll mod=1e9+7;\n\nint main()\n{\n ll v1,v2,t,d,i,j,k,sum=0;\n scanf(\"%lld %lld %lld %lld\",&v1,&v2,&t,&d);\n if(d==0) printf(\"%lld\",v1*t);\n else{\n if(t%2==0) k=t/2;\n\telse k=(t+1)/2;\n\tj=v1;\n\tfor(i=0;i\n#include \n#include \n#include \n#include \n\nint x1, x2, x3, x4, x5, x6, y1, y2, y3, y4, y5, y6;\n\nvoid swap(int *a, int *b)\n{\n int t = *a;\n *a = *b;\n *b = t;\n}\n\nchar inside(int x, int y, int x1, int y1, int x2, int y2)\n{\n if (x >= x1 && x <= x2 && y >= y1 && y <= y2)\n return 1;\n return 0;\n}\n\nint main()\n{\n scanf(\"%d%d%d%d\", &x1, &y1, &x2, &y2);\n scanf(\"%d%d%d%d\", &x3, &y3, &x4, &y4);\n scanf(\"%d%d%d%d\", &x5, &y5, &x6, &y6);\n\n if (!(inside(x1, y1, x3, y3, x4, y4) || inside(x1, y1, x5, y5, x6, y6))) {\n printf(\"YES\");\n return 0;\n }\n if (!(inside(x2, y2, x3, y3, x4, y4) || inside(x2, y2, x5, y5, x6, y6))) {\n printf(\"YES\");\n return 0;\n }\n if (!(inside(x1, y2, x3, y3, x4, y4) || inside(x1, y2, x5, y5, x6, y6))) {\n printf(\"YES\");\n return 0;\n }\n if (!(inside(x2, y1, x3, y3, x4, y4) || inside(x2, y1, x5, y5, x6, y6))) {\n printf(\"YES\");\n return 0;\n }\n\n if (x5 < x3) {\n swap(&x3, &x5);\n swap(&x4, &x6);\n swap(&y3, &y5);\n swap(&y4, &y6);\n }\n if (x4 + 1 <= x5 && x4 + 1 >= x1 && x4 + 1 <= x2) {\n printf(\"YES\");\n return 0;\n }\n\n if (y6 > y4) {\n swap(&x3, &x5);\n swap(&x4, &x6);\n swap(&y3, &y5);\n swap(&y4, &y6);\n }\n if (y3 - 1 >= y6 && y3 - 1 <= y2 && y3 - 1 >= y1) {\n printf(\"YES\");\n return 0;\n }\n\n printf(\"NO\");\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "610655d04dfe1f0307f28110d7218c50", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long n;\n scanf(\"%ld\",&n);\n long a,b,c,i,d=0;\n a=1234567;\n b=123456;\n c=1234;\n d=a+b+c;\n \n if(n==d){\n printf(\"YES\\n\");\n break;\n }\n else if(n>d){\n printf(\"NO\\n\");\n break;\n }\n else if(n\n\nint main()\n{\n unsigned long long x1,y1,x2,y2;\n scanf(\"%lli %lli %lli %lli\",&x1,&y1,&x2,&y2);\n printf(\"%lli\",(x2-x1+1)*(y2-y1+1)/2+1)\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "c358e39a33629bc957a0f4f3530ec4f8", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include\nlong n,m,k,ans=1,Reduc_;\n\nint main(){\n scanf(\"%ld%ld%ld\",&n,&m,&k);\n m -= n;\n Reduc_ = 1;\n if(m == 0)\n{\nputs(\"1\");\nreturn 0;\n}\n while(m>0){\n if(k+ans<=n)++Reduc_;\n if(k-ans>=1)++Reduc_;\n m -= Reduc_;\n ++ans;\n }\n printf(\"%d\\n\",ans);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "3de5924a0544162075bdd7bd3b6aeaaa", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint main()\r\n{\r\n int t, i = 0, x, y, r;\r\n\r\n scanf(\"%d\", &t);\r\n\r\n while(t--) {\r\n scanf(\"%d%d\", &x, &y);\r\n if(x == 0) i++;\r\n if(y == 0) i++;\r\n scanf(\"%d%d\", &X, &y);\r\n if(x == 0) i++;\r\n if(y == 0) i++;\r\n\r\n if(i == 0) r = 0;\r\n else if(i < 4) r = 1;\r\n else r = 2;\r\n\r\n printf(\"%d\\n\", r);\r\n }\r\n}\r\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "e6e31cb1cc9daa3950c0f5474a898666", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int x;\n scanf(\"%d\",&x);\n for(long r=1;r=x)\n {\n mul=10*(mul/x)+(mul%x);\n }\n printf(\"%ld\",mul);\n }\n puts(\"\");\n \n }\n return 0;\n }\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9eede54198e536d0702a247587c0ba1f", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint check(long long int n)\n{\n\tint count=0;\n\twhile(n>0)\n\t{\n\t\tn=n/10;\n\t\tcount++;\n\t}\n\treturn count;\n}\nint cmp(const void *a,const void *b)\n{\n\tlong long int p=*(long long int *)a;\n\tlong long int q = *(long long int *)b;\n\tif(p==q)\n\t\treturn 0;\n\telse if(p>q)\n\t\treturn 1;\n\telse\n\t\treturn -1;\n\n}\nlong long int r[100005][20],k=0;\nvoid swap(long long int *x1,long long int *x2)\n {\n long long int x=*x1;\n *x1=*x2;\n *x2=x;\n }\n void per(long long int *arr,long long int st,long long int ls)\n {\n int i=0,l;\n if(st==ls)\n {\n for(l=0;l=n)\n \t\t{\n \t\t\tval=1;\n \t\t\tbreak;\n \t\t}\n \t}\n \tif(val==1)\n \t\tprintf(\"%lld\",ans[i]);\n \telse\n \t{\n \t\tp+=2;\n \t\tfor(i=0;i\n\nint main()\n\n{\n int l,d,v,g,r;\n \n scanf(\"%d%d%d%d%d\",&l,&d,&v,&g,&r);\n \n if((d/v)<=g)\n {\n printf(\"%d\",(l/v));\n }\n\n else\n {\n printf(\"%d\",(g + r + ((l-d)/v)))\n }\nreturn 0; \n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "db0488e6f4a188a0a6be45bcd5deae3b", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int a[6]={0},b,i=0,c;\n scanf(\"%d\",&b);\n while(b)\n {\n a[i]=b%10;\n i++;\n b=b/10;\n }\n int x,y;\n x=a[5]+a[4]+a[3];\n y=a[0]+a[1]+a[2];\n if(x==y)\n {\n printf(\"0\\n\");\n return 0;\n }\n else\n\n {\n int j,k;\n for(i=0;i<10;i++)\n if(x==(a[2]+a[1]+i))\n {\n printf(\"1\\n\");\n return 0;\n }\n for(i=0;i<10;i++)\n if(y==(a[4]+a[5]+i))\n {\n printf(\"1\\n\");\n return 0;\n }\n for(i=0;i<10;i++)\n for(j=0;j<10;j++)\n if(x==(a[2]+j+i))\n {\n printf(\"2\\n\");\n return 0;\n }\n\n for(i=0;i<10;i++)\n for(j=0;j<10;j++)\n if(y==(a[5]+j+i))\n {\n printf(\"2\\n\");\n return 0;\n }\n\n for(i=0;i<10;i++)\n for(j=0;j<10;j++)\n for(k=0;k<10;k++)\n if(x==(k+j+i))\n {\n printf(\"3\\n\");\n return 0;\n }\n\n for(i=0;i<10;i++)\n for(j=0;j<10;j++)\n for(k=0;k<10;k++)\n if(y==(k+j+i))\n {\n printf(\"3\\n\");\n return 0;\n }\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "2a610274a64543d7bcb0b544f59284c6", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define Min(x,y) ((x\n#include \n#include \nchar* tmps1=\"What are you doing while sending \\\"\";\nchar* tmps2=\"\\\"? Are you busy? Will you send \\\"\";\nchar* tmps3=\"\\\"?\";\nchar* f0=\"What are you doing at the end of the world? Are you busy? Will you save us?\";\nlong long pow2[54]={1};\nchar calc(int n,long long k)\n{\n\tif (n==0) return f0[k-1];\n\tif (k<=strlen(tmps1)) return tmps1[k-1];\n\tk-=strlen(tmps1);\n\tlong long len1=pow2[n-1]*143-68;\n\tif (k<=len1) return calc(n-1,k);\n\tk-=len1;\n\tif (k<=strlen(tmps2)) return tmps2[k-1];\n\tk-=strlen(tmps2);\n\tif (k<=len1) return calc(n-1,k);\n\tk-=len1;\n\treturn tmps3[k-1];\n}\nint main()\n{\n\tint i;\n\tfor (i=1;i<=53;i++) pow2[i]=2*pow2[i-1];\n\tint q;\n\tscanf(\"%d\",&q);\n\twhile (q--)\n\t{\n\t\tint n; long long k;\n\t\tscanf(\"%d%I64d\",&n,&k);\n\t\tif (n<=53&&k>pow2[n]*143-68)\n\t\t{\n\t\t\tprintf(\".\"); continue;\n\t\t}\n\t\tif (k<34*n)\n\t\t{\n\t\t\t printf(\"%c\",tmps1[(k-1)%34]);\n\t\t\t continue;\n\t\t}\n\t\tif (n>53)\n\t\t{\n\t\t\tprintf(\"%c\",calc(53,k-34*(n-53)));\n\t\t}\n\t\telse printf(\"%c\",calc(n,k));\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7eb22c04d3525697a29553d2db0238d3", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n\nstatic int c=0,w=0;\nvoid steps(int *x,int* y,int* z)\n{\n if(*x==*y && *y==*z && *z==w)\nreturn;\t \n else\n {\n\t if(*y+*z > w)\n\t {\n\t *x=w;\n\t ++c;\n\t }\n\t else if(*y+*z <=w) \n\t {\n\t ++c;\n\t *x=*y+*z-1;\n\t }\n\tsteps(y,z,x); \n }\n} \n\nint main()\n{\n\n int x,y,z;\n \n scanf(\"%d %d\",&w,&x);\n y=z=x;\n steps(&x,&y,&z);\n printf(\"%d\",c);\n return 0;\n\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cbba40512288d5e9cd2d0d52d4ced253", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\nvoid main()\n{\n\tlong int x=0,y=0,i=0,j=0;\n\tint a=0,b=0,c=0;\n\tscanf(\"%ld%ld\",&x,&y);\n\twhile((100*x)+(10*y)>=220)\n\t{\n\t\tif(y>=2)\n\t\t{\n\t\t\tif(x>=2)\n\t\t\t{x=x-2;\n\t\t\ty=y-2;}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(x>=1&&y>=12)\n\t\t\t\t{x=x-1;\n\t\t\t\ty=y-12;}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(y>=22)\n\t\t\t\t\t\ty=y-22;\n\t\t\t\t\telse\n\t\t\t\t\t{a=1;\n\t\t\t\t\tgoto flag1;}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{a=1;\n\t\tgoto flag1;}\n\t\t\tif(y>=2)\n\t\t{\n\t\t\tif(y>=22)\n\t\t\t{\n\t\t\ty=y-22;}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(x>=1&&y>=12)\n\t\t\t\t{x=x-1;\n\t\t\t\ty=y-12;}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(x>=2)\n\t\t\t\t\t{\ty=y-2;\n\t\t\t\t\tx=x-2;}\n\t\t\t\t\telse\n\t\t\t\t\t{b=1;\n\t\t\t\t\tgoto flag1;}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\tb=1;\n\t\tgoto flag1;}\n\t}\nflag1:\n\tif(a!=1)\n\t{printf(\"Hanako\");}\n\tif(b==1)\n\t{printf(\"Ciel\");}\n}\n \t\t\t \t \t\t \t\t\t \t\t\t", "lang_cluster": "C", "compilation_error": false, "code_uid": "5aeae00f3482f09c4f1113a36264246a", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n\nint n, m;\nint a[400000];\nint b[400000][4];\nint dx[4] = {1, 1, -1, -1};\nint dy[4] = {1, -1, 1, -1};\n\nint min(int a, int b)\n{\n if (a < b) {\n return a;\n } else {\n return b;\n }\n}\n\nint f(int x, int y)\n{\n if (x == 1) {\n return y - 1;\n } else if (x == n) {\n return m + y - 1;\n } else if (y == 1) {\n return 2 * m + x - 1;\n } else {\n return 2 * m + n + x - 1;\n }\n}\n\nint main()\n{\n int x, y, p, r = 0, i;\n long long sum = 1;\n char s[3];\n \n scanf(\"%d %d\", &n, &m);\n scanf(\"%d %d %s\", &x, &y, s);\n \n if (s[0] == 'D') {\n if (s[1] == 'R') {\n p = 0;\n } else {\n p = 1;\n }\n } else {\n if (s[1] == 'R') {\n p = 2;\n } else {\n p = 3;\n }\n }\n \n for (i = 1; i <= m; i++) {\n if ((x + y) % 2 != (i + 1) % 2) a[f(1, i)] = 1;\n if ((x + y) % 2 != (i + n) % 2) a[f(n, i)] = 1;\n }\n \n for (i = 1; i <= n; i++) {\n if ((x + y) % 2 != (i + 1) % 2) a[f(i, 1)] = 1;\n if ((x + y) % 2 != (i + m) % 2) a[f(i, m)] = 1;\n }\n \n a[2 * m] = a[2 * m + n - 1] = a[2 * m + n] = a[2 * m + 2 * n - 1] = a[f(x, y)] = 1;\n \n for (i = 0; i < 2 * m + 2 * n; i++) {\n if (a[i] == 0) r++;\n }\n \n while (1) {\n int c = 1e9;\n \n if (p < 2) {\n c = min(c, n - x);\n } else {\n c = min(c, x - 1);\n }\n \n if (p & 1) {\n c = min(c, y - 1);\n } else {\n c = min(c, m - y);\n }\n \n x += dx[p] * c;\n y += dy[p] * c;\n sum += c;\n \n if (a[f(x, y)] == 0) r--;\n \n if (r == 0) break;\n \n a[f(x, y)] = 1;\n \n if (b[f(x, y)][p] == 1) {\n puts(\"-1\");\n \n return 0;\n }\n \n b[f(x, y)][p] = 1;\n \n if (x == 1 || x == n) p = (p + 2) % 4;\n if (y == 1) p = (p + 3) % 4;\n if (y == m) p = (p + 1) % 4;\n }\n \n printf(\"%I64d\\n\", sum);\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "37419585489130bc40b12d4b8a0e45ae", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n //freopen(\"in.txt\", \"r\", stdin);\n int n, m, j, i, c = 0, sum = 0, c2 = 0, c1 = 0, k, l;\n scanf(\"%d\", &n);\n char st[10][11];\n\n for(i = 0; i<10; i++)\n {\n scanf(\"%s\", st[i]);\n }\n\n for(i = 0; i<10; i++)\n {\n for(j = 0; j<6; j++)\n {\n int cx = 0, co = 0;\n for(k = j; k max) max = cs[i];\n\t}\n\n\tprintf(\"%d\\n\",max);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "f1a2a1bc5842d571c0f1e7e306656ed0", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n \r\ntypedef long long ll;\r\n \r\nint mod = 998244353;\r\n \r\nll qPow(ll a, ll b) {\r\n\tll ret = 1;\r\n\twhile(b) {\r\n\t\tif(b&1)\r\n\t\t\tret = ret * a % mod;\r\n\t\ta = a * a % mod;\r\n\t\tb >>= 1;\r\n\t}\r\n\treturn ret;\r\n}\r\n \r\n \r\nint main() {\r\n int n, x;\r\n scanf(\"%d %d\", &n, &x);\r\n\tll C[n+1][n+1];\r\n\tmemset(C,0,sizeof(C));\r\n\tfor(int i=0;i<=n;i++){\r\n\t\tfor(int j=0;j<=i;j++) {\r\n\t\t\tif(!j)\r\n\t\t\t\tC[i][j] = 1;\r\n\t\t\telse\r\n\t\t\t\tC[i][j] = C[i-1][j] + C[i-1][j-1];\r\n\t\t\t\tif(C[i][j] >= mod)\r\n\t\t\t\t C[i][j] -= mod\r\n\t\t\t\t \r\n\t\t}\r\n\t}\r\n\tll f[n+1][x+1];\r\n\tmemset(f,0,sizeof(f));\r\n\tfor(int i=2;i<=n;i++){\r\n\t\tfor(int j=1;j<=x;j++) {\r\n\t\t\tif(j\n\nint t0,t1,t2;\ndouble comp(int y1,int y2)\n{\n double left = t0;\n double right = (double)((double)t1*y1+(double)t2*y2)/(double)(y1+y2);\n return left-right;\n}\n\nint main(void)\n{\n int x1,x2;\n double temp;\n scanf(\"%d%d%d%d%d\",&t1,&t2,&x1,&x2,&t0);\n int i,j;\n double state;\n temp = 999999.0000;\n int cold,hot;\n for(i=x1,j=x2; i>=0,j>=0;)\n {\n state = comp(i,j);\n if(state < 0.000001 && state > -0.000001)\n {\n cold = i;\n hot = j;\n break;\n }\n else if(i+j==1)\n break;\n else if(state > 0.000001)\n {\n i--;\n }\n else\n {\n if(-statey?g(x,y):g(y,x);x/=g,y/=g;d=(a/=x)<(b/=y)?a:b;printf(\"%d %d\\n\",x*d,y*d);}", "lang_cluster": "C", "compilation_error": true, "code_uid": "422793e9cac931997c273ab3d08f8e32", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n#define maxPrim 80000\n#define int_max 4000000000\n\nint prim[maxPrim] = { 2, 3, 5, 7, 11, 13 };\nint total = 6;\n\nstatic int isPrim(int x)\n{\n static int d;\n \n d = 0;\n while (d < total) {\n if (x == prim[d]) return 1;\n if ((x % prim[d]) == 0) return 0;\n ++d;\n }\n return 1;\n}\n\nstatic void genPrim(void)\n{\n static int i, n;\n \n i = 6, n = prim[5]+1;\n while (i < maxPrim) {\n if (isPrim(n)) { prim[i] = n; ++i; ++total; }\n ++n;\n }\n}\n\nstatic int mirror(int x)\n{\n static int d, i;\n \n d = x; i = 1;\n while (x > 0) {\n x = x / 10; i *= 10;\n }\n x = d;\n \n d = 0;\n while (x > 0) {\n i = i / 10;\n d += (x % 10) * i;\n x = x / 10;\n }\n \n return d;\n}\n\nstatic int findEots(int n)\n{\n static int i, eots, j, m;\n \n for (i = 5, j = 0; (j < n) && (i < maxPrim); ++i) {\n eots = prim[i]; m = mirror(eots);\n if ((m != eots) && isPrim(m)) ++j;\n }\n \n return eots;\n}\n\nint main(void)\n{\n static int n;\n \n genPrim();\n\n fscanf(stdin, \"%d\", &n);\n printf(\"%d\\n\", findEots(n));\n \n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "2eefa05470c8d8e57ffc01e11901fa57", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\ntypedef long long int LL;\n\n#define din(n) scanf(\"%d\",&n)\n#define dout(n) printf(\"%d\\n\",n)\n#define llin(n) scanf(\"%lld\",&n)\n#define llout(n) printf(\"%lld\\n\",n)\n#define strin(n) scanf(\" %s\",n)\n#define strout(n) printf(\"%s\\n\",n)\n#define power(a, b) po(a, b)\n\nint mod=1000000007;\nint graph[550][550];\nint color[550];\nchar out[550];\n\nlong long po(long long x, long long y)\n{\n\tlong long pro=1;\n\twhile(y>0)\n\t{\n\t\tif(y&1 != 0)\n\t\t\tpro=((pro%mod)*(x%mod))%mod;\n\t\tx=(x*x)%mod;\n\t\ty=y>>1;\n\t}\n\treturn pro%mod;\n}\n\ntypedef struct scan\n{\n\tint from;\n\tint to;\n}scan;\n\nint cmp(const void *a, const void *b)\n{\n\tscan a1 = * (scan *)a;\n\tscan b1 = * (scan *)b;\n\tif(a1.from > b1.from)\n\t return 1;\n\telse if(a1.from < b1.from)\n\t return -1;\n\telse\n\t return a1.to - b1.to;\n}\n\nint ulta(int a)\n{\n\tif(a==1)\n\t\treturn 2;\n\treturn 1;\n}\n\nint colorable(int n)\n{\n\tint i, j;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tint k=0;\n\t\tfor(j=1;j<=n;j++)\n\t\t\tif(graph[i][j] == 0)\n\t\t\t\tk++;\n\n\t\tif(color[i]==0)\n\t\t{\n\t\t\tif(k==n)\n\t\t\t\tcolor[i] = 3;\n\t\t\telse\n\t\t\t\tcolor[i] = 1;\n\t\t}\n\n\t\tint green = ulta(color[i]);\n\n\t\tfor(j=1;j<=n;j++)\n\t\t{\n\t\t\tif(graph[i][j] > 0)\n\t\t\t{\n\t\t\t\tif(color[j] == 0)\n\t\t\t\t\tcolor[j] = green;\n\t\t\t\telse if(color[j] == color[i])\n\t\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn(0);\n}\n\nint print(int n)\n{\n\tint i;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tif(color[i]==1)\n\t\t\tout[i-1] = 'a';\n\t\tif(color[i]==2)\n\t\t\tout[i-1] = 'c';\n\t\tif(color[i]==3)\n\t\t\tout[i-1] = 'b';\n\t}\n\tout[n] = '\\0';\n\tstrout(out);\n\treturn(0);\n}\n\nint main(void)\n{\n\tint n,m,i,j;\n\tscanf(\"%d\", &n);\n\tscanf(\"%d\", &m);\n\tscan input[1200];\n\tfor(i=0;i<2*m;i+=2)\n\t{\n\t\tscanf(\"%d %d\", &input[i].from, &input[i].to);\n\t\tinput[i+1].from = input[i].to;\n\t\tinput[i+1].to = input[i].from;\n\t}\n\t\n\tqsort(input, 2*m, sizeof(scan), cmp);\n\n\tfor(i=0;i<550;i++)\n\t\tfor(j=0;j<550;j++)\n\t\t\tgraph[i][j]=0;\n\n\tint count=0;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tfor(j=i+1;j<=n;j++)\n\t\t{\t\n\t\t\twhile(i > input[count].from && count < 2*m)\n\t\t\t\tcount++;\n\t\t\twhile(j > input[count].to && count < 2*m)\n\t\t\t\tcount++;\n\n\t\t\tif(count < 2*m)\n\t\t\t{\n\t\t\t\tint from = input[count].from;\n\t\t\t\tint to = input[count].to;\n\n\t\t\t\tif(from!=i || to!=j)\n\t\t\t\t{\n\t\t\t\t\tif(graph[j][i]==0 && graph[i][j]==0)\n\t\t\t\t\t\tgraph[i][j]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(graph[j][i]==0 && graph[i][j]==0)\n\t\t\t\t\tgraph[i][j]++;\n\t\t\t}\n\t\t}\n\t}\n\n\tint a = colorable(i, n);\n\tif(a==0)\n\t{\n\t\tprintf(\"Yes\\n\");\n\t\tprint(n);\n\t}\n\telse\n\t\tprintf(\"No\\n\");\n\t\n\treturn(0);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "784030ab1fd937dea1b72e1bf54b0cc5", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint arr[1010];\n\nint main() {\n\tint m, n, i, j;\n\tscanf(\"%d\", &n);\n\tfor (i = 1; i <= n; i++) scanf(\"%d\", &arr[i]);\n\tint maxn = 0;\n\tint cur = 0;\n\tarr[0] = 0, arr[n + 1] = 1001;\n\tn++;\n\tcur = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tif (arr[i] == arr[i - 1] + 1) cur++;\n\t\telse {\n\t\t\tcur = 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (maxn < cur) maxn = cur;\n\t}\n\tmaxn -= 2;\n\tprintf(\"%d\\n\", std::max(0, maxn));\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "133f58d74087700216d93cb5a2e9bf3c", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nvoid make(long long *n, char *s)\n{\n *n = 0;\n char c = getchar();\n\n while(isdigit(c))\n {\n (*n) = (*n)*10 + c - '0';\n c = getchar();\n }\n\n *s = c;\n}\n\nint main(void)\n{\n long long n;\n char s;\n\n long long sec = 0;\n long long at1 = 1, at2 = 3;\n\n int diff = 1;\n\n make(&n, &s);\n\n for(;;)\n {\n if(at1 == n)\n break;\n\n if(at2 == n)\n break;\n\n at1 += diff;\n at2 += diff;\n\n sec += 6 + diff;\n\n if(diff == 1)\n diff = 3;\n else\n diff = 1;\n }\n\n if(s == 'f')\n sec++;\n else if(s == 'e')\n sec += 2;\n else if(s == 'd')\n sec += 3;\n else if(s == 'a')\n sec += 4;\n else if(s == 'b')\n sec += 5;\n else\n sec += 6;\n\n printf(\"%lld\\n\", sec);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2003698b1e81a2b4f72d7b952e1c6a45", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\n\nint max(int c){\n \n int max;\n int r;\n int l=0;\n while(c!=0){\n \n max=c%10;\n \n if(max>l)\n {\n r=max;\n l=r;\n \n \n }\n c=c/10;\n }\n return r;\n}\n\nint main(){\n \n int a;\n \n scanf(\"%d\",&a);\n int i=a;\n int j=0;\n while(i!=0){\n // printf(\"r:%d \",max(i));\n i-= max(i);\n j++; \n }\n \n printf(\"%d\",j);\n return 0; \n\n\n\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "71355d8ec4c65911f0aab150df77dca7", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#define MX 1000\nlong long int p,k,k1=1,sm,A[MX];\nint main(){\n int i,j,sz;\n long long int ims;\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n scanf(\"%lld%lld\",&p,&k);\n for(sz=0;;sz+=2){\n sm+=(k-1)*k1;\n A[sz]=k-1;\n if(sm>=p){break;}\n k1*=k;\n k1*=k;\n }\n p=sm-p;\n for(i=0;i<=sz;i++){\n ims=p%k;\n p=p/k;\n if(i%2==0){A[i]-=ims;}\n else{A[i]=ims;}\n }\n printf(\"%d\\n\",sz+1);\n for(i=0;i<=sz;i++){\n printf(\"%lld \",A[i]);\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "fa26cd703343b36565c9f91d336f6a38", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{int n,m,r,i,j,t,s,temp;\nint N[30], M[30];\nscanf(\"%d %d %d\",&n,&m,&r);\nfor(i=0;iN[j])\n { \n t=N[i];\n N[i]=N[j];\n N[j]=t;\n }\n }\n}\nfor(i=0;ir)\n{\n printf(\"%d\",&s);\n}\nelse\nprintf(\"%d\",&r);\nreturn 0;\n}\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "fd77c3fda72a31ace078d28f30ffaed3", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include\nint f(const void *a,const void *b){\nreturn (*(int*)a-*(int*)b);\n}\nint main()\n{\n int i,j,n;\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;i0){\n qsort(a,n,sizeof(int),f);\n for(i=n;i>=1;i--){\n a[i]=a[i]-a[i-1];\n }\n l++;\n }\n int s=0;\n for(i=0;i\n\nint answer(int bx,int by,int cx,int cy);\n\nint main(void){\n struct vector{\n int x;\n int y;\n }a,b,c,d;\n int flg,j,k;\n \n scanf(\"%d %d\",&a.x,&a.y);\n scanf(\"%d %d\",&b.x,&b.y);\n scanf(\"%d %d\",&c.x,&c.y);\n\n flg=0;\n flg+=answer(b.x-a.x,b.y-a.y,c.x,c.y);\n flg+=answer(b.x+a.y,b.y-a.x,c.x,c.y);\n flg+=answer(b.x+a.x,b.y+a.y,c.x,c.y);\n flg+=answer(b.x-a.y,b.y+a.x,c.x,c.y);\n\n if(flg==0) puts(\"NO\");\n else puts(\"YES\");\n return 0;\n}\n\nint answer(int bx,int by,int cx,int cy){\n int tmp;\n if(cx==0 && cy==0){\n if(bx==0 && by==0) return 1;\n return 0;\n }\n if(cx==0){\n if(bx%cy==0 && by%cy==0) return 1;\n return 0;\n }else if(cy==0){\n if(bx%cx==0 && by%cx==0) return 1;\n return 0;\n }else{\n tmp=cx*cx+cy*cy;\n if((bx*cx+by*cy)%tmp==0 && (by*cx-bx*cy)%tmp==0) return 1;\n return 0;\n }\n return 0;\n}\n\n\n\n\n\n \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6761d5bd2aa0fa75d8472a4ab46605bd", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n long long n;\n long long sum;\n char ns[15],k[65];\n scanf(\"%I64d\",&n);\n sprintf(ns,\"%I64d\",n);\n int p=strlen(ns);\n scanf(\"%s\",k);\n int q=strlen(k);\n sum=0;\n long long x=1;\n int nxt;\n while(q!=0)\n {\n long long i,m=0;\n long long y=1;\n nxt=(q-p>0?q-p:0);\n while(k[nxt]=='0'&&nxt=nxt;i--)\n {\n int a;\n a=k[i]-48;\n m+=a*y;\n y*=10;\n }\n if(m>=n)\n {\n sum+=(m%(y/10))*x;\n nxt++;\n while(k[nxt]=='0'&&nxt\n#include \n\nint bsearch(int v, int *a, int h)\n{\n int p, l = 0;\n\n while (l < h) {\n p = (l + h) / 2;\n\n // printf(\"%d : %d : %d [%d]\\n\", l, p, h, a[p]);\n if (a[p] < v)\n l = p + 1;\n else\n h = p;\n\n // printf(\"%d %d [%d]\\n\", l, h, a[p]);\n }\n\n return l;\n}\n\n#define max(a,b) (a>b?a:b)\nint main() {\n int n, M;\n int *m_sum;\n\n // printf(\"x\\n\");\n // int x[] = {2,4,4,10};\n // printf(\"%d\\n\", bsearch(4,x,3));\n // printf(\"%d\\n\", bsearch(2,x,3));\n // printf(\"%d\\n\", bsearch(1,x,3));\n // return 0;\n\n scanf(\"%d %d\", &n, &M);\n m_sum = (int*)malloc(sizeof(int) * n + 1);\n m_sum[0] = 0;\n m_sum++;\n\n int t = 0;\n for (int i=0; i M)\n k = bsearch(t - M, m_sum, i) + 1;\n\n printf(\"%d \", k);\n\n for (int j = i; j >= 0; j--)\n m_sum[j] = max(m_sum[j], m_sum[j - 1] + v);\n }\n printf(\"\\n\");\n}\n\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "c8265eb78732d8804c5c112a652a4f21", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": " #include \n\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n \n int n,h,m,l,r,x,sum=0;\n cin>>n;\n cin>>h;\n cin>>m;\n \n int v[n];\n for(int i=0;i>l;\n cin>>r;\n cin>>x;\n \n for(int j = l-1;j <= r;j++)\n {\n v[j] = x;\n }\n }\n for(int i = 0;i\ntypedef long long ll;\nll MOD = 1000000007 ;\nll MOD2 = 1000000006 ;\n\nll gcdExtended(ll a, ll b, ll *x, ll *y); \n\nll power(ll x, ll y, ll p) ;\n \n// Function to find modulo inverse of a \nll modInverse(ll a, ll m) \n{ \n ll x, y; \n ll g = gcdExtended(a, m, &x, &y); \n \n // m is added to handle negative x \n ll res = (x%m + m) % m; \n return res ;\n\n} \n \n// C function for extended Euclidean Algorithm \nll gcdExtended(ll a, ll b, ll *x, ll *y) \n{ \n // Base Case \n if (a == 0) \n { \n *x = 0, *y = 1; \n return b; \n } \n \n ll x1, y1; // To store results of recursive call \n ll gcd = gcdExtended(b%a, a, &x1, &y1); \n \n // Update x and y using results of recursive \n // call \n *x = y1 - (b/a) * x1; \n *y = x1; \n \n return gcd; \n} \n \nll power(ll x, ll y, ll p)\n{ \n ll res = 1; // Initialize result \n \n x = x % p; // Update x if it is more than or \n // equal to p \n \n while (y > 0) \n { \n // If y is odd, multiply x with result \n if (y & 1) \n res = (res*x) % p; \n // y must be even now \n y = y>>1; // y = y/2 \n x = (x*x) % p; \n } \n return res; \n} \n\nll main(ll argc, char const *argv[])\n{\n ll A,B,n,x; \n scanf(\"%lld %lld %lld %lld\",&A,&B,&n,&x);\n ll answer = 0;\n ll apart = 1;\n ll itna = n%(MOD2);\n if(itna==0)\n {\n printf(\"%lld\\n\",x%MOD);\n }\n else\n {\n ll second = 1;\n if(A!=1)\n {\n ll dot = power(A,itna,MOD);\n answer = (answer +((dot*x) % MOD))%MOD ;\n ll ert = dot-1 ;\n ll gh = A-1 ;\n answer = (answer+(((modInverse(A-1,MOD)*ert)%MOD)*B)%MOD)%MOD;\n }\n else if(A==1)\n {\n answer = (answer + x)%MOD ;\n // printf(\"yele %lld\\n\\n\",itna);\n answer = (answer + ((B%MOD)*(n%MOD)%MOD))%MOD ;\n }\n //prllf(\"%lld\\n\",);\n printf(\"%lld\\n\",answer);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "dd7d1063aad6ed3de40fec31072355c3", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#define N 15\nint sum=0;\nint counter=0;\nint n,r,l,x;\nint c[N];\nint b[N];\nvoid dfs(int start,int deep) {\n int i;\n if(deep==0) {\n for(i=0;i=x && sum>=r){counter++;\n \uff5d\n dfs(i,deep+1);\n b[deep]=0;\n sum-=c[i];\n }\n }\n }\n \nint main() {\n scanf(\"%d%d%d%d\",&n,&l,&r,&x);\n int i;\n for(i=0;i\ntypedef long long ll;\nll a[15], w, ans;\n\nvoid dfs(int x, ll y) {\n\tif (x > 8) { \n\t\tif (y > ans) ans = y;\n\t\treturn;\n\t}\n\tll k = a[x];\n\tll tmp = (w - y) / x;\n\tif (k > tmp) k = tmp;\n\tll i = k - 6;\n\tif (i < 0) i = 0;\n\tfor (; i <= k; i++) dfs(x + 1, y + i * x);\n}\n\nint main() {\n\tscanf(\"%I64d\", &w);\n\tans = 0;\n\tfor (int i = 1; i <= 8; i++) scanf(\"%I64d\", &a[i]);\n\tdfs(1, 0);\n\tprintf(\"%I64d\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "67cdb49dd5655986509216f39fb882b3", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n == 3 || n == 5)\n {\n printf(\"1\");\n }\n else if(n == 1 || n == 4)\n {\n printf(\"2\");\n }\n else\n printf(\"3\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "dea5404f5c43c461062c30045e649d7c", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\n long long int n, k, i, j, sum, toys=0;\n scanf(\"%lld %lld\", &n, &k);\n\n if(n<=10000 || k<10000){\n for(i=1 ; ik){\n break;\n }\n\n for(j=i+1 ; j<=n ; j++)\n {\n sum = i+j ;\n if(sum>k){\n break;\n }\n if(sum == k){\n toys++;\n }\n }\n }\n }\n\n else{\n if(n==k && n%2==0){\n toys = n/2 - 1;\n }\n\n else if(n==k && n%2==1){\n toys = n/2;\n }\n\n else if(k>n)\n {\n toys = n/2-(k-n)/2;\n }\n\n else if(n>k)\n {\n toys = n/2-(n-k)/2-1;\n\n if(n%2==1 && (n-k)%2==0){\n toys = toys + 1;\n }\n }\n\n\n\n if(toys<0)\n toys = 0;\n}\n\n if((n>50000000000000 && n%2 == 1){\n toys = toys+1;\n }\n printf(\"%lld\\n\", toys);\n\n\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2a9cbbe58cd6bb71a8b7c2b41861234e", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include\n#define MAXN 1000002\n#define mod 1000000007\n\nchar vis[MAXN];\n\nlong long quickmi(long long a,int b)\n{\n long long ans=1;\n\n while(b)\n {\n if(b&1)ans=(ans*a)%mod;\n a=(a*a)%mod;\n b>>=1;\n }\n return ans;\n}\n\nint main()\n{\n int p,k,i,cnt,u;\n\n scanf(\"%d%d\",&p,&k);\n cnt=0;\n for(i=1;i\n#include\n#include\n#define max(a,b) ((a>b)?a:b))\n#define min(a,b) ((a\n#include \nchar s[2][105];\nint ans,len;\nint main()\n{\n\tscanf(\"%s\\n%s\",s[0],s[1]);\n\tlen=strlen(s[0]);\n\tfor (int i=0;i0)\n\t\t\t{\n\t\t\t\tif (s[0][i-1]=='0')\n\t\t\t\t{\n\t\t\t\t\tans++;\n\t\t\t\t\ts[0][i-1]='X';\n\t\t\t\t}\n\t\t\t\telse if (s[1][i-1]=='0')\n\t\t\t\t{\n\t\t\t\t\ts[1][i-1]='X';\n\t\t\t\t\tans++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i\n\nint main()\n{\n int n,m,x;\n scanf(\"%d%d%d\",&n,&m,&x);\n n-=2*(x-1);\n m-=2*(x-1);\n if(n<1||m<1||x<1)\n {\n printf(\"0\\n\");\n return 0;\n }\n int current=(2*n)+(2*m)-4;\n current/=2;\n if(n==1)\n current=(m+1)/2;\n if(m==1)\n current=(n+1)/2;\n printf(\"%d\\n\",current);\n return 0;\n} \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a206354ab6206000125f12228d859a99", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "int main()\n{\n long long int n,p,w,d;\n scanf(\"%lld %lld %lld %lld\",&n,&p,&w,&d);\n long long int a,b,c;\n \n a=0;\n while(a<=w)\n {\n if(p-d*a>=0 && a+(p-d*a)/w<=n && (p-d*a)%w==0)\n {\n printf(\"%lld %lld %lld\",(p-d*a)/w,a,n-a-(p-d*a)/w);\n return 0;\n }\n }\n printf(\"-1\\n\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e9b85bed7cc754efe79fb0421768221f", "src_uid": "503116e144d19eb953954d99c5526a7d", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\n#define M 1000000007\n__int64 fastpow(int a,__int64 n){\n __int64 ans;\n if(n==0) return 1;\n if(n==1) return a%M;\n ans=fastpow(a,n/2)%M;\n ans=(ans*ans)%M;\n if(n%2==1)\n ans=((ans%M)*(a%M))%M;\n return ans%M;\n}\nint main(){\n int i;\n __int64 ans;\n __int64 n;\n while(scanf(\"%I64d\",&n)!=EOF){\n if(n==0)\n printf(\"1\\n\");\n else{\n ans=(fastpow(2,n-1)%M+(2*fastpow(4,n-1))%M)%M;\n printf(\"%I64d\\n\",ans);\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0892097a5e846cbac5ddd2ccc7491692", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nint main(){\n int n, res;\n while (scanf(\"%d\", &n) != EOF){\n res = 0;\n if (n <= 2) res = 0;\n else if (n == 3) res = 1;\n else if (n == 99) res = 49;\n else if (n & 1) res = n >> 1;\n else __builtin_trap();\n printf(\"%d\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4b4a23e432cedf2444e3afad68648165", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define HELL 1000000007\nchar fast_char_var;\n#define\tfast_unsigned_dtype\tunsigned long\nfast_unsigned_dtype fast_unsigned_var;\nfast_unsigned_dtype fast_unsigned()\n{\n\tfast_char_var=getchar();\n\twhile(fast_char_var<48||fast_char_var>57)\n\t\tfast_char_var=getchar();\n\tfast_unsigned_var=0;\n\twhile(fast_char_var>47&&fast_char_var<58)\n\t{\n\t\tfast_unsigned_var=(fast_unsigned_var<<1)+(fast_unsigned_var<<3)+fast_char_var-48;\n\t\tfast_char_var=getchar();\n\t}\n\treturn fast_unsigned_var;\n}\n#define\tmerge_sort_dtype\tunsigned long\n#define\tmerge_sort_maxsize\t200005\n\nunsigned long merge_sort_i,merge_sort_j,merge_sort_k,merge_sort_halfsize;\nmerge_sort_dtype merge_sort_array[merge_sort_maxsize],merge_sort_array2[merge_sort_maxsize],supporting_array1[merge_sort_maxsize],supporting_array2[merge_sort_maxsize];\n\nvoid merge_sort_recursive(merge_sort_dtype *array, merge_sort_dtype *sarray, merge_sort_dtype *array2, merge_sort_dtype *sarray2,unsigned long size)\n{\n\tif(size==1)\n\t\treturn;\n\tmerge_sort_recursive(array,sarray,array2,sarray2,size>>1);\n\tmerge_sort_recursive(array+(size>>1),sarray+(size>>1),array2+(size>>1),sarray2+(size>>1),size-(size>>1));\n\tmerge_sort_halfsize=(size>>1);\n\tfor(merge_sort_i=0,merge_sort_j=merge_sort_halfsize,merge_sort_k=0;merge_sort_iarray[merge_sort_i])\n\t\t{\n\t\t\tmerge_sort_array[merge_sort_k++]=array[merge_sort_i++];\n\t\t\tsupporting_array1[merge_sort_k++]=sarray[merge_sort_i++];\n\t\t\tmerge_sort_array2[merge_sort_k++]=array2[merge_sort_i++];\n\t\t\tsupporting_array2[merge_sort_k++]=sarray2[merge_sort_i++];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(array2[merge_sort_j]='z')\n\t\tfast_char_var=getchar();\n\twhile(fast_char_var>='a'&&fast_char_var<='z')\n\t{\n\t\tstr[i++]=fast_char_var();\n\t\tfast_char_var=getchar();\n\t}\n\tstr[i]=0;\n\tlength=i;\n\tfor(i=0;i\n\nlong long a[1000006],b[1000006],ans,count1,count2,lc,count3,count4;\n\nlong long lcm(long long a,long long b)\n{\t\n\tif(a>b)\n\t{\n\t\tif(a%b==0)\n\t\t\treturn b;\n\t\t\t\n\t\treturn lcm(b,a%b);\n\t}\n\telse\n\t{\n\t\tif(b%a==0)\n\t\t\treturn a;\n\t\t\t\n\t\treturn lcm(a,b%a);\n\t}\n}\n\nint main()\n{\n\tlong long m,h1,h2,x1,x2,y1,y2,a1,a2,p,i;\n\t\n\tscanf(\"%lld\",&m);\n\t\n\tscanf(\"%lld%lld\",&h1,&a1);\n\t\n\tscanf(\"%lld%lld\",&x1,&y1);\n\t\n\tscanf(\"%lld%lld\",&h2,&a2);\n\t\n\tscanf(\"%lld%lld\",&x2,&y2);\n\t\n\tp=1;\n\t\n\tfor(i=0;i\n\nunsigned long long n,s,t,m;\n\nint main(void) {\n\t\n\tscanf(\"%I64d%I64d\",&n,&s);\n\ts=s+(9-s%9)%9;\n\twhile (t\nint gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n}\nlong long int vertexes[11111];\nint main(void) {\n\tlong long int n, counter, position, maximum = 1;\n\tscanf(\"%I64d\", &n);\n\tfor(int i = 1; i <= n; i++) {\n scanf(\"%I64d\", &vertexes[i]);\n }\n\tfor(int i = 1; i <= n; i++){\n\t\tcounter = 1;\n\t\tposition = vertexes[i];\n\t\twhile(position != i) {\n\t\t\tposition = vertexes[position];\n\t\t\tcounter++;\n\t\t\tif( counter > 100 || vertexes[position] == position) {\n printf(\"-1\");\n return 0;\n }\n\t\t}\n\t\tif(counter % 2 == 0) {\n counter = counter / 2;\n }\n\t\tif(counter != 0) {\n maximum = maximum * counter / gcd(maximum, counter);\n }\n\t}\n\tprintf(\"%I64d\", maximum);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "04865790eaafb222a6df65158217ba4b", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\nusing namespace std;\n\nint main ()\n{\n int k,i;\n string sequence;\n\n cin>>k;\n\n for(i=0;i<5000;i++)\n {\n sequence=sequence+to_string(i);\n }\n\n cout<\n\nint N, A;\nint S[200], B[200];\nint DP[100000][200], M[200000][200];\nint P[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};\nint Q[60];\n\nint main()\n{\n\t//FILE *input;\n\tint i, j, k, t;\n\tchar c;\n\t\n\t//input = fopen(\"chest.in\", \"r\");\n\t//fscanf(input, \"%d\\n\", &N);\n\tscanf(\"%d\\n\", &N);\n\t\n\tfor(i=0; i DP[j][N] && DP[j][N] != 0)\n\t\t\tA = j;\n\t}\n\t\n\tfor(i=N-1; i>=0; i--)\n\t{\n\t\tB[i] = M[A][i+1];\n\t\tA -= Q[B[i]];\n\t}\n\t\n\tfor(i=0; i\n\nint main()\n {\n \tchar n[10], m[10];\n \tint dd, mm, yy, bd, bm, by, i, a, b, c, flag;\n \tscanf(\"%s\", n);\n\tscanf(\"%s\", m);\n \tdd = (n[0] - '0')*10 + n[1] - '0';\n \tmm = (n[3] - '0')*10 + n[4] - '0' - '0';\n \tyy = (n[6] - '0')*10 + n[7] - '0' - '0';\n \t\n \tbd = (m[0] - '0')*10 + m[1] - '0';\n \tbm = (m[3] - '0')*10 + m[4] - '0';\n \tby = (m[6] - '0')*10 + m[7] - '0';\n \t\n \t{\n \t/*i=0; j=100;\n \tif(i<=bd) i=bd;\n \tif(i<=bm) i=bm;\n \tif(i<=by) i=by;\n \tif(j>=bd) j=bd;\n \tif(j>=bm) j=bm;\n \tif(j>=by) j=by;\n \tk=bd + bm + by - i - k;\n \tif(k > 12 && i <= 12)\n \t {\n \t \tflag=k;\n \t \tk=i;\n \t \ti=flag;\n\t }\n\tif(k > 12 && i > 12 )\n\t {\n\t \tflag=k;\n\t \tk=j;\n\t \tif(flag > i)\n\t \t {\n\t \t \tj=i;\n\t \t \ti=flag;\n\t\t }\n\t\telse \n\t\t {\n\t\t \tj=flag;\n\t\t }\n\t }\n \tif(yy-j== 18 && k<=mm && i<=dd) flag = 1;\n \telse flag = 0;\n \tif(yy-j > 18) flag = 1;\n \tif(flag == 1) printf(\"YES\");\n \telse printf(\"NO\");\n \tgetchar();\n \tgetchar();\n \treturn 0;*/\n }\n \t\n \tfor(i=0; i<6; i++)\n \t {\n \t \tif(i == 0)\n \t \t {\n \t \t \ta = bd;\n \t \t \tb = bm;\n \t \t \tc = by;\n\t\t }\n \t \tif(i == 1)\n \t \t {\n \t \t \ta=by;\n \t \t \tb=bm;\n \t \t \tc=bd;\n\t\t }\n\t\tif(i == 2)\n\t\t {\n\t\t \ta=by;\n\t\t \tb=bd;\n\t\t \tc=bm;\n\t\t }\n\t\tif(i == 3)\n\t\t {\n\t\t \ta=bm;\n\t\t \tb=by;\n\t\t \tc=bd;\n\t\t } \n\t\tif(i == 4)\n\t\t {\n\t\t \ta=bm;\n\t\t \tb=bd;\n\t\t \tc=by;\n\t\t }\n\t\tif(i == 5)\n\t\t {\n\t\t \ta=bd; \n\t\t \tb=by;\n\t\t \tc=bm;\n \t }\n\t if(a == 0) continue;\n\t\tif(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)\n\t\t if(c > 31) continue;\n\t\tif(b == 4 || b == 6 || b == 9|| b == 11)\n\t\t if(c > 30) continue;\n\t\tif(b == 2 && a%4 == 0 && c>29) continue;\n\t\tif(b == 2 && a%4 != 0 && c>28) continue;\n\t\tif(b > 12) continue;\n\t if(yy-a == 18 && mm > b)\n\t flag = 1;\n\t if(yy-a == 18 && mm == b && dd >= c)\n\t flag = 1;\n\t if(yy-a>18)\n\t flag = 1;\n\t if(flag == 1)\n\t {\n//\t \tprintf(\"1 \");\n\t \tprintf(\"YES\");\n\t \tgetchar();\n\t \tgetchar();\n\t \treturn 0;\n\t\t }\n//\t\tprintf(\"%d %d \", i, flag);\n// if(i == 5) printf(\"%d %d %d \", a, b, c);\n\t }\n\tif(flag == 1) printf(\"YES\");\n\telse printf(\"NO\");\n\tgetchar();\n\tgetchar();\n\treturn 0;\n }\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "35f64ed943e82cea6abe52852201db2f", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "/* Author Kh. Assaduzzaman Sohan */\n\n#include\n#include\n#include\n#define mod 100000007\n//int x[100005]= {0};\nint main()\n{\n long long int n,k,i,j,r1,r2;\n\n scanf(\"%I64d %I64d\",&n,&k);\n\n // if(k<=2) printf(\"YES\");\n // else if(n==5 && k==3) printf(\"YES\");\n // else printf(\"NO\");\n for(i=1; i<=k; i++)\n {\n r1=n%i;\n for(j=1; j<=k; j++)\n {\n r2=n%j;\n if(i!=j && r1==r2)\n {\n\n printf(\"NO\");\n return 0;\n }\n }\n }\n printf(\"YES\");\n // for(i=1; i<=k; i++) printf(\"%I64d \",n%i);\n // printf(\"\\n\");\n\n\n return 0;\n }\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "f76237508101f480ffc4467da312bf10", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n char colors[8]=\"ROYGBIV\";\n int n;\n scanf(\"%d\",&n);\n int i;\n printf(\"%c%c%c\",colors[0],colors[1],colors[2]);\n n-=3;\n while(n>0)\n {\n i=3;\n while((i<=6)&&(n>0))\n {\n printf(\"%c\",colors[i]);\n i++;\n n--;\n }\n }\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "ba10e5742893b4930bb0337e2ecad0f0", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\n#define N 100000\n#define EPS 1E-8\n\ninline int sign(double x) { \n return x < -EPS ? -1 : x > EPS; \n}\n\ninline double sqr(double x) { \n return x * x; \n}\n\ntypedef struct point {\n double x, y;\n} point;\n\ndouble dist(point a, point b) {\n return hypot(a.x - b.x, a.y - b.y);\n}\n\ndouble cross(point a, point b, point c) {\n return (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);\n}\n\n/* PA * PB */\ndouble dot(point p, point a, point b) {\n return (a.x - p.x) * (b.x - p.x) + (a.y - p.y) * (b.y - p.y);\n}\n\n/* delta angle of ABC */\ninline double delta_angle(point a, point b, point c) {\n return acos(dot(b, a, c) / (dist(a, b) * dist(b, c)));\n}\n\npoint *__o;\n\nint angle_cmp(point *p, point *q) {\n int c;\n if (c = sign(cross(*__o, *p, *q)))\n return -c;\n return sign(dist(*p, *__o) - dist(*q, *__o));\n}\n\npoint stack[N];\n\nint convex_hull(point *ps, int n) {\n int i, k, top;\n\n k = 0;\n for (i = 1; i < n; i++)\n if (ps[i].y < ps[k].y || ps[i].y == ps[k].y && ps[i].x < ps[k].x)\n k = i;\n\n __o = &ps[k];\n qsort(ps, n, sizeof(point), (int (*)(const void *, const void *))angle_cmp);\n\n top = 0;\n for (i = 0; i < n; i++) {\n while (top >= 2 && sign(cross(stack[top - 2], stack[top - 1], ps[i])) <= 0) top--;\n stack[top++] = ps[i];\n }\n memcpy(ps, stack, sizeof(point) * top);\n return top;\n}\n\nint too_straight(point A, point B, point C, double r) {\n double a, b, c, cos_B, sin_B, R;\n\n if (!sign(cross(A, B, C)))\n return 1;\n a = dist(B, C);\n b = dist(A, C);\n c = dist(A, B);\n cos_B = (a * a + c * c - b * b) / (2 * a * c);\n sin_B = sqrt(1.0 - cos_B * cos_B);\n R = b / sin_B / 2.0;\n// printf(\"R=%lf vs r=%lf\\n\", R, r);\n return sign(R - r) > 0;\n}\n\ndouble area_bow(double r, double l) {\n double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;\n double theta = 2 * asin(l / (r + r));\n double sector = theta * r * r / 2;\n return sector - tri;\n}\n\ndouble area_polygon(const point a[], int n) {\n int i, j;\n double area = 0.0;\n for (j = 0, i = n - 1; j < n; i = j++)\n area += a[i].x * a[j].y - a[i].y * a[j].x;\n return fabs(area) / 2;\n}\n\nint main() {\n static point ps[N];\n int n;\n double r, ans, da, damin;\n int i, j, k, z, top;\n\n scanf(\"%d %lf\", &n, &r);\n for (i = 0; i < n; i++)\n scanf(\"%lf %lf\", &ps[i].x, &ps[i].y);\n\n if (n == 1) {\n puts(\"0\");\n } else {\n n = convex_hull(ps, n);\n// printf(\"n=%d\\n\", n);\n\n z = -1;\n for (i = 0, j = 1, k = 2 % n; i < n; i++, j = (j + 1) % n, k = (k + 1) % n) {\n da = delta_angle(ps[i], ps[j], ps[k]);\n if (z == -1 || damin > da) {\n damin = da;\n z = j;\n }\n }\n\n top = 0;\n for (j = 0, i = z; j < n; j++, i = (i + 1) % n) {\n// printf(\"%lf,%lf\\n\", ps[i].x, ps[i].y);\n while (top >= 2 && too_straight(stack[top - 2], stack[top - 1], ps[i], r))\n top--;\n stack[top++] = ps[i];\n }\n// printf(\"top=%d\\n\", top);\n\n ans = area_polygon(stack, top);\n for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top) {\n// printf(\"%lf,%lf\\n\", stack[i].x, stack[i].y);\n ans += area_bow(r, dist(stack[i], stack[j]));\n }\n printf(\"%.9lf\\n\", ans);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "9a36de82a2529646117d3d4a35c08fb2", "src_uid": "5f2a0960bab9bdc91b190ed07d6adcf7", "difficulty": 3000.0} {"lang": "GNU C", "source_code": "#include\n#define ll long long\n#define MOD 1000000007\nll g_pow(ll k)\n{\n\tll x=2,e=1;\n\twhile(k)\n\t{\n\t\tif(k%2)\n\t\t{\n\t\t\te*=x;\n\t\t\tif(e>MOD)\n\t\t\t\te%=MOD;\n\t\t}\n\t\tk/=2;\n\t\tx*=x;\n\t\tif(x>MOD)\n\t\t\tx%=MOD;\n\t}\n\treturn e;\n}\nint main()\n{\n\tll x,k,res;\n\tscanf(\"%I64d%I64d\",&x,&k);\n\tx%=MOD;\n\tif(x==0)\n\t{\n\t\tprintf(\"0\");\n\t\treturn 0;\n\t}\n\tif(k==0)\n\t{\n\t\tres=2*x;\n\t\tif(res>MOD)\n\t\t\tres%=MOD;\n\t\tprintf(\"%I64d\",res);\n\t\treturn 0;\n\t}\n\tres=g_pow(k+1)*x-g_pow(k)+1;\n\tif(res>MOD)\n\t\tres%=MOD;\n\tprintf(\"%I64d\",res);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "8949387acb62ea24ebfb59e7f6046bfa", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#define sq(A) ((A)*(A))\n\nint x[4], y[4], r[4];\n\nbool intersect(int i, int j){\n\tint dist=sq(x[i]-x[j])+sq(y[i]-y[j]);\n\tif(dist>=sq(r[i]+r[j])) return false;\n\tif(r[i]\n#include\nint main()\n{\n int n, R, r, i;\n float PI=2*acos(0.0), j;\n scanf(\"%d %d %d\", &n, &R, &r);\n i=R-r;\n j=2*PI*i;\n if(n==1 && R==r) printf(\"YES\");\n else if((2*n*r)<=j) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "845ec64981fa363172b7a1df569f5aca", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n\nlong long gcd (long long a, long long b) {\n if (a <= 0LL || b <= 0LL) {\n return -1LL;\n }\n \n if (a%b == 0LL) {\n return b;\n }\n \n return gcd(b, a%b);\n}\n\nint main () {\n int n = 0;\n \n int res = 0;\n \n long long ans = 0LL;\n long long mod_num = 1000000007LL;\n \n long long sum_c[50001] = {};\n \n res = scanf(\"%d\", &n);\n \n for (int i = n/2; i > 0; i--) {\n long long k = (long long) (n/i);\n long long d = gcd((long long)n, (long long)i);\n if (n%i == 0) {\n k -= 1LL;\n }\n sum_c[i] = (((long long)n)*(k*(k-1LL))/2LL)%mod_num;\n sum_c[i] += mod_num-((((k*(k+1LL)*(k-1LL))/3LL)%mod_num)*((long long)i))%mod_num;\n for (int p = 2; i*p <= n/2; p++) {\n sum_c[i] += mod_num-sum_c[i*p];\n }\n sum_c[i] %= mod_num;\n ans += sum_c[i]*(((long long)i)/d);\n ans %= mod_num;\n }\n \n printf(\"%lld\\n\", ans);\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4b3dfd131dbbf52928a9ecc3ea01e984", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include \n\n#define MOD 1000000007\ntypedef long long LL_t;\n\nint main()\n{\n LL_t A, B, i, Ans;\n scanf(\"%I64d %I64d\", &A, &B);\n Ans = 0;\n for(i=1; i<=A; ++i)\n {\n LL_t temp = B*(B-1)/2;\n Ans += temp*i*B+temp;\n Ans %= MOD;\n }\n printf(\"%I64d\\n\", Ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0133eb25deaf0cce97dbea323a5f2ded", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nconst i32 mod = 1000000007;\n\n#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)\n#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)\n\ni32 inv (i32 a) {\n i32 t = 1;\n while (a > 1) {\n t = (i64) t * (mod - mod / a) % mod;\n a = mod % a;\n }\n return t;\n}\n\ni32 calc (const i64 p, const i32 c, const i32 k) {\n i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));\n dp[c] = 1;\n i32 *prob = (i32 *) calloc (c + 1, sizeof (i32));\n for (i32 i = 0; i <= c; ++i) {\n prob[i] = inv (i + 1);\n }\n for (i32 i = 0; i < k; ++i) {\n i32 sum = 0;\n for (i32 j = 0; j <= c; ++j) {\n i32 v = (i64) prob[j] * dp[j] % mod;\n ADD(sum, v);\n }\n for (i32 j = 0; j <= c; ++j) {\n i32 assign = sum;\n i32 v = (i64) prob[j] * dp[j] % mod;\n SUB(sum, v);\n dp[j] = assign;\n }\n }\n i32 ans = 0;\n for (i32 i = c; i >= 0; --i) {\n ans = ((i64) p * ans + dp[i]) % mod;\n }\n free (dp);\n free (prob);\n return ans;\n}\n\nvoid run (void) {\n i64 n = read_int();\n i32 k = read_int();\n i64 ans = 1;\n for (i64 p = 2; p * p <= n; ++p) {\n if (n % p != 0) continue;\n i32 c = 0;\n while (n % p == 0) {\n n /= p;\n ++c;\n }\n ans = ans * calc (p, c, k) % mod;\n }\n if (n > 1) ans = ans * calc (n, 1, k) % mod;\n print_int (ans);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7181dc2f86d5fe5780e347b889df77f1", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include \n#include \n#define min(a,b) ((a)<(b)?(a):(b))\n\ntypedef long long ll;\n\nchar str[200002];\n\nint main()\n{\n\tint i,n,m,res;\n\tll val, pw;\n\tscanf(\"%s%d\",str,&m);\n\tn=strlen(str);\n\tres=m;\n\tpw=1;\n\tval=0;\n\tfor(i=0;i\n\n#define N\t100000\n\nint jj[N], pp[N], dd[N], mn;\n\nvoid match(int i) {\n\twhile (dd[i] == 1) {\n\t\tint j = jj[i], tmp;\n\n\t\tif (pp[i] == i || dd[j] == 1)\n\t\t\ttmp = pp[i], pp[i] = pp[j], pp[j] = tmp;\n\t\telse\n\t\t\tmn -= 2;\n\t\tjj[i] ^= j, dd[i] = 0, jj[j] ^= i, dd[j]--;\n\t\ti = j;\n\t}\n}\n\nint main() {\n\tint n, h, i, j;\n\n\tscanf(\"%d\", &n);\n\tfor (h = 0; h < n - 1; h++) {\n\t\tscanf(\"%d%d\", &i, &j), i--, j--;\n\t\tjj[i] ^= j, dd[i]++, jj[j] ^= i, dd[j]++;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tpp[i] = i;\n\tmn = (n - 1) * 2;\n\tfor (i = 0; i < n; i++)\n\t\tmatch(i);\n\tprintf(\"%d\\n\", mn);\n\tfor (i = 0; i < n; i++)\n\t\tprintf(\"%d \", pp[i] + 1);\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "24da39b461eecf7ffd174962c10698be", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "#include\nlong long int dp[4000][4000];\nint main()\n{\n\tlong long int n, m, k, j, i;\n\tscanf(\"%lld%lld%lld\", &n, &m, &k);\n\tfor (long long int i = 1; i <=n; ++i)\n\t{\n\t\tfor(dp[i][0]=m, j=1; j<=m; j++)\n\t\t{\n\t\t\tdp[i][j]=dp[i-1][j]+dp[i-1][j-1]*(m-1);\n\t\t\t//printf(\"%d %d %d\\n\", i, j, dp[i][j]);\n\t\t\t\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", dp[n][k]);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "014de7165dc99ce6727825f441c03fdb", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\nlong long int mod= 1000000007;\n\nlong long int power (long long int x, long long int y)\n{\n long long int ans = 1;\n\n while (y!=0)\n {\n if (y%2==1)\n ans = (ans*x) % mod;\n\n y = y/2;\n x = (x*x) % mod;\n }\n\n return ans;\n}\n\n\n\nint main ()\n{\n long double n,m;\n\n scanf(\"%Lf %Lf\", &n, &m);\n\n long double c=1,sum=0,t=0;\n\n while (t<=n)\n {\n sum = sum + c*power(power(2,n-(long long int)t),m)*power(-1,(long long int)t);\n c=(c*(n-t))/(t+1);\n t++;\n }\n\n\tsum=sum+0;\n \n\tprintf(\"%lld\\n\",(long long int)sum);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "29068712947040fb63d4d622c179141c", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\nint main(){\nlong long int n,m,k,x=1,y=1,a;\nscanf(\"%I64d%I64d%I64d\",&n,&m,&k);\nif(k=n){\n k=k-n+1;\na=k/m;\nx=n-a;\ny=2+(k%m);\nif(k\nint n, a[5], temp;\n\n\nvoid sort() {\n for (int step = 1; step < n; step++)\n {\n for (int c = 0; c < (n - step); c++)\n {\n if (a[c] > a[c + 1])\n {\n temp = a[c];\n a[c] = a[c + 1];\n a[c + 1] = temp;\n }\n }\n }\n}\n\n\nint main() {\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &a[i]);\n }\n sort();\n\n printf(\"%d\\n\", a[(n / 2)]);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "a834947b0066ad5e5ffd3991c0fc302a", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n//#include \n#ifndef LL\n#define LL long long\n#endif\n#ifndef uLL\n#define uLL unsigned long long\n#endif\n#ifndef uL\n#define uL unsigned int\n#endif\n#ifndef iL\n#define iL int\n#endif\n#ifndef iS\n#define iS short\n#endif\n#ifndef uS\n#define uS unsigned short\n#endif\n#ifndef uC\n#define uC unsigned char\n#endif\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n#define abs(a) (((a)<0)?(-(a)):(a))\n#define sgn(a) (((a)<0)?(1):(0))\n#define movs(a,b,l) (memmove((a),(b),sizeof(*(b))*(l)))\n#define stosb(a,b,l) (memset((a),(b),sizeof(*(a))*(l)))\nstatic inline uL bsr(uL a)\n{\n __asm__(\"bsrl %0,%0\":\"+r\"((uL)a));\n return a;\n}\nstatic inline uLL sqrt64(uLL x)\n{\n uLL t,g;\n for (g=(x>>1)+(x&1),t=x;g>1)\n {\n t=g;\n }\n return t;\n}\nstatic inline uLL gcd(uLL a,uLL b)\n{\n while (a>0)\n {\n b=(b%a)^a;\n a=a^b;\n b=a^b;\n }\n return b;\n}\nuLL prime[4000001];\nuLL EulerSieve(uLL n)\n{\n uLL i,j;\n memset(prime,0,sizeof(*prime)*(n+1));\n *prime=0;\n for (i=2;i<=n;i++)\n {\n if (prime[i]==0)\n {\n prime[++(*prime)]=i;\n prime[i]=i;\n }\n for (j=1;j<=*prime;j++)\n {\n if (i*prime[j]>n) {break;}\n prime[i*prime[j]]=prime[j];\n if (prime[i]==prime[j]) {break;}\n }\n }\n return *prime;\n}\nuLL fac[10000];\nuLL times[10000];\nuLL factoring(uLL a,uLL *fac,uLL *times)\n{\n\tuLL k,i,l;\n\tl=sqrt64(a);\n\tfor (k=0,i=1;(i<=prime[0])&&(prime[i]<=l);i++)\n\t{\n\t\tif (a%prime[i]==0)\n\t\t{\n\t\t\tfac[++k]=prime[i];\n\t\t\ttimes[k]=1;\n\t\t\tfor (a=a/prime[i];a%prime[i]==0;a=a/prime[i],times[k]+=1);\n\t\t}\n\t}\n\tif (a>1)\n\t{\n\t\tfac[++k]=a;\n\t\ttimes[k]=1;\n\t}\n\treturn k;\n}\nLL aa,bb,kk,ans1,ans2;\nLL dfs(LL x,LL id)\n{\n\tLL i,j,y;\n\tif (id>*fac)\n\t{\n\t\tkk=x-aa%x;\n\t\tif (x-bb%x==kk)\n\t\t{\n\t\t\t//printf(\"%lld %lld\\n\",x,kk);\n\t\t\tif ((aa+kk)/x*(bb+kk)b) {c=a;a=b;b=c;}\n\tif (b%a==0)\n\t{\n\t\tprintf(\"0\\n\");\n\t}\n\telse\n\t{\n\t\tans1=a/gcd(a,b)*b;ans2=0;\n\t\t*fac=factoring(b-a,fac,times);\n\t\taa=a;bb=b;\n\t\tdfs(1,1);\n\t\tprintf(\"%lld\\n\",ans2);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "1af79d8286071245e6d1293e55778ef5", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#define ll long long\r\n#define min(a,b) (a < b ? a : b)\r\ntypedef struct node {\r\n struct node * head[10];\r\n short cnt; char ed;\r\n} n;\r\nn * mk() {\r\n n * temp = malloc(sizeof(n));\r\n for (int i = 0; i < 10; i++)\r\n temp->head[i] = 0;\r\n temp->cnt = 0, temp->ed = '0';\r\n return temp;\r\n}\r\nn * fnd (n * tr, ll v) {\r\n while (v) {\r\n if (!tr->head[v%10]) tr->head[v%10] = mk();\r\n tr = tr->head[v%10];\r\n v/=10;\r\n }\r\n if (tr->ed == '0') tr->ed = '1', tr->cnt = 100;\r\n return tr;\r\n}\r\nvoid del (n * tr) {\r\n for (int i = 0; i < 10; i++)\r\n if (tr->head[i]) {\r\n del (tr->head[i]);\r\n free(tr->head[i]);\r\n }\r\n}\r\nn tr;\r\nint dfs (ll v, int s) {\r\n ll k = v; int len = 0;\r\n while (k) len++, k/=10;\r\n if (len == s) return 0;\r\n else if (len > s) return 100;\r\n n * chk = fnd( &tr, v ); k = v;\r\n if (chk->cnt != 100) return chk->cnt;\r\n while (k) {\r\n if (k%10 > 1) chk->cnt = min(chk->cnt, 1 + dfs(v * (k%10), s));\r\n k/=10;\r\n } return chk->cnt;\r\n}\r\nint main () {\r\n for (int i = 0; i < 10; i++) tr.head[i] = 0;\r\n int m; ll f;\r\n scanf(\"%d%lld\",&m,&f);\r\n int ans = dfs(f,m);\r\n printf(\"%d\\n\",(ans == 100) ? -1 : ans);\r\n del(&tr);\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "bdd96785d887890d2893565143929ed7", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int n,m,a,b;\n while(scanf(\"%d%d%d%d\",&n,&m,&a,&b)!=0)\n {\n int remainder = n%m;\n //printf(\"%d\\n\",remainder);\n if(remainder)\n {\n int anwser1 = remainder*b;\n int anwser2 = (m-remainder)*a;\n if(anwser1>anwser2) printf(\"%d\\n\",anwser2);\n else printf(\"%d\\n\",anwser1);\n }else{\n printf(\"0\\n\");\n }\n }\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "71400473cde7613b8139a2286c7960d3", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{\n\tchar a[7];\n int i,sum=0;\n scanf(\"%s\",a);\n for(i=0;i<7;i++)\n {\n\t\tif(a[i]=='A')\n\t\t\tsum=sum+1;\n else if(a[i]=='1')\n\t\t\tsum=sum+10;\n else\n\t\t\tsum=sum+a[i]-'0';\n }\n printf(\"%d\",sum);\n\t/system(\"pause\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "cf5a2f770bcbe678a413c3603c9b0b1e", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n\nint sq(int x, int y) {\n int i, a;\n\n a = 1;\n for (i = 0; i < y; i++) a = a * x;\n\n return a;\n}\n\nint main() {\n int n, m, k;\n\n scanf(\"%d%d%d\", &n, &m, &k);\n \n if (k == 1) printf(\"%d\", sq(m, n));\n else if (k == 2) printf(\"%d\", m);\n else if (k%2 == 1) {\n if (k == n) printf(\"%d\", sq(m, (k+1)/2));\n else printf(\"%d\", sq(m, 2));\n } else {\n if (k == n) printf(\"%d\", sq(m, k/2));\n else printf(\"%d\", m);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cf26d02fffbfbac860bc8255e9068406", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n#include \r\n\r\nint main()\r\n{\r\n int x,y,z,i,j,k,a,b,c,n,m,t;\r\n char s[20];\r\n \r\n scanf(\"%s\",s);\r\n k = strlen(s);\r\n for(x = 2; x < k; x++)\r\n {\r\n if(s[x] != ((s[x-1] + s[x-2] + 'Z' - 'A' + 1) % ('Z' - 'A' + 1)) + 'A')\r\n break;\r\n }\r\n printf( x == k ? \"YES\\n\" : \"NO\\n\");\r\n system(\"pause\"); \r\n return 0;\r\n}\r\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "93e0ce242f5ec70ce3bf1a8bfa1f1077", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "//C n+m-1 m;\r\n//2^(y-1); \r\n \r\n#include\r\n#include\r\n#include\r\n#include\r\nusing namespace std;\r\nvectorv[1000500];\r\nconst int mod=1000000007;\r\nint cur[1000500];\r\nlong long inv[2000050];\r\nlong long fc[2000050];\r\nlong long vv[1000500];\r\nlong long f(long long a,long long b);\r\nvoid init()\r\n{\r\n\tmemset(cur,0,sizeof(cur));\r\n\tfc[0]=1LL;\r\n\tfor(int i=1;i<2000000;i++)\r\n\tfc[i]=fc[i-1]*i%mod;\r\n\tfor(int i=0;i<2000000;i++)\r\n\tinv[i]=f(fc[i],mod-2);\r\n\tfor(int i=1;i<=1000000;i++)\r\n\tvv[i]=i;\r\n\tcur[1]=1;\r\n\tfor(int i=2;i<=1000000;i++)\r\n\t{\r\n\t\tif(!cur[i])\r\n\t\t{\r\n\t\t\tv[i].push_back(1);\r\n\t\t\tfor(int j=i+i;j<=1000000;j+=i)\r\n\t\t\t{\r\n\t\t\t\tcur[j]=1;\r\n\t\t\t\tint q=0;\r\n\t\t\t\twhile(vv[j]%i==0)\r\n\t\t\t\t{\r\n\t\t\t\t\tq++;\r\n\t\t\t\t\tvv[j]/=i;\r\n\t\t\t\t}\r\n\t\t\t\tv[j].push_back(q);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\nlong long f(long long a,long long b)\r\n{\r\n\tlong long c=1;\r\n\twhile(b)\r\n\t{\r\n\t\tif(b&1)\r\n\t\t{\r\n\t\t\tc*=a;\r\n\t\t\tc%=mod;\r\n\t\t}\r\n\t\ta*=a;\r\n\t\ta%=mod;\r\n\t\tb>>=1;\r\n\t}\r\n\treturn c;\r\n}\r\nint main()\r\n{\r\n\t\r\n\tinit();\r\n\tint T;\r\n\tscanf(\"%d\",&T);\r\n\twhile(T--)\r\n\t{\r\n\t\tlong long x,y;\r\n\t\tscanf(\"%lld%lld\",&x,&y);\r\n\t\tlong long ans=1;\r\n\t\tfor(int i=0;i\n#include\n#include\n\nint main() \n{\n \n\tlong long int n,m;\n\tscanf(\"%lld %lld\",&n,&m);\n\tlong long int k;\n\t\n\t\n\tk = (-1 + sqrt(1 + 8*(n-m)))/2;\n\tif(k*(k+1) < 2*(n-m))\n\t k++;\n\tprintf(\"%lld\",k+m);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "084f3b9d84db19d1baa8320b59884c82", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \r\n\r\ntypedef long long ll;\r\n\r\nll dp[200007][7], sum[200007][7];\r\n\r\nint main(){\r\n\tint n, m;\r\n\tscanf(\"%d %d\", &n, &m);\r\n\tfor (register int i = 2; i <= n; i++){\r\n\t\tint half_i = i / 2;\r\n\t\tdp[i][1] = (sum[i - 1][1] + sum[i - 1][2] + 1) % m;\r\n\t\tdp[i][2] = i - half_i;\r\n\t\tfor (register int j = 2, k; j <= half_i; j = k + 1){\r\n\t\t\tint ti = i / j;\r\n\t\t\tk = i / ti;\r\n\t\t\tdp[i][2] = (dp[i][2] + (dp[ti][1] + dp[ti][2]) * (k - j + 1) % m) % m;\r\n\t\t}\r\n\t\tsum[i][1] = (sum[i - 1][1] + dp[i][1]) % m;\r\n\t\tsum[i][2] = (sum[i - 1][2] + dp[i][2]) % m;\r\n\t}\r\n\tprintf(\"%lld\", (dp[n][1] + dp[n][2]) % m);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "09a4449d9efcee49fa28c0c89167306e", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \ntypedef long long i64;\ni64 gcd(i64 a, i64 b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\nbool is_prime(i64 n) {\n\tif(n <= 1) return false;\n\telse if(n <= 3) return true;\n\telse if(n % 2 == 0 || n % 3 == 0) return false;\n\tfor(i64 i = 5; i * i <= n; i += 6) if(n % i == 0 || n % (i + 2) == 0) return false;\n\treturn true;\n}\ni64 f(i64 x, i64 y) {\n\ti64 ans = 0, d;\n\twhile(y != 0) {\n\t\tif(is_prime(x)) {\n\t\t\tans += x < y ? y / x + y % x : y;\n\t\t\tbreak;\n\t\t}\n\t\twhile((d = gcd(x, y)) == 1LL && y != 0) ans++, y--;\n\t\tif(y == 0) break;\n\t\tx /= d, y /= d;\n\t}\n\treturn ans;\n}\nint main(void) {\n\ti64 x, y;\n\tscanf(\"%lld%lld\", &x, &y);\n\tprintf(\"%lld\\n\", f(x, y));\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "00e8aa79ea19973ebd08ac1c7c08dad8", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "/* upsolved with https://codeforces.com/blog/entry/70162 */\n#include \n\n#define N\t250\n#define MD\t1000000007\n\nlong long power(int a, int k) {\n\tlong long b = a, p = 1;\n\n\twhile (k > 0) {\n\t\tif (k & 1)\n\t\t\tp = p * b % MD;\n\t\tb = b * b % MD;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint ff[N + 1], gg[N + 1];\n\nvoid init() {\n\tint i;\n\tlong long f = 1;\n\n\tfor (i = 0; i <= N; i++) {\n\t\tgg[i] = power(ff[i] = f, MD - 2);\n\t\tf = f * (i + 1) % MD;\n\t}\n}\n\nlong long choose(int n, int k) {\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nint main() {\n\tint n, k, r, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tans = 0;\n\tfor (r = 0; r <= n; r++)\n\t\tans = (ans + (r % 2 == 0 ? 1 : -1) * choose(n, r) * power(power(k - 1, r) * (power(k, n - r) - power(k - 1, n - r)) % MD, n)) % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "fb90d7792ae1d0666aae5f3cdd225259", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include\nint main(void)\n{\n int n,res=1;\n scanf(\"%d\",&n);\n if(!n)puts(\"0\");\n else{\n while(--n){\n res*=3;\n res%=1000003;\n }\n printf(\"%d\\n\",res);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "88b6186aacd069664b69681ff5baacaf", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n\nint cmp(long long a, long long b) {\n\treturn a == b ? 0 : a < b ? -1 : 1;\n}\n\nint main() {\n\tint n, i, j, zero;\n\tlong long k, l, r, cnt, a, a_;\n\n\tscanf(\"%d%lld\", &n, &k);\n\tl = 1;\n\tr = 1LL << (n / 2 - 1);\n\tcnt = (l + r) * (r - l + 1);\n\tif (n % 2 == 1)\n\t\tcnt = cnt + (cnt - (r - l + 1));\n\tif (k >= cnt) {\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\tprintf(\"0\");\n\ta = 0;\n\tfor (i = 1; i < n / 2; i++) {\n\t\tr = (1LL << (n / 2 - 1)) - a;\n\t\tl = r - ((1LL << (n / 2 - 1 - i)) - 1);\n\t\tcnt = (l + r) * (r - l + 1);\n\t\tif (n % 2 == 1)\n\t\t\tcnt = cnt + (cnt - (r - l + 1));\n\t\tif (k >= cnt) {\n\t\t\tk -= cnt;\n\t\t\ta |= 1LL << (n / 2 - 1 - i);\n\t\t\tprintf(\"1\");\n\t\t} else\n\t\t\tprintf(\"0\");\n\t}\n\tzero = 1;\n\tif (n % 2 == 1) {\n\t\tl = r = (1LL << (n / 2 - 1)) - a;\n\t\tcnt = (l + r) * (r - l + 1);\n\t\tif (k >= cnt) {\n\t\t\tk -= cnt;\n\t\t\tzero = 0;\n\t\t\tprintf(\"1\");\n\t\t} else {\n\t\t\tzero = 1;\n\t\t\tprintf(\"0\");\n\t\t}\n\t}\n\ta_ = 0;\n\tfor (i = (n + 1) / 2; i < n; i++) {\n\t\tint cmp1 = cmp(a_, a % (1LL << (i - (n - 1) / 2)));\n\t\tint cmp2 = cmp(a_ ^ ((1LL << (i - (n - 1) / 2)) - 1), a % (1LL << (i - (n - 1) / 2)));\n\n\t\tcnt = 0;\n\t\tfor (j = n - 2; j > i; j--)\n\t\t\tif ((a & 1LL << (j - i)) == 0)\n\t\t\t\tcnt += 1LL << (j - i - 1);\n\t\tcnt *= 2;\n\t\tif (cmp1 >= 0)\n\t\t\tcnt++;\n\t\tif (i < n - 1 && (cmp2 > 0 || (cmp2 == 0 && zero)))\n\t\t\tcnt++;\n\t\tif (k >= cnt) {\n\t\t\tk -= cnt;\n\t\t\ta_ |= 1LL << (n - 1 - i);\n\t\t\tprintf(\"1\");\n\t\t} else\n\t\t\tprintf(\"0\");\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "84377fd0ed20d6fc0ed991bcf9734411", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "#include \n\nconst unsigned char N = (unsigned char) 10;\n\nunsigned char n;\nint x;\nunsigned char mat[10][10];\n\ninline unsigned char smin(const unsigned char a, const unsigned char b) { return a < b ? a : b; }\ninline unsigned char smax(const unsigned char a, const unsigned char b) { return a > b ? a : b; }\n\ninline unsigned char FOR3(const unsigned char k, const unsigned char i, const unsigned char j) {\n mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);\n return j + 1 < n ? FOR3(k, i, j + 1) : 0;\n}\n\ninline unsigned char FOR2(const unsigned char i, const unsigned char j) {\n FOR3(i, j, 0);\n return j + 1 < n ? FOR2(i, j + 1) : 0;\n}\n\ninline unsigned char FOR1(const unsigned char i) {\n FOR2(i, 0);\n return i + 1 < n ? FOR1(i + 1) : 0;\n}\n\ninline unsigned char FOR4(const unsigned char k, const unsigned char i, const unsigned char j) {\n mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);\n return j + 1 < n ? FOR4(k, i, j + 1) :\n i + 1 < n ? FOR4(k, i + 1, 0) :\n k + 1 < n ? FOR4(k + 1, 0, 0) : 0;\n}\n\ninline unsigned char FOR_INPUT2(const unsigned char i, const unsigned char j) {\n scanf(\"%d\", &x);\n mat[i][j] = x;\n return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;\n}\n\ninline unsigned char FOR_INPUT1(const unsigned char i) {\n FOR_INPUT2(i, 0);\n return i + 1 < n ? FOR_INPUT1(i + 1) : 0;\n}\n\ninline unsigned char BILLY2(const unsigned char i, const unsigned char j) {\n return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);\n}\n\ninline unsigned char BILLY1(const unsigned char i) {\n unsigned char ans = BILLY2(i, 0);\n unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;\n return smax(ans, other);\n}\n\ninline void solve() {\n scanf(\"%d\", &x); n = x;\n FOR_INPUT1(0);\n // FOR1(0);\n FOR4(0, 0, 0);\n printf(\"%d\\n\", BILLY1(0));\n}\n\nint main() {\n solve();\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "119c83cf2865c7d00fdf7b9bbe8bda77", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include\n#define lli long long int\n\nlli n,c1,c2,pr=0;\n\nlli calc(lli gr)\n{\n if(gr==0 || gr>pr)\n return 1000000000000000;\n lli num=n/gr;\n lli r=n%gr;\n lli ret=gr*c1;\n ret+=r*(n/gr)*(n/gr)*c2;\n ret+=(gr-r)*(n/gr-1)*(n/gr-1)*c2;\n return ret;\n}\n\nint main() {\n scanf(\"%lld%\",&n);\n scanf(\"%lld%\",&c1);\n scanf(\"%lld%\",&c2);\n char s[n+1];\n gets(s);\n int ch=0;\n int i;\n for(i=0;inm && n2>nm)\n {ans=nm;\n break;}\n else if(n2\n#include\n#define ifdot(a) (str[a]=='d' && str[a+1]=='o' && str[a+2]=='t')\n#define ifat(a) \t(str[a]=='a' && str[a+1]=='t')\n#define endl puts(\"\");\nchar str[200];\nint main ()\n{\n\tscanf(\"%s\",str);\n\tint i,len=strlen(str);\n\tprintf(\"%c\",str[0]);\n\tfor(i=1; i\n#include\n#include\n\nint a[2][12]={{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\nbool fre(int x)\n{return (x%4==0&&x%100!=0)||(x%400==0);}\n\nint res (int y,int x,int d)\n{ int sum=d;\n for(int i=0;i\n int main(void){\n\tint n,m,a,b,x,y,s,t;\n int ans;\n\tscanf(\"%d%d%d%d\",&n,&m,&a,&b);\n\tx=(b-1)/m+1;\n\ty=(a-1)/m+1;\n\ts=(b-1)%m+1;\n\tt=(a-1)%m+1;\n\tif(x==y){\n\t puts(\"1\");\n\t}else if(t-1==s){\n\t puts(\"2\");\n\t}else if(x==y+1){\n\t\tif(t==1 && (s==m || b==n)) puts(\"1\");\n\t\telse puts(\"2\");\n\t}else {\n\t\tans=3;\n\t\tif(t==1) ans--;\n if((s==m)||(b==n)) ans--;\n\t printf(\"%d\\n\",ans);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d8641fe1dbc078b1d03f9052154b11a3", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char s[100005];\n scanf(\"%s\",s);\n int l=strlen(s);\n int k=0;\n char s1[100005];\n int a=0;\n int p=0;\n int y=0;\n for(int i=0;ii)\n {\n s1[a]=c1;\n a++;\n }\n else\n {\n s1[a]=(char)i;\n a++;\n k=j+1;\n break;\n }\n k++;\n }\n if(k>=l&&i<122)\n {\n p=1;\n break;\n }\n }\n for(int i=k;i\n#include \n#include \nint intcmp(int a,int b);\nmain()\n{\n\tint n,B,a[100],b[100],i,d[2],c=0,max=0,j,sum=0;\n\tscanf(\"%d%d\",&n,&B);\n\tfor(i=0; ib)return 1;\n\telse if(a\n#include\n\nint main(){\n int n, k, c_time[26], i, flag[26], j, unguarded, sum;\n char s[100005];\n memset(flag, 0, sizeof(flag));\n memset(c_time, 0, sizeof(c_time));\n scanf(\"%d %d\\n%s\", &n, &k, s);\n if(k == 26){\n printf(\"YES\\n\");\n } else {\n for (i = 0; i < n; i++){\n if (i > c_time[s[i] - 'A']){\n c_time[s[i] - 'A'] = i;\n }\n }\n for (i = 0, unguarded = 0; i < n && !unguarded; i++){\n flag[s[i] - 'A'] = 1;\n for (j = 0, sum = 0; j < 26; j++){\n sum += flag[j];\n }\n unguarded = (sum > k);\n flag[s[i] - 'A'] = !(c_time[s[i] - 'A'] == i);\n }\n printf(\"%s\\n\", unguarded ? \"YES\" : \"NO\");\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "5e752434c5029fa2bc3185e4c784e876", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nint max=10;\n//int arr[]={0,2,3,5,7,11,13,17,19,23,29,31,33,37,39,};\n\nint main(){\n int k;\n scanf(\"%d\",&k);\n int sum=k;\n int res=k;\n while(res!=1){\n for(int i=2;i<=res;i++)\n if(res%i==0){\n res=res/i;\n sum+=res;\n break;\n }\n }\n printf(\"%d\\n\",sum);\n}\n\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "77cba31a7343072f35dc15c4bc933c3d", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "/*\n author: Maksim1744\n created: 24.10.2020 17:14:50\n*/\n\n#include \n#include \n\n#define max(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })\n#define min(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })\n\n#define mod 1000000007\n\nint a[1005];\n\nint main() {\n int n, x, pos;\n scanf(\"%d%d%d\", &n, &x, &pos);\n for (int i = 0; i < n; ++i) {\n a[i] = 0;\n }\n int left = 0, right = n;\n while (left < right) {\n int middle = (left + right) / 2;\n if (pos < middle) {\n a[middle] = 1;\n right = middle;\n } else {\n a[middle] = -1;\n left = middle + 1;\n }\n }\n int bigger = 0, smaller = 0;\n for (int i = 0; i < n; ++i) {\n if (i != pos) {\n if (a[i] == 1) bigger++;\n else if (a[i] == -1) smaller++;\n }\n if (a[i] == 1 && i == pos) {\n printf(\"0\\n\");\n return 0;\n }\n }\n\n long long C[1005][1005];\n for (int i = 0; i < 1005; ++i) {\n C[0][i] = 0;\n C[i][0] = 1;\n }\n\n for (int i = 1; i < 1005; ++i) {\n for (int j = 1; j < 1005; ++j) {\n C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;\n }\n }\n\n // printf(\"%d %d\\n\", smaller, bigger);\n // for (int i = 0; i < n; ++i) {\n // printf(\"%d \", a[i]);\n // }\n // printf(\"\\n\");\n\n long long f[1005];\n f[0] = 1;\n for (int i = 1; i < 1005; ++i)\n f[i] = (f[i - 1] * i) % mod;\n\n if (smaller > x - 1 || bigger > n - x) {\n printf(\"0\\n\");\n return 0;\n }\n\n long long res = C[x - 1][smaller] * C[n - x][bigger] % mod * f[smaller] % mod * f[bigger] % mod * f[n - smaller - bigger - 1] % mod;\n printf(\"%d\\n\", res);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "65b9724b29e4dc0941cc127fed23ce6a", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int a , b , w , x , c , count = 0 ;\n scanf(\"%d %d %d %d %d\", &a, &b, &w, &x, &c);\n while(c > a)\n {\n count++;\n c--;\n if(b >= x) b -= x ;\n else\n {\n a--;\n b = w -( x - b) ;\n }\n if(c <= a)\n break;\n }\n printf(\"%d\\n\", count);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "505b0a59f4d8b3c045c86b4bb905b315", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "/*\n * main.c\n *\n * Created on: 03 \ufffd\ufffd\ufffd. 2014 \ufffd.\n * Author: ulgish\n */\n\n\n/*\n * util.c\n *\n * Created on: 30 \ufffd\ufffd\ufffd\ufffd 2014 \ufffd.\n * Author: ulgish\n */\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\n#define LN printf(\"\\n\")\n#define TAB printf(\"\\t\")\n#define SPACE printf(\" \")\n\ntypedef unsigned long long uint64;\ntypedef long long int64;\ntypedef signed short int16;\ntypedef unsigned short uint16;\ntypedef char byte;\n\n\nvoid int64_print(int64 n){\n\tint64 carry = 10;\n\tif (n == 0){\n\t\tprintf(\"0\");\n\t\treturn;\n\t}\n\tchar buf[20];\n\tbuf[0] = '\\0';\n\tint i = 0, j;\n\twhile (n > 0){\n\t\tbuf[i] = n % carry;\n\t\tn = n / carry;\n\t\ti += 1;\n\t}\n\ti--;\n\tfor (j = i; j>= 0; j--){\n\t\tprintf(\"%c\", 48 + buf[j]);\n\t}\n}\nvoid uint64_print(uint64 n){\n\tuint64 carry = 10;\n\tchar buf[20];\n\tbuf[0] = '\\0';\n\tint i = 0, j;\n\twhile (n > 0){\n\t\tbuf[i] = n % carry;\n\t\tn = n / carry;\n\t\ti += 1;\n\t}\n\ti--;\n\tfor (j = i; j>= 0; j--){\n\t\tprintf(\"%c\", 48 + buf[j]);\n\t}\n}\n\n\nuint64 uint64_read(){\n\tchar* s = (char*) calloc(20, sizeof(char));\n\ts[0] = '\\0';\n\tscanf(\"%s\", s);\n\t//printf(\"=======%s\\n\", s);\n\tuint64 ret = 0;\n\tuint64 carry = 1;\n\tint len = strlen(s), i;\n\tfor (i = 0; i < len; i++){\n\t\tret += carry * (s[len-1-i] - 48);\n\t\tcarry*=10;\n\t};\n\tfree(s);\n\treturn ret;\n}\n\n\nint64 int64_read(){\n\tchar* s = (char*) calloc(21, sizeof(char));\n\ts[0] = '\\0';\n\tscanf(\"%s\", s);\n\t//printf(\"=======%s\\n\", s);\n\tint64 ret = 0;\n\tint64 carry = 1;\n\tint len = strlen(s), i;\n\tfor (i = 0; i < len; i++){\n\t\tret += carry * (s[len-1-i] - 48);\n\t\tcarry*=10;\n\t};\n\tfree(s);\n\treturn ret;\n}\n\n//#define DEBUG\n\nint64 x;\nint a[100001];\nint b[100001];\n\nint n,d;\n\nvoid swap(int* a, int* b){\n\tint c;\n\tc = *a;\n\t*a = *b;\n\t*b = c;\n\treturn;\n}\nint64 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[(int)(getNextX() % (i + 1LL))]));\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[(int)(getNextX() % (i + 1LL))]));\n }\n}\n\n\nint main(){\n\tscanf(\"%d %d\", &n, &d);\n\tx = int64_read();\n\tint i,j;\n\tinitAB();\n\tint max_a[100000];\n\tint index_a[100001];\n\n\tmax_a[0] = a[0];\n#ifdef DEBUG\n\tprintf(\"d:%d\\n\", d);\n\tfor (i = 0 ; i < n; i++){\n\t\tprintf(\"%d\\t\", b[i]);\n\t}\n\tLN;\n\n#endif\n\tif (b[0] == 0){\n\t\tprintf(\"0\\n\");\n\t}else{\n\t\tprintf(\"%d\\n\", a[0]);\n\t}\n\tfor (i = 0; i< n; i++){\n\t\tindex_a[a[i]] = i;\n\t}\n\tfor (i = 1; i < n; i++){\n\t\tint c = 0;\n\t\tmax_a[i] = MAX(a[i], max_a[i-1]);\n\t\tint s = 0;\n\t\tbyte next = 0;\n\t\tfor (j = max_a[i]; j >= 0 && s < 30; j--, s++){\n\t\t\tif (index_a[j] <= i){\n\t\t\t\tif (b[i - index_a[j]]){\n\t\t\t\t\tnext = 1;\n\t\t\t\t\tprintf(\"%d\\n\", j);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (next){\n\t\t\tcontinue;\n\t\t}\n\t\tfor (j = 0; j<= i; j++){\n\t\t\tc = MAX(c, a[j]*b[i-j]);\n\t\t}\n\t\tprintf(\"%d\\n\",c);\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "665583d2f4bc8f826ce806ed0a4f0656", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n\tint n,m,t,k;\r\n\tscanf(\"%d\",&t);\r\n\twhile(t--){\r\n\t\tscanf(\"%d %d %d\",&n,&m,&k);\r\n\t\tint sum=n*m/2;\r\n\t\tif(n%2==1){\r\n\t\t\tsum-=m/2;\r\n\t\t\tk-=m/2;\r\n\t\t}\r\n\t\tif(m%2==1){\r\n\t\t\tsum-=n/2;\r\n\t\t}\r\n\t\tif(k<0||k%2==1||k>sum){\r\n\t\t\tprintf(\"NO\\n\");\r\n\t\t}else printf(\"YES\\n\");*\r\n\t}\r\n\treturn 0;\r\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "4270e5ad769c81784ac136123a4d2bd9", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \nlong long num[70]={0};\nlong long num1[70]={0};\nlong long change(long long n)\n{\n long long i=0;\n while(n)\n {\n num[i++]=n%2;\n n=n/2;\n }\n return 0;\n}\nint main()\n{\n long long n=0,m=0,ans=0;//min\u8868\u793a2\u7684\u6307\u6570,minn\u8868\u793a\u6700\u5c0f\u5355\u4f4d\u503c\n scanf(\"%lld%lld\",&n,&m);\n change(n);\n for(long long i=0;i<=69;i++)\n {\n num1[i]=num[i];\n }\n if(mmax) max=num[i];\n }\n printf(\"%lld\\n\",max);\n for(long long i=1,j=0,x=0;i<=max;i++)\n {\n ans=0;\n x=1;\n j=0;\n for(j=0;j<=69;j++,x=2*x)\n {\n if(num[j]>=1)\n {\n ans=ans+x;\n num[j]--;\n }\n }\n if(i==1) printf(\"%lld\",ans);\n else printf(\" %lld\",ans);\n }\n printf(\"\\n\");\n }\n return 0;\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4bb912c150d41c8afd3e4f75b0400bbf", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nint main()\n{\n int n,k;\n while(~scanf(\"%d%d\",&n,&k))\n {\n int a[100],i,vis[100],money=0;\n memset(vis,0,sizeof(vis));\n for(i=0;i1&exit[a[i]]==0&flag==0)\n {\n money++;\n booknum++;\n exit[a[i]]=1;\n //printf(\"money2=%d booknum=%d\\n\",money,booknum);\n flag=1;\n vis[a[i]]--;\n }\n if(booknum==k&exit[a[i]]==0&flag==0)\n {\n int j,exit1[100],b[100],k=-1;\n memset(exit1,0,sizeof(exit1));\n if(i+1==n)\n {\n money++;\n break;\n }\n for(j=i+1;j\n#include\nint main(){\n int q;\n scanf(\"%d\",&q);\n while(q--){\n long long int a,b,m;\n scanf(\"%lld %lld %lld\",&a,&b,&m);\n long long int k=1;\n if(a==b)\n printf(\"%lld %lld\\n\",k,a);\n else{\n long long int c=a+m;\n //double n;\n k = log2((b*1.0)/c) + 1;\n long long int d=c*pow(2,k-1);\n if(b!=d){\n k++;\n d=d*2;\n }\n //printf(\"%lld\",k+1);\n c=a+1;\n long long int s=c*pow(2,k-1);\n if(k>=50 || s>b){\n printf(\"-1\\n\");\n }\n else{\n m--;\n long long int r[k+1];\n long long int diff = b-s;\n for(long long int i=1;im)\n f=m;\n r[i] = f + 1;\n diff = diff - (k-i)*f;\n }\n r[k] = diff + 1;\n printf(\"%lld %lld \",(k+1),a);\n long long int sum=a;\n for(long long int i=1;i<=k;i++){\n long long int temp = sum + r[i];\n printf(\"%lld \",temp);\n sum = sum + temp;\n }\n printf(\"\\n\");\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4862e111d244cd1b7d687c280b895b11", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,m,max,min, var, temp,i,flag=0;\n scanf(\"%d %d %d %d\",&n,&m,&min,&max);\n var= n-m;\n //printf(\"%d\\n\",var);\n for(i=0;i max)\n //printf(\"Incorrect\\n\");\n flag=1; \n else if(var < 2 && (temp == min || temp == max) )\n //printf(\"Correct\\n\");\n flag=0;\n else if(var < 2 && (temp != min || temp != max) )\n //printf(\"Incorrect\\n\");\n flag=1;\n else if( var >= 2 && temp>=min && temp <=max)\n //printf(\"Correct\\n\"); \n flag=0;\n }\n }\n if(flag==1)\n printf(\"Incorrect\\n\");\n else\n printf(\"Correct\\n\");\n //getch();\n reurn 0;\n \n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "6173701b04ab4e8fb7a6893dc84560f5", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nconst double MULTIPLIER = 0.997;\n\nint n, X[25], Y[25], dis[25][25];\nint m, l, ar[100], out[100], pos[100];\n\ndouble rand_real(){\n return (double)rand() / RAND_MAX;\n}\n\nint solve(){\n int i, res = 0;\n for (i = 1; i < m; i++){\n res += dis[ar[i]][ar[i - 1]];\n }\n return res;\n}\n\nint main(){\n double temperature;\n int i, j, k, l, x, y, z, u, v, w, res, lim, idx;\n\n while (scanf(\"%d %d\", &x, &y) != EOF){\n scanf(\"%d\", &n);\n for (i = 1; i <= n; i++) scanf(\"%d %d\", &X[i], &Y[i]);\n X[0] = x, Y[0] = y, n++;\n\n for (i = 0; i < n; i++){\n for (j = 0; j < n; j++){\n x = X[i] - X[j], y = Y[i] - Y[j];\n dis[i][j] = x * x + y * y;\n }\n }\n\n m = 0, ar[m++] = 0;\n for (i = 1; (i + 1) < n; i += 2) ar[m++] = i, ar[m++] = i + 1, ar[m++] = 0;\n if (n % 2 == 0) ar[m++] = n - 1, ar[m++] = 0;\n\n for (i = 0, l = 0; i < m; i++){\n if (ar[i]) pos[l++] = i;\n }\n\n res = solve();\n lim = 6666666, temperature = 1e9;\n\n for (idx = 0; idx < lim; idx++){\n u = pos[rand() % l], v = pos[rand() % l];\n w = ar[u], ar[u] = ar[v], ar[v] = w;\n\n z = solve();\n if (z < res){\n res = z;\n for (i = 0; i < n; i++) out[i] = ar[i];\n }\n else{\n double p = exp((double)(res - z) / temperature);\n\n if (rand_real() <= p){\n res = z;\n for (i = 0; i < n; i++) out[i] = ar[i];\n }\n else w = ar[u], ar[u] = ar[v], ar[v] = w;\n }\n\n if (temperature > 1e-20) temperature *= MULTIPLIER;\n }\n\n printf(\"%d\\n\", res);\n for (i = 0; i < m; i++){\n if (i) putchar(32);\n printf(\"%d\", out[i]);\n }\n puts(\"\");\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0be0873ef64e6bfdaa6c2833b752c755", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \nint main() {\n\tint n,m,k;\n\tint i;\n\tchar a[3],b[5];\n\tchar c[201];\n\tchar *p;\n\t// 1-> -1<-\n\tint d;\n\tscanf(\"%d %d %d\", &n, &m, &k);\n\tscanf(\"%s %s\",a,b);\n\tscanf(\"%s\", c);\n\n\tif(b[0] == 'h')\n\t\td = -1;\n\telse\n\t\td = 1;\n\n\tfor(p=c,i=1; *p!='\\0'; p++,i++) {\n\t\tif(*p=='0') {\n\t\t\t// move stowaway\n\t\t\tif(d == 1 && m-k==1 && m!=n){\n\t\t\t\tm += 1;\n\t\t\t}else if(d == -1 && k-m==1 && m!=1){\n\t\t\t\tm -= 1;\n\t\t\t}\n\t\t\t// move controller\n\t\t\tk += d;\n\t\t\tif(k == 1)\n\t\t\t\td = 1;\n\t\t\tif(k == n)\n\t\t\t\td = -1;\n\t\t} else {\n\t\t\t// move controller\n\t\t\tk += d;\n\t\t\tif(k == 1)\n\t\t\t\td = 1;\n\t\t\tif(k == n)\n\t\t\t\td = -1;\n\t\t\t// move stowaway\n\t\t\tif(d == 1) {\n\t\t\t\tif(n==2)\n\t\t\t\t\tm = 2;\n\t\t\t\telse if(k==1)\n\t\t\t\t\tm = k+2;\n\t\t\t\telse\n\t\t\t\t\tm = k-1;\n\t\t\t}else{\n\t\t\t\tif(n==2)\n\t\t\t\t\tm = 1;\n\t\t\t\telse if(k!=n)\n\t\t\t\t\tm = k+1;\n\t\t\t\telse\n\t\t\t\t\tm = k-2;\n\t\t\t}\n\t\t}\n\n\t\tif(k == m){\n\t\t\tprintf(\"Controller %d\\n\",i);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tprintf(\"Stowaway\\n\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "238d2dead32093688d942a6bbbb70df3", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,ta;\n\tscanf(\"%d%d\",&a,&ta);\n\tint b,tb;\n\tscanf(\"%d%d\",&b,&tb);\n\tint h,m;\n\tscanf(\"%d:%d\",&h,&m);\n\tint x,y,w=0,z=300;\n\tx=60*h+m;\n\ty=60*h+m+ta;\n\tjump:\n\t\tif(z+tbx && zy)\n\t\t{\n\t\t\tgoto temp;\n\t\t}\n\t\telse if(z+tb==x || z==y)\n\t\t{\n\t\t\tz=z+b;\n\t\t\tgoto jump;\n\t\t}\n\t\ttemp:\n\t\tprintf(\"%d\\n\",w);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "f4744bba82522c012edb7c05171b4b93", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \nint mx, mx_len, k, arr_len;\nchar arr[12], temp[12];\nvoid sq_max(char *s){\n int n=atoi(s), temp=sqrt(n);\n if(s[0]=='0') return;\n if(temp*temp==n && n>mx)\n mx=n, mx_len=strlen(s);\n}\nint main()\n{\n scanf(\"%s\", arr), arr_len=strlen(arr);\n for (int b = 0; b < (1<\n\nint main(){\n int n,h,i,j,m;\n scanf(\"%d%d\",&n,&h);\n long long matriz[n+1][n+1];\n for (i=0;i\n#include\n#include\n#include\n//...........................................................\n\n#define pi 3.14159265358979323846 //float type\n#define MAX 100000 //for rmq\n#define SQRTMAX 317 //for rmq\n//#define gc getchar_unlocked\n\n#define FOR(i,a,b) for(i=(a);i<(b);i++)\n\n//only for +ve and single terms\n#define s(x) scanf(\"%d\",&x);\n#define sl(x) scanf(\"%lld\",&x);\n#define p(x) printf(\"%d\\n\",x);\n#define pl(x) printf(\"%lld\\n\",x);\n//..........................................................\n\ntypedef long long int ll;\nconst ll MOD=1000000007;\n\n//returns int and +ve numbers\n\n/*inline int inp(){\n int n=0;\n char c;\n c=gc();\n while(c<'0' || c>'9'){\n c=gc();\n }\n while(c>='0' && c<='9'){\n n=(n<<3)+(n<<1)+c-'0';\n c=gc();\n }\n return n;\n}\n*/\n//...................................\n\n//power with mod........long long int\n ll power(ll a,ll b,ll mod){\n if(b==0)\n return 1;\n ll temp=power(a,b/2,mod);\n temp=(temp*temp)%mod;\n if(b&1)\n temp=(temp*a)%mod;\n return temp;\n}\n\n //power without mod........ int\nll pwr(ll a,ll b){\n if(b==0)\n return 1;\n ll temp=pwr(a,b/2);\n temp=(temp*temp);\n if(b&1)\n temp=(temp*a);\n return temp;\n}\n // .....long long int\nll gcd(ll a,ll b){\n return b==0?a:gcd(b,a%b);\n}\n //......long long int\nll lcm(ll a,ll b){\n return (a/gcd(a,b))*b;\n}\n //......long long int with mod\nll modularInverse(ll a,ll m){\n return power(a,m-2,m);\n}\n\n //only for int\n//inline int min(int a,int b) { return ab? a : b; }\n\n//normal compare func on integers //for qsort(name,size,sizeof(type),compare)\nint compare (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint BinarySearch(int *array, int number_of_elements, int key)\n{\n int low = 0, high = number_of_elements-1, mid;\n while(low <= high)\n {\n mid = (low + high)/2;\n if(array[mid] < key)\n {\n low = mid + 1;\n }\n else if(array[mid] == key)\n {\n return mid;\n }\n else if(array[mid] > key)\n {\n high = mid-1;\n }\n\n }\n return -1;\n}\n//.......................................................\n\n//segment tree\n//not template but how to use ST\n//for minimum element\n/*\nlong long s[400000];\nlong long a[1000000];\nint create(long long b,long long e,long long n)\n{\n if(b==e)\n {\n s[n]=a[b];\n }\n else\n {\n create(b,(b+e)/2,2*n+1);\n create((b+e)/2+1,e,2*n+2);\n s[n]=s[2*n+1]r)\n {\n return 100000001;\n }\n if(b>=l&&e<=r)\n {\n return s[n];\n }\n i=messi(b,(b+e)/2,l,r,2*n+1);\n j=messi((b+e)/2+1,e,l,r,2*n+2);\n return ib[i])\n minimum = b[i];\n if(maximum b[l]){\n minimum = b[l];\n\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n while(j<=j2 && l<=r && j min[j])\n minimum = min[j];\n l = (j+1)*size;\n //printf(\"Checked for %d <--> %d\\n\", j*size, l-1);\n j++;\n }\n while(l<=r){\n if(minimum > b[l]){\n minimum = b[l];\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n return minimum;\n}\n\n//finding max value\nlong findMax(int l, int r){\n int j, j2;\n long maximum = b[l];\n\n j = l/size + 1;\n j2 = r/size - 1;\n\n //printf(\"j= %d and j2 = %d\\n\", j,j2);\n while(l %d\\n\", j*size, l-1);\n j++;\n }\n while(l<=r){\n if(maximum < b[l]){\n maximum = b[l];\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n return maximum;\n}\n*/\n\n//...........................................END OF TEMPLATE.................................................................\nll flen(ll b)\n{\n ll len=0;\n while(b!=0)\n {\n b=b>>1;\n len++;\n }\n\n return len;\n\n}\n\nll arr[70];\nint main()\n{ ll i,j,k,t,n,len,tot=0,f1=0,f2=0,a,b,ans=0,f3=0;\n\n sl(a)\n sl(b)\n\n len= flen(b);\n\n\n //pl(len)\n\n if(((a>>(len-1))&1)==((b>>(len-1))&1))\n {\n arr[tot++]=0;\n }\n\n else\n {\n arr[tot++]=1;\n\n if(((a>>(len-1))&1)==0 && ((b>>(len-1))&1)==1)\n f3=1;\n }\n\n i=len-2;\n\n while((((a>>(i))&1)==((b>>(i))&1))&& f3==0 && i>=0)\n {\n arr[tot++]=0;\n i--;\n }\n\n for(;i>=0;i--)\n {\n if(f1==1 || f2==1)\n {\n arr[tot++]=1;\n }\n\n else\n {\n if(((a>>i)&1)==0)\n {\n if(((b>>i)&1)==0)\n {\n arr[tot++]=1;\n f1=1;\n }\n else\n {\n arr[tot++]=1;\n f1=f2=1;\n f3=1;\n }\n\n }\n else\n {\n if(((b>>i)&1)==0)\n {\n arr[tot++]=1;\n // f1=1;\n }\n else\n {\n arr[tot++]=1;\n f2=1;\n }\n }\n\n\n\n\n }\n }\n\n//pl(tot)\n FOR(i,0,tot)\n {\n ans=ans+arr[i]*pwr(2,tot-i-1);\n }\n\n pl(ans)\n\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "89fe8fde6f6e6f03fd9557d91a9e2d02", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define N\t17\n#define M\t17\n\nchar i2s[] = \"CDHS\";\nchar i2r[] = \"23456789TJQKA\";\nint s2i[128], r2i[128];\n\nvoid init() {\n\tint i;\n\n\tfor (i = 0; i < 4; i++)\n\t\ts2i[(int) i2s[i]] = i;\n\tfor (i = 0; i < 13; i++)\n\t\tr2i[(int) i2r[i]] = i;\n}\n\nchar used[4][13], used_[13];\nint rr[N][M];\n\nint ip, jp, iq, jq;\n\nint distinct(int i, int j) {\n\tint di, dj;\n\n\tmemset(used_, 0, sizeof used_);\n\tfor (di = 0; di < 3; di++)\n\t\tfor (dj = 0; dj < 3; dj++) {\n\t\t\tint r = rr[i + di][j + dj];\n\n\t\t\tif (used_[r])\n\t\t\t\treturn 0;\n\t\t\tused_[r] = 1;\n\t\t}\n\treturn 1;\n}\n\nint check(int n, int m) {\n\tint il, jl, ir, jr, iu, ju, id, jd, i, j;\n\n\til = ir = -1, jl = m, jr = -1;\n\tju = jd = -1, iu = n, id = -1;\n\tfor (i = 0; i + 3 <= n; i++)\n\t\tfor (j = 0; j + 3 <= m; j++)\n\t\t\tif (distinct(i, j)) {\n\t\t\t\tif (jl > j)\n\t\t\t\t\til = i, jl = j;\n\t\t\t\tif (jr < j)\n\t\t\t\t\tir = i, jr = j;\n\t\t\t\tif (iu > i)\n\t\t\t\t\tiu = i, ju = j;\n\t\t\t\tif (id < i)\n\t\t\t\t\tid = i, jd = j;\n\t\t\t}\n\tif (jr - jl >= 3) {\n\t\tip = il, jp = jl;\n\t\tiq = ir, jq = jr;\n\t\treturn 1;\n\t}\n\tif (id - iu >= 3) {\n\t\tip = iu, jp = ju;\n\t\tiq = id, jq = jd;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nint check_(int n, int m, int s1, int r1, int s2, int r2) {\n\tif (!check(n, m))\n\t\treturn 0;\n\tprintf(\"Solution exists.\\n\");\n\tif (s1 == -1 && s2 == -1)\n\t\tprintf(\"There are no jokers.\\n\");\n\telse if (s2 == -1)\n\t\tprintf(\"Replace J1 with %c%c.\\n\", i2r[r1], i2s[s1]);\n\telse if (s1 == -1)\n\t\tprintf(\"Replace J2 with %c%c.\\n\", i2r[r2], i2s[s2]);\n\telse\n\t\tprintf(\"Replace J1 with %c%c and J2 with %c%c.\\n\", i2r[r1], i2s[s1], i2r[r2], i2s[s2]);\n\tprintf(\"Put the first square to (%d, %d).\\n\", ip + 1, jp + 1); printf(\"Put the second square to (%d, %d).\\n\", iq + 1, jq + 1);\n\treturn 1;\n}\n\nint main() {\n\tint n, m, i, j, i1, j1, i2, j2, s1, r1, s2, r2;\n\n\tinit();\n\ti1 = j1 = i2 = j2 = -1;\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < m; j++) {\n\t\t\tstatic char str[4];\n\t\t\tint r, s;\n\n\t\t\tscanf(\"%s\", str);\n\t\t\tr = str[0];\n\t\t\ts = str[1];\n\t\t\tif (s == '1')\n\t\t\t\ti1 = i, j1 = j;\n\t\t\telse if (s == '2')\n\t\t\t\ti2 = i, j2 = j;\n\t\t\telse\n\t\t\t\tused[s2i[s]][rr[i][j] = r2i[r]] = 1;\n\t\t}\n\tif (j1 == -1 && j2 == -1) {\n\t\tif (check_(n, m, -1, -1, -1, -1))\n\t\t\treturn 0;\n\t} else if (j1 != -1 && j2 == -1) {\n\t\tfor (s1 = 0; s1 < 4; s1++)\n\t\t\tfor (r1 = 0; r1 < 13; r1++)\n\t\t\t\tif (!used[s1][r1]) {\n\t\t\t\t\tused[s1][r1] = 1;\n\t\t\t\t\trr[i1][j1] = r1;\n\t\t\t\t\tif (check_(n, m, s1, r1, -1, -1))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\tused[s1][r1] = 0;\n\t\t\t\t}\n\t} else if (j1 == -1 && j2 != -1) {\n\t\tfor (s2 = 0; s2 < 4; s2++)\n\t\t\tfor (r2 = 0; r2 < 13; r2++)\n\t\t\t\tif (!used[s2][r2]) {\n\t\t\t\t\tused[s2][r2] = 1;\n\t\t\t\t\trr[i2][j2] = r2;\n\t\t\t\t\tif (check_(n, m, -1, -1, s2, r2))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\tused[s2][r2] = 0;\n\t\t\t\t}\n\t} else {\n\t\tfor (s1 = 0; s1 < 4; s1++)\n\t\t\tfor (r1 = 0; r1 < 13; r1++)\n\t\t\t\tif (!used[s1][r1]) {\n\t\t\t\t\tused[s1][r1] = 1;\n\t\t\t\t\trr[i1][j1] = r1;\n\t\t\t\t\tfor (s2 = 0; s2 < 4; s2++)\n\t\t\t\t\t\tfor (r2 = 0; r2 < 13; r2++)\n\t\t\t\t\t\t\tif (!used[s2][r2]) {\n\t\t\t\t\t\t\t\tused[s2][r2] = 1;\n\t\t\t\t\t\t\t\trr[i2][j2] = r2;\n\t\t\t\t\t\t\t\tif (check_(n, m, s1, r1, s2, r2))\n\t\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\t\tused[s2][r2] = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\tused[s1][r1] = 0;\n\t\t\t\t}\n\t}\n\tprintf(\"No solution.\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "5bc7aea5610c3e8c0973d9a3894d5aad", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include \n\nint number(char c, int i)\n{ // \u043d\u043e\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u044b [0, 24]\n switch (c)\n {\n case 'R': return i - 1;\n case 'G': return 5 + i - 1;\n case 'B': return 10 + i - 1;\n case 'Y': return 15 + i - 1;\n case 'W': return 20 + i - 1;\n }\n return 25;\n}\n\nint color(int number)\n{\n return number / 5;\n}\n\nint value(int number)\n{\n return number % 5;\n}\n\nint check_color(int number, int mask)\n{\n return (1 << (5 + color(number))) & mask;\n}\n\nint check_value(int number, int mask)\n{\n return (1 << value(number)) & mask;\n}\n\nint count(int mask)\n{\n int res = 0;\n while (mask)\n {\n res += mask % 2;\n mask /= 2;\n }\n return res;\n}\n\nint main()\n{\n int cards[25] = {0};\n int n, ans, i, j, mask, flag;\n char s[3];\n char c;\n scanf(\"%d\", &n);\n for(i = 0; i < n; i++)\n {\n scanf(\"%s\", s);\n c = s[0];\n j = s[1] - '0';\n cards[number(c, j)] = 1;\n }\n\n ans = 10;\n for(mask = 0; mask < 1023; mask++)\n {\n flag = 1;\n for (i = 0; i < 25; i++)\n if (cards[i])\n {\n for (j = i+1; j < 25; j++)\n if (cards[j])\n {\n if (color(i) != color(j) &&\n (check_color(i, mask) ||\n check_color(j, mask)))\n continue;\n if (value(i) != value(j) &&\n (check_value(i, mask) ||\n check_value(j, mask)))\n continue;\n\n flag = 0;\n break;\n }\n if (!flag)\n break;\n }\n if (flag && count(mask) < ans)\n ans = count(mask);\n }\n\n printf(\"%d\\n\", ans);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "63222fee8b3f1ae004934a5a9187efd4", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n#define N 1002\n#define MOD 1000000007\n\ntypedef long long typec;\n\nint n, m, k;\ntypec ftable[N];\ntypec facmod[1000001];\nint com[N][N];\n\ntypec extend_gcd(typec a, typec b, typec *x, typec *y)\n{\n\tif(!b) return *x = 1, *y = 0, a;\n\ttypec res = extend_gcd(b, a % b, x, y), tmp = *x;\n\t*x = *y, *y = tmp - (a / b) * (*y);\n\treturn res;\n}\n\ntypec inverse(typec a, typec m)\n{\n\ttypec x, y;\n\ty = extend_gcd(a, m, &x, &y);\n\twhile(x < 0) x += m;\n\treturn x;\n}\n\ntypec pow_mod(typec x, typec k, typec m)\n{\n\ttypec res = 1;\n\twhile(x %= m, k) {\n\t\tif(k&1) res *= x, res %= m;\n\t\tx *= x, k >>= 1;\n\t}\n\treturn res;\n}\n\nint mymin(int x, int y)\n{\n\treturn x < y? x : y;\n}\n\ntypec combines(int i, int j)\n{\n\tif(i < j) return 0;\n\treturn facmod[i] * inverse(facmod[j], MOD) % MOD * inverse(facmod[i - j], MOD) % MOD;\n}\n\nvoid init()\n{\n\tint i, j;\n\ttypec sum = 0;\n\tfacmod[0] = 1;\n\tfor(i = 1; i <= 1000000; i++) {\n\t\tfacmod[i] = facmod[i - 1] * i;\n\t\tfacmod[i] %= MOD;\n\t}\n\tfor(i = 0; i < N; i++) {\n\t\tfor(j = 0; j <= i; j++) {\n\t\t\tif(!i) com[i][j] = 1;\n\t\t\telse com[i][j] = (com[i - 1][j] + com[i - 1][j - 1]) % MOD;\n\t\t}\n\t}\n\tftable[1] = 1;\n\tfor(i = 2; i <= n; i++) {\n\t\tftable[i] = pow_mod(i, n, MOD) + MOD;\t\t\n\t\tsum = 0;\n\t\tfor(j = 1; j < i; j++) {\n\t\t\tsum += com[i][j] * ftable[j] % MOD;\n\t\t\tsum %= MOD;\n\t\t}\n\t\tftable[i] -= sum;\n\t\tftable[i] %= MOD;\n\t}\n}\n\n\ntypec calc()\n{\n\tint i, j, m1, m2;\n\ttypec res = 0, tmp, stmp;\n\tm1 = mymin(n, k);\n\tfor(i = 0; i <= m1; i++) {\n\t\ttmp = combines(k, i) * pow_mod(i, (m - 2) * n, MOD) % MOD;\n\t\tm2 = mymin(n - i, (k - i) / 2);\n\t\tstmp = 0;\n\t\tfor(j = 0; j <= m2; j++) {\n\t\t\tif(!i && !j) continue;\n\t\t\tstmp += combines(k - i, j) * combines(k - i - j, j) % MOD * ftable[i + j] % MOD * ftable[i + j] % MOD;\n\t\t\tstmp %= MOD;\n\t\t}\n\t\tres += tmp * stmp % MOD;\n\t\tres %= MOD;\n\t}\n\treturn res;\n}\nint main()\n{\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tif(m == 1) {\n\t\tprintf(\"%d\\n\", (int)pow_mod(k, n, MOD));\n\t\treturn 0;\n\t}\n\tinit();\n\tprintf(\"%d\\n\", (int)calc());\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2a77461a5292eaf993eedba896a533e0", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include\nlong long c[9],z;\nint n;\nint main()\n{\n scanf(\"%d\",&n);\n for(int i=1;i<=n;i++)\n c[i%9]++,z-=n/i;\n for(int i=0;i<9;i++)\n for(int j=0;j<9;j++)\n z+=c[i]*c[j]*c[i*j%9];\n printf(\"%I64d\",z);\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "df793049c74c23bde818506b9a0f6266", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define MD 1000000007\n\nint f[11][10], g[11][10];\n\nint a[10];\nint n;\n\ninline int P(int k) {\n\tint i, j = 1;\n\tfor (i = 0; i < 6; ++i) j = (long long)j * (k - i) % MD;\n\treturn j;\n}\n\nint main() {\n\tint i, j, k, l;\n\tscanf(\"%d\", &n);\n\tfor (i = 0, j = n; i < 10; ++i, j /= 10) a[i] = j % 10;\n\n\tmemset(f, 0, sizeof f), f[10][0] = 1;\n\tmemset(g, 0, sizeof g);\n\tfor (i = 9; i >= 0; --i) {\n\t\t// f -> f =\n\t\t// f -> g <\n\t\t// g -> g (any)\n\t\tk = a[i] == 4 || a[i] == 7;\n\t\tfor (j = k; j <= 9; ++j) f[i][j] = f[i + 1][j - k];\n\n\t\tfor (k = 0; k < a[i]; ++k) {\n\t\t\tl = k == 4 || k == 7;\n\t\t\tfor (j = l; j <= 9; ++j) g[i][j] += f[i + 1][j - l];\n\t\t}\n\n\t\tfor (k = 0; k <= 9; ++k) {\n\t\t\tl = k == 4 || k == 7;\n\t\t\tfor (j = l; j <= 9; ++j) g[i][j] += g[i + 1][j - l];\n\t\t}\n\t}\n\t--g[0][0]; // 0\u4e0d\u5408\u6cd5\n\n\tk = 0;\n\tfor (i = 0, l = 0; i <= 9; l += g[0][i++]) {\n\t\tg[0][i] += f[0][i];\n\t\tk += (long long)g[0][i] * P(l) % MD;\n\t\tif (k >= MD) k -= MD;\n\t}\n\tprintf(\"%d\", k);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "c955ac7565eaaf0980f8c27e9f8aa858", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#define MOD 1000000007\n#include \n\nint num[3];\nlong long dp[200000][3];\nint n, l, r;\n\nint main()\n{\n\tint buf;\n\n\tscanf(\"%d %d %d\", &n, &l, &r);\n\n\tbuf = (r - l + 1) % 3;\n\n\tif (buf == 0)\n\t{\n\t\tnum[0] = num[1] = num[2] = (r - l + 1) / 3;\n\t}\n\telse if (buf == 1)\n\t{\n\t\tbuf = l % 3;\n\t\tnum[0] = num[1] = num[2] = (r - l + 1) / 3;\n\t\tnum[buf]++;\n\t}\n\telse\n\t{\n\t\tbuf = (r + 1) % 3;\n\t\tnum[0] = num[1] = num[2] = (r - l + 1) / 3 + 1;\n\t\tnum[buf]--;\n\t}\n\n\tfor (int j = 0; j < 3; j++)\n\t{\n\t\tdp[0][j] += num[j];\n\t}\n\n\tfor (int i = 1; i < n; i++)\n\t{\n\t\tfor (int j = 0; j < 3; j++)\n\t\t{\n\t\t\tfor (int k = 0; k < 3; k++)\n\t\t\t{\n\t\t\t\tdp[i][j] += (dp[i - 1][k] * num[(j - k + 3) % 3]);\n\t\t\t\tdp[i][j] %= MOD;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\", (int)dp[n - 1][0]);\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "47366f8272592f4d79749a92cbb58d56", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define A\t5000\n#define N_\t(A * 3)\n#define INF\t0x3f3f3f3f3f3f3f3fLL\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\n\nint oo[1 + (N_ - 1) * 2], oj[1 + (N_ - 1) * 2];\n\nint link(int o, int j) {\n\tstatic int _ = 1;\n\n\too[_] = o, oj[_] = j;\n\treturn _++;\n}\n\nint count(int n, int p) {\n\treturn n < p ? 0 : n / p + count(n / p, p);\n}\n\nint ae[N_], pp[N_], dd[N_], sz[N_], ii[A + 1], n;\n\nvoid init() {\n\tstatic char composite[A + 1];\n\tstatic int primes[A + 1];\n\tint n_, a, b, cnt, i, j;\n\n\tfor (a = 2; a <= A / a; a++) {\n\t\tif (composite[a])\n\t\t\tcontinue;\n\t\tfor (b = a * a; b <= A; b += a)\n\t\t\tcomposite[b] = 1;\n\t}\n\tcnt = 0;\n\tfor (a = 2; a <= A; a++)\n\t\tif (!composite[a])\n\t\t\tprimes[cnt++] = a;\n\tn_ = 0;\n\tpp[n_] = -1, dd[n_] = 0;\n\tii[1] = n_++;\n\tfor (a = 2; a <= A; a++) {\n\t\tint h, d, d_;\n\n\t\td = 0;\n\t\tfor (h = 0; h < cnt; h++)\n\t\t\td += count(a, primes[h]);\n\t\td_ = 0;\n\t\tfor (h = cnt - 1; h >= 0; h--) {\n\t\t\td_ += count(a - 1, primes[h]);\n\t\t\tif (a % primes[h] == 0)\n\t\t\t\tbreak;\n\t\t}\n\t\ti = ii[a - 1], j = -1;\n\t\twhile (1)\n\t\t\tif (dd[i] > d_)\n\t\t\t\tj = i, i = pp[i];\n\t\t\telse if (dd[i] == d_) {\n\t\t\t\tpp[n_] = i, dd[n_] = d, n_++;\n\t\t\t\tii[a] = n_ - 1;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tint k = n_++;\n\n\t\t\t\tpp[k] = i, dd[k] = d_;\n\t\t\t\tif (j != -1)\n\t\t\t\t\tpp[j] = k;\n\t\t\t\tpp[n_] = k, dd[n_] = d, n_++;\n\t\t\t\tii[a] = n_ - 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tfor (j = 1; j < n_; j++) {\n\t\ti = pp[j];\n\t\tae[i] = link(ae[i], j), ae[j] = link(ae[j], i);\n\t}\n}\n\nlong long dfs1(int p, int i) {\n\tint o;\n\tlong long x;\n\n\tx = (long long) sz[i] * dd[i];\n\tfor (o = ae[i]; o; o = oo[o]) {\n\t\tint j = oj[o];\n\t\t\n\t\tif (j != p) {\n\t\t\tx += dfs1(i, j);\n\t\t\tsz[i] += sz[j];\n\t\t}\n\t}\n\treturn x;\n}\n\nlong long ans;\n\nvoid dfs2(int p, int i, long long x) {\n\tint o;\n\n\tans = min(ans, x);\n\tfor (o = ae[i]; o; o = oo[o]) {\n\t\tint j = oj[o];\n\n\t\tif (j != p) {\n\t\t\tint w = abs(dd[i] - dd[j]);\n\n\t\t\tdfs2(i, j, x - (long long) sz[j] * w + (long long) (n - sz[j]) * w);\n\t\t}\n\t}\n}\n\nint main() {\n\tint i;\n\n\tinit();\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) {\n\t\tint a;\n\n\t\tscanf(\"%d\", &a);\n\t\tsz[ii[a > 0 ? a : 1]]++;\n\t}\n\tans = INF;\n\tdfs2(-1, 0, dfs1(-1, 0));\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8137e207d810d8f3bfe2b4deef41de5d", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(void){\n int fib[45],stock[45];\n int s,k,i,n,sum=0,num=0;\n scanf(\"%d %d\",&s,&k);\n for(i=0;fib[i-1]<=s;i++){\n if(i<=1) fib[i]=1;\n else if(i=0;i--){\n if(fib[i]<=s){\n stock[num++]=fib[i];\n s-=fib[i];\n if(s==0) break;\n }\n }\n printf(\"%d\\n\",num);\n for(i=num-1;i>=0;i--){\n printf(\"%d\",stock[i]);\n putchar((i>0)?' ':'\\n');\n }\n //printf(\"%d %d\\n\",n,fib[(i-1)%3]);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4632282871280c57f92b0102ed9daec8", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define LL long long\n#define uLL unsigned long long\nlong ms[2000000];\nvoid print(LL *a,long size) {long i;for (i=1;isize) {e=size;}\n\t\t\tfor (j=1;(s=s;b--)\n\t\t\t{\n\t\t\t\tds[e--]=ds[b];\n\t\t\t}\n\t\t\tfor (b=1;b>1;\n}\ninline uLL bsf64(uLL a)\n{\n\t__asm__(\"bsfq %0,%0\":\"+r\"(a));\n\treturn a; \n}\ninline uLL bsr64(uLL a)\n{\n\t__asm__(\"bsrq %0,%0\":\"+r\"(a));\n\treturn a; \n}\ninline LL max(LL a,LL b) {if (b>a) {a=b;}return a;}\ninline LL min(LL a,LL b) {if (a>b) {a=b;}return a;}\nLL ans1[1000000],ans2[1000000];\nlong num[1000],num2[1000];\nint main()\n{\n//\tfreopen(\"in.in\",\"r\",stdin);\n\tlong i,j,k,a,b,c,l,p,q,baka,r,m,n,mid;\n\tscanf(\"%ld %ld\\n\",&n,&m);\n//\tprintf(\"%ld %ld\\n\",n,m);\n\tfor (i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%ld\",&num[i]);\n\t}\t\n\tif (n>10) {q=n>>1;} {q=n;}\n\t*ans1=(LL)1<>1;\n\t\t\tif (ans1[mid]0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}\n\t\tl=1;r=*ans1;a=2*m-1-ans2[i];\n\t\twhile (l<=r)\n\t\t{\n\t\t\tmid=(l+r)>>1;\n\t\t\tif (ans1[mid]0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}\t\t\n\t}\n\tprintf(\"%lld\\n\",baka);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "51316e9817ec9e8521d351432b7c8b91", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include \r\nlong long a[4000001];\r\nlong long n, p, c, k;\r\nint main()\r\n{\r\n scanf(\"%lld%lld\", &n, &p);\r\n a[1] = 1;\r\n a[2] = 2;\r\n for (int i = 3; i <= n; i++)\r\n {\r\n a[i] = (2 * a[i - 1] + 1) % p;\r\n for (int j = 2; j * j <= i; j++)\r\n {\r\n if (i % j)\r\n {\r\n continue;\r\n }\r\n c = j;\r\n a[i] += a[c] - a[c - 1] + p;\r\n if (j * j == i)\r\n {\r\n break;\r\n }\r\n c = i / j;\r\n a[i] += a[c] - a[c - 1] + p;\r\n a[i] %= p;\r\n }\r\n a[i] %= p;\r\n }\r\n printf(\"%lld\\n\", a[n]);\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "027307c434a1dd5bd1b4e98c57f6e75d", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n __int64 n;\n scanf(\"%I64d\",&n);\n __int64 x,y;\n double a;\n if(!n)\n printf(\"0 0\\n\");\n else\n { \n a=0.5*(-1+sqrt(1+8*(n/6)));\n if(a!=(long long)a)\n a=ceil(a);\n else \n a++; \n //a\u8bb0\u5f55\u7b2c\u51e0\u5708\n n=n-0.5*(a*(a-1))*6;\n if(n==0)\n printf(\"%I64d 0\\n\",2*(long long)(a-1));\n else{\n \n x=2*(a-1);y=0; //\u7b2ca\u5708\u7684\u8d77\u70b9 \n i=0; //i\u8bb0\u5f55\u79fb\u52a8\u51e0\u6b21 \n x+=1;y+=2;i++;\n if(i==n)\n {\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n }\n n--;\n if(n<=a-1)\n {\n x=x-(n);\n y+=2*(n);\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n }\n else\n {\n x-=a-1;\n y+=2*(a-1);\n }\n n-=a-1; \n if(n>0&&n<=a)\n {\n x-=2*n;\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n }\n else\n {\n x-=2*a;\n }\n n-=a;\n if(n<=a)\n {\n x=x-n;\n y-=2*n;\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n }\n else\n {\n x-=a;\n y-=2*a;\n }\n n-=a;\n if(n<=a)\n {\n x+=n;\n y-=2*n;\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n }\n else\n {\n x+=a;\n y-=2*a;\n }\n n-=a;\n if(n<=a)\n {\n x+=2*n;\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n }\n else\n {\n x+=2*a;\n }\n n-=a;\n x+=n;\n y+=2*n;\n printf(\"%I64d %I64d\\n\",x,y);\n return 0;\n \n }\n }\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "5d2455791812a96733af36c248d89a69", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n\n#define SET(a,b) memset(a,b,sizeof(a))\n#define scan(n) scanf(\"%d\",&n)\n#define print(n) printf(\"%d\\n\",n)\n#define scanl(n) scanf(\"%lld\",&n)\n#define printl(n) printf(\"%lld\\n\",n)\n\n//stacks\n/*void push(int n,int ar[],int i)\n {\n ar[i]=n;\n i++;\n }\n void pop(int ar[],int i)\n {\n if(i>0)\n {\n ar[i-1]=0;\n i--;\n }\n }*/\n\n//queues\n/*void qpush(int ar[],int val,int head,int tail,int range)\n {\n if(head==tail)\n {\n ar[head]=val;\n if(tail+1==range)\n tail=0;\n else\n tail++;\n }\n else\n {\n ar[tail]=val;\n if(tail+1==range)\n tail=0;\n else\n tail++;\n }\n if(tail==head)\n {\n if(head+1==range)\n head=0;\n else\n head++;\n }\n }\n\n void qpop(int head,int tail,int range)\n {\n if(head+1==range)\n head=0;\n else\n head++;\n }*/\n\n//pow\n/*int fun(int a,int b,int m)\n {\n if(b==0)\n return 1;\n int d,x;\n d=fun(a,b/2,m);\n x=(d*d)%m;\n if(b%2==0)\n return x;\n else\n return (x*a%m)%m;\n }\n */\n//bst\n/*typedef struct tree\n {\n int val;\n struct tree *l;\n struct tree *r;\n }node;\n//node *head;\nnode *insert(int x,node *root)\n{\nif(root==NULL)\n{\nroot=(node *)malloc(sizeof(node));\nroot->val=x;\n}\nelse\n{\nif(x<=root->val)\n{\nif(root->l==NULL)\n{\nroot->l=(node *)malloc(sizeof(node));\nroot->l->val=x;\n}\nelse\nroot->l=insert(x,root->l);\n}\nelse\n{\nif(root->r==NULL)\n{\nroot->r=(node *)malloc(sizeof(node));\nroot->r->val=x;\n}\nelse\n{\nroot->r=insert(x,root->r);\n}\n}\n}\nreturn root;\n}\nnode *find(int x,node *root)\n{\nif(root==NULL)\n{\nreturn 0;\n}\nelse\n{\nif(x==root->val)\nreturn root;\nelse if(xval)\n{\nif(root->l==NULL)\n{\nreturn 0;\n}\nelse\n{\nfind(x,root->l);\n}\n}\nelse\n{\nif(root->r==NULL)\n{\nreturn 0;\n}\nelse\n{\nfind(x,root->r);\n}\n}\n}\n}\n\nvoid inorder(node *root)\n{\n if(root==NULL)\n {\n return;\n }\n if(root->l==NULL)\n {\n printf(\"%d\",root->val);\n if(root->r==NULL)\n return;\n else\n inorder(root->r);\n }\n else\n {\n inorder(root->l);\n printf(\"%d\",root->val);\n if(root->r==NULL)\n return;\n else\n inorder(root->r);\n }\n}\nvoid preorder(node *root)\n{\n if(root==NULL)\n {\n return;\n }\n else\n {\n printf(\"%d\",root->val);\n preorder(root->l);\n preorder(root->r);\n }\n}\n\nvoid postorder(node *root)\n{\n if(root==NULL)\n {\n return;\n }\n else\n {\n postorder(root->l);\n postorder(root->r);\n printf(\"%d\",root->val);\n }\n}\n*/\n//adjacency list\n/*typedef struct ll\n {\n int val;\n struct ll *next;\n }nd;\n\n//n *ar[100001];\nvoid insert(int a,int b)\n{\nif(ar[a]==NULL)\n{\nar[a]=(nd *)malloc(sizeof(nd));\nar[a]->val=b;\nar[a]->next=NULL;\n}\nelse\n{\nnd *temp=(nd *)malloc(sizeof(nd)),*t;\ntemp->val=b;\ntemp->next=ar[a];\nar[a]=temp;\n}\n}\n\n//dfs\n//int state[100001];\nvoid dfs(int a)\n{\nstate[a]=1;\ncount++;\nnd *temp=ar[a];\nwhile(temp!=NULL)\n{\nif(state[temp->val]!=1)\ndfs(temp->val);\ntemp=temp->next;\n}\nreturn;\n}*/\n\n//dijkstra + heaps\n/*typedef struct ll2\n {\n int val;\n int weight;\n struct ll2 *next;\n }nde;\n */\n//nde *ar[500005];\n//int state[500005];\n\n/*void insert(int a,int b,int w)//insert to adjacency list\n {\n if(ar[a]==NULL)\n {\n ar[a]=(node *)malloc(sizeof(node));\n ar[a]->val=b;\n ar[a]->weight=w;\n ar[a]->next=NULL;\n }\n else\n {\n node *temp=(node *)malloc(sizeof(node)),*t;\n temp->val=b;\n temp->weight=w;\n temp->next=ar[a];\n ar[a]=temp;\n }\n }*/\n\n//int pt[500005],d[500005];\n//int heap[500005][2];\n//int ptr;\n/*void decpty(int val,int pos)//decrease priority\n {\n heap[pos][0]=val;\n int x=pos;\n while(x>0)\n {\n if(heap[x][0]>=heap[x/2][0])\n break;\n else\n {\n pt[heap[x][1]]=x/2;\n pt[heap[x/2][1]]=x;\n int temp=heap[x][0],t2=heap[x][1];\n heap[x][0]=heap[x/2][0];\n heap[x][1]=heap[x/2][1];\n heap[x/2][0]=temp;\n heap[x/2][1]=t2;\n x=x/2;\n }\n }\n }\n\n void hinsert(int val,int val2)//insert to heap\n {\n heap[ptr][0]=val;\n heap[ptr][1]=val2;\n pt[val2]=ptr;\n int x=ptr;\n ptr++;\n while(x>0)\n {\n if(heap[x][0]>=heap[x/2][0])\n break;\n else\n {\n pt[heap[x][1]]=x/2;\n pt[heap[x/2][1]]=x;\n int temp=heap[x][0],t2=heap[x][1];\n heap[x][0]=heap[x/2][0];\n heap[x][1]=heap[x/2][1];\n heap[x/2][0]=temp;\n heap[x/2][1]=t2;\n x=x/2;\n }\n }\n }\n\n int hdeletemin()//delete min elem from heap\n {\n int ret;\n ret=heap[1][1];\n pt[heap[1][1]]=-1;\n pt[heap[ptr-1][1]]=1;\n heap[1][0]=heap[ptr-1][0];\n heap[1][1]=heap[ptr-1][1];\n ptr--;\n int x=1;\n while(x=ptr)\n {\n if(2*xval;\n if(d[v]+temp->weight < d[w])\n {\n d[w]=d[v]+temp->weight;\n decpty(d[w],pt[w]);\n }\n temp=temp->next;\n }\n }\n}*/\n\n/*int main()\n {\n int n,m,u,v,w,i;\n scanf(\"%d%d\",&n,&m);\n for(i=0;i<=n;i++)\n state[i]=0;\n while(m--)\n {\n scanf(\"%d%d%d\",&u,&v,&w);\n insert(u,v,w);\n }\n scanf(\"%d%d\",&u,&v);\n ptr=1;\n hinsert(0,u);\n d[u]=0;\n for(i=1;i<=n;i++)\n {\n if(i!=u)\n {\n hinsert(1000000000,i);\n d[i]=1000000000;\n }\n }\n dikstra(u,v);\n if(d[v]==1000000000)\n printf(\"NO\\n\");\n else\n printf(\"%d\\n\",d[v]);\n return 0;\n }*/\n\n//kruskal + dsu\n\n//int dsu[N];\n/*int find(int x)\n {\n if(dsu[x]==x)return x;\n return dsu[x] = find(dsu[x]);\n }\n\n void Union(int a,int b)\n {\n if(a==b)\n return;\n dsu[a] = b;\n }\n\n typedef struct edge\n {\n int u,v;\n int weight;\n }edge;\n */\n//edge e[N];\n/*int cmp(const void *a,const void *b)\n {\n return ((edge*)a)->weight - ((edge*)b)->weight;\n }*/\n/*int main()\n {\n int i;\n int n,m;\n scanf(\"%d %d\\n\",&n,&m);\n for(i=0;ib)\n return a;\n else\n return b;\n }\n */\n//qsort\n\n/*int cmpfunc(const void *a,const void *b)\n {\n return (*(int *)a - *(int *)b);\n }*/\n//qsort(ar,n,sizeof(int),cmpfunc);\n\n\n//-------------------------------------------------------------------------------------------------------------------------------------\n\nint main()\n{\n int n,m,ct,ans=0;\n scan(n);\n scan(m);\n int i,j,k,val=0;\n int dig1,dig2;\n val=(n-1)/7;\n dig1=1;\n dig2=1;\n while(val>0)\n {\n dig1++;\n val=val/7;\n }\n \n val=(m-1)/7;\n while(val>0)\n {\n dig2++;\n val=val/7;\n }\n val=dig1+dig2;\n if(val>7)\n {\n ans=0;\n print(ans);\n return 0;\n }\n int status[10],st2[10],cond=0;\n for(i=0;i\nlong max(long x , long y){ return x>y?x:y; }\nint main()\n{\n long i,j,n,m,a,b,ans[4],min,f=0;\n long cint,dint;\n float c,d;\n scanf(\"%ld%ld%ld%ld%ld%ld\",&n,&m,&i,&j,&a,&b);\n if(a>=n || b>=m)\n {\n printf(\"Poor Inna and pony!\");\n return 0;\n }\n c=(i-1)*1.0/a;\n d=(j-1)*1.0/b;\n\n if(c==(long int)c && d==(long int)d)\n {\n cint=(long int)c;\n dint=(long int)d;\n if(abs(cint-dint)%2==0)\n ans[f++]=max(cint,dint);\n }\n \n c=(n-i)*1.0/a;\n d=(j-1)*1.0/b;\n\n if(c==(long int)c && d==(long int)d)\n {\n cint=(long int)c;\n dint=(long int)d;\n if((abs(cint-dint))%2==0)\n ans[f++]=max(cint,dint);\n }\n \n c=(i-1)*1.0/a;\n d=(m-j)*1.0/b;\n\n if(c==(long int)c && d==(long int)d)\n {\n cint=(long int)c;\n dint=(long int)d;\n if(abs(cint-dint)%2==0)\n ans[f++]=max(cint,dint);\n }\n \n c=(n-i)*1.0/a;\n d=(m-j)*1.0/b;\n\n if(c==(long int)c && d==(long int)d)\n {\n cint=(long int)c;\n dint=(long int)d;\n if(abs(cint-dint)%2==0)\n ans[f++]=max(cint,dint);\n }\n \n if(f==0)\n {\n printf(\"Poor Inna and pony!\");\n return 0;\n }\n min=1000000;\n for(i=0;ians[i])\n min=ans[i];\n \n printf(\"%ld\",min);\n getch();\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "43e7817b0d1cdf9dcc7c8b6491014bbe", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n\nint mod_inv(int a, int p){\n\tint y = p-2;\n\tint res = 1;\n\twhile(y!=0){\n\t\tif(y&1){\n\t\t\tres = ((long long)res * a)%p;\n\t\t}\n\t\ta = ((long long)a*a)%p;\n\t\ty = y>>1;\n\t}\n\treturn res;\n}\n\nint main(void) {\n\t// your code goes here\n\tint n,c,i;\n\tscanf(\"%d %d\",&n,&c);\n\tint res = c;\n\tint prev = c;\n\tint p = 1000003;\n\tfor(i=2; i<=n ;i++){\n\t\tprev = ((((long long)(c+i-1)*prev)%p)*mod_inv(i,p))%p;\n\t\tres = (res + prev)%p;\n\t}\n\tprintf(\"%d\\n\",res);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "2bee17fa7fc58fff2f99e7f5dd68a268", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint isSolved(int r[])\n{\n int i;\n /*\n for(i=1;i<=24;i++)\n printf(\"%d \", r[i]);\n printf(\"\\n\\n\");\n*/\n for(i=1;i<=24;i=i+4)\n if(!(r[i+1] == r[i] && r[i+2] == r[i] && r[i+3] == r[i]))\n return 0;\n\n return 1;\n}\n\nvoid rotate1(int r[])\n{\n int aux1, aux2;\n aux1 = r[24];\n aux2 = r[22];\n r[24] = r[1];\n r[22] = r[3];\n r[1] = r[5];\n r[3] = r[7];\n r[5] = r[9];\n r[7] = r[11];\n r[9] = aux1;\n r[11] = aux2;\n\n}\n\n\n\nvoid rotate2(int r[])\n{\n int aux1, aux2;\n aux1 = r[23];\n aux2 = r[21];\n r[23] = r[2];\n r[21] = r[4];\n r[2] = r[6];\n r[4] = r[8];\n r[6] = r[9];\n r[8] = r[12];\n r[10] = aux1;\n r[12] = aux2;\n}\n\nvoid rotate3(int r[])\n{\n int aux1, aux2;\n aux1 = r[13];\n aux2 = r[14];\n r[13] = r[5];\n r[14] = r[6];\n r[5] = r[17];\n r[6] = r[18];\n r[17] = r[21];\n r[18] = r[22];\n r[21] = aux1;\n r[22] = aux2;\n}\n\nvoid rotate4(int r[])\n{\n int aux1, aux2;\n aux1 = r[15];\n aux2 = r[16];\n r[15] = r[7];\n r[16] = r[8];\n r[7] = r[19];\n r[8] = r[20];\n r[19] = r[23];\n r[20] = r[24];\n r[23] = aux1;\n r[24] = aux2;\n}\n\nint main()\n{\n int i, r[25];\n\n for(i=1;i<=24;i++)\n scanf(\"%d\", &r[i]);\n\n for(i=1;i<=4; i++)\n {\n rotate1(r);\n if((i == 1 || i == 3) && isSolved(r))\n {\n printf(\"yes\");\n return 0;\n }\n }\n\n for(i=1;i<=4; i++)\n {\n rotate2(r);\n if((i == 1 || i == 3) && isSolved(r))\n {\n printf(\"yes\");\n return 0;\n }\n }\n\n for(i=1;i<=4; i++)\n {\n rotate3(r);\n if((i == 1 || i == 3) && isSolved(r))\n {\n printf(\"yes\");\n return 0;\n }\n }\n\n for(i=1;i<=4; i++)\n {\n rotate4(r);\n if((i == 1 || i == 3) && isSolved(r))\n {\n printf(\"yes\");\n return 0;\n }\n }\n\n printf(\"no\");\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "54f0578b842ee26033e57dc3d30da10b", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{int a,i=5;\n int s[6];\n for(int j=0;j<6;++j)\n s[j]=0;\n scanf(\"%d\",&a);\n while(a)\n {s[i]=a%2;\n a=a/2;\n --i;\n }\n int b[6];\n b[0]=s[0];\n b[1]=s[5];\n b[2]=s[3];\n b[3]=s[2];\n b[4]=s[4];\n b[5]=s[1];\n cout<<32*b[0]+16*b[1]+8*b[2]+4*b[3]+2*b[4]+b[5];\n return 0; \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "2f353a4948ca1617efb3ec9052a4f867", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n int x[2],i,sum=0,b=0,c,t,l[2],z[2][4],o;\n scanf(\"%d%d\",&x[0],&x[1]);\n for(o=0;o<2;o++)\n for(l[o]=0;x[o]>0;l[o]++)\n {\n z[o][l[o]]=x[o]%10;\n if(z[o][l[o]]>b)\n b=z[o][l[o]];\n x[o]/=10;\n }\n b+=1;\n for(o=0;o<2;o++)\n {\n t=1;\n for(i=0;i=b;i++)\n b*=c;\n printf(\"%d\",i);\n return 0 ;\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "41455ddff86895046395f42a7a105bbc", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#include\n\n#define MOD 998244353\nint fact[1000006], wpar[1000006<<1], n, level;\n\nint mul(int a, int b){\n return (a*1ll*b)%MOD;\n}\n\nint powmod(int b, int p){\n int t = 1;\n while(p){\n if(p&1)t = mul(t, b);\n b = mul(b, b);\n p>>=1;\n }\n return t;\n}\n\nint ncr(int _n, int r){\n return mul(mul(fact[_n], powmod(fact[r], MOD - 2)), powmod(fact[_n - r], MOD - 2));\n}\n\nint main(){\n int i;\n scanf(\"%d\", &n);\n \n fact[0] = 1;\n for(i = 1;i < 1000006;i++)fact[i] = mul(fact[i - 1], i);\n \n if(n == 1 || n == 2){printf(\"1\\n\");return 0;}\n if(n == 3){printf(\"0\\n\");return 0;}\n \n for(level = 0; (1< half){printf(\"0\\n\");return 0;}\n printf(\"%d\\n\", ncr(half, rem));\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "f07dd66e9dac715af201f7e39cd8314f", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "GNU C", "source_code": "#include \n\n/* http://codeforces.com/contest/894/submission/34556698 (Dukkha) */\n\n#define MD\t1000000007\n\nint power(int a, int b) {\n\tint p;\n\n\tif (b == 0)\n\t\treturn 1;\n\tp = power(a, b / 2);\n\tp = (long long) p * p % MD;\n\tif (b % 2 == 1)\n\t\tp = (long long) p * a % MD;\n\treturn p;\n}\n\nint main() {\n\tint n, m, k;\n\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tprintf(\"%d\\n\", k == -1 && n % 2 != m % 2 ? 0 : power(2, (long long) (n - 1) % (MD - 1) * (m - 1) % (MD - 1));\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "76b209707567b85162684a4091a35cab", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\n int n2, n3;\n\n int res = 0;\n\n scanf(\"%u%u\", &n2, &n3);\n\n while (n2 >= 2 && n3 >= 1) {\n --n2; --n2; --n3;\n res += 4;\n if (n2 > 0 && n3 > 0) {\n n2 >> 1 >= n3 ? --n2 : --n3;\n res += 2;\n }\n }\n res += (n3 ? 3 * n3 : 2 * n2);\n\n printf(\"%d\", res);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6e664e6462fe2219b27069cd12060bf9", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "float a,i,s,u,v;main(n){for(scanf(\"%d\",&n);iu?u=v:0;printf(\"%f\",u);}", "lang_cluster": "C", "compilation_error": false, "code_uid": "abeee9649c84cb6c2de51c2f6869f4ed", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n\n\nint main()\n{\n long long unsigned int n,i,j,result=0;\n int m;\n int ss;\n scanf(\"%I64d\",&n);\n scanf(\"%d\",&m);\n if(m==1)\n {\n printf(\"%I64d\",n*n);\n return 0;\n }\n for(i=1;i<=n;i++)\n for(j=1;j<=i;j++)\n {\n if( (i*i+j*j)%m==0 && i!=j) result+=2;\n if( (i*i+j*j)%m==0 && i==j) result+=1;\n }\n printf(\"%I64d\",result);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3c26ba7daefdfa4106c9659c39da4cef", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\n#include\ntypedef long long unsigned llu;\ntypedef unsigned u;\ntypedef struct S\n{\n\tu val,ki,ka;llu sum;\n\tstruct S *lc,*rc;\n}v;\nv*alloc(u ki,u ka,u val)\n{\n\tv*x;\n\tx=(v*)malloc(sizeof(v));\n\tx->val=val;\n\tx->ki=ki;\n\tx->ka=ka;\n\tx->sum=(ka-ki+1)*(llu)val;\n\tx->lc=x->rc=NULL;\n\treturn x;\n}\nllu que(v *x,u lo,u hi)\n{\n\tprintf(\"que %u %u\\n\",lo,hi);\n\tif(hiki||lo>x->ka)\n\t{\n\t\tprintf(\"return 0\\n\");\n\t\treturn 0;\n\t}\n\tif(lo<=x->ki&&hi>=x->ka)\n\t{\n\t\tprintf(\"Return %I64u\\n\",x->sum);\n\t\treturn x->sum;\n\t}\n\tu ll,rr;\n\tif(x->val)\n\t{\n\t\tll=loki?x->ki:lo;\n\t\trr=hi>x->ka?x->ka:hi;\n\t\tif(rrval=%u\\n\",ll,rr,x->val);\n\t\treturn(rr-ll+1)*(llu)x->val;\n\t}\n\tllu a=que(x->lc,lo,hi)+que(x->rc,lo,hi);\n\tprintf(\"Retu5n %I64u\\n\",a);\n\treturn a;\n}\nvoid set(v *x,u lo,u hi,u val)\n{\n\tif(hiki||lo>x->ka)return;\n\tu m;\n\tif(x->val)\n\t{\n\t\tif(val<=x->val)return;\n\t\tif(lo<=x->ki&&hi>=x->ka)\n\t\t{\n\t\t\tx->val=val;\n\t\t\tx->sum=val*(llu)(x->ka-x->ki+1);\n\t\t\treturn;\n\t\t}\n\t\tm=(x->ki+x->ka)>>1;\n\t\tif(!x->lc)x->lc=alloc(x->ki,m,val);\n\t\tif(!x->rc)x->rc=alloc(m+1,x->ka,val);\n\t\tx->val=0;\n\t}\n\tset(x->lc,lo,hi,val);\n\tset(x->rc,lo,hi,val);\n\tif(x->lc->val&&x->lc->val==x->rc->val)\n\t{\n\t\tx->val=x->lc->val;\n\t\tx->sum=x->val*(llu)(x->ka-x->ki+1);\n\t}\n\telse x->sum=x->lc->sum+x->rc->sum;\n\treturn;\n}\nv *p;\nu A[222222],F[222222];\nint main()\n{\n\tu n,i,j,k,x;llu r=0llu;\n\tscanf(\"%u\",&n);\n\tp=alloc(1,n,1);\n\tfor(i=0;++i<=n;A[i]=x)\n\t{\n\t\tscanf(\"%u\",&x);\n\t\tfor(j=1;j*j<=x;++j)if(x%j==0)\n\t\t{\n\t\t\tif(!F[j])F[j]=i;\n\t\t\tif(!F[k=x/j])F[k]=i;\n\t\t}\n\t}\n\tfor(i=n;i;--i)\n\t{\n\t\tfor(x=A[i],j=1;j*j<=x;++j)if(x%j==0)\n\t\t{\n\t\t\tif(F[j]&&F[j]\nint main()\n{\n long long n,m,sum,sum1,sum11,sum2,sum21,s,n1,n12,n2,n3,m1,m12,m2,m3;\n int b,a,j,k,l;\n while(scanf(\"%I64d%I64d\",&n,&m)!=EOF)\n {\n n3=n;\n m3=m;\n b=0;\n a=1;\n sum=0;\n sum1=0;\n sum2=0;\n j=k=0;\n n2=n%10;\n while(n>0)\n {\n j++;\n n1=n%10;\n n=n/10; \n }\n n12=n1;\n if(n10)\n {\n k++;\n m1=m%10;\n m=m/10; \n }\n m12=m1;\n if(m1>m2)\n {\n m1--;\n b=1;\n }\n if(j==k)\n {\n if(j>=3)\n {\n s=10;\n for(l=0;lm1)\n sum=0;\n else\n sum=m1-n1+1;\n } \n }\n else\n {\n if((j==1)&&(k==2))\n {\n sum=10-n1+m1;\n }\n else \n {\n if((j==2)||(j==1&&k>=3))\n {\n sum1=10-n1;\n }\n else\n {\n s=10;\n for(l=0;l\n#define oo 1000000000\n#define gmin(a,b) ((a)>(b)?(b):(a))\nlong getans=0,w[10000]={0},h[10000]={0},n,min,total=0,hash[40000000]={0},z[2000000]={0},an[200000]={0};\nvoid work(long k,long tot)\n{\n long i,o,j;\n if(k<=n)\n {\n if(k>min)\n return ;\n for(i=1;i<=tot;i++)\n {\n w[i]-=k;\n o=min;\n h[k]=i;\n if(w[i] && w[i]=0;i++)\n {\n an[k]=z[i];\n dfs(i+1,k+1,tot,count-z[i]);\n if(getans)\n return ;\n }\n }\n else\n {\n if(hash[count]==0)\n {\n for(i=1;i\n#include \n#include \n\n#define MAX 102\n#define LIM 303\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nbool visited[MAX][303][LIM][2];\nint n, t, counter[1010], ar[MAX], dp[MAX][303][LIM][2];\n\nint F(int i, int l, int r, int flag){\n if (i > n){\n if (r == t || r == LIM){\n if (!flag) return (counter[l] * (t - r));\n else return 0;\n }\n else return F(0, l, r + 1, flag);\n }\n if (visited[i][l][r][flag]) return dp[i][l][r][flag];\n\n int x, res = F(i + 1, l, r, flag);\n if (ar[i] >= l){\n x = 1 + F(i + 1, ar[i], r, flag);\n if (x > res) res = x;\n }\n if (!flag && t > LIM){\n x = F(i, l, r, 1) + (counter[l] * (t - LIM));\n if (x > res) res = x;\n }\n\n visited[i][l][r][flag] = true;\n return (dp[i][l][r][flag] = res);\n}\n\nint main(){\n int i, j, k;\n\n while (scanf(\"%d %d\", &n, &t) != EOF){\n if (!n) break;\n\n clr(counter);\n for (i = 1; i <= n; i++){\n scanf(\"%d\", &ar[i]);\n counter[ar[i]]++;\n }\n\n clr(visited);\n int res = F(1, 0, 1, 0);\n printf(\"%d\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "676fd89cf947c01cdd61dd30e694ed53", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include\n#include\nlong long int fact(long int x){\n if(x==1)\n return 1;\n long long int ans,d;\n ans= x*fact(x-1);\n d= pow(10,9)+7;\n return ans%d;\n}\nlong long int power(long int x){\n long int i;\n long long int ans=1,d;\n d= pow(10,9)+7;\n for(i=0;i\n#include \n#include \n\n#define M\t4167669\t/* (23 choose 7) * 17 */\n#define C\t16\n#define K\t2000000000\n#define T\t7\n\nvoid print(int k) {\n\tif (k == 0)\n\t\treturn;\n\tprint(k / C);\n\tprintf(\"%c\", k % C < 10 ? k % C + '0' : k % C - 10 + 'a');\n}\n\nint add(int a, int b) { return (long long) a + b < K ? a + b : K; }\n\nint choose[C + T][C + T];\n\nvoid init() {\n\tint n, r;\n\n\tchoose[0][0] = 1;\n\tfor (n = 1; n < C + T; n++) {\n\t\tchoose[n][0] = 1;\n\t\tfor (r = 1; r <= n; r++)\n\t\t\tchoose[n][r] = choose[n - 1][r - 1] + choose[n - 1][r];\n\t}\n}\n\nint dp[M], m;\n\nvoid branch(int *aa, int h) {\n\tint a, len, j;\n\n\tif (h == C) {\n\t\tfor (len = 0; len <= C; len++) {\n\t\t\tif (len == 0)\n\t\t\t\tdp[m] = 1;\n\t\t\telse\n\t\t\t\tfor (h = 0; h < C; h++) {\n\t\t\t\t\tif (aa[h] == 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (h == 0 || aa[h - 1] != aa[h]) {\n\t\t\t\t\t\ta = aa[h] - 1;\n\t\t\t\t\t\tj = m / (C + 1) - choose[C - h - 1 + T - a][T - a];\n\t\t\t\t\t\tif (h < C - 1)\n\t\t\t\t\t\t\tj += choose[C - h - 2 + T - a][T - a];\n\t\t\t\t\t\tj = j * (C + 1) + len - 1;\n\t\t\t\t\t}\n\t\t\t\t\tdp[m] = add(dp[m], dp[j]);\n\t\t\t\t}\n\t\t\tm++;\n\t\t}\n\t\treturn;\n\t}\n\tfor (a = h == 0 ? 0 : aa[h - 1]; a <= T; a++) {\n\t\taa[h] = a;\n\t\tbranch(aa, h + 1);\n\t}\n}\n\nint idx(int *aa, int len) {\n\tint h, a, sum;\n\n\tsum = 0;\n\tfor (h = 0; h < C; h++)\n\t\tfor (a = h == 0 ? 0 : aa[h - 1]; a < aa[h]; a++)\n\t\t\tsum += choose[C - h - 1 + T - a][T - a];\n\treturn sum * (C + 1) + len;\n}\n\nint compare(const void *a, const void *b) {\n\tint ia = *(int *) a;\n\tint ib = *(int *) b;\n\n\treturn ia - ib;\n}\n\nint main() {\n\tstatic int aa[C], bb[C];\n\tint k, t, h, i, len, first;\n\n\tscanf(\"%d%d\", &k, &t);\n\tif (t >= 8) {\n\t\tprint(k);\n\t\tprintf(\"\\n\");\n\t\treturn 0;\n\t}\n\tinit();\n\tbranch(aa, 0);\n\tfor (h = 0; h < C; h++)\n\t\taa[h] = t;\n\tfor (len = 1; ; len++) {\n\t\tint cnt = dp[idx(aa, len)];\n\n\t\taa[0]--; cnt -= dp[idx(aa, len - 1)]; aa[0]++;\n\t\tif (k <= cnt)\n\t\t\tbreak;\n\t\tk -= cnt;\n\t}\n\tfirst = 1;\n\twhile (len-- > 0) {\n\t\tfor (h = first ? 1 : 0; h < C; h++) {\n\t\t\tmemcpy(bb, aa, C * sizeof *aa);\n\t\t\tif (bb[h] == 0)\n\t\t\t\tcontinue;\n\t\t\tbb[h]--;\n\t\t\tqsort(bb, C, sizeof *bb, compare);\n\t\t\tif (k > dp[i = idx(bb, len)]) {\n\t\t\t\tk -= dp[i];\n\t\t\t\tbb[h]++;\n\t\t\t} else {\n\t\t\t\tprintf(\"%c\", h < 10 ? h + '0' : h - 10 + 'a');\n\t\t\t\taa[h]--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfirst = 0;\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "513f9b9073fd6a099b3d5a8f6e591680", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0} {"lang": "GNU C", "source_code": "#include\nlong long int fib[55];\nvoid fibo(int n)\n{\n\tif(n==53)\n\t\treturn;\n\tfib[n]=fib[n-1]+fib[n-2];\n\tfibo(n+1);\n}\nvoid func(int k,int r,int n)\n{\n\tif(n==0)\n\t\treturn;\n\tif(k<=fib[n])\n\t{\n\t\tprintf(\"%d \",1+r);\n\t\tfunc(k,r+1,n-1);\n\t}\n\telse\n\t{\n\t\tprintf(\"%d %d \",2+r,1+r);\n\t\tfunc(k-fib[n],r+2,n-2);\n\t}\n}\nint main()\n{\n\tint n,k;\n\tscanf(\"%d %d\",&n,&k);\n\tfib[1]=1;\n\tfib[2]=1;\n\tfibo(3);\n\tfunc(k,0,n);\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7442fb9ee5fe6c81218b61c36219d8ee", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d 2\\n1 2\",2*n+1);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d09f9b7f55e1ec896e37ee7c40c7e986", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int k,i,a,j;\n int t[k];\n int max ;\n printf(\"donner un k : \");\n scanf(\"%d\",&k);\n for ( i = 0; i < k; i++) {\n printf(\"donner r %d : \",i);\n scanf(\"%d\",&t[i]);\n }\n max= t[0];\n for ( j = 1; j < k; j++) {\n if (max\n#include\n\nchar a[50][5], b[50][5];\nchar dict[50000][10];\nint ans=0;\n\nint dfs(char str[], int q, int n)\n{\n\tint i,j,k;\n\n\t//printf(\"%s\\n\", str);\n\n\tif(strlen(str)==n)\n\t{\n\t\tint flag=0;\n\t\tfor(i=0;i\n#include \n\n#define N\t100000\n\nint md;\n\nlong long power(long long a, int k) {\n\tlong long p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * a % md;\n\t\ta = a * a % md;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint vv[N + 1], ff[N + 1], gg[N + 1];\n\nvoid init() {\n\tint i;\n\n\tff[0] = gg[0] = 1;\n\tfor (i = 1; i <= N; i++) {\n\t\tvv[i] = i == 1 ? 1 : (long long) vv[i - md % i] * (md / i + 1) % md;\n\t\tff[i] = (long long) ff[i - 1] * i % md;\n\t\tgg[i] = (long long) gg[i - 1] * vv[i] % md;\n\t}\n}\n\nint choose(int n, int k) {\n\treturn k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % md * gg[n - k] % md;\n}\n\nint aa[N], cnt;\n\nvoid brute(int i, int n) {\n\tif (i == n) {\n\t\tint b, c, d, i, j;\n\n\t\tfor (b = 0; b < 1 << n; b++) {\n\t\t\tc = (1 << n) - 1;\n\t\t\tfor (i = 0; i < n; i++)\n\t\t\t\tif ((b & 1 << i) != 0) {\n\t\t\t\t\tif ((c & 1 << aa[i]) == 0)\n\t\t\t\t\t\tgoto out;\n\t\t\t\t\tc &= ~(1 << aa[i]);\n\t\t\t\t}\n\t\t\tfor (i = 0; i < n; i++)\n\t\t\t\tif ((c & 1 << i) != 0 && (c & 1 << aa[i]) != 0)\n\t\t\t\t\tgoto out;\n\t\t\tc = 0;\n\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\tif ((c & 1 << i) != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tj = i, d = 0;\n\t\t\t\twhile (((c | d) & 1 << j) == 0)\n\t\t\t\t\td |= 1 << j, j = aa[j];\n\t\t\t\tif ((c & 1 << j) != 0) {\n\t\t\t\t\tc |= d;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tc |= d, d = 0;\n\t\t\t\twhile ((d & 1 << j) == 0)\n\t\t\t\t\td |= 1 << j, j = aa[j];\n\t\t\t\tif ((b & d) == d)\n\t\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tcnt++;\nout:;\n\t\t}\n\t\treturn;\n\t}\n\tfor (aa[i] = 0; aa[i] < n; aa[i]++)\n\t\tif (aa[i] != i)\n\t\t\tbrute(i + 1, n);\n}\n\nint slow(int n) {\n\tint k, l, ans;\n\n\tans = 0;\n\tfor (k = 1; k <= n; k++)\n\t\tfor (l = k; l + k <= n; l++)\n\t\t\tans = (ans + (long long) choose(n, l + k)\n\t\t\t\t\t* ff[l + k] % md\n\t\t\t\t\t* gg[k] % md\n\t\t\t\t\t* choose(l - 1, k - 1) % md\n\t\t\t\t\t* power(n - 1, k) % md\n\t\t\t\t\t* power(l, n - l - k)) % md;\n\treturn ans;\n}\n\nint main() {\n\tint n, n1;\n\n\tscanf(\"%d%d\", &n1, &md), init();\n\tfor (n = n1; n <= n1; n++) {\n#if 0\n\t\tcnt = 0, brute(0, n);\n\t\tprintf(\"%d\\n\", cnt);\n#else\n\t\tprintf(\"%d\\n\", slow(n));\n#endif\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1be2e220263cc2e1035c31bc7517164d", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0} {"lang": "GNU C", "source_code": "/*\nID: Sfiction\nOJ: CF128 Div2\nPROB: D\n*/\n#include \nint main()\n{\n double a,b,m,vx,vy,vz;\n double x,z,t;\n scanf(\"%lf%lf%lf\",&a,&b,&m);\n scanf(\"%lf%lf%lf\",&vx,&vy,&vz);\n t=-m/vy;\n x=a/2+t*vx;\n z=t*vz;\n while (x<0||x>a)\n if (x>a) x=2*a-x;\n else x=-x;\n while (z<0||z>b)\n if (z>b) z=2*b-z;\n else z=-z;\n printf(\"%.10lf %.10lf\",x,z);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8628726ab1181b1309291c4956547c27", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define ll long long\n\nll solve(ll a, ll b) {\n ll i,k = 0;\n int* factors = malloc(sizeof(int)*1000*1000);\n //record the smaller factors of a\n for (i = 1; i*i <= a; i++) {\n if (a%i == 0) {\n factors[k++] = i;\n // printf(\"factor of a:%lli\\n\", i);\n }\n }\n //for each smaller factor of a+b\n ll answer = 2*(a+b+1);\n for (i = 1; i*i <= a+b; i++) {\n if ((a+b)%i == 0) {\n // printf(\"factor of a+b:%lli\\n\", i);\n //binary search a factor of a that is smaller than or equal to i\n int found = 0;\n ll hi = k;\n ll lo = 1;\n ll middle = 0;\n while (!found) {\n middle = (lo + hi)/2;\n if (middle == lo || middle == hi) {\n break;\n } else if (factors[middle] < i) {\n lo = middle;\n } else if (factors[middle] > i) {\n hi = middle;\n } else { // middle = i\n found = 1;\n break;\n }\n }\n // printf(\"i found %lli for a, %lli for a+b\\n\", factors[middle],i);\n // printf(\"a/fact=%lli <= a+b/i=%lli?\\n\",a/factors[middle],(a+b)/i);\n if (a/factors[middle] <= (a+b)/i) {\n if (answer > 2*(i + (a+b)/i)) {\n answer = 2*(i + (a+b)/i);\n // printf(\"NEW answer: %lli\\n\", answer);\n }\n }\n }\n }\n return answer;\n}\n\nint main(int argc, char* argv[]) {\n ll a,b = 0;\n scanf(\"%lli %lli\",&a,&b);\n // printf(\"%lli + %lli = %lli\\n\", a, b, a+b);\n ll answer_a = solve(a,b);\n ll answer_b = solve(b,a);\n if (answer_a < answer_b) {\n printf(\"%lli\\n\", answer_a);\n } else {\n printf(\"%lli\\n\", answer_b);\n\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a02932887b138ec61426f7e057549831", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int a,b,c,d,e;\n int i = 0;\n\n scanf(\"%d %d %d %d %d\", &a, &b, &c, &d, &e);\n\n while((a-1) > 0 && (b-1) > 0 && (c-2) > 0 && (d-7) > 0 && (e-4) > 0)\n {\n a -= 1;\n b -= 1;\n c -= 2;\n d -= 7;\n e -= 4;\n i++;\n }\n printf(\"%d\", i);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ba23ce8d1c429d09f7fff15971685db4", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint winning(int n, int k);\nint expmod(int a, int b, int m);\nconst int mod = 1000000007;\n\nint main () {\n int t;\n int n;\n int k;\n scanf(\"%d\", &t);\n for (int i = 0; i < t; i++) {\n scanf(\"%d %d\", &n, &k);\n printf(\"%d\\n\", winning(n, k));\n }\n}\n\nint winning (int n, int k) {\n if (k == 0) {\n return 1;\n }\n if (n % 2 == 0) {\n long long int result = expmod(2, n*(k-1), mod) + (expmod(2, n-1, mod)-1)*winning(n, k-1);\n return result % mod;\n }\n else {\n long long int result = (expmod(2, n-1, mod)+1)*winning(n, k-1);\n return result % mod;\n }\n}\n\nint expmod(int a, int b, int m)\n{\n\tint res = 1;\n\ta = a % m; \n\n\tif (a == 0) return 0;\n\n\twhile (b > 0)\n\t{\n\t\tif (b & 1)\n\t\t\tres = (res*a) % m;\n\n\t\tb = b>>1;\n\t\ta = (a*a) % m;\n\t}\n\treturn res;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "313ae65c4e6ad97357aa1aa1da70e551", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \nint f(int k)\n{\n return ((min(k,25)+k)mod(2+k%3) > 0)? 1: 0;\n}\nint main()\n{\n for (int _ = 21; _ <= 50; ++ _)\n printf(\"%d\\n\", f(_));\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "345030da0c7b108e7beade24e3f70e8a", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#define mod 1000000007\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n__attribute__((always_inline, optimize(3)))\n__inline__ void add(int *x, int y) {\n\t(*x += y) >= mod && (*x -= mod);\n}\n__attribute__((always_inline, optimize(3)))\n__inline__ int mul(int x, int y) {\n\treturn (long long)x * y - (long long)x * y / mod * mod;\n}\n__attribute__((always_inline, optimize(3)))\n__inline__ int f(int n, int x, int y) {\n\tint tmp = 1 << x;\n\ty && (tmp *= 3);\n\treturn n / tmp;\n}\n#ifdef __cplusplus\n}\n#endif\nint main() {\n\tint n, p = 0; scanf(\"%d\", &n);\n\tstatic int dp[1000005][21][2] = { };\n\twhile ((1 << p) <= n) ++ p; dp[1][-- p][0] = 1;\n\tif ((3 << p - 1) <= n) dp[1][p - 1][1] = 1;\n\tfor (int i = 1; i < n; ++ i)\n\t\tfor (int x = 0; x <= p; ++ x)\n\t\t\tfor (int y = 0; y < 2; ++ y) {\n\t\t\t\tadd(dp[i + 1][x] + y, mul(dp[i][x][y], f(n, x, y) - i));\n\t\t\t\tx && (add(dp[i + 1][x - 1] + y, mul(dp[i][x][y], f(n, x - 1, y) - f(n, x, y))), 0);\n\t\t\t\ty && (add(dp[i + 1][x] + y - 1, mul(dp[i][x][y], f(n, x, y - 1) - f(n, x, y))), 0);\n\t\t\t}\n\tprintf(\"%d\\n\", dp[n][0][0]);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "d177fd015bd00ff6db74f85efe6afd81", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t500\n#define M\t(N * (N - 1) / 2)\n\nint dr[M + 1], ds[M + 1], md;\n\nint sum(int l, int r) {\n\treturn (dr[r] - (l <= 0 ? 0 : dr[l - 1])) % md;\n}\n\nint sum_(int l, int r) {\n\treturn (ds[r] - (l <= 0 ? 0 : ds[l - 1] + (long long) dr[l - 1] * (r - l + 1))) % md;\n}\n\nint main() {\n\tstatic int dp[M + 1], dq[M + 1];\n\tint n, k, h, i, ans;\n\n\tscanf(\"%d%d\", &n, &md);\n\tans = 0, dp[0] = 1;\n\tfor (k = 1; k <= n; k++) {\n\t\tint m = (k - 1) * (k - 2) / 2, x;\n\n\t\tfor (h = 0; h <= m; h++)\n\t\t\tdq[h] = ((h == 0 ? 0 : dq[h - 1]) + dp[h]) % md;\n\t\tfor (h = 0; h <= m; h++)\n\t\t\tdr[h] = ((h == 0 ? 0 : dr[h - 1]) + dq[h]) % md;\n\t\tfor (h = 0; h <= m; h++)\n\t\t\tds[h] = ((h == 0 ? 0 : ds[h - 1]) + dr[h]) % md;\n\t\tx = 0;\n\t\tfor (h = 2; h <= m; h++)\n\t\t\tx = (x + ((long long) sum(h - k, h - 2) * k - sum_(h - k, h - 2)) % md * dp[h]) % md;\n\t\tfor (i = 0; i < n - k; i++)\n\t\t\tx = (long long) x * (n - i) % md;\n\t\tans = (ans + x) % md;\n\t\tfor (h = 1; h <= m + k - 1; h++)\n\t\t\tdp[h] = (dp[h] + dp[h - 1]) % md;\n\t\tfor (h = m + k - 1; h >= k; h--)\n\t\t\tdp[h] = (dp[h] - dp[h - k]) % md;\n\t}\n\tif (ans < 0)\n\t\tans += md;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "35ca7667284664c6ebac9a136bd0a3f8", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "GNU C11", "source_code": "#include \n\nusing namespace std;\n\nconst int maxn = 105;\n\nint used[maxn];\nint l[maxn];\nint a[maxn];\n\nint main() {\n int n, m;\n cin >> n >> m;\n for(int i = 0; i < m; i++) cin >> l[i];\n for(int i = 1; i < m; i++) {\n int delta = l[i] - l[i-1];\n if(delta <= 0) {\n delta = n + delta;\n }\n if(l[i-1] != used[delta] && used[delta] != 0) {\n cout << \"-1\" << endl;\n return 0;\n }\n a[l[i-1]] = delta;\n used[delta] = l[i-1];\n }\n if(a[1] == 0) {\n for(int i = 1; i < maxn; i++) {\n if(!used[i]) {\n a[1] = i;\n used[i] = true;\n break;\n }\n }\n }\n cout << a[1];\n for(int i = 2; i <= n; i++) {\n if(a[i] == 0) {\n for(int j = 1; j < maxn; j++) {\n if(!used[j]) {\n a[i] = j;\n used[j] = true;\n break;\n } \n } \n }\n cout << \" \" << a[i];\n }\n cout << endl;\n return 0;\n} ", "lang_cluster": "C", "compilation_error": true, "code_uid": "2788c6c1cd9e071370c58acc1063caf2", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include\n#include\n#define ll long long\n\nint max(int x, int y) {\n\tif(x > y) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\nint n, k;\nchar s[200];\nint dp[200][200];\nint poo(int ind, int rem) {\n\tif(rem < 0) {\n\t\treturn 0;\n\t}\n\tif(ind == n) {\n\t\treturn (rem == 0);\n\t}\n\tif(dp[ind][rem] != -1) {\n\t\treturn dp[ind][rem];\n\t}\n\tif(rem == 0 && s[ind] != 'N') {\n\t\treturn dp[ind][rem] = 1;\n\t}\n\tint ret = 0;\n\tif(s[ind] == 'Y') {\n\t\tret = poo(ind+1, k);\n\t} else if(s[ind] == 'N') {\n\t\tret = poo(ind+1, rem-1);\n\t} else {\n\t\tret = poo(ind+1, rem-1) | poo(ind+1, k);\n\t}\n\treturn dp[ind][rem] = ret;\n}\n\nint main() {\n\tfor(int i=0;i<200;i++) {\n\t\tfor(int j=0;j<200;j++) {\n\t\t\tdp[i][j] = -1;\n\t\t}\n\t}\n\tscanf(\"%d%d\", &n, &k);\n\tscanf(\"%s\", s);\n\n\tint ct = 0;\n\tfor(int i=0;i k) {\n\t\t\t\tprintf(\"NO\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tct = 0;\n\t\t}\n\t}\n\tif(ct > k) {\n\t\tprintf(\"NO\");\n\t\treturn 0;\n\t}\n\n\tll ret = poo(0, k);\n\tif(ret) {\n\t\tprintf(\"YES\\n\");\n\t} else {\n\t\tprintf(\"NO\\n\");\n\t}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "5013825dbe2e0bd325fa3c89382f2a3c", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t100000\n#define M\t100000\n#define A\t200000\n#define L_\t18\t/* L_ = ceil(log2(A + 1)) */\n#define N_\t(1 << L_)\n#define M0\t469762049\t/* M0 = 56 * 2^23 + 1 */\n#define M1\t595591169\t/* M1 = 71 * 2^23 + 1 */\n\nint MM[2] = { M0, M1 };\n\nlong long power(int a, int k, int md) {\n\tlong long b = a, p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * b % md;\n\t\tb = b * b % md;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nlong long wu[2][L_ + 1][N_], wv[2][L_ + 1][N_], VV[2], V01;\n\nvoid init() {\n\tint g, l, u, v;\n\n\tV01 = power(M0, M1 - 2, M1);\n\tfor (g = 0; g < 2; g++) {\n\t\tint md = MM[g], i;\n\n\t\tu = power(3, md - 1 >> L_, md), v = power(u, md - 2, md);\n\t\tVV[g] = power(N_, md - 2, md);\n\t\tfor (l = L_; l > 0; l--) {\n\t\t\twu[g][l][0] = wv[g][l][0] = 1;\n\t\t\tfor (i = 1; i < 1 << l; i++)\n\t\t\t\twu[g][l][i] = wu[g][l][i - 1] * u % md, wv[g][l][i] = wv[g][l][i - 1] * v % md;\n\t\t\tu = (long long) u * u % md, v = (long long) v * v % md;\n\t\t}\n\t}\n}\n\nvoid ntt(int *aa, int g, int inverse) {\n\tint md = MM[g], h, i, j, l, r;\n\n\tfor (i = 0, j = 1; j < N_; j++) {\n\t\tint n, tmp;\n\n\t\tn = N_ >> 1;\n\t\twhile ((i ^= n) < n)\n\t\t\tn >>= 1;\n\t\tif (i < j)\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tfor (l = 1; l <= L_; l++) {\n\t\tint n = 1 << l, m = n >> 1;\n\n\t\tfor (h = 0; h < N_; h += n)\n\t\t\tfor (r = 0; r < m; r++) {\n\t\t\t\tint a, b;\n\n\t\t\t\ti = h + r, j = i + m;\n\t\t\t\ta = aa[i], b = aa[j] * (inverse ? wv[g][l][r] : wu[g][l][r]) % md;\n\t\t\t\tif ((aa[i] = a + b) >= md)\n\t\t\t\t\taa[i] -= md;\n\t\t\t\tif ((aa[j] = a - b) < 0)\n\t\t\t\t\taa[j] += md;\n\t\t\t}\n\t}\n}\n\nlong long garner(int r0, int r1) {\n\tr1 = (r1 - r0) * V01 % M1;\n\tif (r1 < 0)\n\t\tr1 += M1;\n\treturn (long long) r1 * M0 + r0;\n}\n\nint main() {\n\tstatic long long ans[A + 1];\n\tstatic int aa[N], bb[M], aaa[2][2][N_], bbb[2][2][N_], cc[2][N_];\n\tint n, m, q, g, h, h1, h2, i, j, x, y, z, c;\n\n\tinit();\n\tscanf(\"%d%d%d\", &n, &m, &q);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tfor (j = 0; j < m; j++)\n\t\tscanf(\"%d\", &bb[j]);\n\tif (n == 1 && m == 1)\n\t\tans[aa[0] + bb[0]] = 1;\n\telse if (n == 1)\n\t\tans[aa[0] + bb[0]]--, ans[aa[0] + bb[m - 1]]--;\n\telse if (m == 1)\n\t\tans[aa[0] + bb[0]]--, ans[aa[n - 1] + bb[0]]--;\n\telse {\n\t\tz = aa[0] > aa[1];\n\t\ty = bb[0] > bb[1], c = aa[0] + bb[0];\n\t\tif (z == y)\n\t\t\tans[c]--;\n\t\tx = bb[m - 1] >= bb[m - 2], c = aa[0] + bb[m - 1];\n\t\tif (z == x)\n\t\t\tans[c]--;\n\t\tfor (j = 1; j < m - 1; j++) {\n\t\t\tx = bb[j] >= bb[j - 1], y = bb[j] > bb[j + 1], c = aa[0] + bb[j];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tz = aa[n - 1] >= aa[n - 2];\n\t\ty = bb[0] > bb[1], c = aa[n - 1] + bb[0];\n\t\tif (z == y)\n\t\t\tans[c]--;\n\t\tx = bb[m - 1] >= bb[m - 2], c = aa[n - 1] + bb[m - 1];\n\t\tif (z == x)\n\t\t\tans[c]--;\n\t\tfor (j = 1; j < m - 1; j++) {\n\t\t\tx = bb[j] >= bb[j - 1], y = bb[j] > bb[j + 1], c = aa[n - 1] + bb[j];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tz = bb[0] > bb[1];\n\t\tfor (i = 1; i < n - 1; i++) {\n\t\t\tx = aa[i] >= aa[i - 1], y = aa[i] > aa[i + 1], c = aa[i] + bb[0];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tz = bb[m - 1] >= bb[m - 2];\n\t\tfor (i = 1; i < n - 1; i++) {\n\t\t\tx = aa[i] >= aa[i - 1], y = aa[i] > aa[i + 1], c = aa[i] + bb[m - 1];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tfor (i = 1; i < n - 1; i++) {\n\t\t\tx = aa[i] >= aa[i - 1], y = aa[i] > aa[i + 1];\n\t\t\tif (!x && !y)\n\t\t\t\taaa[0][0][aa[i]]++;\n\t\t\telse if (x && y)\n\t\t\t\taaa[1][0][aa[i]]++;\n\t\t}\n\t\tfor (j = 1; j < m - 1; j++) {\n\t\t\tx = bb[j] >= bb[j - 1], y = bb[j] > bb[j + 1];\n\t\t\tif (!x && !y)\n\t\t\t\tbbb[0][0][bb[j]]++;\n\t\t\telse if (x && y)\n\t\t\t\tbbb[1][0][bb[j]]++;\n\t\t}\n\t\tfor (h = 0; h < 2; h++) {\n\t\t\tmemcpy(aaa[h][1], aaa[h][0], sizeof aaa[h][0]);\n\t\t\tfor (g = 0; g < 2; g++)\n\t\t\t\tntt(aaa[h][g], g, 0);\n\t\t}\n\t\tfor (h = 0; h < 2; h++) {\n\t\t\tmemcpy(bbb[h][1], bbb[h][0], sizeof bbb[h][0]);\n\t\t\tfor (g = 0; g < 2; g++)\n\t\t\t\tntt(bbb[h][g], g, 0);\n\t\t}\n\t\tfor (h1 = 0; h1 < 2; h1++)\n\t\t\tfor (h2 = 0; h2 < 2; h2++)\n\t\t\t\tfor (g = 0; g < 2; g++) {\n\t\t\t\t\tint md = MM[g], d = h1 == h2 ? md - 2 : 2;\n\n\t\t\t\t\tfor (i = 0; i < N_; i++)\n\t\t\t\t\t\tcc[g][i] = (cc[g][i] + (long long) aaa[h1][g][i] * bbb[h2][g][i] % md * d) % md;\n\t\t\t\t}\n\t\tfor (g = 0; g < 2; g++) {\n\t\t\tint md;\n\t\t\tlong long v;\n\n\t\t\tntt(cc[g], g, 1);\n\t\t\tmd = MM[g], v = VV[g];\n\t\t\tfor (i = 0; i < N_; i++)\n\t\t\t\tcc[g][i] = (long long) cc[g][i] * v % md;\n\t\t}\n\t\tfor (i = 0; i <= A; i++) {\n\t\t\tlong long x = garner(cc[0][i], cc[1][i]);\n\n\t\t\tif (x > (long long) M0 * M1 - x)\n\t\t\t\tx -= (long long) M0 * M1;\n\t\t\tans[i] += x;\n\t\t}\n\t}\n\tans[0]++;\n\tfor (i = 1; i <= A; i++)\n\t\tans[i] += ans[i - 1];\n\twhile (q--) {\n\t\tint x;\n\n\t\tscanf(\"%d\", &x);\n\t\tprintf(\"%lld\\n\", ans[x - 1]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "da6d46f9646e0e9b0a9eb55475bfe647", "src_uid": "25a6428f57022c12dfabdabbcc69c5a4", "difficulty": 3300.0} {"lang": "GNU C11", "source_code": "/* upsolve with Dukkha */\n#include \n\n#define N\t2000\n#define MD\t998244353\n\nint ch[1 + N][1 + N];\n\nvoid init(int n) {\n\tint i, j;\n\n\tch[0][0] = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tch[i][0] = 1;\n\t\tfor (j = 1; j <= i; j++)\n\t\t\tch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;\n\t}\n}\n\nlong long power(int a, int k) {\n\tlong long p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k / 2);\n\tp = p * p % MD;\n\tif (k % 2)\n\t\tp = p * a % MD;\n\treturn p;\n}\n\nint main() {\n\tstatic long long pp[1 + N + N], qq[1 + N + N], aa[1 + N + N];\n\tint n, k, l, i, j;\n\tlong long inv2, a;\n\n\tscanf(\"%d%d%d\", &n, &k, &l);\n\tinit(n);\n\tpp[n] = power(2, n);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = n + n; j > 0; j--)\n\t\t\tpp[j] = (pp[j] - pp[j - 1]) % MD;\n\tfor (j = 0; j <= n + n; j++)\n\t\taa[j] = pp[j];\n\tinv2 = (MD + 1) / 2;\n\tfor (i = 1; i <= n - k; i++) {\n\t\t/* qq := pp / p, where p = 2x (1 - x) */\n\t\t/* divide by 2x */\n\t\tfor (j = 1; j < n + n; j++)\n\t\t\tqq[j] = pp[j + 1] * inv2 % MD;\n\t\tqq[n + n] = 0;\n\t\t/* divide by 1 - x is multiply by 1 + x + x^2 + x^3 + ... */\n\t\tfor (j = 1; j <= n + n; j++)\n\t\t\tqq[j] = (qq[j] + qq[j - 1]) % MD;\n\t\t/* pp := pp * (1 - p) / p = pp / p - pp = qq - pp */\n\t\tfor (j = 0; j <= n + n; j++)\n\t\t\tpp[j] = (qq[j] - pp[j]) % MD;\n\t\ta = ch[n][i];\n\t\tfor (j = 0; j <= n + n; j++)\n\t\t\taa[j] = (aa[j] + a * pp[j]) % MD;\n\t}\n\t/* integrate x^i to x^{i + 1} / (i + 1) */\n\ta = 0;\n\tfor (i = 0; i <= n + n; i++)\n\t\ta = (a + aa[i] * power(i + 1, MD - 2)) % MD;\n\ta = (a * l % MD + MD) % MD;\n\tprintf(\"%lld\\n\", a);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c444ed820c00ef6baefd86e8416ee62b", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MAX 5010\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nchar S[MAX], T[MAX];\nshort next[MAX][MAX];\nbool visited[MAX][MAX];\nint n, m, dp[MAX][MAX];\n\nint F(int i, int j){\n if (i >= n || j >= m) return 0;\n if (visited[i][j]) return dp[i][j];\n\n unsigned int res = 0;\n if (next[i][j] != -1){\n res = res + F(i + 1, next[i][j] + 1) + 1;\n if (res >= MOD) res -= MOD;\n res = res + F(i, next[i][j] + 1);\n if (res >= MOD) res -= MOD;\n }\n\n visited[i][j] = true;\n return (dp[i][j] = res);\n}\n\nint main(){\n int i, j, k;\n\n while (scanf(\"%s %s\", S, T) != EOF){\n clr(visited);\n n = strlen(S), m = strlen(T);\n for (i = 0; i < n; i++){\n for (j = m - 1; j >= 0; j--){\n next[i][j] = -1;\n if (S[i] == T[j]) next[i][j] = j;\n else if ((j + 1) != m) next[i][j] = next[i][j + 1];\n }\n }\n\n long long res = 0;\n for (i = 0; i < n; i++){\n for (j = 0; j < m; j++){\n if (S[i] == T[j]){\n res = res + F(i + 1, j + 1) + 1;\n }\n }\n }\n printf(\"%lld\\n\", res % MOD);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4368a5bec2b898863e0d35f88adb7531", "src_uid": "4022f8f796d4f2b7e43a8360bf34e35f", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#define size 100\nint max(int a,int b)\n{\n\tif(a>b)\n\t return a;\n\telse\n\t return b;\n}\nint partition(int a[],int l,int u)\n{\n\tint v,i,j,temp;\n\tv=a[l];\n\ti=l;\n\tj=u+1;\n\t\n\tdo\n\t{\n\t\tdo\n\t\t\ti++;\n\t\t\t\n\t\twhile(a[i]=m)\n\t{\n\t\tprintf(\"%d\",i);\n\t\texit(0);\n\t}\n}\nprintf(\"-1\");\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "7bcfc5180bfe815d0cfd823ce7ae34dd", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \ntypedef long long ll;\nll MIN = 1111111111111111111;\nll MAX = -1111111111111111111;\nll max = -1111111111111111111;\n\n\n\nvoid merge(ll arr[], ll l, ll m, ll r) \n{ \n ll i, j, k; \n ll n1 = m - l + 1; \n ll n2 = r - m; \n \n /* create temp arrays */\n ll L[n1], R[n2]; \n \n /* Copy data to temp arrays L[] and R[] */\n for (i = 0; i < n1; i++) \n L[i] = arr[l + i]; \n for (j = 0; j < n2; j++) \n R[j] = arr[m + 1+ j]; \n \n /* Merge the temp arrays back llo arr[l..r]*/\n i = 0; // Initial index of first subarray \n j = 0; // Initial index of second subarray \n k = l; // Initial index of merged subarray \n while (i < n1 && j < n2) \n { \n if (L[i] <= R[j]) \n { \n arr[k] = L[i]; \n i++; \n } \n else\n { \n arr[k] = R[j]; \n j++; \n } \n k++; \n } \n \n /* Copy the remaining elements of L[], if there \n are any */\n while (i < n1) \n { \n arr[k] = L[i]; \n i++; \n k++; \n } \n \n /* Copy the remaining elements of R[], if there \n are any */\n while (j < n2) \n { \n arr[k] = R[j]; \n j++; \n k++; \n } \n} \n \n/* l is for left index and r is right index of the \n sub-array of arr to be sorted */\nvoid mergeSort(ll arr[], ll l, ll r) \n{ \n if (l < r) \n { \n // Same as (l+r)/2, but avoids overflow for \n // large l and h \n ll m = l+(r-l)/2; \n \n // Sort first and second halves \n mergeSort(arr, l, m); \n mergeSort(arr, m+1, r); \n \n merge(arr, l, m, r); \n } \n} \n \n\nll power(ll x, ll y) \n{ \n if (y == 0) \n return 1; \n else if (y%2 == 0) \n return power(x, y/2)*power(x, y/2); \n else\n return x*power(x, y/2)*power(x, y/2); \n}\n\nint main(ll argc, char const *argv[])\n{\n ll T;\n // scanf(\"%lld\",&T);\n T = 1;\n // printf(\"%lld %lld %lld\",MIN,MAX,max);\n for (ll tqw = 0; tqw < T; tqw++)\n {\n ll x,y,l,r ;\n scanf(\"%lld %lld %lld %lld\",&x,&y,&l,&r);\n ll o = l;\n ll xcountl = -1;\n while(o)\n {\n xcountl++;\n o = o/x ;\n }\n\n ll p = r;\n ll xcountr = 0;\n while(p)\n {\n xcountr++;\n p = p/x;\n }\n ll e = r;\n ll ycountr = 0;\n while(e)\n {\n ycountr++;\n e = e/y;\n }\n ll qw = l;\n ll ycountl = -1;\n while(qw)\n {\n ycountl++;\n qw = qw/y;\n }\n \n // printf(\"%lld %lld\\n\",xcountl,xcountr);\n\n ll totalcount = 0;\n ll A[1000000];\n ll idx = 0;\n for(ll s=xcountl;sMAX)\n MAX = A[idx] ;\n if(A[idx]MAX)\n MAX = A[idx] ;\n if(A[idx]max)\n max = A[sd]-A[sd-1]-1 ;\n // if(max<0)max=0;\n }\n ll finalanswer = 0;\n ll left = MIN-l;\n if(left<0)left = 0;\n ll right = r-MAX;\n if(right<0)right = 0;\n /* printf(\"l %lld r %lld %lld|\",left,right,max);*/\n if(left>right)\n {\n if(left>max)\n {\n finalanswer = left;\n }\n else \n {\n finalanswer = max ;\n }\n }\n else \n {\n if(right>max)\n {\n finalanswer = right;\n }\n else \n {\n finalanswer = max ;\n }\n }\n // printf(\"<%lld>\",totalcount);\n if(totalcount==0)\n {\n finalanswer = r-l+1 ;\n }\n if(l==1)\n {\n if(r-l+1-totalcount==0)\n printf(\"0\\n\");\n else\n {printf(\"%lld\\n\",finalanswer);}\n }\n\n else{\n if(r-l+1-totalcount==0)\n printf(\"0\\n\");\n else\n { printf(\"%lld\\n\",finalanswer);}\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e99496778abef9eea39e776c36a6786f", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void)\n{\n char num[101];\n char str[101];\n \n gets(num);\n gets(str);\n\n int in[10], out[10];\n\n memset(in, 0, sizeof(in));\n memset(out, 0, sizeof(out));\n\n for(int i = 0; num[i] != 0; ++i)\n {\n if(num[i] == '9') in[6]++;\n else if(num[i] == '5') in[2]++;\n else in[num[i] - '0']++;\n }\n for(int i = 0; str[i] != 0; ++i)\n {\n if(str[i] == '9') out[6]++;\n else if(str[i] == '5') out[2]++;\n else out[str[i] - '0']++;\n }\n\n for(int i = 0; i < 10; ++i)\n if(in[i] != 0)\n out[i] /= in[i];\n else out[i] = 0;\n \n int min = 0;\n while(out[min] == 0) min++;\n\n if(min < 9)\n for(int i = 0; i < 10; ++i)\n if(out[i] != 0)\n min = out[i] < out[min] ? i : min;\n\n printf(\"%d\", out[min]);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "2d3644e9e4d493cef301f0a977e287cb", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include\n#define M 510\n#define ll long long\nll mod=1000000007;\nll f[M][M];\nll pp[1000000];\nll ans;\nint n,k;\nvoid prepare(){\n ll cnt;\n int i,j;\n pp[0]=1;\n for(i=1;i<1000000;i++)pp[i]=(pp[i-1]*2)%mod;\n for(i=0;i<=500;i++)f[i][0]=1;\n for(n=1;n<=500;n++)for(k=1;k<=n;k++){\n for(j=k;j<=n;j++){\n cnt=(pp[j*(n-j+1)]-pp[(j-1)*(n-j+1)]+mod)%mod;\n cnt=(f[j-1][k-1]*cnt)%mod;\n f[n][k]=(f[n][k]+cnt);\n }\n f[n][k]%=mod;\n }\n}\nint main(){\n int i,j;\n prepare();\n scanf(\"%d %d\",&n,&k);\n printf(\"%lld\\n\",f[n][k]);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9e82bafe0068dfd6fa16cfae727e5ed1", "src_uid": "111673158df2e37ac6c019bb99225ccb", "difficulty": 2500.0} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long int n, m;\n\tscanf(\"%lld %lld\", &n, &m);\n\tlong long int fact[2500006];\n\tlong long int i;\n\tfact[0] = 1;\n\tfor (i = 1; i < 2500006; i++)\n\t\tfact[i] = fact[i - 1] * i % m;\n\tlong long int ans = 0;\n\tfor (i = 0; i < n; i++)\n\t\tans = (ans + (n - i) * fact[i + 1] % m * fact[n - i] % m) % m;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "8331622883540ffbefd0b2f1e9ae80d6", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "\nint s[99];\n\nchar l[99];\nint main() {\n int f, I, t;\n scanf(\"%d %d %d\",&f,&i,&t);\n for(int i=0; i= t;\n printf(\"%d\", o);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "3f142d4248dc9a01eb5ba5cfd80b3138", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i MX) break;\n solve(depth+1, i+1, sum+k);\n if(in[st]=='0') break;\n }\n}\n\nint main(){\n int i,j,k;\n\n scanf(\"%s\",in);\n len = strlen(in);\n\n res = -1;\n solve(0,0,0);\n\n printf(\"%d\\n\",res);\n\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "14e14d797fb739b6aff21f8ce99b08df", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "GNU C", "source_code": "#include \n\nint interior(int x, int y, int a, int b, int c) {\n if ((x>=a) && (x <= a+c) && (y>=b) && (y<=b+c)) return 1;\n return 0;\n};\n\nint main(void) {\n int x1, y1, x2, y2, a1, b1, a2, b2, c1, c2, n;\n scanf(\"%d %d %*d %*d %d %d %*d %*d\", &x1, &y1, &x2, &y2); // * skip input\n scanf(\"%d %d %*d %*d %d %d %*d %*d\", &a1, &b1, &a2, &b2);\n c1 = (x1 > x2)?(x1 - x2):(x2 - x1);\n x1 = (x1 < x2)?x1:x2;\n y1 = (y1 < y2)?y1:y2; \n n=0;\n if (a1 == a2) {\n c2 = ((b1 > b2)?(b1 - b2):(b2 - b1))/2;\n b1 = (b1 > b2)?b1:b2;\n for (int i=0; i<=c2; ++i)\n for (int j=-i; j<=i; ++j) {\n n = interior(a1+j, b1-i, x1, y1, c1)||interior(a2+j, b1-2*c2+i, x1, y1, c1);\n if (n == 1) break;\n }\n }\n else {\n c2 = ((a1 > a2)?(a1 - a2):(a2 - a1))/2;\n a1 = (a1 > a2)?a1:a2;\n for (int i=0; i<=c2; ++i)\n for (int j=-i; j<=i; ++j) {\n n = interior(b1+j, a1-i, x1, y1, c1)||interior(b1+j, a1-2*c+i, x1, y1, c1);\n if (n == 1) break;\n }\n }\n if (n == 1) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "6f009185477381e999a47d8057e072a0", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nlong long int k,i,j,max,min,S;\n\nint main()\n{\n int n,m,x,y;\n \n scanf(\"%d%d%lld%d%d\",&n,&m,&k,&x,&y);\n \n if(n*m > k)\n {\n max = 1;\n min = 0;\n if((x-1)*m+y <= k)S = 1;\n else S = 0;\n }\n else if(n <= 2)\n {\n min = k/(m*n);\n max = (k%(m*n) == 0)?min:min + 1;\n \n if(max == min)S = max;\n else\n {\n if(n == 1)\n {\n if(k%m >= y)S = max;\n else S = min;\n }\n else\n {\n j = k%(m*n);\n if(j > m)\n {\n if(x == 2 && j-m >= y)S = max;\n else S = min;\n }\n else\n {\n if(x == 1 && j >= y)S = max;\n else S = min;\n }\n }\n }\n }\n else\n {\n i = k/(m*(2*n-2));\n j = k%(m*(2*n-2));\n max = i*2;\n min = i;\n if(j == 0)\n {\n if(x == 1 || x == n)S = min;\n else S = max;\n }\n else\n {\n if(j <= m)\n {\n if(x == 1)\n {\n if(y > j)S = min;\n else S = min+1;\n }\n else if(x == n)S = min;\n else S = max;\n }\n else if(j <= m*(n-1))\n {\n max++;\n if(x == 1)S = min+1;\n else if(x == n)S = min;\n else \n {\n if((x-1)*m+y <= j)S = max;\n else S = max-1;\n }\n }\n else if(j <= m*n)\n {\n max++;\n if(j == m*n)min++;\n if(x == 1)S = i+1;\n else if(x == n)\n {\n if(y <= j%m || j%m == 0)S = i+1;\n else S = i;\n }\n else S = max;\n }\n else\n {\n max+=2;\n min++;\n if(x == 1)S = i+1;\n else if(x == n)S = i+1;\n else\n {\n S = i*2+1;\n j-=m*n;\n if(j%m == 0)\n {\n if(x + j/m > (n-2))S++;\n }\n else\n {\n if(x + j/m > (n-1))S++;\n else if(x + j/m == (n-1))\n {\n if(j%m >= y||j%m == 0)S++;\n }\n }\n }\n }\n }\n }\n \n printf(\"%lld %lld %lld\\n\",max,min,S);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "fb6d1dcddf6f2dd5a6bf8ba2f13293b9", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nchar pre[1010][100000];\n\nchar *strrev(char *s)\n{\n char *real,*forward,temp;\n real=s;\n forward=s;\n while(*s)\n s++;\n while(forward=0; k--)\n {\n if(drr[k]!='0')\n {\n drr[k+1]='\\0';\n break;\n }\n }\n strcpy(pre[i],strrev(drr));\n }\n while(scanf(\"%d\",&n)==1)\n {\n if(n==0 || n==1)\n printf(\"1\\n\");\n else if(n==2)\n printf(\"2\\n\");\n else\n printf(\"%s\\n\",pre[n]);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9c7f5390c0026d5a6e93e59a5d94cb53", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "typedef unsigned char __u_char;\ntypedef unsigned short int __u_short;\ntypedef unsigned int __u_int;\ntypedef unsigned long int __u_long;\ntypedef signed char __int8_t;\ntypedef unsigned char __uint8_t;\ntypedef signed short int __int16_t;\ntypedef unsigned short int __uint16_t;\ntypedef signed int __int32_t;\ntypedef unsigned int __uint32_t;\ntypedef signed long int __int64_t;\ntypedef unsigned long int __uint64_t;\ntypedef long int __quad_t;\ntypedef unsigned long int __u_quad_t;\ntypedef long int __intmax_t;\ntypedef unsigned long int __uintmax_t;\ntypedef unsigned long int __dev_t;\ntypedef unsigned int __uid_t;\ntypedef unsigned int __gid_t;\ntypedef unsigned long int __ino_t;\ntypedef unsigned long int __ino64_t;\ntypedef unsigned int __mode_t;\ntypedef unsigned long int __nlink_t;\ntypedef long int __off_t;\ntypedef long int __off64_t;\ntypedef int __pid_t;\ntypedef struct { int __val[2]; } __fsid_t;\ntypedef long int __clock_t;\ntypedef unsigned long int __rlim_t;\ntypedef unsigned long int __rlim64_t;\ntypedef unsigned int __id_t;\ntypedef long int __time_t;\ntypedef unsigned int __useconds_t;\ntypedef long int __suseconds_t;\ntypedef int __daddr_t;\ntypedef int __key_t;\ntypedef int __clockid_t;\ntypedef void * __timer_t;\ntypedef long int __blksize_t;\ntypedef long int __blkcnt_t;\ntypedef long int __blkcnt64_t;\ntypedef unsigned long int __fsblkcnt_t;\ntypedef unsigned long int __fsblkcnt64_t;\ntypedef unsigned long int __fsfilcnt_t;\ntypedef unsigned long int __fsfilcnt64_t;\ntypedef long int __fsword_t;\ntypedef long int __ssize_t;\ntypedef long int __syscall_slong_t;\ntypedef unsigned long int __syscall_ulong_t;\ntypedef __off64_t __loff_t;\ntypedef char *__caddr_t;\ntypedef long int __intptr_t;\ntypedef unsigned int __socklen_t;\ntypedef int __sig_atomic_t;\ntypedef __int8_t int8_t;\ntypedef __int16_t int16_t;\ntypedef __int32_t int32_t;\ntypedef __int64_t int64_t;\ntypedef __uint8_t uint8_t;\ntypedef __uint16_t uint16_t;\ntypedef __uint32_t uint32_t;\ntypedef __uint64_t uint64_t;\ntypedef signed char int_least8_t;\ntypedef short int int_least16_t;\ntypedef int int_least32_t;\ntypedef long int int_least64_t;\ntypedef unsigned char uint_least8_t;\ntypedef unsigned short int uint_least16_t;\ntypedef unsigned int uint_least32_t;\ntypedef unsigned long int uint_least64_t;\ntypedef signed char int_fast8_t;\ntypedef long int int_fast16_t;\ntypedef long int int_fast32_t;\ntypedef long int int_fast64_t;\ntypedef unsigned char uint_fast8_t;\ntypedef unsigned long int uint_fast16_t;\ntypedef unsigned long int uint_fast32_t;\ntypedef unsigned long int uint_fast64_t;\ntypedef long int intptr_t;\ntypedef unsigned long int uintptr_t;\ntypedef __intmax_t intmax_t;\ntypedef __uintmax_t uintmax_t;\ntypedef int __gwchar_t;\n\ntypedef struct\n {\n long int quot;\n long int rem;\n } imaxdiv_t;\nextern intmax_t imaxabs (intmax_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\nextern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\nextern intmax_t strtoimax (const char *__restrict __nptr,\n char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__));\nextern uintmax_t strtoumax (const char *__restrict __nptr,\n char ** __restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__));\nextern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr,\n __gwchar_t **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__));\nextern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr,\n __gwchar_t ** __restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__));\n\n\ntypedef long unsigned int size_t;\nstruct _IO_FILE;\ntypedef struct _IO_FILE __FILE;\nstruct _IO_FILE;\ntypedef struct _IO_FILE FILE;\ntypedef struct\n{\n int __count;\n union\n {\n unsigned int __wch;\n char __wchb[4];\n } __value;\n} __mbstate_t;\ntypedef struct\n{\n __off_t __pos;\n __mbstate_t __state;\n} _G_fpos_t;\ntypedef struct\n{\n __off64_t __pos;\n __mbstate_t __state;\n} _G_fpos64_t;\ntypedef __builtin_va_list __gnuc_va_list;\nstruct _IO_jump_t; struct _IO_FILE;\ntypedef void _IO_lock_t;\nstruct _IO_marker {\n struct _IO_marker *_next;\n struct _IO_FILE *_sbuf;\n int _pos;\n};\nenum __codecvt_result\n{\n __codecvt_ok,\n __codecvt_partial,\n __codecvt_error,\n __codecvt_noconv\n};\nstruct _IO_FILE {\n int _flags;\n char* _IO_read_ptr;\n char* _IO_read_end;\n char* _IO_read_base;\n char* _IO_write_base;\n char* _IO_write_ptr;\n char* _IO_write_end;\n char* _IO_buf_base;\n char* _IO_buf_end;\n char *_IO_save_base;\n char *_IO_backup_base;\n char *_IO_save_end;\n struct _IO_marker *_markers;\n struct _IO_FILE *_chain;\n int _fileno;\n int _flags2;\n __off_t _old_offset;\n unsigned short _cur_column;\n signed char _vtable_offset;\n char _shortbuf[1];\n _IO_lock_t *_lock;\n __off64_t _offset;\n void *__pad1;\n void *__pad2;\n void *__pad3;\n void *__pad4;\n size_t __pad5;\n int _mode;\n char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];\n};\ntypedef struct _IO_FILE _IO_FILE;\nstruct _IO_FILE_plus;\nextern struct _IO_FILE_plus _IO_2_1_stdin_;\nextern struct _IO_FILE_plus _IO_2_1_stdout_;\nextern struct _IO_FILE_plus _IO_2_1_stderr_;\ntypedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);\ntypedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,\n size_t __n);\ntypedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);\ntypedef int __io_close_fn (void *__cookie);\nextern int __underflow (_IO_FILE *);\nextern int __uflow (_IO_FILE *);\nextern int __overflow (_IO_FILE *, int);\nextern int _IO_getc (_IO_FILE *__fp);\nextern int _IO_putc (int __c, _IO_FILE *__fp);\nextern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));\nextern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));\nextern int _IO_peekc_locked (_IO_FILE *__fp);\nextern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));\nextern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));\nextern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));\nextern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,\n __gnuc_va_list, int *__restrict);\nextern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,\n __gnuc_va_list);\nextern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);\nextern size_t _IO_sgetn (_IO_FILE *, void *, size_t);\nextern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);\nextern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);\nextern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));\ntypedef __gnuc_va_list va_list;\ntypedef __off_t off_t;\ntypedef __ssize_t ssize_t;\ntypedef _G_fpos_t fpos_t;\nextern struct _IO_FILE *stdin;\nextern struct _IO_FILE *stdout;\nextern struct _IO_FILE *stderr;\nextern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));\nextern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));\nextern int renameat (int __oldfd, const char *__old, int __newfd,\n const char *__new) __attribute__ ((__nothrow__ , __leaf__));\nextern FILE *tmpfile (void) ;\nextern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern char *tempnam (const char *__dir, const char *__pfx)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;\nextern int fclose (FILE *__stream);\nextern int fflush (FILE *__stream);\nextern int fflush_unlocked (FILE *__stream);\nextern FILE *fopen (const char *__restrict __filename,\n const char *__restrict __modes) ;\nextern FILE *freopen (const char *__restrict __filename,\n const char *__restrict __modes,\n FILE *__restrict __stream) ;\nextern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern FILE *fmemopen (void *__s, size_t __len, const char *__modes)\n __attribute__ ((__nothrow__ , __leaf__)) ;\nextern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));\nextern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,\n int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));\nextern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,\n size_t __size) __attribute__ ((__nothrow__ , __leaf__));\nextern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));\nextern int fprintf (FILE *__restrict __stream,\n const char *__restrict __format, ...);\nextern int printf (const char *__restrict __format, ...);\nextern int sprintf (char *__restrict __s,\n const char *__restrict __format, ...) __attribute__ ((__nothrow__));\nextern int vfprintf (FILE *__restrict __s, const char *__restrict __format,\n __gnuc_va_list __arg);\nextern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);\nextern int vsprintf (char *__restrict __s, const char *__restrict __format,\n __gnuc_va_list __arg) __attribute__ ((__nothrow__));\nextern int snprintf (char *__restrict __s, size_t __maxlen,\n const char *__restrict __format, ...)\n __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));\nextern int vsnprintf (char *__restrict __s, size_t __maxlen,\n const char *__restrict __format, __gnuc_va_list __arg)\n __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));\nextern int vdprintf (int __fd, const char *__restrict __fmt,\n __gnuc_va_list __arg)\n __attribute__ ((__format__ (__printf__, 2, 0)));\nextern int dprintf (int __fd, const char *__restrict __fmt, ...)\n __attribute__ ((__format__ (__printf__, 2, 3)));\nextern int fscanf (FILE *__restrict __stream,\n const char *__restrict __format, ...) ;\nextern int scanf (const char *__restrict __format, ...) ;\nextern int sscanf (const char *__restrict __s,\n const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));\nextern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ (\"\" \"__isoc99_fscanf\") ;\nextern int scanf (const char *__restrict __format, ...) __asm__ (\"\" \"__isoc99_scanf\") ;\nextern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __asm__ (\"\" \"__isoc99_sscanf\") __attribute__ ((__nothrow__ , __leaf__));\nextern int vfscanf (FILE *__restrict __s, const char *__restrict __format,\n __gnuc_va_list __arg)\n __attribute__ ((__format__ (__scanf__, 2, 0))) ;\nextern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)\n __attribute__ ((__format__ (__scanf__, 1, 0))) ;\nextern int vsscanf (const char *__restrict __s,\n const char *__restrict __format, __gnuc_va_list __arg)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0)));\nextern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ (\"\" \"__isoc99_vfscanf\")\n __attribute__ ((__format__ (__scanf__, 2, 0))) ;\nextern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ (\"\" \"__isoc99_vscanf\")\n __attribute__ ((__format__ (__scanf__, 1, 0))) ;\nextern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ (\"\" \"__isoc99_vsscanf\") __attribute__ ((__nothrow__ , __leaf__))\n __attribute__ ((__format__ (__scanf__, 2, 0)));\nextern int fgetc (FILE *__stream);\nextern int getc (FILE *__stream);\nextern int getchar (void);\nextern int getc_unlocked (FILE *__stream);\nextern int getchar_unlocked (void);\nextern int fgetc_unlocked (FILE *__stream);\nextern int fputc (int __c, FILE *__stream);\nextern int putc (int __c, FILE *__stream);\nextern int putchar (int __c);\nextern int fputc_unlocked (int __c, FILE *__stream);\nextern int putc_unlocked (int __c, FILE *__stream);\nextern int putchar_unlocked (int __c);\nextern int getw (FILE *__stream);\nextern int putw (int __w, FILE *__stream);\nextern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)\n ;\nextern __ssize_t __getdelim (char **__restrict __lineptr,\n size_t *__restrict __n, int __delimiter,\n FILE *__restrict __stream) ;\nextern __ssize_t getdelim (char **__restrict __lineptr,\n size_t *__restrict __n, int __delimiter,\n FILE *__restrict __stream) ;\nextern __ssize_t getline (char **__restrict __lineptr,\n size_t *__restrict __n,\n FILE *__restrict __stream) ;\nextern int fputs (const char *__restrict __s, FILE *__restrict __stream);\nextern int puts (const char *__s);\nextern int ungetc (int __c, FILE *__stream);\nextern size_t fread (void *__restrict __ptr, size_t __size,\n size_t __n, FILE *__restrict __stream) ;\nextern size_t fwrite (const void *__restrict __ptr, size_t __size,\n size_t __n, FILE *__restrict __s);\nextern size_t fread_unlocked (void *__restrict __ptr, size_t __size,\n size_t __n, FILE *__restrict __stream) ;\nextern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,\n size_t __n, FILE *__restrict __stream);\nextern int fseek (FILE *__stream, long int __off, int __whence);\nextern long int ftell (FILE *__stream) ;\nextern void rewind (FILE *__stream);\nextern int fseeko (FILE *__stream, __off_t __off, int __whence);\nextern __off_t ftello (FILE *__stream) ;\nextern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);\nextern int fsetpos (FILE *__stream, const fpos_t *__pos);\nextern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));\nextern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));\nextern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern void perror (const char *__s);\nextern int sys_nerr;\nextern const char *const sys_errlist[];\nextern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern FILE *popen (const char *__command, const char *__modes) ;\nextern int pclose (FILE *__stream);\nextern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));\nextern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));\nextern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));\n\ntypedef int wchar_t;\n\ntypedef enum\n{\n P_ALL,\n P_PID,\n P_PGID\n} idtype_t;\ntypedef struct\n {\n int quot;\n int rem;\n } div_t;\ntypedef struct\n {\n long int quot;\n long int rem;\n } ldiv_t;\n__extension__ typedef struct\n {\n long long int quot;\n long long int rem;\n } lldiv_t;\nextern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern double atof (const char *__nptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;\nextern int atoi (const char *__nptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;\nextern long int atol (const char *__nptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;\n__extension__ extern long long int atoll (const char *__nptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;\nextern double strtod (const char *__restrict __nptr,\n char **__restrict __endptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern float strtof (const char *__restrict __nptr,\n char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern long double strtold (const char *__restrict __nptr,\n char **__restrict __endptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern long int strtol (const char *__restrict __nptr,\n char **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern unsigned long int strtoul (const char *__restrict __nptr,\n char **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\n__extension__\nextern long long int strtoq (const char *__restrict __nptr,\n char **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\n__extension__\nextern unsigned long long int strtouq (const char *__restrict __nptr,\n char **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\n__extension__\nextern long long int strtoll (const char *__restrict __nptr,\n char **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\n__extension__\nextern unsigned long long int strtoull (const char *__restrict __nptr,\n char **__restrict __endptr, int __base)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) ;\nextern long int a64l (const char *__s)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;\n\ntypedef __u_char u_char;\ntypedef __u_short u_short;\ntypedef __u_int u_int;\ntypedef __u_long u_long;\ntypedef __quad_t quad_t;\ntypedef __u_quad_t u_quad_t;\ntypedef __fsid_t fsid_t;\ntypedef __loff_t loff_t;\ntypedef __ino_t ino_t;\ntypedef __dev_t dev_t;\ntypedef __gid_t gid_t;\ntypedef __mode_t mode_t;\ntypedef __nlink_t nlink_t;\ntypedef __uid_t uid_t;\ntypedef __pid_t pid_t;\ntypedef __id_t id_t;\ntypedef __daddr_t daddr_t;\ntypedef __caddr_t caddr_t;\ntypedef __key_t key_t;\ntypedef __clock_t clock_t;\ntypedef __clockid_t clockid_t;\ntypedef __time_t time_t;\ntypedef __timer_t timer_t;\ntypedef unsigned long int ulong;\ntypedef unsigned short int ushort;\ntypedef unsigned int uint;\ntypedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));\ntypedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));\ntypedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));\ntypedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));\ntypedef int register_t __attribute__ ((__mode__ (__word__)));\nstatic __inline unsigned int\n__bswap_32 (unsigned int __bsx)\n{\n return __builtin_bswap32 (__bsx);\n}\nstatic __inline __uint64_t\n__bswap_64 (__uint64_t __bsx)\n{\n return __builtin_bswap64 (__bsx);\n}\nstatic __inline __uint16_t\n__uint16_identity (__uint16_t __x)\n{\n return __x;\n}\nstatic __inline __uint32_t\n__uint32_identity (__uint32_t __x)\n{\n return __x;\n}\nstatic __inline __uint64_t\n__uint64_identity (__uint64_t __x)\n{\n return __x;\n}\ntypedef struct\n{\n unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];\n} __sigset_t;\ntypedef __sigset_t sigset_t;\nstruct timeval\n{\n __time_t tv_sec;\n __suseconds_t tv_usec;\n};\nstruct timespec\n{\n __time_t tv_sec;\n __syscall_slong_t tv_nsec;\n};\ntypedef __suseconds_t suseconds_t;\ntypedef long int __fd_mask;\ntypedef struct\n {\n __fd_mask __fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];\n } fd_set;\ntypedef __fd_mask fd_mask;\n\nextern int select (int __nfds, fd_set *__restrict __readfds,\n fd_set *__restrict __writefds,\n fd_set *__restrict __exceptfds,\n struct timeval *__restrict __timeout);\nextern int pselect (int __nfds, fd_set *__restrict __readfds,\n fd_set *__restrict __writefds,\n fd_set *__restrict __exceptfds,\n const struct timespec *__restrict __timeout,\n const __sigset_t *__restrict __sigmask);\n\n\nextern unsigned int gnu_dev_major (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\nextern unsigned int gnu_dev_minor (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\nextern __dev_t gnu_dev_makedev (unsigned int __major, unsigned int __minor) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\n\ntypedef __blksize_t blksize_t;\ntypedef __blkcnt_t blkcnt_t;\ntypedef __fsblkcnt_t fsblkcnt_t;\ntypedef __fsfilcnt_t fsfilcnt_t;\nstruct __pthread_rwlock_arch_t\n{\n unsigned int __readers;\n unsigned int __writers;\n unsigned int __wrphase_futex;\n unsigned int __writers_futex;\n unsigned int __pad3;\n unsigned int __pad4;\n int __cur_writer;\n int __shared;\n signed char __rwelision;\n unsigned char __pad1[7];\n unsigned long int __pad2;\n unsigned int __flags;\n};\ntypedef struct __pthread_internal_list\n{\n struct __pthread_internal_list *__prev;\n struct __pthread_internal_list *__next;\n} __pthread_list_t;\nstruct __pthread_mutex_s\n{\n int __lock ;\n unsigned int __count;\n int __owner;\n unsigned int __nusers;\n int __kind;\n \n short __spins; short __elision;\n __pthread_list_t __list;\n \n};\nstruct __pthread_cond_s\n{\n __extension__ union\n {\n __extension__ unsigned long long int __wseq;\n struct\n {\n unsigned int __low;\n unsigned int __high;\n } __wseq32;\n };\n __extension__ union\n {\n __extension__ unsigned long long int __g1_start;\n struct\n {\n unsigned int __low;\n unsigned int __high;\n } __g1_start32;\n };\n unsigned int __g_refs[2] ;\n unsigned int __g_size[2];\n unsigned int __g1_orig_size;\n unsigned int __wrefs;\n unsigned int __g_signals[2];\n};\ntypedef unsigned long int pthread_t;\ntypedef union\n{\n char __size[4];\n int __align;\n} pthread_mutexattr_t;\ntypedef union\n{\n char __size[4];\n int __align;\n} pthread_condattr_t;\ntypedef unsigned int pthread_key_t;\ntypedef int pthread_once_t;\nunion pthread_attr_t\n{\n char __size[56];\n long int __align;\n};\ntypedef union pthread_attr_t pthread_attr_t;\ntypedef union\n{\n struct __pthread_mutex_s __data;\n char __size[40];\n long int __align;\n} pthread_mutex_t;\ntypedef union\n{\n struct __pthread_cond_s __data;\n char __size[48];\n __extension__ long long int __align;\n} pthread_cond_t;\ntypedef union\n{\n struct __pthread_rwlock_arch_t __data;\n char __size[56];\n long int __align;\n} pthread_rwlock_t;\ntypedef union\n{\n char __size[8];\n long int __align;\n} pthread_rwlockattr_t;\ntypedef volatile int pthread_spinlock_t;\ntypedef union\n{\n char __size[32];\n long int __align;\n} pthread_barrier_t;\ntypedef union\n{\n char __size[4];\n int __align;\n} pthread_barrierattr_t;\n\nextern long int random (void) __attribute__ ((__nothrow__ , __leaf__));\nextern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));\nextern char *initstate (unsigned int __seed, char *__statebuf,\n size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nextern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nstruct random_data\n {\n int32_t *fptr;\n int32_t *rptr;\n int32_t *state;\n int rand_type;\n int rand_deg;\n int rand_sep;\n int32_t *end_ptr;\n };\nextern int random_r (struct random_data *__restrict __buf,\n int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int srandom_r (unsigned int __seed, struct random_data *__buf)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nextern int initstate_r (unsigned int __seed, char *__restrict __statebuf,\n size_t __statelen,\n struct random_data *__restrict __buf)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));\nextern int setstate_r (char *__restrict __statebuf,\n struct random_data *__restrict __buf)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int rand (void) __attribute__ ((__nothrow__ , __leaf__));\nextern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));\nextern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__));\nextern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__));\nextern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__));\nextern long int nrand48 (unsigned short int __xsubi[3])\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__));\nextern long int jrand48 (unsigned short int __xsubi[3])\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__));\nextern unsigned short int *seed48 (unsigned short int __seed16v[3])\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nstruct drand48_data\n {\n unsigned short int __x[3];\n unsigned short int __old_x[3];\n unsigned short int __c;\n unsigned short int __init;\n __extension__ unsigned long long int __a;\n };\nextern int drand48_r (struct drand48_data *__restrict __buffer,\n double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int erand48_r (unsigned short int __xsubi[3],\n struct drand48_data *__restrict __buffer,\n double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int lrand48_r (struct drand48_data *__restrict __buffer,\n long int *__restrict __result)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int nrand48_r (unsigned short int __xsubi[3],\n struct drand48_data *__restrict __buffer,\n long int *__restrict __result)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int mrand48_r (struct drand48_data *__restrict __buffer,\n long int *__restrict __result)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int jrand48_r (unsigned short int __xsubi[3],\n struct drand48_data *__restrict __buffer,\n long int *__restrict __result)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int srand48_r (long int __seedval, struct drand48_data *__buffer)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nextern int seed48_r (unsigned short int __seed16v[3],\n struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int lcong48_r (unsigned short int __param[7],\n struct drand48_data *__buffer)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;\nextern void *calloc (size_t __nmemb, size_t __size)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;\nextern void *realloc (void *__ptr, size_t __size)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));\nextern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));\n\nextern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__));\n\nextern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;\nextern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;\nextern void *aligned_alloc (size_t __alignment, size_t __size)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) ;\nextern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));\nextern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));\nextern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));\nextern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));\nextern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;\nextern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern int setenv (const char *__name, const char *__value, int __replace)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nextern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__));\nextern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ;\nextern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ;\nextern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;\nextern int system (const char *__command) ;\nextern char *realpath (const char *__restrict __name,\n char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) ;\ntypedef int (*__compar_fn_t) (const void *, const void *);\nextern void *bsearch (const void *__key, const void *__base,\n size_t __nmemb, size_t __size, __compar_fn_t __compar)\n __attribute__ ((__nonnull__ (1, 2, 5))) ;\nextern void qsort (void *__base, size_t __nmemb, size_t __size,\n __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));\nextern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;\nextern long int labs (long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;\n__extension__ extern long long int llabs (long long int __x)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;\nextern div_t div (int __numer, int __denom)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;\nextern ldiv_t ldiv (long int __numer, long int __denom)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;\n__extension__ extern lldiv_t lldiv (long long int __numer,\n long long int __denom)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;\nextern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,\n int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;\nextern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,\n int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;\nextern char *gcvt (double __value, int __ndigit, char *__buf)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ;\nextern char *qecvt (long double __value, int __ndigit,\n int *__restrict __decpt, int *__restrict __sign)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;\nextern char *qfcvt (long double __value, int __ndigit,\n int *__restrict __decpt, int *__restrict __sign)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;\nextern char *qgcvt (long double __value, int __ndigit, char *__buf)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ;\nextern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,\n int *__restrict __sign, char *__restrict __buf,\n size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));\nextern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,\n int *__restrict __sign, char *__restrict __buf,\n size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));\nextern int qecvt_r (long double __value, int __ndigit,\n int *__restrict __decpt, int *__restrict __sign,\n char *__restrict __buf, size_t __len)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));\nextern int qfcvt_r (long double __value, int __ndigit,\n int *__restrict __decpt, int *__restrict __sign,\n char *__restrict __buf, size_t __len)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));\nextern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));\nextern int mbtowc (wchar_t *__restrict __pwc,\n const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));\nextern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__));\nextern size_t mbstowcs (wchar_t *__restrict __pwcs,\n const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));\nextern size_t wcstombs (char *__restrict __s,\n const wchar_t *__restrict __pwcs, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__));\nextern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;\nextern int getsubopt (char **__restrict __optionp,\n char *const *__restrict __tokens,\n char **__restrict __valuep)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3))) ;\nextern int getloadavg (double __loadavg[], int __nelem)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\n\n\nextern void *memcpy (void *__restrict __dest, const void *__restrict __src,\n size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void *memmove (void *__dest, const void *__src, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void *memccpy (void *__restrict __dest, const void *__restrict __src,\n int __c, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern int memcmp (const void *__s1, const void *__s2, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void *memchr (const void *__s, int __c, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern char *strcpy (char *__restrict __dest, const char *__restrict __src)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strncpy (char *__restrict __dest,\n const char *__restrict __src, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strcat (char *__restrict __dest, const char *__restrict __src)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strncat (char *__restrict __dest, const char *__restrict __src,\n size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int strcmp (const char *__s1, const char *__s2)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int strncmp (const char *__s1, const char *__s2, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int strcoll (const char *__s1, const char *__s2)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern size_t strxfrm (char *__restrict __dest,\n const char *__restrict __src, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nstruct __locale_struct\n{\n struct __locale_data *__locales[13];\n const unsigned short int *__ctype_b;\n const int *__ctype_tolower;\n const int *__ctype_toupper;\n const char *__names[13];\n};\ntypedef struct __locale_struct *__locale_t;\ntypedef __locale_t locale_t;\nextern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));\nextern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,\n locale_t __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));\nextern char *strdup (const char *__s)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));\nextern char *strndup (const char *__string, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));\nextern char *strchr (const char *__s, int __c)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern char *strrchr (const char *__s, int __c)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern size_t strcspn (const char *__s, const char *__reject)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern size_t strspn (const char *__s, const char *__accept)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strpbrk (const char *__s, const char *__accept)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strstr (const char *__haystack, const char *__needle)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strtok (char *__restrict __s, const char *__restrict __delim)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nextern char *__strtok_r (char *__restrict __s,\n const char *__restrict __delim,\n char **__restrict __save_ptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));\nextern char *strtok_r (char *__restrict __s, const char *__restrict __delim,\n char **__restrict __save_ptr)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));\nextern size_t strlen (const char *__s)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern size_t strnlen (const char *__string, size_t __maxlen)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern char *strerror (int __errnum) __attribute__ ((__nothrow__ , __leaf__));\nextern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ (\"\" \"__xpg_strerror_r\") __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));\nextern char *strerror_l (int __errnum, locale_t __l) __attribute__ ((__nothrow__ , __leaf__));\n\nextern int bcmp (const void *__s1, const void *__s2, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void bcopy (const void *__src, void *__dest, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern char *index (const char *__s, int __c)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern char *rindex (const char *__s, int __c)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));\nextern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\nextern int ffsl (long int __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\n__extension__ extern int ffsll (long long int __ll)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));\nextern int strcasecmp (const char *__s1, const char *__s2)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int strncasecmp (const char *__s1, const char *__s2, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));\nextern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));\nextern int strncasecmp_l (const char *__s1, const char *__s2,\n size_t __n, locale_t __loc)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));\n\nextern void explicit_bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));\nextern char *strsep (char **__restrict __stringp,\n const char *__restrict __delim)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *strsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));\nextern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *stpcpy (char *__restrict __dest, const char *__restrict __src)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *__stpncpy (char *__restrict __dest,\n const char *__restrict __src, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\nextern char *stpncpy (char *__restrict __dest,\n const char *__restrict __src, size_t __n)\n __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));\n\nstatic struct cmc_alloc_node\n{\n void *(*malloc)(size_t);\n void *(*calloc)(size_t, size_t);\n void *(*realloc)(void *, size_t);\n void (*free)(void *);\n} cmc_alloc_node_default = { malloc, calloc, realloc, free };\nstruct cmc_callbacks\n{\n void (*create)(void);\n void (*read)(void);\n void (*update)(void);\n void (*delete)(void);\n void (*resize)(void);\n};\nenum cmc_flags\n{\n CMC_FLAG_OK = 0,\n CMC_FLAG_ALLOC = 1,\n CMC_FLAG_EMPTY = 2,\n CMC_FLAG_NOT_FOUND = 3,\n CMC_FLAG_INVALID = 4,\n CMC_FLAG_RANGE = 5,\n CMC_FLAG_DUPLICATE = 6,\n CMC_FLAG_ERROR = 7,\n CMC_FLAG_THREAD = 8,\n CMC_FLAG_MUTEX = 9\n};\n__attribute__((__unused__)) static const char *cmc_flags_to_str[10] = { \"OK\", \"ALLOC\", \"EMPTY\", \"NOT_FOUND\", \"INVALID\",\n \"RANGE\", \"DUPLICATE\", \"ERROR\", \"THREAD\", \"MUTEX\" };\nstruct fragment {\n long len;\n long b;\n};\nstatic inline int fragment_compare(struct fragment f1, struct fragment f2) {\n if (f1.len < f2.len) {\n return -1;\n } else if (f1.len > f2.len) {\n return 1;\n }\n return f1.b - f2.b;\n}\nC_MACRO_COLLECTIONS_ALL(CMC, TREESET, (ls, lset, , , long))\nC_MACRO_COLLECTIONS_ALL(CMC, TREESET, (fs, fset, , , struct fragment));\nC_MACRO_COLLECTIONS_ALL(CMC, TREEMAP, (tm, treemap, , long, long))\nlong moves(struct lset *piles, struct fset *fragments) {\n long max_pile, min_pile;\n ls_max(piles, &max_pile);\n ls_min(piles, &min_pile);\n struct fragment max_frag;\n fs_max(fragments, &max_frag);\n return max_pile - min_pile - max_frag.len;\n}\nstatic struct lset_node* lset_impl_get_node(struct lset * _set_, long value) {\n struct lset_node *scan = _set_->root;\n while (scan != ((void *)0)) {\n if (_set_->f_val->cmp(scan->value, value) > 0)\n scan = scan->left;\n else if (_set_->f_val->cmp(scan->value, value) < 0)\n scan = scan->right;\n else\n return scan;\n }\n return ((void *)0);\n}\nstatic struct lset_node* lset_impl_get_node_gte(struct lset_node *nd, long value) {\n if (nd == ((void *)0) || nd->value == value) {\n return nd;\n }\n if (nd->value < value) {\n return lset_impl_get_node_gte(nd->right, value);\n }\n struct lset_node *nd_gte = lset_impl_get_node_gte(nd->left, value);\n if (nd_gte) {\n return nd_gte;\n }\n return nd;\n}\nstatic struct lset_node* lset_impl_tree_min(struct lset_node* nd) {\n if (nd->left != ((void *)0)) {\n return lset_impl_tree_min(nd->left);\n }\n return nd;\n}\nstatic struct lset_node* lset_impl_tree_max(struct lset_node* nd) {\n if (nd->right != ((void *)0)) {\n return lset_impl_tree_max(nd->right);\n }\n return nd;\n}\nstatic struct lset_node* lset_impl_tree_predecessor(struct lset_node* nd) {\n if (nd->left != ((void *)0)) {\n return lset_impl_tree_max(nd->left);\n }\n struct lset_node* par = nd->parent;\n while (par != ((void *)0) && nd == par->left) {\n nd = par;\n par = par->parent;\n }\n return par;\n}\nstatic struct lset_node* lset_impl_tree_successor(struct lset_node* nd) {\n if (nd->right != ((void *)0)) {\n return lset_impl_tree_min(nd->right);\n }\n struct lset_node* par = nd->parent;\n while (par != ((void *)0) && nd == par->right) {\n nd = par;\n par = par->right;\n }\n return par;\n}\nint main() {\n struct lset *piles = ls_new(&(struct lset_fval){\n .cmp = cmc_i64_cmp\n });\n int n, q;\n scanf(\"%d%d\", &n, &q);\n for (int i = 0; i < n; ++i) {\n long pile;\n scanf(\"%ld\", &pile);\n ls_insert(piles, pile);\n }\n struct fset *fragments = fs_new(&(struct fset_fval){\n .cmp = fragment_compare\n });\n {\n long b, e;\n struct lset_iter it = ls_iter_start(piles);\n for (;!ls_iter_at_end(&it); ls_iter_next(&it)) {\n if (ls_iter_at_start(&it)) {\n b = ls_iter_value(&it);\n } else {\n e = ls_iter_value(&it);\n fs_insert(fragments, (struct fragment){e - b, b});\n b = e;\n }\n }\n }\n printf(\"%ld\\n\", moves(piles, fragments));\n for (int i = 0; i < q; ++i) {\n long t, x;\n scanf(\"%ld%ld\", &t, &x);\n if (t == 0) {\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "b17197f59b8860eee006896abc867de2", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b)\n{\n if (a % b == 0) {\n return b;\n } else {\n return gcd(b, a % b);\n }\n}\n\nint min(int a, int b)\n{\n if (a < b) {\n return a;\n } else {\n return b;\n }\n}\n\nint main()\n{\n int n, m, x, y, a, b, g, p, x1, y1, x2, y2;\n \n scanf(\"%d %d %d %d %d %d\", &n, &m, &x, &y, &a, &b);\n \n g = gcd(a, b);\n \n a /= g;\n b /= g;\n \n p = min(n / a, m / b);\n \n a *= p;\n b *= p;\n \n if ((a + 1) / 2 <= x && n - a / 2 >= x) {\n x1 = x - (a + 1) / 2;\n x2 = x1 + a;\n } else if ((a + 1) / 2 <= x) {\n x1 = n - a;\n x2 = n;\n } else {\n x1 = 0;\n x2 = a;\n }\n \n if ((b + 1) / 2 <= y && m - b / 2 >= y) {\n y1 = y - (b + 1) / 2;\n y2 = y1 + b;\n } else if ((b + 1) / 2 <= y) {\n y1 = m - b;\n y2 = m;\n } else {\n y1 = 0;\n y2 = b;\n }\n \n printf(\"%d %d %d %d\\n\", x1, y1, x2, y2);\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e84e02f58ee411094d64dba011f91841", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \nstruct node\n{\n int a, b;\n};\nint z[75];\n\nint main()\n{\n int i, j, n;\n struct node x[75], y[75], t;\n scanf(\"%d\", &n);\n for(i = 1; i <= n; ++i)\n {\n scanf(\"%d\", &x[i].a);\n x[i].b = i;\n y[i].a = x[i].a;\n y[i].b = x[i].b;\n }\n for(i = 1; i <= n; ++i)\n for(j = 1; j < n; ++j)\n if(x[j].a < x[j + 1].a)\n {\n t = x[j];\n x[j] = x[j + 1];\n x[j + 1] = t;\n }\n for(i = 1; i < n; ++i)\n z[i] = x[i + 1].b;\n z[n] = x[1].b;\n for(i = 1; i <= n; ++i)\n printf(\"%d \", y[z[i]].a);\n puts(\"\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "b7455fc7a164a0101e24e7d9109495ff", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int ix;\n long long int l,r,m,n,x,y,n2,dc,nd2;\n scanf(\"%I64d\",&n);\n if(n==1)\n {\n printf(\"4\");\n return 0;\n }\n l=1;r=n;nd2=n*n;\n nd2/=2;\n while(l+1nd2)\n r=m;\n else\n l=m;\n }\n if(r*r<=nd2)\n x=r;\n else\n x=l;\n \n n2=n*n;\n dc=2*x*x+2*x+1;\n \n ix=x;\n if(dc-n2<=0)\n {\n printf(\"%d\",8*ix+4);\n }\n else\n {\n printf(\"%d\",8*ix);\n }\n return 0;\n \n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "05d0a072443d9b80554cb3e5f1eb5752", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null} {"lang": "GNU C11", "source_code": "#include\nint a[110];\nchar c[][10]={\"NO\",\"YES\"};\nint main(){\n\tint i,n;\n\ta[2]=a[3]=a[4]=a[5]=a[46]=a[12]=a[23]=a[30]=a[35]=a[43]=a[52]=a[64]=a[86]=1;\n\tscanf(\"%d\",&n);\n\tprintf(\"%s\",c[a[n]]);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "6762f3ed26fb66f86d79ebfcb6e2cf06", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "GNU C11", "source_code": "/* AUTHOR:AKASH JAIN\n* USERNAME:akash19jain \n* DATE:28/09/2019 \n*/\n/*#include\n#include \nusing namespace std;*/\n\n#include\n#include\n#include\n#include\n#include\n#define SC1(x) scanf(\"%lld\",&x)\n#define SC2(x,y) scanf(\"%lld%lld\",&x,&y)\n#define SC3(x,y,z) scanf(\"%lld%lld%lld\",&x,&y,&z)\n#define SCS(x) scanf(\"\\n%s\", x)\n#define PF1(x) printf(\"%lld\\n\",x)\n#define PF2(x,y) printf(\"%lld %lld\\n\",x,y)\n#define PF3(x,y,z) printf(\"%lld %lld %lld\\n\",x,y,z)\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 WHILE(n) while(n--)\n#define MEM(a, b) memset(a, (b), sizeof(a))\n#define ITOC(c) ((char)(((int)'0')+c))\n#define MID(s,e) (s+(e-s)/2)\n#define SZ(a) strlen(a)\n#define MOD 1000000007\n#define MAX 10000000005\n#define MIN -10000000005\n#define PI 3.1415926535897932384626433832795\n#define DEB(x) printf(\"The value of \\\"%s\\\" is: %d\\n\",#x,x)\n#define CASES ll t;SC1(t);while(t--)\n#define ABS(a) ((a>0)?a:-(a))\n\nconst int INF = 1<<29;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define FILEIO(name) \\ freopen(name\".in\", \"r\", stdin); \\ freopen(name\".out\", \"w\", stdout);\nint cmp(const void * a,const void * b);\nlong long maxv(long long a,long long b);\nlong long minv(long long a,long long b);\nlong long gcd(long long u,long long v);\nll binpow(ll a,ll b,ll m)\n{\n ll res=1;\n a=a%m;\n while(b>0)\n {\n if(b&1)\n res=res*a%m;\n a=a*a%m;\n b>>=1;\n }\n return res;\n}\nll multiply(ll a, ll b, ll mod) \n{ \n return ((a % mod) * (b % mod)) % mod; \n} \nint main()\n{\n\tll n,m;\n\tSC2(n,m);\n\tunsigned long long ans=0;\n\tn++;\n\tll x=2*n;\n\tunsigned long long z=binpow(x,m,MOD);\n\tz=z%MOD;\n\tunsigned long long z1=(n-m)%MOD;\n\tunsigned long long z2=multiply(z,z1,MOD);\n\tans=(z2/n);\n\tans=ans%MOD;\n\tprintf(\"%llu\\n\",ans);\n\n\treturn 0;\n}\n \n \n//qsort(arr,n,sizeof(arr[0]),cmp);\nint cmp (const void * a, const void * b)\n{\n if( *(ll*)a - *(ll*)b < 0 ) return -1;\n if( *(ll*)a - *(ll*)b > 0 ) return 1;\n return 0;\n}\nlong long maxv(long long a,long long b)\n{\n if(a>b) return a;\n return b;\n}\nlong long minv(long long a,long long b)\n{\n if(a\n\nint n;\nchar s[55];\nlong long res;\n\nint main() { int i;\n scanf(\"%d%s\", &n, s);\n for( i = 0; i < n; i++) if(s[i] == 'B') res |= 1ll << i;\n printf(\"%I64d\\n\", res);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "220b3f780189bcb60b3fd7b0980d553a", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n long int i,j,p,n,maxx=-1,maxy=-1,minx=31400,miny=31400;\n scanf(\"%ld\",&n);\n long int a[n][4],b[n];\n long int z,k =0;\n for(i=0;imaxx)\n {\n maxx=a[i][2];\n }\n if(a[i][0]maxy)\n {\n maxy=a[i][3];\n }\n }\n z=(maxx-minx)*(maxy-miny);\n for(p=0;p\n#define MAXN 2003\n\nint main()\n{\n int n, t, i, j, cur = 0;\n double p, f[2][MAXN];\n scanf(\"%d%lf%d\", &n, &p, &t);\n // f[t][n] -> the possibility that (exactly) n people\n // are standing on the escalator after t seconds\n for (i = 1; i <= n; ++i) f[cur][i] = 0;\n f[cur][0] = 1;\n#define next (!cur)\n for (i = 0; i < t; ++i) {\n for (j = 0; j <= i; ++j)\n if (j >= n) f[next][j] += f[cur][j];\n else {\n f[next][j + 1] += f[cur][j] * p;\n f[next][j] += f[cur][j] * (1.0 - p);\n }\n cur = !cur;\n for (j = 0; j <= n; ++j) f[next][j] = 0;\n }\n#undef next\n double ans = 0;\n for (i = 0; i <= n; ++i) ans += f[cur][i] * i;\n printf(\"%.8lf\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "cd8f2b9dd0c618ca5d19c4bc784d611e", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "\n#include\n#include\n#include\nusing namespace std;\nint main(){\n\tchar ch;\n\tint a[5];\n\tint i,sum = 100;\n\tint mul = 0,add = 0;\n\tint resu[4];\n\tfor(i = 1; i <= 4; i++){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\tsort(a+1,a+5);\n\tfor(i = 1; i <= 3; i++){\n\t\tscanf(\"%c\",&ch);\n\t\tif(ch =='*')\n\t\t\tmul++;\n\t\tif(ch == '+')\n\t\t\tadd++;\n\t}\n\tif(mul == 3)\n\t\tsum = a[1]*a[2]*a[3]*a[4];\n\tif(mul == 2 ){\n\t\tresu[1] = a[1] + a[2] * a[3] *a[4];\n\t\tresu[2] = a[1] * a[2] + a[3] *a[4];\n\t\tresu[3] = a[1] * a[2] * a[3] +a[4];\n\t\tsum = resu[1] > resu [2] ? resu[2]:resu[1];\n\t\tif(sum > resu [3])\n\t\t\tsum = resu [3];\n\t}\n\tif(mul == 1 ){\n\t\tresu[1] = a[1] + a[2] + a[3] *a[4];\n\t\tresu[2] = a[1] * a[2] + a[3] +a[4];\n\t\tresu[3] = a[1] + a[2] * a[3] +a[4];\n\t\tsum = resu[1] > resu [2] ? resu[2]:resu[1];\n\t\tif(sum > resu [3])\n\t\t\tsum = resu [3];\n\t}\n\tif(add == 3)\n\t\tsum = a[1]+a[2]+a[3]+a[4];\n\tprintf(\"%d\",sum);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "cdd5ef7c99bf96e8060088cf0b800c47", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint cmpfunc (const void * a, const void * b)\n{\n\t return ( *(int*)a - *(int*)b );\n}\n\nint abso(int a,int b)\n{\n\tif(a>b)return a-b;\n\telse return b-a;\n}\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i=0;\n\tint a[200]={0};\n\tfor(i=0;i<2*n;i++)scanf(\"%d\",&a[i]);\n\n\tqsort(a, 2*n, sizeof(int), cmpfunc);\n\n\tint sing = 0;\n\tif(abso(a[1],a[0]) > abso(a[2*n-1],a[2*n-2]))sing=1;\n\t\n\tif(sing==0){n--;i=0;}\n\telse i=2;\n\t\n\tint sum=0;\n\tfor(;i<2*n;i+=2)\n\t\tsum+=abso(a[i],a[i+1]);\n\n\tprintf(\"%d\\n\",sum);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "79805d26267df222cd43fc0cc5c7ccee", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \nint dp[500100];\nint main()\n{\n int n,d,i,x,sum,ans,ans1,j;\n scanf(\"%d%d\",&n,&d);\n sum=0;\n dp[0]=1;\n for(i=0;i=x;j--){\n if(dp[j-x])\n dp[j]=1;\n }\n }\n ans=ans1=0;\n while(1)\n {\n j=ans+d;\n while(j>ans&&!dp[j])\n j--;\n if(j==ans)\n break;\n ans=j;\n ans1++;\n }\n printf(\"%d %d\\n\",ans,ans1);\n \n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "fcb6657cb7b598a8b979e20c166a6f4b", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main() {\n int n, m;\n scanf(\"%d %d\", &n, &m);\n\n int digits[9] = {0};\n bool dup = true;\n while (n) {\n int d = n % m;\n if (digits[d]) {\n dup = false;\n } else {\n digits[d] = 1;\n }\n\n n /= m;\n }\n\n if (dup) {\n puts(\"YES\");\n } else {\n puts(\"NO\");\n }\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "38063e05ece90b613426b13f554118f7", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\n#include\nint cmp(const void *a,const void *b) \n{ \nreturn *(int *)a-*(int *)b; \n} \nint main()\n{\n\tint n,time,t[100],d[5000];\n\tint i,j,k=0;\n\twhile(scanf(\"%d\",&n)!=EOF)\n\t{\n\t\tfor(i=0;i=0;j--)\n\t\t{\n\t\t\tfor(i=0;i<=j;i++)\n\t\t\t{\n\t\t\t\tif((t[j]-t[i])<=time)\n\t\t\t\td[k++]=j-i+1;\n\t\t\t}\n\t\t}\n\t\tqsort(d,k,sizeof(d[0]),cmp);\n\t\tprintf(\"%d\\n\",d[k-1]);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "468ece4cb37e186acf9096919538991b", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N 1100000\n\nint a[N];\n\nint max(int x, int y) {\n return x > y ? x : y;\n}\n\nint perfect(int x) {\n int i;\n for (i = 0; i < 30; i++) {\n int num = 1 << i;\n if (num == x)\n return 1;\n }\n return 0;\n}\n\nint step(int x) {\n int i;\n for (i = 0; i < 30; i++) {\n int num = 1 << i;\n if (num >= x)\n return i;\n }\n return -1;\n}\n\nint main(int argc, char** argv) {\n int i, n, x, y, z, s;\n \n memset(a, 0, sizeof a);\n scanf(\"%d\", &n);\n for (i = 2; i < N; i++) {\n while (n % i == 0) {\n n /= i;\n a[i]++;\n }\n }\n \n x = 1;\n y = 0;\n z = 0;\n s = 1;\n for (i = 2; i < N; i++)\n if (a[i] > 0) {\n x *= i;\n z = max(z, a[i]);\n }\n for (i = 2; i < N; i++)\n if (a[i] > 0 && a[i] != z)\n s = 0;\n \n if (s == 1 && perfect(z))\n y = step(z);\n else\n y = step(z) + 1;\n \n printf(\"%d %d\\n\", x, y);\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "17a7dfc2d74ad2c6d2147139186c6847", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include\nint a[11];\nint max(int a ,int b){ return (a > b ? a : b); }\nint isnext(int n){\n int m = 0 ,r = -1 ,i;\n for( i = 0 ; i < n - 1 ; i++){ if(abs(a[i] - a[i + 1]) >= 2) return -1;\n if(a[i] > m){\n r = i;\n m = a[i];\n }\n }\n if(a[i] > m) r = i;\n return r;\n}\nint main(){\n int n ,r; scanf(\"%d\" ,&n);\n for(int i = 0 ; i < n ; i++) scanf(\"%d\" ,a + i);\n while(1){\n if((r = isnext(n)) == -1){\n puts(\"NO\"); return 0;\n }\n for(int j = r + 1 ; j < n ; j++) a[j] = a[j - 1];\n n--;\n if(n == 1) break;\n }\n puts(\"YES\");\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9db9f7c7529832f8bc824b51a4c3dc36", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\n#define MAX 16\n#define max(a,b) ((a)>(b) ? (a):(b))\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nconst double multiplier = 0.997;\n\nchar str[MAX], color[MAX];\nint n, m, last[MAX], order[MAX], R[MAX], B[MAX];\n\ndouble rand_real(){\n return (double)rand() / RAND_MAX;\n}\n\nint solve(){\n int i, j, res = 0, red = 0, blue = 0, rcard = 0, bcard = 0;\n\n for (j = 0; j < n; j++){\n i = order[j];\n int req_red = max(R[i] - rcard, 0);\n int req_blue = max(B[i] - bcard, 0);\n\n int buy_red = max(req_red - red, 0);\n int buy_blue = max(req_blue - blue, 0);\n\n int tokens_bought = max(buy_red, buy_blue);\n\n res += tokens_bought;\n red += tokens_bought, blue += tokens_bought;\n red -= req_red, blue -= req_blue;\n\n if (color[i] == 'R') rcard++;\n else bcard++;\n }\n return res + n;\n}\n\nint main(){\n int t, i, j, k, x, lim, res, cur, next;\n\n while (scanf(\"%d\", &n) != EOF){\n for (i = 0; i < n; i++){\n scanf(\"%s %d %d\", str, &R[i], &B[i]);\n color[i] = str[0];\n }\n for (i = 0; i < n; i++) order[i] = i;\n\n\n double temperature = 3e5;\n cur = res = solve(), lim = 3e5;\n\n for (t = 0; t < lim; t++){\n m = ((lim - t - 1) * n / lim) + 1;\n for (i = 0; i < n; i++) last[i] = order[i];\n\n while (m--){\n i = rand() % n, j = rand() % n;\n x = order[i], order[i] = order[j], order[j] = x;\n }\n\n next = solve();\n if (next < res) res = next;\n\n if (next < cur) cur = next;\n else{\n double p = exp((double)-(next - cur) / temperature);\n if (rand_real() <= p) cur = next;\n else{\n for (i = 0; i < n; i++) order[i] = last[i];\n }\n }\n\n if (temperature > 1e-20) temperature *= multiplier;\n }\n\n printf(\"%d\\n\", res);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "238436bdbf91ecaec8d09daa5237c29b", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0} {"lang": "GNU C", "source_code": "#include \n\nlong long two(long long n);\n\nlong long three(long long n);\nlong long absolute(long long x)\n{\n if(x<0)\n return -x;\n else\n return x;\n }\n\nint main(void) {\n // your code goes here\n long long a1,b1,a2,b2,two_1,three_1,two_2,three_2,diff_2,diff_3,temp;\n scanf(\"%lld %lld %lld %lld\",&a1,&b1,&a2,&b2);\n \n two_1=two(a1)+two(b1);\n three_1=three(a1)+three(b1);\n \n two_2=two(a2)+two(b2);\n three_2=three(a2)+three(b2);\n \n two_1+=three_1;\n two_2+=three_2;\n \n diff_2=absolute(two_1-two_2);\n diff_3=absolute(three_1-three_2);\n //printf(\"%lld %lld\",diff_2,diff_3);\n \n if(three_1>three_2)\n {\n temp=diff_3;\n while(temp>0)\n {\n if(a1%3==0)\n a1=(a1/3)*2;\n else if(b1%3==0)\n b1=(b1/3)*2;\n temp--;\n }\n \n }\n else \n {\n temp=diff_3;\n while(temp>0)\n {\n if(a2%3==0)\n a2=(a2/3)*2;\n else if(b2%3==0)\n b2=(b2/3)*2;\n temp--;\n }\n \n }\n \n if(two_1>two_2)\n {\n temp=diff_2;\n while(temp>0)\n {\n if(a1%2==0)\n a1=a1/2;\n else if(b1%2==0)\n b1=b1/2;\n temp--;\n }\n \n }\n else \n {\n temp=diff_2;\n while(temp>0)\n {\n if(a2%2==0)\n a2=a2/2;\n else if(b2%2==0)\n b2=b2/2;\n temp--;\n }\n \n }\n \n \n// printf(\"%lld %lld\\n%lld %lld\\n\",a1,b1,a2,b2);\n if((a1*b1)==(a2*b2))\n {\n printf(\"%lld\\n\",diff_2+diff_3);\n printf(\"%lld %lld\\n%lld %lld\\n\",a1,b1,a2,b2);\n }\n else\n printf(\"-1\\n\");\n\n return 0;\n}\n\n\n\nlong long two(long long n)\n{\n long long count=0;\n while(n%2==0)\n {\n n=n/2;\n count++;\n \n }\n return count;\n}\nlong long three(long long n)\n{\n long long count=0;\n while(n%3==0)\n {\n n=n/3;\n count++;\n \n }\n return count;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "818fc7869184203c6436db5143c54de6", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nchar visited[12][105];\nlong long ar[10], dp[12][105], binomial[1010][1010] = {0};\n\nlong long F(long long i, long long n){\n if (i == 10) return (n == 0);\n if (visited[i][n]) return dp[i][n];\n\n long long j, k;\n long long x, y, res = 0;\n for (j = ar[i]; j <= n; j++){\n if (i == 0) x = (long long)binomial[n - 1][j] * F(i + 1, n - j);\n else x = (long long)binomial[n][j] * F(i + 1, n - j);\n res = (res + x) % MOD;\n }\n\n visited[i][n] = 1;\n return (dp[i][n] = res);\n}\n\nlong long solve(long long n){\n clr(visited);\n long long i, j, x, s = 0, res = 0;\n for (i = 1; i < 10; i++) s += ar[i];\n\n for (i = 1; i <= n; i++){\n x = F(0, i);\n res = (res + x) % MOD;\n }\n return (res % MOD);\n}\n\nint main(){\n long long n, i, j, k, res;\n\n for (i = 0; i < 1010; i++){\n for (j = 0; j <= i; j++){\n if (i == j || j == 0) binomial[i][j] = 1;\n else binomial[i][j] = (binomial[i - 1][j - 1] + binomial[i - 1][j]) % MOD;\n }\n }\n\n while (scanf(\"%lld\", &n) != EOF){\n if (n == 0) break;\n for (i = 0; i < 10; i++) scanf(\"%lld\", &ar[i]);\n res = solve(n);\n printf(\"%lld\\n\", res);\n }\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "b7eed2dc04e59f6cabebeddfc3d348c2", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t400000\n#define A\t26\n\nchar aa[1 + N + 1]; int ss[1 + N], n_;\nint len[2 + N * 2], tt[2 + N * 2][A], fff[2 + N * 2][A], ff[2 + N * 2];\n\nint node(int l) {\n\tstatic int _;\n\n\tlen[_] = l;\n\treturn _++;\n}\n\nvoid init() {\n\tint a;\n\n\tnode(0), node(-1);\n\taa[0] = -1;\n\tff[0] = ff[1] = 1;\n\tfor (a = 0; a < A; a++)\n\t\tfff[0][a] = fff[1][a] = 1;\n}\n\nvoid add(int a) {\n\tint s = ss[n_];\n\n\taa[++n_] = a;\n\tif (aa[n_ - 1 - len[s]] != a)\n\t\ts = fff[s][a];\n\tif (!tt[s][a]) {\n\t\tint t = node(len[s] + 2), f = tt[fff[s][a]][a];\n\n\t\tff[t] = f;\n\t\tmemcpy(fff[t], fff[f], sizeof fff[f]), fff[t][(int) aa[n_ - len[f]]] = f;\n\t\ttt[s][a] = t;\n\t}\n\tss[n_] = tt[s][a];\n}\n\nint next(int a, int d) {\n\tint s = ss[n_], a1 = -1, a2 = -1;\n\n\twhile (len[s] >= d - 2) {\n\t\tif (a1 == -1)\n\t\t\ta1 = aa[n_ - len[s]];\n\t\telse\n\t\t\ta2 = aa[n_ - len[s]];\n\t\ts = ff[s];\n\t}\n\twhile (a < A && (a == a1 || a == a2))\n\t\ta++;\n\treturn a;\n}\n\nint main() {\n\tstatic char cc[N + 1];\n\tint n, d, i, i_, a_;\n\n\tinit();\n\tscanf(\"%d%s\", &d, cc), n = strlen(cc);\n\tif (d == 1) {\n\t\tprintf(\"Impossible\\n\");\n\t\treturn 0;\n\t}\n\ti_ = -1, a_ = -1;\n\tfor (i = 0; i < n; i++) {\n\t\tint a;\n\n\t\tif ((a = next(cc[i] - 'a' + 1, d)) < A)\n\t\t\ti_ = i, a_ = a;\n\t\tadd(cc[i] - 'a');\n\t\tif (len[ss[n_]] >= d)\n\t\t\tbreak;\n\t}\n\tif (i_ == -1) {\n\t\tprintf(\"Impossible\\n\");\n\t\treturn 0;\n\t}\n\tn_ = i_;\n\tcc[i_] = a_ + 'a', add(a_);\n\tfor (i = i_ + 1; i < n; i++) {\n\t\tint a = next(0, d);\n\n\t\tcc[i] = a + 'a', add(a);\n\t}\n\tprintf(\"%s\\n\", cc);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "72bfeb6d8cdcdf1348d9d2fccc985362", "src_uid": "959a274a06219f4a8c061cd6f5b17160", "difficulty": 2800.0} {"lang": "GNU C11", "source_code": "#include\n#include\nint fun(char *);\nint fun(char *s)\n{\n int sum=0;\n while(*s)\n {\n if(*s>='A'&&*s<='Z')\n {\n sum=sum+(*s-'A'+1);\n }\n if(*s>='a'&&*s<='z')\n {\n sum=sum-(*s-'a'+1);\n }\n s++;\n }\n return sum;\n}\nint main()\n{\n char a[10001];\n scanf(\"%s\",a);\n printf(\"%d\\n\",fun(a));\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "7637f1b139b809be7032f550fadfbb06", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main() {\n\tint i, j, n, m, cnt;\n\tstatic char *s;\n\tstatic int **ee, *aa;\n\n\tscanf(\"%d%d\", &n, &m);\n\tee = malloc(sizeof(*ee) * (n + 1));\n\tfor (i = 1; i <= n; i++)\n\t\tee[i] = calloc(3, sizeof(*ee[i]));\n\taa = malloc(sizeof(*aa) * 4 * n);\n\ts = malloc((n + 2) * sizeof(*s));\n\tmemset(s + 1, '0', n);\n\ts[n + 1] = '\\0';\n\twhile (m-- > 0) {\n\t\tint u, v;\n\n\t\tscanf(\"%d%d\", &u, &v);\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (ee[u][j] == 0) {\n\t\t\t\tee[u][j] = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (ee[v][j] == 0) {\n\t\t\t\tee[v][j] = u;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tfor (i = 0; i < n; i++)\n\t\taa[i] = i + 1;\n\tcnt = n;\n\twhile (cnt > 0) {\n\t\tint a, k;\n\n\t\ta = aa[--cnt];\n\t\tk = 0;\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (ee[a][j] > 0 && s[a] == s[ee[a][j]])\n\t\t\t\tk++;\n\t\tif (k > 1) {\n\t\t\ts[a] = s[a] == '1' ? '0' : '1';\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\tif (ee[a][j] > 0)\n\t\t\t\t\taa[cnt++] = ee[a][j];\n\t\t}\n\t}\n\tprintf(\"%s\\n\", s + 1);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "50bd4efd821716b3150e8a8426d35eca", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include \n#define ll long long\n#define rsw 998244353\n#define add(x,y) (x=((x)+(y)>=rsw)?((x)+(y)-rsw):((x)+(y)))\nusing namespace std;\nint T,n,a[2005],b[2005],c[2005],dp1[2005][2005][11],dp2[2005][2005][11],n1,n2,ans,p[2005],inv[2005];\nint C(int n,int m)\n{\n return (ll)p[n]*inv[m]%rsw*inv[n-m]%rsw;\n}\nint get(int m,int n)\n{\n if(m==0) return n?0:1;\n return (ll)p[n]*C(n+m-1,n)%rsw;\n}\nint main()\n{\n cin>>T;\n p[0]=1;\n for(int i=1;i<2005;i++) p[i]=(ll)p[i-1]*i%rsw;\n inv[0]=inv[1]=1;\n for(int i=2;i<2005;i++) inv[i]=(ll)(rsw-rsw/i)*inv[rsw%i]%rsw;\n for(int i=2;i<2005;i++) inv[i]=(ll)inv[i]*inv[i-1]%rsw;\n while(T--)\n {\n cin>>n,n1=n2=0;\n for(int i=1;i<=n;i++)\n {\n cin>>a[i];\n int len=0,now=a[i];\n while(now)\n {\n now/=10;\n len++;\n }\n if(len&1) b[++n1]=a[i]%11;\n else c[++n2]=a[i]%11;\n }\n dp1[0][0][0]=dp2[0][0][0]=1;\n memset(dp1,0,sizeof dp1);memset(dp2,0,sizeof dp2);\n for(int i=1;i<=n1;i++)\n for(int j=0;j<=i;j++)\n for(int k=0;k<11;k++)\n {\n dp1[i][j][k]=0;\n add(dp1[i][j][k],dp1[i-1][j][(k-b[i]+11)%11]);\n if(j) add(dp1[i][j][k],dp1[i-1][j-1][(k+b[i])%11]);\n }\n for(int i=1;i<=n2;i++)\n for(int j=0;j<=i;j++)\n for(int k=0;k<11;k++)\n {\n dp2[i][j][k]=0;\n add(dp2[i][j][k],dp2[i-1][j][(k-c[i]+11)%11]);\n if(j) add(dp2[i][j][k],dp2[i-1][j-1][(k+c[i])%11]);\n }\n for(int i=0;i<=n2;i++)\n for(int k=0;k<11;k++)\n add(ans,(ll)dp1[n1][n1/2][k]*p[n1/2]%rsw*p[n1-n1/2]%rsw*dp2[n2][i][(11-k)%11]%rsw*get(n1+1-(n1+1)/2,n2-i)%rsw*get((n1+1)/2,i)%rsw);\n printf(\"%d\\n\",ans);\n }\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "892a8849a5f436802a5a9e21f4fa563d", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n\n#define rep(i,n) for(i=0;i d*d ) return 1;\n\tint & ans = mem[a+N/2][b+N/2];\n\tif( ans > -1 ) return ans;\n\tint i;\n\trep(i,n) if( !rec( a+vx[i], b+vy[i] ) ) return ans = 1;\n\treturn ans = 0;\n}\n\nint main()\n{\n\tint i, j;\n\trep(i,N) rep(j,N) mem[i][j] = -1;\n\tscanf( \"%d%d%d%d\", &x, &y, &n, &d );\n\tfor( i = 0; i < n; i++ ) scanf( \"%d%d\", &vx[i], &vy[i] );\n\tprintf( rec(x,y) ? \"Anton\\n\" : \"Dasha\\n\" );\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "e93ed4d356715ad8c0e09a6039a244e6", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MOD 1000000007\n\nlong long waysToPlay(int n, int m, int k);\nlong long oldWaysToPlay(int n, int m, int k, long long mult);\nlong long choose(long long a, long long b);\n\nlong long oldWays;\nlong long known[1000][1000][1000];\n\nint main() {\n int n, m, k;\n scanf(\"%d %d %d\", &n, &m, &k);\n\n // n: dimension\n // y: dimension\n // k: amount of moves\n\n printf(\"%lld\\n\", (choose(n-1, 2*k) * choose(m-1, 2*k)) % MOD);\n\n oldWays = 0;\n //long long ways = waysToPlay(n, m, k) % MOD;\n //printf(\"%lld\\n\")\n //printf(\"%lld\\n\", ways);\n\n // Old\n //oldWaysToPlay(n, m, k, 1);\n //printf(\"%lld\\n\", oldWays);\n\n return EXIT_SUCCESS;\n}\n\nlong long waysToPlay(int n, int m, int k) {\n // 6, 7, 2\n // \n // 4, 4, 1 => 9\n // 6, 7, 2 => 75\n\n // If no more moves\n if (k == 0) {\n return 1;\n } else if (k == 1) {\n //printf(\"%d %d %d %lld\\n\", n, m, k, choose(n-1, 2) * choose(m-1, 2));\n return choose(n-1, 2) * choose(m-1, 2);\n } else {\n // For 5x5 (3x3)\n // Answer = 36\n // k = 1\n // x = 4c2\n // y = 4c2\n\n // 10 * 10 = 100\n\n // Smallest cases\n int n_small = 1 + 2*(k-1);\n int m_small = 1 + 2*(k-1);\n long long ways = 0;\n\n // They must be TWO less\n for (int n_i = n_small; n_i < n-1; n_i++) {\n for (int m_i = m_small; m_i < m-1; m_i++) {\n // The amount of positions that the new rectangle\n // can fit into\n int newMult = (n-n_i-1)*(m-m_i-1);\n\n // Cache the result\n if (known[m_i][n_i][k-1] == 0) {\n known[m_i][n_i][k-1] = waysToPlay(n_i, m_i, k-1);\n }\n\n // Add it to ways\n ways += newMult * known[m_i][n_i][k-1];\n }\n }\n\n //printf(\"%d %d %d %lld\\n\", n, m, k, ways);\n \n return ways;\n }\n\n // Otherwise there are no ways\n return 0;\n}\n\nlong long choose(long long a, long long b) {\n if (b > a) return 0;\n\n //aCb = a!/((a-b)!*b!)\n // = a*(a-1)...(a-b+1)/\n // b*(b-1)...1\n\n // = a*(a-1)...(a-b+1)/\n // 1*2*......b\n\n long long result = 1;\n for (int i = 0; i < b; i++) {\n result = (result * (a-i)) % MOD;\n result = (result / (i+1)) % MOD;\n }\n\n //printf(\"%lldC%lld = %lld\\n\", a, b, result);\n return result % MOD;\n}\n\n\n//OLD method\nlong long oldWaysToPlay(int n, int m, int k, long long mult) {\n // 3x3 in 6x7 (4x5)\n if (k == 0) {\n oldWays = (oldWays+mult) % MOD;\n //printf(\"+ %lld\\n\", mult);\n } else if (k == 1 && n == 1 && m == 1) {\n oldWays = (oldWays+mult) % MOD;\n } else {\n // Smallest cases\n int n_small = 1 + 2*(k-1);\n int m_small = 1 + 2*(k-1);\n\n // How many places it can go X inside solutions\n\n // They must be TWO less\n for (int n_i = n_small; n_i < n-1; n_i++) {\n for (int m_i = m_small; m_i < m-1; m_i++) {\n // Positional permutation (x,y and y,x)\n // int twice = (m_i != n_i) ? 2 : 1;\n\n //printf(\"passing: %d %d %lld\\n\", n_i, m_i, mult);\n oldWaysToPlay(n_i, m_i, k-1, mult*(n-n_i-1)*(m-m_i-1));\n }\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "4e8f3320653c77a79d86788e6b374685", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "// write in C...\n#include \n\n#ifdef DEBUG\n#define D(x...) fprintf(stderr, x)\n#else\n#define D(x...)\n#endif\n\n#define MOD 1000000009\n\nint n, w, b;\nint c[4005][4005];\n\nint p(int n, int k) {\n if (k > n || k < 1) return 0;\n else return c[n-1][k-1];\n}\n\nint main() {\n int i, j;\n\n scanf(\"%d %d %d\", &n, &w, &b);\n\n for (i = 0; i < 4005; i++) c[i][0] = 1;\n for (i = 1; i < 4005; i++)\n for (j = 1; j <= i; j++)\n c[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD;\n\n long long res = 0;\n\n for (i = 0; i <= n; i++) {\n res = (res + (long long)p(b, i) * (long long)p(w, n-i) * (long long)(n-i-1)) % MOD;\n }\n\n for (i = 1; i <= w; i++) res = (res * i) % MOD;\n for (i = 1; i <= b; i++) res = (res * i) % MOD;\n\n printf(\"%d\\n\", (int)res);\n\n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "54f6dd7664fb8a98765aba7d9345e12b", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint v[10][10];\nint r[10][10];\n\nint aux[10][10];\n\nint n;\n\nvoid rot()\n{\n int i,j;\n for(i=0; i\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;ik2);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;r=m[i];m[i]=m[j];m[j]=r;}doubleIntSort(d,m,i);doubleIntSort(d+j+1,m+j+1,s-j-1);}\n\nint n;\nint nf, ne, ns;\nint rf, re, rs; double Rf, Re, Rs;\nint df, de;\nint h[21];\ndouble res;\n\ndouble x[100]; int ev[100];\nint F, E, S;\n\nvoid calc(void){\n int i,j,k;\n double w, tmp;\n\n if(n%2==0){\n i = h[0] + h[1]*10;\n j = h[n-2] + h[n-1]*10;\n if(i>j) return;\n }\n \n F = E = S = 0;\n rep(i,n){\n if(h[i]==0){\n x[2*i ] = (i/2) - Rf;\n x[2*i+1] = (i/2) + Rf;\n ev[2*i ] = 1;\n ev[2*i+1] = -1;\n }\n if(h[i]==1){\n x[2*i ] = (i/2) - Re;\n x[2*i+1] = (i/2) + Re;\n ev[2*i ] = 2;\n ev[2*i+1] = -2;\n }\n if(h[i]==2){\n x[2*i ] = (i/2) - Rs;\n x[2*i+1] = (i/2) + Rs;\n ev[2*i ] = 3;\n ev[2*i+1] = -3;\n }\n }\n doubleIntSort(x, ev, 2*n);\n\n tmp = 0;\n rep(i,2*n-1){\n w = x[i+1] - x[i];\n if(ev[i]==1) F++; if(ev[i]==-1) F--;\n if(ev[i]==2) E++; if(ev[i]==-2) E--;\n if(ev[i]==3) S++; if(ev[i]==-3) S--;\n tmp += (F*df + E*de) * (w * (S+1));\n }\n if(res < tmp) res = tmp;\n}\n\nvoid brute(int depth){\n if(depth==n) calc();\n \n if(nf > 0){\n h[depth] = 0;\n nf--;\n if(depth%2==0 || h[depth-1] <= h[depth]) brute(depth+1);\n nf++;\n }\n if(ne > 0){\n h[depth] = 1;\n ne--;\n if(depth%2==0 || h[depth-1] <= h[depth]) brute(depth+1);\n ne++;\n }\n if(ns > 0){\n h[depth] = 2;\n ns--;\n if(depth%2==0 || h[depth-1] <= h[depth]) brute(depth+1);\n ns++;\n }\n}\n\nint main(){\n int i,j,k,l,m;\n\n res = 0;\n\n scanf(\"%d%d%d\",&nf,&ne,&ns);\n n = nf + ne + ns;\n scanf(\"%d%d%d\",&rf,&re,&rs);\n scanf(\"%d%d\",&df,&de);\n\n Rf = sqrt(rf*rf-1); if(rf==1) Rf = 0;\n Re = sqrt(re*re-1); if(re==1) Re = 0;\n Rs = sqrt(rs*rs-1); if(rs==1) Rs = 0;\n \n brute(0);\n\n printf(\"%.15f\\n\",res);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "d5cd290aff00295b77f6e088b5b657f9", "src_uid": "de5a42225714552cc5422d8a45734d58", "difficulty": 2600.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint f[10],p[10],n,k,dmin;\nchar a[10][10];\nvoid pp(int j){\n\tint i,i1,sum,min,max;\n\tif(j==k){\n\t\tfor(i1=0;i1max)max=sum;\n\t\t\t\tif(summax-min)dmin=max-min;\n\t\treturn;\n\t}\n\tfor(i=0;i\n\n\n\nint main() {\n\tint k;\n\tscanf(\"%d\", &k);\n\tint i;\n\tint count = 1;\n\tint square = 1;\n\tchar cha = 'a';\n\tif(k == 0) {\n\t\tprintf(\"a\\n\"); \n\t\treturn 0;\n\t}\n\twhile(k > 0) {\n\t\twhile(square <= k) {\n\t\t\tcount++;\n\t\t\tsquare += count;\n\t\t}\n\t\tfor(i=0;i\n#include \n#include \n#include \n\n#define MAX (10 << 6)\n\nchar iscomp[MAX];\n\nvoid\ndo_comp (void)\n{\n\tint i;\n\n\tiscomp[1] = 1;\n\n for (i = 2; i < MAX; i++) {\n int jx;\n int sx;\n\n if (iscomp[i]) {\n continue;\n }\n\n for (jx = i; (jx * i) < MAX ;jx++) {\n sx = jx * i;\n if (!iscomp[sx]) iscomp[sx] = 1;\n }\n }\n}\n\nint\nispal (int inp)\n{\n\tint\ti, j;\n\tchar\ttmp[32];\n\tint\tlen;\n\n\tsprintf(tmp, \"%d\", inp);\n\tlen = strlen(tmp)-1;\n\t\n\tfor (i = 0, j = len; i <= j; i++, --j) {\n\t\tif (tmp[i] != tmp[j]) {\n\t\t\treturn 0;\n\t\t}\n\t} \n\t\n\treturn 1;\n}\n\nint\nmain ()\n{\n\tint\ti,n = 1;\n\tint\tp, q;\n\tint\tnpr = 0, npa = 0;\n\tint\tans = 0;\n\n\tdo_comp();\n\tscanf (\"%d%d\", &p, &q);\n\n\tfor (i = 1; i < MAX; i++) {\n\t\tnpa += ispal (i);\n\t\tnpr += !(iscomp[i]);\n\n\t\tif (q * npr <= p * npa) {\n\t\t\tans = i;\n\t\t}\n\t}\n\tif (ans) {\n\t\tprintf (\"%d\\n\", ans);\n\t} else {\n\t\tputs (\"Palindromic tree is better than splay tree\");\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4ebcebe3e9c18417a31ea9402775f3a3", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n\nstruct dxy\n{\n\tlong long d;\n\tlong long x;\n\tlong long y;\n};\n\nlong long gcd(long long a, long long b)\n{\n\t return (a*b == 0) ? (a + b) : gcd(b, a%b);\n}\n\nstruct dxy ext_euc(long long a, long long b)\n{\n\tlong long x, y;\n\tstruct dxy ans;\n\tif (b == 0)\n\t{\n\t\tans.d = a;\n\t\tans.x = 1;\n\t\tans.y = 0;\n\t\treturn ans;\n\t}\n\t\n\tans = ext_euc(b, a%b);\n\tx = ans.y;\n\ty = ans.x - (a/b)*ans.y;\n\t\n\tans.x = x;\n\tans.y = y;\n\treturn ans;\n}\n\nlong long box(long long numer, long long denom)\n{\n\tif (numer % denom == 0 || numer * denom >= 0)\n\t{\n\t\treturn numer / denom;\n\t}\n\t\n\treturn (numer / denom) - 1;\n}\n\nint main()\n{\n\tlong long a1, a2, b1, b2;\n\tlong long L, R;\n\tlong long alpha1, alpha2, r, start, end;\n\tlong long p, p1, q, i, j;\n\tlong long hcf;\n\tstruct dxy temp;\n\t\n\tscanf(\"%lld %lld %lld %lld %lld %lld\", &a1, &b1, &a2, &b2, &L, &R);\n\t\n\thcf = gcd(a1, a2);\n\tif ((b2 - b1) % hcf != 0)\n\t{\n\t\tprintf(\"%d\\n\", 0);\n\t\treturn 0;\n\t}\n\t\n\tr = box((b2 - b1), hcf);\n\talpha1 = box(a1, hcf);\n\talpha2 = box(a2, hcf);\n\t\n\ttemp = ext_euc(alpha1, -alpha2);\n\tp = temp.x * r;\n\tp1 = temp.y * r;\n\tif (temp.d < 0)\n\t{\n\t\tp = -p;\n\t\tp1 = -p1;\n\t}\n\t\n\tstart = box((L-b1), a1) + 1;\n\tstart -= ((L-b1) % a1) == 0 ? 1 : 0;\n\tend = box((R-b1), a1);\n\t\n\tq = box((start-p), alpha2) + 1;\n\tq -= ((start-p) % alpha2) == 0 ? 1 : 0;\n\t\n\tj = 0;\n\tfor (i = q; i <= box((end-p), alpha2); i++)\n\t{\n\t\tif (p + i*alpha2 >=0 && p1 + i*alpha1 >= 0)\n\t\t{\n\t\t\tj++;\n\t\t}\n\t}\n\t\n\t//printf(\"%lld %lld\\n\", start, end);\n\t//printf(\"%lld %lld %lld %lld\\n\", p, p1, q, r);\n\t//printf(\"%lld %lld\\n\", box((end-p), alpha2), box((start-p), alpha2));\n\t/*\n\tif (p + q*alpha2 < 0 || p1 + q*alpha1 < 0)\n\t{\n\t\tprintf(\"%d\\n\", 0);\n\t\treturn 0;\n\t}\n\t*/\n\tprintf(\"%lld\\n\", j);\n\treturn 0;\n}\n\n\n\n\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "77a610cfe82c4dc12b747153662901c2", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "GNU C", "source_code": "#include \n\n#define min(a, b) (((a) < (b)) ? (a) : (b))\n#define max(a, b) (((a) > (b)) ? (a) : (b))\n\n\nint main(void) {\n int i;\n int n;\n int l[5], r[5];\n int val;\n long long cnt[10001];\n double sum, ans;\n\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++)\n scanf(\"%d %d\", l + i, r + i);\n\n sum = 0.0;\n for (val = 1; val <= 10000; val++) {\n int high1, high2, high3, high4, high5;\n int sec1, sec2, sec3, sec4;\n\n cnt[val] = 0;\n\n // high1\u30d1\u30bf\u30fc\u30f3\n // sec1 \u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (sec1 = 0; sec1 < n; sec1++)\n if (high1 != sec1) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1)\n way *= max(r[i] - max(l[i], val + 1) + 1, 0);\n else if (i == sec1)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n // sec2 \u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (sec1 = 0; sec1 < n; sec1++)\n for (sec2 = sec1 + 1; sec2 < n; sec2++)\n if (high1 != sec1 && high1 != sec2) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1)\n way *= max(r[i] - max(l[i], val + 1) + 1, 0);\n else if (i == sec1 || i == sec2)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n // sec3 \u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (sec1 = 0; sec1 < n; sec1++)\n for (sec2 = sec1 + 1; sec2 < n; sec2++)\n for (sec3 = sec2 + 1; sec3 < n; sec3++)\n if (high1 != sec1 && high1 != sec2 && high1 != sec3) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1)\n way *= max(r[i] - max(l[i], val + 1) + 1, 0);\n else if (i == sec1 || i == sec2 || i == sec3)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n // sec4 \u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (sec1 = 0; sec1 < n; sec1++)\n for (sec2 = sec1 + 1; sec2 < n; sec2++)\n for (sec3 = sec2 + 1; sec3 < n; sec3++)\n for (sec4 = sec3 + 1; sec4 < n; sec4++)\n if (high1 != sec1 && high1 != sec2 && high1 != sec3 && high1 != sec4) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1)\n way *= max(r[i] - max(l[i], val + 1) + 1, 0);\n else if (i == sec1 || i == sec2 || i == sec3 || i == sec4)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n\n // high2\u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (high2 = high1 + 1; high2 < n; high2++) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1 || i == high2)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n // high3\u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (high2 = high1 + 1; high2 < n; high2++)\n for (high3 = high2 + 1; high3 < n; high3++) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1 || i == high2 || i == high3)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n // high4\u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (high2 = high1 + 1; high2 < n; high2++)\n for (high3 = high2 + 1; high3 < n; high3++)\n for (high4 = high3 + 1; high4 < n; high4++) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1 || i == high2 || i == high3 || i == high4)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n // high5\u30d1\u30bf\u30fc\u30f3\n for (high1 = 0; high1 < n; high1++)\n for (high2 = high1 + 1; high2 < n; high2++)\n for (high3 = high2 + 1; high3 < n; high3++)\n for (high4 = high3 + 1; high4 < n; high4++)\n for (high5 = high4 + 1; high4 < n; high4++) {\n long long way;\n\n way = 1LL;\n for (i = 0; i < n; i++)\n if (i == high1 || i == high2 || i == high3 || i == high4 || i == high5)\n way *= val >= l[i] && val <= r[i];\n else\n way *= max(min(r[i], val - 1) - l[i] + 1, 0);\n\n cnt[val] += way;\n }\n\n sum += cnt[val];\n }\n\n ans = 0.0;\n for (i = 1; i <= 10000; i++)\n ans += (double)i * cnt[i] / sum;\n\n printf(\"%.15f\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c209031449eaa72b6d519c05b9ec1662", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint ExChange(int a,int b)\n{\n if(a>=b)\n return a;\n else\n return b;\n}\nint main()\n{\n int m,n,Max;\n scanf(\"%d%d\",&n,&m);\n Max=ExChange(m,n);\n if (n==1||m==1)\n printf(\"%d\\n\",n*m);\n\n else if (n==2||m==2)\n {\n if (Max%4==0)\n printf(\"%d\\n\",Max);\n else if (Max%4==1)\n printf(\"%d\\n\",Max+1);\n else\n printf(\"%d\\n\",(Max/4)*4+4);\n }\n else\n printf(\"%d\\n\",(m*n+1)/2);\n return 0;\n}\n\n\n ", "lang_cluster": "C", "compilation_error": false, "code_uid": "716abdd89b7c18f5d415f11e83be3ea5", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n#define MIN(A,B) ((A) < (B)) ? (A) : (B)\n\nlong long int dp[45][3][3];\nint cost[5][5];\n\nlong long int solve(int disk, int from, int to) {\n int aux;\n long long int price1;\n long long int price2;\n\n if (dp[disk][from][to] != -1) {\n return dp[disk][from][to];\n }\n\n for (aux = 0; aux < 3; aux++) {\n if (aux != from && aux != to) {\n break;\n }\n }\n\n if (disk == 1) {\n return MIN(cost[from][to], cost[from][aux] + cost[aux][to]);\n }\n if (disk == 2) {\n price1 = solve(1, from, aux) + cost[from][to] + solve(1, aux, to);\n price2 = solve(1, from, to) + cost[from][aux] + solve(1, to, from) + cost[aux][to] + solve(1, from, to);\n dp[disk][from][to] = MIN(price1, price2);\n return dp[disk][from][to];\n }\n\n price1 = solve(disk - 1, from, aux) + cost[from][to] + solve(disk - 1, aux, to);\n /*price2 = solve(disk - 1, from, aux) + cost[from][to] + cost[aux][from] +\n cost[from][to] + solve(disk - 1, aux, from) + cost[to][from] + solve(disk - 1, from, to); */\n price2 = solve(disk - 1, from, to) + cost[from][aux] + solve(disk - 1, to, from) +\n cost[aux][to] + solve(disk - 1, from, to);\n\n dp[disk][from][to] = MIN(price1, price2);\n\n return dp[disk][from][to];\n}\n\nint main(void) {\n int n;\n int i, j, k;\n\n for (i = 0; i < 3; i++) {\n for (j = 0; j < 3; j++) {\n scanf(\" %d\", &cost[i][j]);\n }\n }\n scanf(\" %d\", &n);\n\n for (k = 0; k <= n; k++) {\n for (i = 0; i < 3; i++) {\n for (j = 0; j < 3; j++) {\n dp[k][i][j] = -1;\n }\n }\n }\n\n printf(\"%I64d\\n\", solve(n, 0, 2));\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "52dbce261d4265625e0fcdfc8006faea", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "GNU C", "source_code": "#include \n\nconst int p = 1000000007;\n\nchar s[101];\n\nint\npow(int a, int b)\n{\n if (b == 0) return 1;\n if (b == 1) return a;\n\n if (b%2) return (a*pow(a*a, b/2))%p;\n \n return pow(a*a, b/2)%p;\n}\n\nint\nmain(void)\n{\n int i, res=1, n;\n\n gets(s);\n \n for (i=0; s[i]; ++i);\n n = i;\n\n if (s[n-1] == '1') res = 1;\n else res = 0;\n\n for (i=n-2; i >= 0; --i)\n {\n if (s[i] == '0') \n {\n res *= 2;\n res %= p;\n }\n else\n {\n res = res*2 + pow(2, 2*(n-i - 1));\n res %= p;\n }\n }\n\n printf(\"%d\\n\", res);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b08e44cde543ab9b3bcc01e6c8b9c624", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t500\n\nint main() {\n\tstatic char s[N + 1];\n\tstatic int dp[N][N];\n\tint n, h, i, j;\n\n\tscanf(\"%d%s\", &n, s);\n\tfor (i = 0, j = 1; j < n; j++)\n\t\tif (s[i] != s[j])\n\t\t\ts[++i] = s[j];\n\tn = i + 1;\n\tfor (i = 0; i < n; i++)\n\t\tdp[i][i] = 1;\n\tfor (i = n - 1; i >= 0; i--)\n\t\tfor (j = i + 1; j < n; j++) {\n\t\t\tdp[i][j] = 1 + dp[i][j - 1];\n\t\t\tfor (h = j - 1; h >= i && s[h] != s[j]; h--)\n\t\t\t\t;\n\t\t\tif (h >= i) {\n\t\t\t\tint x = dp[i][h] + dp[h + 1][j - 1];\n\n\t\t\t\tif (dp[i][j] > x)\n\t\t\t\t\tdp[i][j] = x;\n\t\t\t}\n\t\t}\n\tprintf(\"%d\\n\", dp[0][n - 1]);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "45e2b51abd7dc9ec71ace49ad1af4d38", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar g[64][64];\nint x,y;\n\n#define PUT(a,b) if(a>=0 && a=0 && b=x || b>=y || !g[a][b])\n#define INSIDE(a,b) (a>=0 && b>=0 && a0) {\n ret--;\n put(x2,y2);\n }\n }\n return ret;\n}\n\n \nint main() {\n int best=0,t,cur,i,ans;\n scanf(\"%d %d\",&x,&y);\n if(x>y) t=x,x=y,y=t;\n if(x==1 && y==1) { printf(\"0\\n\"); return 0; }\n if(x==1) {\n printf(\"%d\\n\",y-(y-1)/3-1);\n return 0;\n }\n if(x==3) {\n printf(\"%d\\n\",2*y); return 0;\n }\n if(x==2) {\n ans=0;\n for(i=0;i\n#include \n\nint main() {\n int n;\n scanf(\"%d\", &n);\n char s[n];\n scanf(\"%s\", s);\n char alphabet[26] = \"abcdefghijklmnopqrstuvwxyz\";\n int cur = 25;\n int deleted = 0;\n while(cur != 0 && (n - deleted) != 1) {\n int found = 0;\n // printf(\"Cur: %i Str: %s Del: %i\\n\", cur, s, deleted);\n for (int i = 0; i < (n - deleted); i++) {\n if (alphabet[cur] == s[i]) {\n if (i != (n - deleted) - 1) {\n if (alphabet[cur-1] == s[i+1]) {\n for (int j = i; j < n-1; j++) {\n s[j] = s[j+1];\n }\n s[n - deleted - 1] = '\\0';\n found = 1;\n deleted += 1;\n continue;\n }\n }\n if (i != 0) {\n if (alphabet[cur-1] == s[i-1]) {\n for (int j = i; j < n-1; j++) {\n s[j] = s[j+1];\n }\n s[n - deleted - 1] = '\\0';\n found = 1;\n deleted += 1;\n continue;\n }\n }\n }\n }\n\n if (found == 0) {\n cur -= 1;\n }\n }\n printf(\"%d\", deleted);\n}\n// strcpy(&str[idx_to_delete], &str[idx_to_delete + 1]);\n// RemoveAdjacent.c\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b2a5434195d03f21327107828dc8d1ee", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n , a ,b;\n int diva = 0;\n int divb = 0;\n int totalmatches=0;\n int counter=1;\n\n scanf(\"%d %d %d\" , &n , &a , &b);\n if( ((b > n/2) || (a > n/2)) && ( (b <= n/2) || (a <= n/2)) )\n {\n printf(\"Final!\");\n return 0;\n }\n int temp=n;\n while(temp!=1)\n {\n temp = temp/2;\n totalmatches++;\n }\n totalmatches--;\n if(a%2!=0)\n a = (a+1);\n if(b%2!=0)\n b = (b+1);\n while(1)\n {\n if(a > n/2)\n {\n n=n/2;\n a=a-n;\n b=b-n;\n }\n else\n n=n/2;\n if( ((b > n/2) || (a > n/2)) && ( (b <= n/2) || (a <= n/2)))\n {\n printf(\"%d\" , totalmatches);\n return 0;\n }\n else if(a==b)\n {\n printf(\"1\");\n return 0;\n }\n totalmatches--;\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9cbbcaffbcae5d5eb4bcac9020419e6a", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n\nint main() {\n int sign = 1;\n int current = 0;\n int value = 0;\n\n for(char c; '\\n' != (c = getchar()); ) {\n if(c == '+' or c == '-') {\n value += sign * current;\n sign = (c == '+' ? 1 : -1);\n current = 0;\n }\n\n current *= 10;\n current += c - '0';\n }\n\n printf(\"%d\", value + sign * current);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b96f0ee47e6e185d8269568dbb211494", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\n int len1,len2,k,max=0,i,j,pan=0;\n char s[99999],t[99999];\n int p=0;\n scanf(\"%s\",s);\n scanf(\"%s\",t);\n len1=strlen(s);\n len2=strlen(t);\n int start[10],last[10];\n if(len1==len2)\n {\n max=0;\n pan=1;\n }\n else\n {\n for(i=0; i\n#include \n\nenum {\n N = 1010\n};\nconst int MOD = 1e9 + 7;\n\nint dp[N][2 * N], k, ls;\nchar s[N];\n\n\nint rec(int pos, int dist, int anyDigit) {\n if(pos == ls)\n return dist == 0;\n if(anyDigit && dp[ls - pos][dist] != -1)\n return dp[ls - pos][dist];\n\n int limit = anyDigit ? 9 : s[pos] - '0';\n int ret = 0, i;\n for(i = 0; i <= limit; i++) {\n int ndist = dist + (dist != 0);\n if(i == 4 || i == 7)\n ndist = dist <= k ? 0 : 1;\n ret += rec(pos + 1, ndist, anyDigit || (i < limit));\n while(ret >= MOD)\n ret -= MOD;\n }\n if(anyDigit)\n dp[ls - pos][dist] = ret;\n return ret;\n}\n\nint isLucky() {\n int i, prev = 0;\n while(prev < ls && s[prev] != '4' && s[prev] != '7')\n prev++;\n for(i = prev + 1; i < ls; i++) {\n if(s[i] == '4' || s[i] == '7') {\n if(i - prev <= k)\n return 1;\n prev = i;\n }\n }\n return 0;\n}\n\nint main() {\n int t;\n scanf(\"%d %d\", &t, &k);\n memset(dp, -1, sizeof(dp));\n while(t--) {\n scanf(\"%s\", s);\n ls = strlen(s);\n int val = rec(0, k + 1, 0) - isLucky();\n\n scanf(\"%s\", s);\n ls = strlen(s);\n val = rec(0, k + 1, 0) - val;\n while(val < 0)\n val += MOD;\n while(val >= MOD)\n val -= MOD;\n printf(\"%d\\n\", val);\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "dccd8288d7daf1997da0eaa349d02793", "src_uid": "5517efa2fc9362fdf342d32adac889f4", "difficulty": 2500.0} {"lang": "GNU C11", "source_code": "#include\nint dp[200][101][101][11][11];\nint n1, n2, k1, k2;\nint call(int i, int x, int y, int x1, int y1)\n{\n\tif(i>=(n1+n2)) return 1;\n\tif(dp[i][x][y][x1][y1]==-1){\n\t\tint r=0;\n\t\tif(x1\n#include \nint main() {\n\tlong long s,x,S,X;\n\tscanf(\"%lld %lld\",&s,&x);\n\tint a[50]={0},b[50]={0},ci[50]={0},co[50]={0};\n\tint i,a1,a2,max;\n\tint count=0,count1=0;\n\tlong long ans=0;\n\tS=s;\n\tX=x;\n\tfor(i=0;;i++)\n\t{\n\t\ta[i]=s%2;\n\t\ts=s/2;\n\t\ta1=i;\n\t\tif(s==0)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(i=0;;i++)\n\t{\n\t\tb[i]=x%2;\n\t\tif(b[i]==1)\n\t\tcount++;\n\t\tx=x/2;\n\t\ta2=i;\n\t//\tprintf(\"%d \",b[i]);\n\t\tif(x==0)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(a1>a2)\n\t{\n\t\tmax=a1;\n\t}\n\telse\n\t{\n\t\tmax=a2;\n\t}\n\t//printf(\"\\n\");\n\tfor(i=0;i<=max;i++)\n\t{\n\t\tci[i]=a[i]^b[i];\n\t//\tprintf(\"%d \",ci[i]);\n\t}\n\tprintf(\"\\n\");\n\tfor(i=0;i<=max;i++)\n\t{\n\t\tco[i]=ci[i+1];\n\t//\tprintf(\"%d \",co[i]);\n\t}\n\tfor(i=0;i<=max;i++)\n\t{\n\t\tif((b[i]==1&&co[i]==0)||(b[i]==1&&ci[i]==1&&co[i]==1))\n\t\t{\n\t\t\tcount1++;\n\t\t}\n\t\tif((b[i]==1&&ci[i]==1&&co[i]==0))\n\t\t{\n\t\t\tcount1--;\n\t\t}\n\t}\n\t//printf(\"%d %d \",count,count1);\n\tans=pow(2,count);\n\tif(S==X)\n\t{\n\t\tans=ans-2;\n\t}\n\tif(ci[0]==1||(count!=count1)||(S\nlong long int abs(long long int n)\n{\n\tif (n < 0)\n\t\tn *= -1;\n\treturn n;\n}\nint main()\n{\n\tlong long int x0, y0, ax, ay, bx, by;\n\tscanf(\"%lld %lld %lld %lld %lld %lld\", &x0, &y0, &ax, &ay, &bx, &by);\n\tlong long int xs, ys, t;\n\tscanf(\"%lld %lld %lld\", &xs, &ys, &t);\n\tlong long int max = 10000000000000016;\n\tlong long int x[102], y[102];\n\tx[0] = x0;\n\ty[0] = y0;\n\tlong long int i, j;\n\tfor (i = 0; x[i] <= max && y[i] <= max; i++)\n\t{\n\t\tx[i + 1] = ax * x[i] + bx;\n\t\ty[i + 1] = ay * y[i] + by;\n\t}\n\tlong long int c = i;\n\tlong long int ans = 0;\n\tfor (i = 0; i < c; i++)\n\t\tfor (j = 0; j < c; j++)\n\t\t\tif (abs(xs - x[i]) + abs(ys - y[i]) + abs(x[i] - x[j]) + abs(y[i] - y[j]) <= t)\n\t\t\t\tif (ans < abs(i - j) + 1)\n\t\t\t\t\tans = abs(i - j) + 1;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "4b5b39dda487ea271d9c878cf841b8a2", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#define M 1000000007LL\nconst long long MSQ = M * M;\ninline int mul(int a, int b) { return int(a * 1LL * b % M); }\ninline int powr(int a, int b) {\n int ans = 1;\n while (b) {if (b & 1) ans = mul(ans, a); a = mul(a, a); b >>= 1;}\n return ans;\n}\nint main(){\n int n, k, i, j, c, d;\n long long x, y, z, u, v, res;\n scanf(\"%d %d\", &n, &k);\n if (k == 0) res = n;\n else{\n if (n <= (k + 1)){\n for (i = 1, res = 0; i <= n; i++) res += powr(i, k);\n }\n else{\n res = 0;\n u = 1, v = 1, z = 0;\n for (i = 0; i <= (k + 1); i++){\n u = (u * (n - i)) % M;\n if (i) v = ((v * -i) + MSQ) % M;\n }\n for (i = 0, c = 1, d = k + 1; i <= (k + 1); i++, c++, d--){\n z = (z + powr(i, k)) % M;\n x = (u * z) % M;\n x = (x * powr(n - i, M - 2)) % M;\n y = ((x * powr(v, M - 2)) % M);\n v = (v * c) % M;\n if (d) v = (v * powr(d, M - 2)) % M;\n if (i & 1) y = M - y;\n res += y;\n }\n }\n }\n printf(\"%lld\\n\", res % M);\n return 0;\n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "0e4054e72903384d97100f5edd87583e", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "#include \n#define max(a,b) (((a)>(b)) ? (a) : (b))\n\nint main()\n{\n\tint n, m, c0, d0, i, j, t;\n\tscanf(\"%d %d %d %d\",&n,&m,&c0,&d0);\n\tint arr[m+1][4];//[0] ai,[1] bi, [2] ci, [3] di\n\tint max_num[m+1];\n\tfor(i = 0; i < m;i++){\n\t\tscanf(\"%d %d %d %d\",&arr[i][0],&arr[i][1],&arr[i][2],&arr[i][3]);\n\t}\n\tarr[m][2] = c0;arr[m][3] = d0;\n\tfor(i = 0;i < m; i++){\n\t\tmax_num[i] = arr[i][0] / arr[i][1];\n\t}max_num[m] = n / c0;\n\tint dp[n+1] = {0};\n\tfor(i = 0; i < m+1; i++){\n\t\tfor(j = 0; j < max_num[i];j++){\n\t\t\tfor(t = n+1; t >= arr[i][2];t--){\n\t\t\t\tdp[t] = max(dp[t], dp[t-arr[i][2]] + arr[i][3]);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\", dp[n]);\n}\n", "lang_cluster": "C", "compilation_error": true, "code_uid": "425be8f4099d43cdd567de17b57f151c", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include\n#define m 1000000007\nlong long int power(long long int x,long long int y)\n { long long int p;\n if(y==1)\n return(x%m);\n else\n {p=power(x,y/2)%m;\n if(y%2==0)\n return((p*p)%m);\n else\n return((x*p*p)%m);}\n }\nint main()\n{\n long long int n,a[40] = {1, 2, 4, 6, 12, 16, 18, 30, 60, 88, 106, 126, 520, 606, 1278, 2202, 2280, 3216, 4252, 4422, 9688, 9940, 11212, 19936, 21700, 23208, 44496, 86242, 110502, 132048, 216090, 756838, 859432, 1257786, 1398268, 2976220, 3021376, 6972592, 13466916, 20996010};\nlong long int r;\nscanf(\"%I64d\",&n);\nr=power(2,a[n-1]);\nprintf(\"%I64d\",r-1);\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c64df143fd7a458db39f7f7a9a6f4ac1", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nint md;\n\nlong long power(int a, long long k) {\n\tlong long p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k / 2);\n\tp = p * p % md;\n\tif (k % 2)\n\t\tp = p * a % md;\n\treturn p;\n}\n\nvoid mult(int aa[][2], int bb[][2], int cc[][2]) {\n\tint i, j, k;\n\n\tfor (i = 0; i < 2; i++)\n\t\tfor (j = 0; j < 2; j++) {\n\t\t\tlong long c = 0;\n\n\t\t\tfor (k = 0; k < 2; k++)\n\t\t\t\tc += (long long) aa[i][k] * bb[k][j];\n\t\t\tcc[i][j] = c % md;\n\t\t}\n}\n\nvoid power_(int aa[][2], int pp[][2], int tt[][2], long long k) {\n\tif (k == 0) {\n\t\tpp[0][0] = pp[1][1] = 1;\n\t\tpp[0][1] = pp[1][0] = 0;\n\t\treturn;\n\t}\n\tif (k % 2 == 0) {\n\t\tpower_(aa, tt, pp, k / 2);\n\t\tmult(tt, tt, pp);\n\t} else {\n\t\tpower_(aa, pp, tt, k / 2);\n\t\tmult(pp, pp, tt);\n\t\tmult(tt, aa, pp);\n\t}\n}\n\nint main() {\n\tstatic int aa[2][2], pp[2][2], tt[2][2];\n\tlong long n, k, x0, x1, ans;\n\tint l, h;\n\n\tscanf(\"%lld%lld%d%d\", &n, &k, &l, &md);\n\tif (l < 64 && k >= 1LL << l) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\taa[0][0] = 1, aa[0][1] = 1;\n\taa[1][0] = 1, aa[1][1] = 0;\n\tpower_(aa, pp, tt, n);\n\tx0 = (pp[0][0] + pp[0][1]) % md;\n\tx1 = (power(2, n) - x0 + md) % md;\n\tans = 1;\n\tfor (h = 0; h < l; h++)\n\t\tans = ans * ((k & 1LL << h) == 0 ? x0 : x1) % md;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3ef814d182d78ecd59b798d803413b8e", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include\n\nint Length(long long int x)\n{\n\tint cnt = 0;\n\twhile(x)\n\t{\n\t\tx /= 10;\n\t\tcnt++;\n\t}\n\treturn cnt;\n}\n\nint main()\n{\n\tlong long int a, b;\n\tscanf(\"%I64d %I64d\", &a, &b);\n\tint digitA[15] = {};\n\tint digitB[20] = {};\n\tlong long int c = a;\n\twhile(c)\n\t{\t\n\t\tdigitA[c%10] ++;\n\t\tc /= 10;\n\t}\n\tif(Length(a) < Length(b))\n\t{\n\t\tfor(int i=9; i>=0; i--)\n\t\t{\n\t\t\tfor(int j=0; j= 0 && digitA[digitB[num]] >= 1)\n\t\t{\n\t\t\tprintf(\"%d\", digitB[num]);\n\t\t\tdigitA[digitB[num]]--;\n\t\t\tnum --;\n\t\t}\n\t\tif(num >= 0)\n\t\t{\n\t\t\tfor(int i=digitB[num]-1; i>=0; i--)\n\t\t\t\tif(digitA[i])\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%d\", i);\n\t\t\t\t\tdigitA[i] --;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\n\t\t\tfor(int i=9; i>=0; i--)\n\t\t\t{\n\t\t\t\tfor(int j=0; j\nlong long dp(int,int,char);\nlong long dar[1003][102],MOD,powmod[1003],modmod[1003];\nint n,k;\nint main(){\n\tint i,j,l;\n\tscanf(\"%d %d %d\",&n,&k,&i);\n\tMOD=(long long)i;\n\tpowmod[0]=1%k;\n\tmodmod[0]=1%MOD;\n\tfor(i=1;i<=n;i++){\n\t\tpowmod[i]=(powmod[i-1]*10)%k;\n\t\tmodmod[i]=(modmod[i-1]*10)%MOD;\n\t}\n\tfor(i=0;i<1003;i++){\n\t\tfor(j=0;j<102;j++){\n\t\t\tdar[i][j]=-1;\n\t\t}\n\t}\n\tdar[n][0]=1;\n\tfor(i=n-1;i>0;i--){\n\t\tdar[i][0]=(9*modmod[n-1-i])%MOD;\n\t}\n\tprintf(\"%d\\n\",(int)dp(0,0,0));\n\treturn 0;\n}\n\nlong long dp(int dig,int mod,char fl){\n\tlong long toret;\n\tint i;\n\tif(dig>n){\n\t\treturn 0;\n\t}\n\tif(fl&&mod==0){\n\t\treturn dar[dig][0];\n\t}\n\tif(fl==0||dar[dig][mod]==-1){\n\t\ttoret=0;\n\t\ttoret+=dp(dig+1,mod,fl);\n\t\tfor(i=1;i<10;i++){\n\t\t\ttoret=(toret+dp(dig+1,(mod+i*powmod[dig])%k,1))%MOD;\n\t\t}\n\t\tif(fl!=0){\n\t\t\tdar[dig][mod]=toret;\n\t\t}\n\t}\n\telse{\n\t\ttoret=dar[dig][mod];\n\t}\n\treturn toret;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ab3e6aa640c5bee4fc8fbb8327ddeac4", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint main(){\nchar a[10];\nscanf(\"%s\",a);\nint n=0;\nif((a[0]=='J')&&(a[1]=='U')&&(a[2]=='R')&&(a[3]=='O')&&(a[4]=='R')){\n\n}\n\nelse for (int i=0;a[i]!='\\0';i++){\n if((a[i]=='B')||(a[i]=='C')||(a[i]=='D')||(a[i]=='G')||(a[i]=='J')||(a[i]=='O')||(a[i]=='P')||(a[i]=='Q')||(a[i]=='R')||(a[i]=='S')||(a[i]=='U')){\n n++;\n\n\n }\n\n\n\n}\n if(n!=0){printf(\"NO\");}\n else {printf(\"YES\");}\n\n\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3a514dbebd0e7f4af00e49a4eff76a20", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\ntypedef long long int lli;\n\n#define TRUE (1==1)\n#define FALSE (!(TRUE))\n#define in32(x) scanf(\"%d\", &(x))\n#define in64(x) scanf(\"%I64d\", &(x))\n#define instr(x) scanf(\"%s\", (x))\n#define out32(x) printf(\"%d\\n\", (x))\n#define out64(x) printf(\"%I64d\\n\", (x))\n#define outstr(x) printf(\"%s\\n\", (x))\n#define max(a,b) ((a)<(b))?(b):(a)\n#define min(a,b) ((a)>(b))?(b):(a)\n#define abs(a) ((a)<0)?(-(a)):(a)\n#define fo3(i,a,b) for(i=(int)(a);i<=(int)(b);i++)\n#define of3(i,a,b) for(i=(int)(a);i>=(int)(b);i--)\n\n#define MOD 998244353\n#define MAX 5005\n#define SENT -1\n\ntypedef struct Pair {\n int fi, se;\n} Pair; \n\nint comp(Pair * f, Pair * s) {\n return (f->fi - s->fi);\n}\n\nvoid sort(Pair ** arr, int size) { // CHANGE THIS\n int i;\n if (size < 6) {\n int nSize = 0;\n int s = size;\n while (size != 0) {\n nSize = 0;\n for (i = 0; i < size - 1; i++) \n if (comp(arr[i], arr[i+1]) > 0) { // CHANGE THIS\n Pair * tmp = arr[i];\n arr[i] = arr[i+1];\n arr[i+1] = tmp;\n nSize = i+1;\n }\n size = nSize;\n }\n return;\n }\n Pair ** tmp = (Pair **)calloc(size, sizeof(Pair *)); // CHANGE THIS\n int lSize = (size >> 1);\n int rSize = size - lSize;\n sort(arr, lSize); sort(arr + lSize, rSize);\n int lPtr = 0, rPtr = 0;\n int ptr = 0;\n while (ptr != size) {\n if (lPtr == lSize)\n tmp[ptr] = arr[lSize + (rPtr++)];\n else if (rPtr == rSize || comp(arr[lPtr], arr[lSize + rPtr]) <= 0) // CHANGE THIS\n tmp[ptr] = arr[lPtr++];\n else\n tmp[ptr] = arr[lSize + (rPtr++)];\n ptr++;\n }\n for (i = 0; i < size; i++)\n arr[i] = tmp[i];\n free(tmp);\n}\n \n \nint main(void) {\n int i, n, m;\n in32(n);\n in32(m);\n int need[n];\n fo3(i,0,n-1) \n in32(need[i]);\n Pair ** p = calloc(m, sizeof(Pair*));\n fo3(i,0,m-1) {\n p[i] = calloc(1,sizeof(Pair));\n in32(p[i]->fi);\n in32(p[i]->se);\n }\n sort(p,m);\n lli pos = 2000000, min = 0, max = 2000000 - 1;\n int have[n];\n while (min <= max) {\n lli mid = (min + max) >> 1;\n fo3(i,0,n-1)\n have[i] = 0;\n lli spent = 0;\n lli maxDay = mid;\n of3(i,m-1,0) {\n int day = p[i]->fi;\n if (day > mid)\n continue;\n int ind = p[i]->se-1;\n int miss = need[ind] - have[ind];\n if (maxDay > day)\n maxDay = day;\n int buy = miss;\n if (buy > maxDay)\n buy = maxDay;\n have[ind] += buy;\n maxDay -= buy;\n spent += buy;\n }\n fo3(i,0,n-1)\n spent += ((need[i] - have[i])<<1);\n if (spent <= mid) {\n pos = mid;\n max = mid - 1;\n } else\n min = mid + 1;\n }\n out64(pos);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "81538130cafb77a179cb2e4cec24e2c5", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\n\nint N, M;\nlong long ans;\n\nint main()\n{\n\tscanf(\"%d%d\",&N,&M);\n\tregister int z, y, x;\n\tfor (x=M+1;2*x<=N+1;x++)\n\t{\n\t\tint st=(N-M-2*x)*(N+1-x)/(M-N-x);\n\t\tif (st<=M) st=M+1;\n\t\tans+=(st-M-1)*(N-M-M);\n\t\ty=x*(2*(N+1-x)-z)/(N+1-x+z);\n\t\tif (y>N-M) y=N-M;\n\t\tfor (z=st,y=N-M; z<=N-M && y>M; z++)\n\t\t{\n\t\t\twhile (y>M && (x-N-1)*(x+x-y)+(x+y)*z>=0) y--;\n\t\t\tans+=(y-M)*((2*x\n#include\n\nint main()\n{\n int d,y,p,page,sr;\n scanf(\"%d %d\",&d,&y);\n page=0;\n while(y--)\n {\n\n sr=(int)sqrt(d);\n if((sr*sr)==d)\n {\n page+=1;\n }\n else\n {\n while(sr--)\n {\n if(d%(sr*sr)==0)\n {\n p=d/(sr*sr);\n if((sr*sr)*p==d)\n {\n page+=p;\n break;\n }\n else\n {\n sr--;\n } \n } \n }\n \n }\n d++;\n }\n \n printf(\"%d\",page);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "35d941a2129b387ef42b1dfdbb093db1", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "#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\nint cmpfunc (const void * a, const void * b){\n\t//qsort(values, 5, sizeof(int), cmpfunc);\n\treturn ( *(int*)a - *(int*)b );\n}\n\nlong long min(long long a,long long b){\n\treturn a < b ? a : b;\n}\n\nlong long max(long long a,long long b){\n\treturn a > b ? a : b;\n}\n// long long ncr(int n, int k) \n// { \n// long long C[k+1]; \n// memset(C, 0, sizeof(C)); \n// \tint i;\n// \tint j;\n// C[0] = 1; // nC0 is 1 \n \n// for (i = 1; i <= n; i++) \n// { \n// // Compute next row of pascal triangle using \n// // the previous row \n// for ( j = min(i, k); j > 0; j--) \n// C[j] = C[j] + C[j-1]; \n// } \n// return C[k]; \n// } \n\nvoid solve(int t){\n\tint n,k;\n\tscanf(\"%d%d\",&n,&k);\n\tint a[n];\n\tint i,j;\n\tfor(i = 0;i < n;i++){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\n\t// printf(\"Case #%d: %ld\\n\",t,count);\t\n}\n\nlong long gcd(long long a , long long b)\n{\n if(b==0) return a;\n a%=b;\n return gcd(b,a);\n}\n\nint main(){\n\tint n,k,a,b;\n\tscanf(\"%d%d\",&n,&k);\n\tscanf(\"%d%d\",&a,&b);\n\tint i,j;\n\tlong long maximum = LONG_MIN, minimum = LONG_MAX;\n\tlong long l = a-b;\n\tlong long total = (long long)n*k;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tl = a+b;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tl = k-a+b;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tl = k-a-b;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tprintf(\"%I64d %I64d\\n\",minimum,maximum);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "5d769011aba600efff0f74f1ca87afd9", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include\nchar mp[9][9];\nint dir;\nint n,m,x,y;\nint get_dis(int dir){\n if(dir==0&&y==m)return 100;\n if(dir==1&&x==n)return 100;\n if(dir==0){\n for(int i=y+1;i<=m;i++)\n if(mp[x][i]=='*')return i-y;\n }else\n for(int i=x+1;i<=n;i++)\n if(mp[i][y]=='*')return i-x;\t\n return 100;\n}\n\nint main(void){\n scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=n;i++)scanf(\"%s\",mp[i]+1);\n dir=0;\n int ans=0;\n x=1;y=1;\n for(int i=0;i\n\nint main()\n{\n int n, m = 1e9, i;\n\n scanf(\"%d\", &n);\n\n for (i = 1; i <= n; i++) {\n\t int p = n, q = i, c = 0;\n\n\t while (1) {\n\t if (p == q) {\n\t\t if (p > 1) c = -1;\n\n\t\t break;\n\t }\n\n\t if (p > q) {\n\t\t if (q == 1) {\n\t\t\t c += p - 1;\n\n\t\t\t break;\n\t\t }\n\n\t\t p -= q;\n\t } else {\n\t\t if (p == 1) {\n\t\t\t c += q - 1;\n\n\t\t\t break;\n\t\t }\n\n\t\t q -= p;\n\t }\n\n\t c++;\n\t }\n\n\t if (c >= 0 && c < m) m = c;\n }\n\n printf(\"%d\\n\", m);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "25819864855b1f80ce82e99156994240", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(){\n int i, num, flag=0;\n char str[11];\n scanf(\"%s\", str);\n num = strlen(str);\n if(num == 1){\n if(str[0] != '3' || str[0] != '7'){\n printf(\"No\\n\");\n }\n else\n printf(\"Yes\\n\");\n }\n else{\n for(i=0; i\n#define MOD 998244353\n\n__int64 Pow(__int64 a, __int64 b)\n{\n if (b == 0) return 1;\n\tif (b % 2 > 0) return (Pow(a, b - 1) * a) % MOD;\n\t__int64 half = Pow(a, b / 2) % MOD;\n\treturn (half * half) % MOD;\n}\n__int64 nCr(__int64 n, __int64 r)\n{\n __int64 A = 1; // A = n!, B = (n-r)!r!\n __int64 B = 1;\n __int64 ans;\n __int64 i;\n\n for(i=1;i<=n;i++)\n {\n A *= i;\n A %= MOD;\n }\n for(i=1;i<=n-r;i++)\n {\n B *= i;\n B %= MOD;\n }\n for(i=1;i<=r;i++)\n {\n B *= i;\n B %= MOD;\n }\n __int64 B2 = Pow(B, MOD-2);\n ans = (A * B2) % MOD;\n return ans;\n}\n\nint main(void)\n{\n __int64 size, max;\n __int64 ans;\n\n while(scanf(\"%lld %lld\", &size, &max))\n { \n ans = nCr(max, size - 1) * (size-2) % MOD;\n ans = (ans * Pow(2, size-3)) % MOD;\n printf(\"%lld\\n\", ans);\n }\n \n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "7c8de9be0c54b3a576167cb968cf32b8", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n#define MOD (1000000007ULL)\n#define min(a, b) ( ((a) < (b)) ? (a) : (b) )\n\nunsigned long long cnk[101][101], pows[101], pows2[101][101], dp[101][10001];\n\nunsigned long long quick_pow(unsigned long long a, unsigned long long n)\n{\n if (n == 0) {\n return 1;\n } else if ((n & 1ULL) == 0) {\n unsigned long long tmp = quick_pow(a, n / 2ULL);\n return (tmp * tmp) % MOD;\n } else {\n return (quick_pow(a, n - 1) * a) % MOD;\n }\n}\n\nvoid count_cnk(void)\n{\n int i, j;\n cnk[0][0] = 1;\n for(i = 1; i < 101; ++i){\n cnk[i][0] = 1;\n for(j = 1; j < 101; ++j){\n cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % MOD;\n }\n }\n}\n\nint\nmain(void)\n{\n int i, j, t;\n unsigned long long n, m, k;\n\n count_cnk();\n\n scanf(\"%I64u%I64u%I64u\", &n, &m, &k);\n\n unsigned long long rem = m % n;\n for (i = 1; i <= n; ++i) {\n if (rem) {\n pows[i] = m / n + 1;\n --rem;\n } else {\n pows[i] = m / n;\n }\n for (j = 0; j <= n; ++j) {\n pows2[i][j] = quick_pow(cnk[n][j], pows[i]);\n }\n }\n\n dp[0][0] = 1;\n for (i = 1; i <= n; ++i) {\n for (j = 0; j <= min(k, i * n); ++j) {\n for (t = 0; t <= min(n, j); ++t) {\n dp[i][j] = (dp[i][j] + dp[i - 1][j - t] * pows2[i][t]) % MOD;\n }\n }\n }\n\n printf(\"%I64u\", dp[n][k]);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8b2ce68c93706fc923385a3566555db5", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint n;\n\ndouble p(double a, double e) {\n return a / e;\n}\ndouble q(double a, double b, double c, double d, double e, double f) {\n return (a / d) * (b / e) * (c / f);\n}\n\ndouble solve(int k) {\n const double q3 = q(k, k-1, k-2, n, n-1, n-2);\n const double q0 = q(n-k, n-k-1, n-k-2, n, n-1, n-2);\n const double q11 = q(k, n-k, n-k-1, n, n-1, n-2);\n const double q10 = 2 * q11;\n const double q20 = q(k, k-1, n-k, n, n-1, n-2);\n const double q21 = 2 * q20;\n const double res = q3 + q10 + q20 + q21;\n assert(res >= 0.);\n assert(res <= 1.);\n return res;\n}\n\nint main(void) {\n double p;\n scanf(\"%d%lf\", &n, &p);\n int l = 0, r = n - 1;\n if (p == 0) {\n puts(\"0\");\n return 0;\n }\n while (l + 1 < r) {\n const int m = (l + r) >> 1;\n if (solve(m) >= p) {\n r = m;\n } else {\n l = m;\n }\n }\n assert(r > 0);\n assert(r < n);\n printf(\"%d\\n\", r);\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "85e971ffaf5bfc6c036f775d16d7467e", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n\nint main () {\n\tchar input_1[2] = {0};\n\tchar input_2[2] = {0};\n\tchar input[4] = {0};\n\tchar check_1[2] = {0};\n\tchar check_2[2] = {0};\n\tchar check[4] = {0};\n\tint i =0;\n\tint idx = 0;\n\tint input_posi_x = 0;\n\tint check_idx = 0;\n\tchar temp;\n\t\n\tscanf(\"%s\", input_1);\n\tscanf(\"%s\", input_2);\n\tscanf(\"%s\", check_1);\n\tscanf(\"%s\", check_2);\n\n\tfor (i =0; i<2; i++) {\n\t\tif (input_1[i] == 'X')\n\t\t\tidx =i;\n\t\telse if (check_1[i] == 'X')\n\t\t\tcheck_idx = i;\n\t\tinput[i] = input_1[i];\n\t\tcheck[i] = check_1[i];\n\t}\n\t//printf(\"%d\\n\\n\", i);\n\tfor (; i<4; i++) {\n\t\tif (input_2[i-2] == 'X')\n\t\t\tidx =i;\n\t\telse if (check_2[i-2] == 'X')\n\t\t\tcheck_idx =i;\n\t\tinput[i] = input_2[i-2];\n\t\tcheck[i] = check_2[i-2];\n\t}\n\t/*for (i =0; i<4; i++) {\n\t\tprintf(\"%c %c\\n\", input[i], check[i]);\n\t}*/\n\t//printf(\"%d %d\", idx, check_idx);\n\tif (idx%2 == idx/2) {\n\t\tinput_posi_x = 1<<1 && 1<<2;\n\t} else {\n\t\tinput_posi_x = 1<<0 && 1<<3;\n\t}\n\n\tif (!(input_posi_x && (1 << check_idx))) {\n\t\tprintf(\"NO\");\n\t\treturn 0;\n\t} else {\n\t\ttemp = input[idx];\n\t\tinput[idx] = input[check_idx];\n\t\tinput[check_idx] = temp;\n\t\tfor (i=0; i<4; i++) {\n\t\t\tif(input[i] != check[i]) {\n\t\t\t\tprintf(\"NO\");\n\t\t\t\treturn 0;\t\n\t\t\t}\n\t\t}\n\t\tprintf(\"YES\");\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "51d2605f8e4a37c3fdec355cfd7de0f2", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "GNU C", "source_code": "#include\nint x[100100];\nint main()\n{\nlong long i,j,k,n,max,min;\nmax=0;\nmin=-1;\nscanf(\"%I64d\",&n);\nfor(i=1;i<=n;i++)\n for(j=1;j<=n;j++)\n{\n\n if(i*j>n)\n break;\n for(k=j;k<=n;k++)\n {\n if(i*j*k>n)\n break;\nif(i*j*k==n)\n{\n\n if(min==-1)\n min=(i+1)*(j+2)*(k+2);\n else if((i+1)*(j+2)*(k+2)\n#include\nint n,m;\nint s[107],d[107],c[107];\nint ix[107];\nint r[107];\nint slt(const void *p,const void *q){\n\treturn d[*((int *)p)]-d[*((int *)q)];\n}\nvoid run(){\n\tint i,j,k;\n\twhile(scanf(\"%d%d\",&n,&m)!=EOF){\n\t\tfor(i=0;i\n#include \n#include \n\n\nint min(int a, int b)\n{\n\tif(a < b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\n\nint max(int a, int b)\n{\n\tif(a > b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\n\tfor(int i=0; i=0; i--)\n\t{\n\t\tdsc[i][0] = a[i] + min( dsc[i+1][0], dsc[i+1][1] );\n\t\tdsc[i][1] = max( dsc[i+1][0], dsc[i+1][1] );\n\t}\n\n\tprintf(\"%d %d\\n\",min(dsc[0][0],dsc[0][1]),max(dsc[0][0],dsc[0][1]) ) ;\n\n\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "21ee4e297dd449e01086da5b78e4d8c9", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/blog/entry/451 */\n#include \n\n#define N\t150\n#define M\t50\n#define MD\t51123987\n\nint main() {\n\tstatic char cc[N + 1];\n\tstatic int next[N][3], dp[N + 1][M + 1][M + 1][M + 1];\n\tint n, m, i, a, ka, kb, kc, ans;\n\n\tscanf(\"%d%s\", &n, cc), m = (n + 2) / 3;\n\tif (n < 3) {\n\t\tprintf(n == 1 || cc[0] != cc[1] ? \"1\\n\" : \"0\\n\");\n\t\treturn 0;\n\t}\n\tfor (i = n - 1; i >= 0; i--)\n\t\tfor (a = 0; a < 3; a++)\n\t\t\tnext[i][a] = cc[i] == a + 'a' ? i : (i + 1 == n ? n : next[i + 1][a]);\n\tdp[0][0][0][0] = 1;\n\tfor (i = 0; i < n; i++)\n\t\tfor (ka = 0; ka <= m; ka++)\n\t\t\tfor (kb = 0; kb <= m; kb++)\n\t\t\t\tfor (kc = 0; kc <= m; kc++) {\n\t\t\t\t\tint x = dp[i][ka][kb][kc], j;\n\n\t\t\t\t\tif (x == 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif ((j = next[i][0]) < n)\n\t\t\t\t\t\tdp[j][ka + 1][kb][kc] = (dp[j][ka + 1][kb][kc] + x) % MD;\n\t\t\t\t\tif ((j = next[i][1]) < n)\n\t\t\t\t\t\tdp[j][ka][kb + 1][kc] = (dp[j][ka][kb + 1][kc] + x) % MD;\n\t\t\t\t\tif ((j = next[i][2]) < n)\n\t\t\t\t\t\tdp[j][ka][kb][kc + 1] = (dp[j][ka][kb][kc + 1] + x) % MD;\n\t\t\t\t}\n\tans = 0;\n\tif (n % 3 == 0) {\n\t\tka = m, kb = m, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t} else if (n % 3 == 1) {\n\t\tka = m - 1, kb = m - 1, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m, kb = m - 1, kc = m - 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m - 1, kb = m, kc = m - 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t} else {\n\t\tka = m - 1, kb = m, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m, kb = m - 1, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m, kb = m, kc = m - 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2be4f644149e3ea815f2720c1040c914", "src_uid": "64fada10630906e052ff05f2afbf337e", "difficulty": 2500.0} {"lang": "GNU C", "source_code": "#include\n#define MAX(x, y) (((x) > (y)) ? (x) : (y))\nint main()\n{\n long long int a,b,c,d,move,move_p,move_v;\n scanf(\"%lld %lld %lld %lld\",&a,&b,&c,&d);\n if(ad)||(a>c&&bc&&b>d)){\n move_p=a+b;\n move_v=MAX(c,d);\n if(move_p<=move_v)printf(\"Polycarp\");\n else printf(\"Vasiliy\");\n }\n else if(a==c&&b\n#include \n#include \n\nlong long int M(long long int n) {\n\tlong long int r = 0;\n\tfor(int k = 2 ; k <= pow(n, 1./3.) ; k++) {\n\t\tr += (long long int)((float)n / k / k / k);\n\t}\n\treturn r;\n}\n\nlong long int bs(long long int m) {\n\tlong long int l = 1, r = 200000, c, mm;\n\twhile(l < r) {\n\t\tc = l + r >> 1;\n\t\tmm = M(c);\n\t\tif(mm >= m) {\n\t\t\tr = c;\n\t\t} else {\n\t\t\tl = c + 1;\n\t\t}\n\t}\n\tif(M(c) == m) return c;\n\treturn -1;\n}\n\nint main() {\n\tlong long int m;\n\tscanf(\"%I64d\", &m);\n\tprintf(\"%I64d\\n\", bs(m));\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "57b030f72220a1428d159bb5ebdb32da", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t10\n#define INF\t0x3f3f3f3f\n\nint kx[] = { -1, -1, 1, 1, -2, -2, 2, 2 }, ky[] = { -2, 2, -2, 2, -1, 1, -1, 1 };\nint bx[] = { -1, -1, 1, 1 }, by[] = { -1, 1, -1, 1 };\nint rx[] = { -1, 1, 0, 0 }, ry[] = { 0, 0, -1, 1 };\n\nint n, d1[N * N * 3], d2[N * N * 3];\nint qq[N * N * 3], head, cnt;\n\nvoid move(int *xx, int *yy, int i, int j, int h, int m, int l) {\n\tint ijh = (i * n + j) * 3 + h;\n\tint k, g;\n\n\tfor (k = 1; k <= l; k++)\n\t\tfor (g = 0; g < m; g++) {\n\t\t\tint i_ = i + k * xx[g], j_ = j + k * yy[g];\n\n\t\t\tif (i_ >= 0 && i_ < n && j_ >= 0 && j_ < n) {\n\t\t\t\tint ijh_ = (i_ * n + j_) * 3 + h;\n\n\t\t\t\tif (d1[ijh_] > d1[ijh] + 1 || (d1[ijh_] == d1[ijh] + 1 && d2[ijh_] > d2[ijh])) {\n\t\t\t\t\tif (d1[ijh_] == INF)\n\t\t\t\t\t\tqq[head + cnt++] = ijh_;\n\t\t\t\t\td1[ijh_] = d1[ijh] + 1;\n\t\t\t\t\td2[ijh_] = d2[ijh];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n}\n\nvoid bfs(int i, int j, int h) {\n\tint nn3, ijh;\n\n\tnn3 = n * n * 3;\n\tfor (ijh = 0; ijh < nn3; ijh++)\n\t\td1[ijh] = d2[ijh] = INF;\n\thead = cnt = 0;\n\tijh = (i * n + j) * 3 + h;\n\td1[ijh] = d2[ijh] = 0;\n\tqq[head + cnt++] = ijh;\n\twhile (cnt) {\n\t\tint h_, ijh_;\n\n\t\tijh = qq[cnt--, head++];\n\t\ti = ijh / 3 / n; j = ijh / 3 % n, h = ijh % 3;\n\t\tfor (h_ = 0; h_ < 3; h_++) {\n\t\t\tijh_ = ijh / 3 * 3 + h_;\n\t\t\tif (d1[ijh_] > d1[ijh] + 1 || (d1[ijh_] == d1[ijh] + 1 && d2[ijh_] > d2[ijh] + 1)) {\n\t\t\t\tif (d1[ijh_] == INF)\n\t\t\t\t\tqq[head + cnt++] = ijh_;\n\t\t\t\td1[ijh_] = d1[ijh] + 1;\n\t\t\t\td2[ijh_] = d2[ijh] + 1;\n\t\t\t}\n\t\t}\n\t\tif (h == 0)\n\t\t\tmove(kx, ky, i, j, h, 8, 1);\n\t\telse if (h == 1)\n\t\t\tmove(bx, by, i, j, h, 4, n);\n\t\telse\n\t\t\tmove(rx, ry, i, j, h, 4, n);\n\t}\n}\n\nint main() {\n\tstatic int aa[N][N], ii[N * N], jj[N * N];\n\tstatic dp1[3], dp2[3], dq1[3], dq2[3];\n\tint h, h_, i, j, a, ans1, ans2;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++) {\n\t\t\tscanf(\"%d\", &a); a--;\n\t\t\taa[i][j] = a;\n\t\t\tii[a] = i, jj[a] = j;\n\t\t}\n\tfor (a = 0; a < n * n - 1; a++) {\n\t\ti = ii[a + 1], j = jj[a + 1];\n\t\tfor (h = 0; h < 3; h++)\n\t\t\tdq1[h] = dq2[h] = INF;\n\t\tfor (h = 0; h < 3; h++) {\n\t\t\tbfs(ii[a], jj[a], h);\n\t\t\tfor (h_ = 0; h_ < 3; h_++) {\n\t\t\t\tint d1_ = d1[(i * n + j) * 3 + h_], d2_ = d2[(i * n + j) * 3 + h_];\n\n\t\t\t\tif (dq1[h_] > dp1[h] + d1_ || (dq1[h_] == dp1[h] + d1_ && dq2[h_] > dp2[h] + d2_)) {\n\t\t\t\t\tdq1[h_] = dp1[h] + d1_;\n\t\t\t\t\tdq2[h_] = dp2[h] + d2_;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (h = 0; h < 3; h++) {\n\t\t\tdp1[h] = dq1[h];\n\t\t\tdp2[h] = dq2[h];\n\t\t}\n\t}\n\tans1 = ans2 = INF;\n\tfor (h = 0; h < 3; h++)\n\t\tif (ans1 > dp1[h] || (ans1 == dp1[h] && ans2 > dp2[h])) {\n\t\t\tans1 = dp1[h];\n\t\t\tans2 = dp2[h];\n\t\t}\n\tprintf(\"%d %d\\n\", ans1, ans2);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b2a55ba36747111e5a0deaf78e3b2ca4", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\nint main()\r\n{\r\n long int n;\r\n scanf(\"%ld\",&n);\r\n if(n==1){\r\n printf(\"3\\n\");\r\n return 0;\r\n }\r\n n= (4*n) -3;\r\n n=n/3;\r\n n=n+4;\r\n \r\n printf(\"%ld\\n\",n);\r\n \r\n \r\n \r\n // return 0;\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "1efe9b8374568fa656f2080cebede61d", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n long times,n,value,lvalue,ans,g,maxg=0,v[46],i,j,k;\n scanf(\"%ld%ld%ld\",×,&n,&value);\n for (i=1;i<=n;i++)\n scanf(\"%ld\",&v[i]);\n ans=0;\n for (i=1;i<=n;i++)\n ans+=v[i];\n for (i=0;i<=times;i++)\n if (value-ans*i>=0)\n {\n g=(n+1)*i;\n lvalue=value-ans*i;\n for (j=1;j<=n;j++)\n for (k=1;k<=times-i;k++)\n if (lvalue-v[j]>=0)\n {\n g++;\n lvalue-=v[j];\n }\n else\n break;\n if (g>maxg)\n maxg=g;\n }\n else\n break;\n printf(\"%ld\\n\",maxg);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "05c6ef6e7b87d13755fdd11af9f72dff", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int n,x,one,i,two,four,z,j,k;\n scanf(\"%d\",&x);\n for(n=1;;n+=2) {\n one=1;\n two=(n-1)/4;\n z=(n+1)/4;\n four=z*z;\n z=(n-1)/4;\n four+=z*z;\n for(i=0;i<=one;i++) for(j=0;j<=two;j++) for(k=0;k<=four;k++) if(i+j*2+k*4==x) goto end;\n if((n&3)==3) for(i=0;i\n\n#define M\t(1 << 15)\n#define A\t29\n\nchar xx[A + 1] = { 0,\n\t1, 2, 1, 4, 3, 2, 1, 5, 6, 2,\n\t1, 8, 7, 5, 9, 8, 7, 3, 4, 7,\n\t4, 2, 1, 10, 9, 3, 6, 11, 12 };\n\n#if 0\nvoid init() {\n\tstatic int bb[A];\n\tstatic char mex[1 << A];\n\tint b, a, c, i, cnt;\n\n\tfor (a = 1; a <= A; a++) {\n\t\tb = 0;\n\t\tfor (c = a; c <= A; c += a)\n\t\t\tb |= 1 << c - 1;\n\t\tbb[a - 1] = (1 << A) - 1 ^ b;\n\t}\n\tcnt = 0;\n\tfor (b = 1; b < 1 << A; b++) {\n\t\tint x = 0;\n\n\t\tfor (a = 1; a <= A; a++)\n\t\t\tif ((b & 1 << a - 1) != 0)\n\t\t\t\tx |= 1 << mex[b & bb[a - 1]];\n\t\tfor (i = 0; ; i++)\n\t\t\tif ((x & 1 << i) == 0) {\n\t\t\t\tmex[b] = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif ((b & b + 1) == 0) {\n\t\t\txx[cnt++] = mex[b];\n\t\t\tprintf(\"%d\\n\", mex[b]);\n\t\t}\n\t}\n}\n#endif\n\nint main() {\n\tstatic char used[M + 1];\n\tint n, a, b, s, grundy;\n\n#if 0\n\tinit();\n#endif\n\tscanf(\"%d\", &n);\n\ts = 1 + (n > M ? n - M : 0);\n\tgrundy = 0;\n\tfor (a = 2; a <= n && a <= M; a++) {\n\t\tint k;\n\n\t\tif (used[a])\n\t\t\tcontinue;\n\t\tk = 1;\n\t\tfor (b = a; b <= n / a; b *= a) {\n\t\t\tif (b * a <= M)\n\t\t\t\tused[b * a] = 1;\n\t\t\telse\n\t\t\t\ts--;\n\t\t\tk++;\n\t\t}\n\t\tgrundy ^= xx[k];\n\t}\n\tgrundy ^= s & 1;\n\tprintf(grundy ? \"Vasya\\n\" : \"Petya\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "de15f2f1610158a474f39ce61f95cc7a", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "GNU C11", "source_code": "#include \ntypedef long long ll;\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\n\nint main() {\n ll k, n;\n scanf(\"%lld%lld\", &n, &k);\n char s[105];\n scanf(\"%s\", s);\n\n char next[105][30]; //next[i][c]: i\u304b\u3089\u898b\u3066\u4e00\u756a\u521d\u3081\u306bc(+'a')\u304c\u73fe\u308c\u308bindex\n for (int j = 0; j < 26; j++) next[n][j] = n;\n for (int i = n-1; i >= 0; i--) {\n for (int j = 0; j < 26; j++) next[i][j] = next[i+1][j];\n next[i][s[i]-'a'] = i;\n }\n\n ll dp[105][105] = {0}; //dp[i][l]: s\u306ei\u6587\u5b57\u76ee\u3092\u63a5\u5c3e\u8f9e\u3068\u3057\u3066\u3082\u3064\uff0c\u9577\u3055l\u306e\u90e8\u5206\u6587\u5b57\u5217\u306e\u6570\n dp[0][0] = 1;\n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < 26; ++j) {\n if (next[i][j] >= n) continue;\n for (int l = 0; l < n; l++)\n dp[next[i][j] + 1][l+1] += dp[i][l];\n }\n }\n\n ll ans = 0, cnt = 0, tmp = 1;\n for (int j = n-1; j >= 0; j--) {\n for (int i = 0; i <= n; i++) {\n tmp += dp[i][j];\n if(tmp < k){ \n ans += (n-j)*dp[i][j];\n }else{\n ans += (n-j)*(k-(tmp-dp[i][j]));\n break;\n }\n }\n if(tmp >= k) break;\n }\n if(tmp < k) ans = -1;\n\n printf(\"%lld\\n\", ans);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "5d50f0fad115e3a2ad833befce159e50", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\nint min(int a, int b) { return a < b ? a : b; }\nint max(int a, int b) { return a > b ? a : b; }\n\nint d_, x_, y_;\n\nvoid gcd_(int a, int b) {\n\tif (b == 0)\n\t\td_ = a, x_ = 1, y_ = 0;\n\telse {\n\t\tint t;\n\n\t\tgcd_(b, a % b);\n\t\tt = x_ - a / b * y_; x_ = y_, y_ = t;\n\t}\n}\n\nint div_(int a, int b) {\t/* b > 0 */\n\treturn a >= 0 ? a / b : -((-a + b - 1) / b);\n}\n\nint main() {\n\tint n, s, i, c3, c4, c5, k3, c4_, c5_, ans, a3, a4, a5;\n\n\tscanf(\"%d%d\", &n, &s);\n\tc3 = c4 = c5 = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tint x;\n\n\t\tscanf(\"%d\", &x);\n\t\tif (x == 3)\n\t\t\tc3++;\n\t\telse if (x == 4)\n\t\t\tc4++;\n\t\telse\n\t\t\tc5++;\n\t}\n\tgcd_(c4, c5);\n\tc4_ = c4 / d_, c5_ = c5 / d_;\n\tans = -1, a3 = a4 = a5 = -1;\n\tfor (k3 = 0; k3 * n <= s; k3++) {\n\t\tint t = s - c3 * k3, k4_, k5_, lower, upper;\n\t\tint lower34, upper34, lower45, upper45;\n\t\tint lower1, upper1, lower2, upper2, lower3, upper3, lower4, upper4;\n\n\t\tif (t % d_ != 0)\n\t\t\tcontinue;\n\t\tt /= d_;\n\t\tk4_ = x_ * t, k5_ = y_ * t;\n\t\t/* k4 = k4_ + c5_ * k */\n\t\t/* k5 = k5_ - c4_ * k */\n\n\t\t/* k4 >= k3\n\t\t * k4_ + c5_ * k >= k3\n\t\t * k4_ + c5_ * k > k3 - 1\n\t\t * c5_ * k > k3 - k4_ - 1\n\t\t * k > (k3 - k4_ - 1) / c5_\n\t\t * k >= (k3 - k4_ - 1) / c5_ + 1\n\t\t */\n\t\tlower = div_(k3 - k4_ - 1, c5_) + 1;\n\n\t\t/* k5 >= k4\n\t\t * k5_ - c4_ * k >= k4_ + c5_ * k\n\t\t * (c4_ + c5_) * k <= k5_ - k4_\n\t\t * k <= (k5_ - k4_) / (c4_ + c5_)\n\t\t */\n\t\tupper = div_(k5_ - k4_, c4_ + c5_);\n\t\tif (lower > upper)\n\t\t\tcontinue;\n\n\t\t/* c3 * k3 >= c4 * k4\n\t\t * c3 * k3 >= c4 * (k4_ + c5_ * k)\n\t\t * c4 * c5_ * k <= c3 * k3 - c4 * k4_\n\t\t * k <= (c3 * k3 - c4 * k4_) / (c4 * c5_)\n\t\t */\n\t\tupper34 = div_(c3 * k3 - c4 * k4_, c4 * c5_);\n\t\t/* c3 * k3 < c4 * k4 */\n\t\tlower34 = upper34 + 1;\n\n\t\t/* c4 * k4 >= c5 * k5\n\t\t * c4 * (k4_ + c5_ * k) >= c5 * (k5_ - c4_ * k)\n\t\t * (c4 * c5_ + c5 * c4_) * k >= c5 * k5_ - c4 * k4_\n\t\t * (c4 * c5_ + c5 * c4_) * k > c5 * k5_ - c4 * k4_ - 1\n\t\t * k > (c5 * k5_ - c4 * k4_ - 1) / (c4 * c5_ + c5 * c4_)\n\t\t * k >= (c5 * k5_ - c4 * k4_ - 1) / (c4 * c5_ + c5 * c4_) + 1\n\t\t */\n\t\tlower45 = div_(c5 * k5_ - c4 * k4_ - 1, c4 * c5_ + c5 * c4_) + 1;\n\t\t/* c4 * k4 < c5 * k5 */\n\t\tupper45 = lower45 - 1;\n\n\t\t/* Case 1: c3 * k3 >= c4 * k4 && c4 * k4 >= c5 * k5\n\t\t * goal\n\t\t * = c3 * k3 - c4 * k4 + c4 * k4 - c5 * k5\n\t\t * = c3 * k3 - c5 * k5\n\t\t * = c3 * k3 - c5 * (k5_ - c4_ * k)\n\t\t * +k\n\t\t * minimize k\n\t\t */\n\t\tlower1 = max(lower, lower45);\n\t\tupper1 = min(upper, upper34);\n\t\tif (lower1 <= upper1) {\n\t\t\tint k = lower1;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t\t/* Case 2: c3 * k3 >= c4 * k4 && c4 * k4 < c5 * k5\n\t\t * goal\n\t\t * = c3 * k3 - c4 * k4 - c4 * k4 + c5 * k5\n\t\t * = c3 * k3 - 2 * c4 * k4 + c5 * k5\n\t\t * = c3 * k3 - 2 * c4 * (k4_ + c5_ * k) + c5 * (k5_ - c4_ * k)\n\t\t * -k\n\t\t * maximize k\n\t\t */\n\t\tlower2 = lower;\n\t\tupper2 = min(upper, min(upper34, upper45));\n\t\tif (lower2 <= upper2) {\n\t\t\tint k = upper2;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t\t/* Case 3: c3 * k3 < c4 * k4 && c4 * k4 < c5 * k5\n\t\t * goal\n\t\t * = -c3 * k3 + c4 * k4 - c4 * k4 + c5 * k5\n\t\t * = -c3 * k3 + c5 * k5\n\t\t * = -c3 * k3 + c5 * (k5_ - c4_ * k)\n\t\t * -k\n\t\t * maximize k\n\t\t */\n\t\tlower3 = max(lower, lower34);\n\t\tupper3 = min(upper, upper45);\n\t\tif (lower3 <= upper3) {\n\t\t\tint k = upper3;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t\t/* Case 4: c3 * k3 < c4 * k4 && c4 * k4 >= c5 * k5\n\t\t * goal\n\t\t * = -c3 * k3 + c4 * k4 + c4 * k4 - c5 * k5\n\t\t * = -c3 * k3 + 2 * c4 * k4 - c5 * k5\n\t\t * = -c3 * k3 + 2 * c4 * (k4_ + c5_ * k) - c5 * (k5_ - c4_ * k)\n\t\t * +k\n\t\t * minimize k\n\t\t */\n\t\tlower4 = max(lower, max(lower34, lower45));\n\t\tupper4 = upper;\n\t\tif (lower4 <= upper4) {\n\t\t\tint k = lower4;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t}\n\tif (ans == -1)\n\t\tprintf(\"-1\\n\");\n\telse\n\t\tprintf(\"%d %d %d\\n\", a3, a4, a5);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a7d62795b84cb11dc7b2ca736fa1bc44", "src_uid": "3f3eb49a127768139283ac04ee44950f", "difficulty": 2400.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t50\n#define N_\t(N + 2)\n#define M_\t(M * 3 + 2)\n#define M\t(N * (N - 1))\n#define X\t100000\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint oo[1 + M], oh[1 + M];\n\nint link(int o, int h) {\n\tstatic int _ = 1;\n\n\too[_] = o, oh[_] = h;\n\treturn _++;\n}\n\nint oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;\n\nint link_(int o, int h) {\n\too_[__] = o, oh_[__] = h;\n\treturn __++;\n}\n\nint ae[N], ae_[N_], dd[N_], n_;\nint ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;\nint pq[1 + N], iq[N], cnt;\n\nint less(int u, int v) { return dd[u] < dd[v]; }\n\nint i2(int i) {\n\treturn (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;\n}\n\nvoid pq_up(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_dn(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_add_last(int u) {\n\tpq[iq[u] = ++cnt] = u;\n}\n\nint pq_remove_first() {\n\tint u = pq[1], v = pq[cnt--];\n\n\tif (v != u)\n\t\tiq[v] = 1, pq_dn(v);\n\tiq[u] = 0;\n\treturn u;\n}\n\nvoid dijkstra(int n, int s) {\n\tmemset(dd, 0x3f, n * sizeof *dd);\n\tdd[s] = 0, pq_add_last(s);\n\twhile (cnt) {\n\t\tint i = pq_remove_first(), o;\n\n\t\tfor (o = ae[i]; o; o = oo[o]) {\n\t\t\tint h = oh[o];\n\n\t\t\tif (!tt[h]) {\n\t\t\t\tint j = jj[h], d = dd[i] + ww[h];\n\n\t\t\t\tif (dd[j] > d) {\n\t\t\t\t\tif (dd[j] == INF)\n\t\t\t\t\t\tpq_add_last(j);\n\t\t\t\t\tdd[j] = d, pq_up(j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid link2(int i, int j, int c) {\n\tint h = m_++;\n\n\tij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;\n\tae_[i] = link_(ae_[i], h << 1);\n\tae_[j] = link_(ae_[j], h << 1 | 1);\n}\n\nint bfs(int s, int t) {\n\tstatic int qu[N_];\n\tint i, head, cnt;\n\n\tfor (i = 0; i < n_; i++)\n\t\tdd[i] = n_;\n\thead = cnt = 0;\n\tdd[s] = 0, qu[head + cnt++] = s;\n\twhile (cnt) {\n\t\tint d, o;\n\n\t\ti = qu[cnt--, head++], d = dd[i] + 1;\n\t\tfor (o = ae_[i]; o; o = oo_[o]) {\n\t\t\tint h_ = oh_[o];\n\n\t\t\tif (cc[h_]) {\n\t\t\t\tint h = h_ >> 1, j = i ^ ij[h];\n\n\t\t\t\tif (dd[j] > d) {\n\t\t\t\t\tdd[j] = d;\n\t\t\t\t\tif (j == t)\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\tqu[head + cnt++] = j;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\nint dfs(int i, int t) {\n\tint d, o;\n\n\tif (i == t)\n\t\treturn 1;\n\td = dd[i] + 1;\n\tfor (o = ae_[i]; o; o = oo_[o]) {\n\t\tint h_ = oh_[o];\n\n\t\tif (cc[h_]) {\n\t\t\tint h = h_ >> 1, j = i ^ ij[h];\n\n\t\t\tif (dd[j] == d && dfs(j, t)) {\n\t\t\t\tcc[h_]--, cc[h_ ^ 1]++;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\tdd[i] = n_;\n\treturn 0;\n}\n\nvoid dinic(int s, int t) {\n\twhile (bfs(s, t))\n\t\twhile (dfs(s, t))\n\t\t\t;\n}\n\nint main() {\n\tstatic double ans[X + 1];\n\tstatic int dd1[N], dd2[N], xx[M];\n\tint n, m, q, h, x, s, t;\n\n\tscanf(\"%d%d\", &n, &m);\n\tfor (h = 0; h < m; h++) {\n\t\tint i, j, w;\n\n\t\tscanf(\"%d%d%d\", &i, &j, &w), i--, j--;\n\t\tii[h] = i, jj[h] = j, ww[h] = w;\n\t\tae[i] = link(ae[i], h);\n\t}\n\tn_ = n + 2, s = n, t = n + 1;\n\tx = 0;\n\twhile (x < X) {\n\t\tint k, y, z, d, d_;\n\n\t\tmemset(tt, 0, m * sizeof *tt);\n\t\tdijkstra(n, 0);\n\t\tmemcpy(dd1, dd, n * sizeof *dd);\n\t\td = dd1[n - 1];\n\t\tmemset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;\n\t\tlink2(s, 0, INF);\n\t\tlink2(n - 1, t, INF);\n\t\tfor (h = 0; h < m; h++) {\n\t\t\tint i = ii[h], j = jj[h], w = ww[h];\n\n\t\t\tif (dd1[i] + w == dd1[j]) {\n\t\t\t\ttt[h] = 1;\n\t\t\t\tlink2(s, j, 1), link2(i, t, 1);\n\t\t\t\tif (xx[h] == 0)\n\t\t\t\t\tlink2(j, i, INF);\n\t\t\t}\n\t\t}\n\t\tdinic(s, t);\n\t\td_ = INF;\n\t\tk = 0;\n\t\tfor (h = 0; h < m; h++) {\n\t\t\tint i = ii[h], j = jj[h];\n\n\t\t\tif (tt[h]) {\n\t\t\t\tif ((dd[i] == n_) == (dd[j] == n_))\n\t\t\t\t\ttt[h] = 0;\n\t\t\t\telse if (dd[i] != n_) {\n\t\t\t\t\ttt[h] = 1;\n\t\t\t\t\tk++;\n\t\t\t\t} else {\n\t\t\t\t\ttt[h] = 2;\n\t\t\t\t\tk--;\n\t\t\t\t\td_ = min(d_, d + xx[h]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdijkstra(n, 0);\n\t\tmemcpy(dd2, dd, n * sizeof *dd);\n\t\td_ = min(d_, dd2[n - 1]);\n\t\tfor (h = 0; h < m; h++)\n\t\t\tif (tt[h] == 2)\n\t\t\t\td_ = min(d_, d + dd2[ii[h]] - dd1[jj[h]]);\n\t\ty = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;\n\t\tfor (z = x; z <= y; z++)\n\t\t\tans[z] = d + (double) (z - x) / k;\n\t\tif (y < X)\n\t\t\tfor (h = 0; h < m; h++)\n\t\t\t\tif (tt[h])\n\t\t\t\t\tww[h] += d_ - d;\n\t\tx = y;\n\t}\n\tscanf(\"%d\", &q);\n\twhile (q--) {\n\t\tscanf(\"%d\", &x);\n\t\tprintf(\"%f\\n\", ans[x]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "370af1512fc4929f7c6a22dc8c924be8", "src_uid": "b0751071e12f729f6700586c5a8eed23", "difficulty": 3100.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint max=0;\nint a[10];\nint p[100];\ntypedef struct\n{\n\tint val;\n\tint mvrg;\n\tint thrg;\n}Ch;\ntypedef Ch CA[4];\nint movethrow(CA,int);\nint search(int pe)\n{\n\tint i,t;\n\tfor (i=1;i<45;i++)\t\n\t{\n\t\tif (p[i]>0)\n\t\t{\n\t\t\tt=p[i];\n\t\t\twhile (t)\n\t\t\t{\n\t\t\t\tif ((t%10)==pe)\n\t\t\t\t\treturn i;\n\t\t\t\tt=t/10;\n\t\t\t}\n\t\t}\n\t}\n}\nint change(int pe,int pos)\n{\n\tint t;\n\tt=search(pe);\n\tp[t]=0;\n\tp[pos]=pe;\n\t\n}\nint tr(CA C,int pe)\n{\n\tint i,j;\n\tint f,m,r,t[4];\n\tint temp;\n\tt[1]=search(1);\n\tt[2]=search(2);\n\tt[3]=search(3);\n\tm=t[pe];\n\ttemp=p[m];\n\tf=m-C[pe].thrg;\n\tr=m+C[pe].thrg;\n\tif (r>max)\n\t\tmax=r;\n\tif (f<=0)\n\t\tf=1;\n\tfor (i=f;i<=r;i++)\n\t{\n\t\tif (i!=m&&p[i]==0&&\n\t\t\t(abs(i-t[1])==1||abs(i-t[2]==1)||abs(i-t[3])==1||i==r))\n\t\t{\n\t\t\t\n\t\t\tp[i]=temp/10;\n\t\t\tp[m]=temp%10;\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp[i]=0;\n\t\t\tp[m]=temp;\n\t\t}\n\t}\n\treturn 0;\n}\nint mv(CA C,int pe)\n{\n\tint i,j;\n\tint f,m,r,t[4];\n\tt[1]=search(1);\n\tt[2]=search(2);\n\tt[3]=search(3);\n\tint temp;\n\ttemp=t[pe];\n\tm=t[pe];\n\tt[pe]=t[3];\n\tt[3]=temp;\n\tf=m-C[pe].mvrg;\n\tr=m+C[pe].mvrg;\n\tif (r>max)\n\t\tmax=r;\n\tif (f<=0)\n\t\tf=1;\n\tfor (i=f;i<=r;i++)\n\t{\n\t\tif (i!=m&&p[i]==0&&\n\t\t\t(abs(i-t[1])<=2||abs(i-t[2]<=2)||i==r))\n\t\t{\n\t\t\tchange(pe,i);\n\t\t\t\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tchange(pe,m);\n\treturn 0;\n}\n\nint movethrow(CA C,int fr)\n{\n\tint i,j;\n\tint rt;\n\tif (fr%3==1)\n\t{\n\t\trt=fr/3+1;\n\t\tif (a[fr+1]==1&&a[fr+2]==0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse if (p[search(rt)]>10)\n\t\t{\n\t\t\treturn 0;\n\t \t}\n\t\telse\n\t\t{\n\t\t\tmv(C,rt);\n\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t}\n\tif (fr%3==2)\n\t{\n\t\tint px;\n\t\trt=fr/3+1;\n\t\tpx=search(rt);\n\t\tif (p[px]>10)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse if (p[px-1]>0)\n\t\t{\n\t\t\tint temp;\n\t\t\tp[px]+=p[px-1]*10;\n\t\t\ttemp=p[px-1];\n\t\t\tp[px-1]=0;\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp[px]=rt;\n\t\t\tp[px-1]=temp;\n\t\t}\n\t\telse if (p[px+1]>0)\n\t\t{\n\t\t\tint temp;\n\t\t\tp[px]+=p[px+1]*10;\n\t\t\ttemp=p[px+1];\n\t\t\tp[px+1]=0;\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp[px]=rt;\n\t\t\tp[px+1]=temp;\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (fr%3==0)\n\t{\n\t\trt=fr/3;\n\t\tint px;\n\t\tpx=search(rt);\n\t\tif (a[fr-1]==0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse if (p[px]%10!=rt)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse \n\t\t{\n\t\t\ttr(C,rt);\n\t\t\treturn 0;\n\t\t}\n\t}\n}\nint main()\n{\n\tCA C;\n\tint i,j;\n\tfor (i=1;i<100;i++)\n\t{\n\t\tp[i]=0;\n\t}\n\tfor (i=1;i<=3;i++)\n\t{\n\t\tscanf(\"%d %d %d\",&C[i].val,&C[i].mvrg,&C[i].thrg);\n\t\tp[C[i].val]=i;\n\t}\n\tfor (i=0;i<=9;i++)\n\t{\n\t\ta[i]=0;\n\t}\n\tfor (i=1;i<=9;i++)\n\t{\n\t\ta[i]=1;a[0]++;\n\t\tmovethrow(C,i);\n\t\ta[i]=0;a[0]--;\n\t}\n\t\n\tprintf(\"%d\",max);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "aacb5440aa43c5d43248e2fc0e7ca660", "src_uid": "a14739b86d1fd62a030226263cdc1afc", "difficulty": 2500.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nbool check(int s, int r)\n{\n int i=(s/50)%475,j;\n for(j=0;j<25;j++)\n {\n i=(i*96+42)%475;\n if(26+i==r)\n\treturn true;\n }\n return false;\n}\n\nint main()\n{\n int p,x,y;\n scanf(\"%d %d %d\",&p, &x, &y);\n int temp=x,i=x,j=x,countn=0,countp=0;\n int key=0;\n while(j>=y)\n\t{\n\t if(check(j,p))\n\t {\n\t key=1;\n\t break;\n\t }\n\t j-=50;\n\t}\n if(key==1)\n printf(\"0\\n\");\n else \n {\n\t while(1)\t\n\t { \n\t i+=50;\n\t countp++;\n\t if(check(i,p))\n\t {\n\t\t key=2;\n\t\t break;\n\t }\n\t }\n\t if(countp%2==0)\n\t printf(\"%d\\n\",countp/2);\n\t else\n\t printf(\"%d\\n\",countp/2+1);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1a12615f09abee3753227140b752cded", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct point {\n int x, idx, rk;\n};\n\nint cmp1 (const void *a, const void *b)\n{\n struct point *m = (struct point *)a, *n = (struct point *)b;\n return m->x - n->x;\n}\n\nint cmp2 (const void *a, const void *b)\n{\n struct point *m = (struct point *)a, *n = (struct point *)b;\n return m->idx - n->idx;\n}\n\nint main (void)\n{\n int i, n, m;\n scanf (\"%d %d\", &n, &m);\n\n struct point pts[n];\n for (i = 0; i < n; i++) {\n scanf (\"%d\", &pts[i].x);\n pts[i].idx = i;\n }\n\n for (i = 0; i < m; i++) {\n int x, y;\n scanf (\"%d %d\", &x, &y);\n }\n\n qsort (pts, n, sizeof (struct point), cmp1);\n for (i = 0; i < n; i++) {\n pts[i].rk = i % 2;\n //printf (\"new %d %d %d\\n\", pts[i].x, pts[i].idx, pts[i].rk);\n }\n\n qsort (pts, n, sizeof (struct point), cmp2);\n for (i = 0; i < n; i++) {\n printf (\"%d \", i% 2);\n }\n\n printf (\"\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1f7fffa64e58e79c74122687e9fe2256", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct Team {\n char name[25];\n int point;\n int score;\n int miss;\n}team[4], tmp_team[4];\n\nvoid swap(int *lhs, int *rhs) {\n int tmp = *lhs;\n *lhs = *rhs;\n *rhs = tmp;\n}\n\nvoid cpy_team() {\n int i;\n for (i = 0; i < 4; ++i) {\n tmp_team[i].point = team[i].point;\n tmp_team[i].score = team[i].score;\n tmp_team[i].miss = team[i].miss;\n strcpy(tmp_team[i].name, team[i].name);\n }\n}\n\nchar hash_s[4][25];\nint hash_idx = 0;\nint hash(const char* str) {\n int i;\n for (i = 0; i < hash_idx; ++i) {\n if (!strcmp(str, hash_s[i])) {\n return i;\n }\n }\n strcpy(hash_s[hash_idx++], str);\n return hash_idx - 1;\n}\n\nint comp(const void *lhs, const void *rhs) {\n struct Team *sa = (struct Team *)lhs;\n struct Team *sb = (struct Team *)rhs;\n if (sa->point != sb->point) {\n return sa->point < sb->point;\n }\n if (sa->score - sa->miss != sb->score - sb->miss) {\n return sa->score - sa->miss < sb->score - sb->miss;\n }\n if (sa->score != sb->score) {\n return sa->score < sb->score;\n }\n return strcmp(sa->name, sb->name) > 0;\n}\n\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n int i, j, ia, ib, na, nb, b_id, opp_id, x, y, min = 10000, cnt[4];\n char sa[25], sb[25];\n\n memset(cnt, 0, sizeof(cnt));\n for (i = 0; i < 5; ++i) {\n scanf(\"%s %s %d:%d\", sa, sb, &na, &nb);\n ia = hash(sa);\n ib = hash(sb);\n strcpy(team[ia].name, sa);\n strcpy(team[ib].name, sb);\n ++cnt[ia];\n ++cnt[ib];\n /*printf(\"%d %d %d %d\\n\", na, nb, ia, ib);*/\n if (nb > na) {\n swap(&na, &nb);\n swap(&ia, &ib);\n }\n /*printf(\"%d %d\\n\", na, nb);*/\n if (na > nb) {\n team[ia].point += 3;\n } else if (na == nb) {\n team[ia].point += 1;\n team[ib].point += 1;\n }\n team[ia].score += na;\n team[ia].miss += nb;\n team[ib].score += nb;\n team[ib].miss += na;\n }\n /*for (i = 0; i < 4; ++i) {*/\n /*printf(\"%d %d %d\\n\", team[i].point, team[i].score, team[i].miss);*/\n /*}*/\n /*return 0;*/\n for (i = 0; i < 4; ++i) {\n if (!strcmp(team[i].name, \"BERLAND\")) {\n b_id = i;\n } else if (cnt[i] != 3) {\n opp_id = i;\n }\n }\n\n cpy_team();\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n /*for (i = 0; i < 4; ++i) {*/\n /*printf(\"%s\\n\", tmp_team[i].name);*/\n /*}*/\n /*printf(\"opp_id = %d, b_id = %d\\n\", opp_id, b_id);*/\n /*for (i = 0; i < hash_idx; ++i) {*/\n /*printf(\"%s\\n\", hash_s[i]);*/\n /*}*/\n for (i = 1; i < 100; ++i) {\n for (j = i - 1; j >= 0; --j) {\n cpy_team();\n tmp_team[b_id].point += 3;\n tmp_team[b_id].score += i;\n tmp_team[opp_id].miss += i;\n\n tmp_team[b_id].miss += j;\n tmp_team[opp_id].score += j;\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n if (!strcmp(tmp_team[0].name, \"BERLAND\") || !strcmp(tmp_team[1].name, \"BERLAND\")) {\n if (i - j < min) {\n min = i - j;\n x = i;\n y = j;\n }\n }\n }\n }\n if (min != 10000) {\n printf(\"%d:%d\\n\", x, y);\n } else {\n puts(\"IMPOSSIBLE\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7a088e198624a6cf12fe828ee10f434b", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include\n#include\ndouble f(int a)\n{\n\tif(a>=0)\n\t{\n\t\treturn sqrt(a)+5*pow(a,3);\n\t}\n\telse\n\t{\n\t\treturn sqrt(-a)+5*pow(a,3);\n\t}\n}\nint main()\n{\n\tdouble b;\n\tint i,j,arr[11];\n\tfor(i=0;i<11;i++)\n\t{\n\t\tscanf(\"%d\",&arr[i]);\n\t}\n\tfor(i=10;i>=0;i--)\n\t{\n\t\tj=arr[i];\n\t\tb=f(arr[i]);\n\t\tif(b>400)\n\t\t{\n\t\t\tprintf(\"f(%d)=MAGNA NIMIS!\\n\",j);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"f(%d)=%0.2f\\n\",j,b);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "298e074f3dbe4c381499db96de88e54e", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "GNU C", "source_code": "#include \n#include \n#define INF 0x3f3f3f3f\n#define MAX(A,B) (((A) > (B)) ? (A) : (B))\n\nchar s1[105];\nchar s2[105];\nchar virus[105];\nint fail[105];\n\nint dp[105][105][105];\nint seq[105][105][105][3];\nint print[105][105][105];\nint n, m, p;\n\nint solve(int pos1, int pos2, int pos3) {\n if (pos3 >= p) {\n return -INF;\n }\n\n if (pos1 >= n || pos2 >= m) {\n return 0;\n }\n\n if (seq[pos1][pos2][pos3][0] != -1) {\n return dp[pos1][pos2][pos3];\n }\n\n int aux, aux2, aux3;\n int way1, way2, way3;\n\n aux = aux2 = aux3 = -INF;\n way1 = way2 = way3 = 0;\n if (s1[pos1] == s2[pos2]) {\n if (s1[pos1] == virus[pos3]) {\n print[pos1][pos2][pos3] = 1;\n aux = 1 + solve(pos1 + 1, pos2 + 1, pos3 + 1);\n way1 = pos1 + 1;\n way2 = pos2 + 1;\n way3 = pos3 + 1;\n } else {\n way1 = pos1;\n way2 = pos2;\n if (pos3 != 0) {\n if (virus[fail[pos3 - 1]] == s1[pos1]) {\n aux = 1 + solve(pos1 + 1, pos2 + 1, fail[pos3 - 1] + 1);\n print[pos1][pos2][pos3] = 1;\n way1++;\n way2++;\n way3 = fail[pos3 - 1] + 1;\n } else {\n aux = solve(pos1, pos2, fail[pos3 - 1]);\n way3 = fail[pos3 - 1];\n }\n } else {\n aux = 1 + solve(pos1 + 1, pos2 + 1, 0);\n print[pos1][pos2][0] = 1;\n way1++;\n way2++;\n way3 = 0;\n }\n }\n }\n\n dp[pos1][pos2][pos3] = aux;\n seq[pos1][pos2][pos3][0] = way1;\n seq[pos1][pos2][pos3][1] = way2;\n seq[pos1][pos2][pos3][2] = way3;\n\n aux2 = solve(pos1 + 1, pos2, pos3);\n aux3 = solve(pos1, pos2 + 1, pos3);\n\n if (aux2 > dp[pos1][pos2][pos3]) {\n dp[pos1][pos2][pos3] = aux2;\n print[pos1][pos2][pos3] = 0;\n seq[pos1][pos2][pos3][0] = pos1 + 1;\n seq[pos1][pos2][pos3][1] = pos2;\n seq[pos1][pos2][pos3][2] = pos3;\n }\n if (aux3 > dp[pos1][pos2][pos3]) {\n dp[pos1][pos2][pos3] = aux3;\n print[pos1][pos2][pos3] = 0;\n seq[pos1][pos2][pos3][0] = pos1;\n seq[pos1][pos2][pos3][1] = pos2 + 1;\n seq[pos1][pos2][pos3][2] = pos3;\n }\n\n return dp[pos1][pos2][pos3];\n}\n\nvoid build_fail(void) {\n int len;\n int i;\n\n fail[0] = 0;\n i = 1;\n len = 0;\n\n while(i < p) {\n if (virus[i] == virus[len]) {\n len++;\n fail[i++] = len;\n } else {\n if (len != 0) {\n len = fail[len - 1];\n } else {\n fail[i++] = 0;\n }\n }\n }\n return;\n}\n\nint main(void) {\n int i, j, k;\n int res;\n\n int w1, w2, w3;\n\n scanf(\" %s %s %s\", s1, s2, virus);\n\n n = strlen(s1);\n m = strlen(s2);\n p = strlen(virus);\n\n\n for (i = 0; i < n; i++) {\n for (j = 0; j < m; j++) {\n for (k = 0; k < p; k++) {\n seq[i][j][k][0] = -1;\n print[i][j][k] = 0;\n }\n }\n }\n\n build_fail();\n res = solve(0, 0, 0);\n\n if (res) {\n i = 0;\n j = 0;\n k = 0;\n while(i != n && j != m) {\n if (print[i][j][k]) {\n printf(\"%c\", s1[i]);\n }\n w1 = seq[i][j][k][0];\n w2 = seq[i][j][k][1];\n w3 = seq[i][j][k][2];\n i = w1;\n j = w2;\n k = w3;\n }\n printf(\"\\n\");\n } else {\n printf(\"0\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2a6f22ba984ed1e364ea7364064b474d", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "// O(1) solution due to whatshisbucket\n#include \n#define ull unsigned long long\n\nconst unsigned ans[201][13] = {{},{2},{4},{11},{32},{97},{295},{940},{3148},{10901},{38324},{135313},{478989},{1704939},{6120951},{22187311},{81129556},{298715961},{1105546606},{4107686743},{2426959363,3},{1411039897,13},{4172194186,49},{3689174689,187},{43344991,708},{2441471173,2674},{2801489501,10124},{260107736,38400},{2954951606,145893},{606296452,555183},{1899297838,2115855},{3084773566,8075123},{234294028,30859921},{691111333,118085088},{2180959654,452401618},{1792754283,1735233324},{2132034018,2368089356,1},{1709961728,4137532123,5},{177031067,4063007484,22},{994451568,1625053238,88},{3917739273,3065624025,340},{1540443642,2939324613,1314},{2048043699,924465791,5077},{1535675300,4143681610,19623},{1508306498,2169966175,75908},{3628011891,3750388408,293847},{690756141,2273958850,1138333},{3186013409,1633929753,4412841},{3713415519,2737515922,17118132},{1580819397,2755090312,66446442},{3380663546,3219914187,258079131},{4204882545,2751845304,1002972229},{2671126449,3985320580,3900042842},{1549923635,2321666527,2288550180,3},{3206088422,3837458666,3229658027,13},{468076678,684189096,2394878431,53},{317846743,2409125435,2929850439,208},{2292706160,2431336997,2081275227,813},{3980228298,3870290811,2271141075,3172},{2281921514,2428712631,3857202388,12377},{1410084376,2665199272,1218646022,48313},{1725477252,938399815,2490820090,188650},{96934866,3021873877,4292106543,736911},{3976807065,4196403427,2309669478,2879607},{381043316,3742984064,581598293,11256562},{75998957,558211513,3386244876,44017760},{2481446098,3420110131,878568493,172184876},{2998084519,2760121094,3693315328,673755597},{1152419028,2385275115,2073185204,2637216508},{2854085154,4023337502,2033791001,1735803802,2},{923550706,4030810318,3175452562,1786539181,9},{971375603,1399426681,1063836258,3816608870,36},{2026326245,317960303,107930394,2395208751,144},{3032216567,1211669851,2768624282,2750243364,566},{962635926,2853748285,932538563,3069568420,2221},{929452190,980373970,1397224474,1107065389,8713},{3844112081,2178623972,365972575,3179860998,34180},{2309493692,3520537616,437394707,1605782278,134118},{2212877625,2922712134,95698419,3521874850,526378},{3552645532,3742906242,3849668270,299359034,2066376},{1938082639,329182225,3901861703,3461124247,8113696},{1135006092,3990987912,565559913,3870994863,31865765},{3496777998,2726710279,3456622192,1473857377,125176826},{726284190,554922189,1177992859,2941984575,491830434},{1174922238,3146728744,935205998,249307383,1932843670},{1927883506,2548886969,3104826080,2071924719,3302449968,1},{552744259,966302059,593280121,3357489715,4099236778,6},{4057737811,3172120154,3385034438,3377497541,1487985982,27},{1120930094,52594514,1676802786,854221959,2375555749,107},{1038179455,2469373338,1067790354,815292734,357146485,423},{3401792308,639953706,455471950,2389477057,2540495932,1664},{814342077,1190616845,1267241187,3067979529,1675977447,6550},{2621993594,2832313139,1127278177,3805827021,746798329,25781},{1714067937,4219985196,3969544797,136803453,2317603907,101487},{4152787624,3611142829,843196231,3916033443,3079218285,399572},{3461864546,3893743275,2900292828,1608204305,1869768837,1573441},{3003514123,3308980254,3534417324,1621178584,481241785,6196916},{2679664471,1996930534,318652848,2268304523,3541589603,24410101},{185152026,3138914840,1871119221,1559019881,2206013312,96168136},{3737829797,1320722003,1895671615,3178554427,3061812461,378930161},{203925008,3794021407,2579620510,3431217976,3019797624,1493317916},{2468134907,3475974877,3086405423,1142109993,4005905823,1590884110,1},{180449137,547269777,665325677,2842676501,2144395769,1727357320,5},{1617684553,878842739,3960341086,1281770673,1738535346,1282366575,21},{123339094,1072406502,1883229773,1124342891,720266287,4222745088,83},{3205877069,1493036374,4168832930,361101124,1207377007,869413080,331},{30245458,166380545,1871598255,2461437325,1132735956,1418272557,1306},{4075272123,2038959813,655609662,3492982470,3995427741,486078374,5153},{608326718,1107150586,1686622377,947478086,1489690413,1051457018,20330},{4136754916,2162103160,1723971343,3979622104,220587964,3441819447,80217},{2175296377,2687555805,2858485317,2068680116,2714338065,3815351148,316557},{941177009,2263937754,4286501999,592569842,2476199853,2077265316,1249363},{72166211,744371576,1452653805,2742004280,2576941298,3652970668,4931474},{3013494591,2372455071,534269120,1360461613,3759274278,3238915720,19467772},{508737026,2615515531,1184239988,3149494987,3669012804,3205495324,76861038},{4046190885,1049147236,347431385,615864993,3013055269,783975557,303491052},{895896758,1263297489,2129431640,4200962499,4253682392,2227802501,1198489786},{862593958,4076271219,471546334,831422713,3429802533,2758946637,438405932,1},{1558843359,3239232053,4200145856,1332916817,3018622542,3909986823,1516372374,4},{3604235363,2959047772,1884763672,3716891921,127819947,2316365163,841289782,17},{2148016453,2600462985,3400301264,3261250221,3339364795,3609467668,4019991120,67},{2057336361,3281406422,2001356007,305233474,2662253073,3418788389,1817744880,268},{1281508345,928813361,2816581598,2007723331,2740688108,4273224708,2920853098,1060},{3426260777,1763297880,1175966776,3062570720,731743090,2726359719,3082793264,4191},{3210960410,3752915728,459191299,128440564,2984187704,97991247,4030488828,16566},{224166267,2234372978,753139562,3865891512,1486162002,1307841019,3762849709,65483},{260505741,545447754,3027390222,3521038051,2886878098,3868240693,2774668015,258861},{3445525626,4221229308,1386534263,2297987493,4173116713,4207227667,4141018726,1023390},{4142247892,2446668656,2319675620,965790995,3309615310,2135638134,1728304023,4046274},{2796886765,2836129926,4105771002,1871082482,3736667518,147213948,2633468854,15999570},{445505098,42453983,2107373830,2161264577,3236071391,3845846548,2434224601,63270306},{3838187199,490614644,3657555088,4103603341,1344831810,990431249,3994847387,250224339},{1047857076,2176168119,682300933,1335570400,3705580851,2101545607,4139870456,989684043},{3026384570,2242942353,2616680991,3487926651,3956283706,1869088125,2484171217,3914717263},{1071498200,3773154979,1706585509,742961663,3077446206,215191244,2514290529,2601141681,3},{2872507125,1304608611,2805013961,3835527537,489570676,3914819730,1656827998,1135993546,14},{3155154964,780193390,2193623906,1209128819,1418105045,725432432,3669496663,1878768769,56},{253659020,3880096607,144011870,1507161628,1464179160,2378916704,1158684783,1341570611,223},{2212582435,445734981,3630891622,2426151389,3122490297,2334190077,1744231515,2896978552,883},{2142647548,3600176835,2830071678,2961075988,1714835724,2925612276,3820302557,339695552,3497},{4294886677,3361034647,906607836,1269791512,1220171111,1544351226,1002394444,2129097500,13840},{501822294,1725262855,3183461603,2954658854,2164388124,640674278,3687166976,244870596,54781},{810510306,323305484,3430675847,1333959229,3023582709,4122725661,4162215479,3998267249,216840},{2066497053,2791669159,1066700710,2401391628,2204319308,382832680,452636133,892117603,858388},{795280433,3187355406,2545609941,3296708892,338474730,3457915698,49592690,624245225,3398266},{1581357444,3332957275,3991329316,1823248956,3664649114,3049475936,1436313055,108314556,13454320},{2890310043,2645865047,96602101,1985398087,2830455143,2769232370,3231689536,3016839684,53271680},{3673691692,78846736,745302479,838402949,1165410335,1692653857,3976907779,1367965842,210940949},{295563602,975450609,3170861384,1205290655,658762743,4047422421,2054553,2367895997,835323744},{2508957223,2683160723,401608967,3574638073,2537772230,3214369508,3288302812,4058536503,3308093533},{3776557089,1460840502,3147310815,2456004160,3562408518,3775964939,3388939830,427668466,216849571,3},{3728035062,1926856823,1177012130,3575198692,2209903221,113586407,3333408737,3712521410,353438384,12},{2607331913,4283270230,3600202517,876899479,1796104827,817161666,294106662,2136843986,3686222256,47},{3314615494,2761020062,2280369741,3898619731,3911823627,1182841733,921495705,1987759554,2490255816,189},{2590245496,3473058917,1492013628,624914759,3628302063,1440754051,3417778275,1003682760,106726210,751},{2633783210,2706506985,3094738545,828125704,2671377987,626840589,3752738738,3900703516,1656794022,2975},{28448344,2669463898,1385628852,1136650614,2118617121,813824129,3389598254,193974302,2158698592,11788},{759262343,302349887,3002808773,3528037846,3942292190,2970558354,2489204802,2262249038,4058358874,46708},{3335417267,309921878,334820301,2461381894,3006674440,3130341194,1757099604,976305824,1192497803,185083},{1960107932,45317162,829795120,2938679609,1321490743,813033324,901851337,2388825974,3085146788,733431},{806769803,4249618887,2322214279,268106502,2400608845,3705101671,1006868560,1555518405,1473524019,2906546},{3016024504,2109541762,302478533,3002549037,3359936194,4230216640,1792321929,1405771399,3338048212,11519126},{405528202,3152747679,1869032290,1022171990,2330178010,2440852913,3340825247,2702598955,1813170149,45654784},{392072299,1470040061,1345165237,334840075,4161634659,3723030012,396217175,2217547197,4143434417,180957739},{1432108212,1114744425,1018959253,2618969148,4172016277,4104617249,229313722,1461796977,1676488993,717285187},{3917524871,829882129,3501994447,4017135301,3074069020,2694309690,2684793248,2587840425,3290780412,2843348555},{1944206482,1442962768,2769991002,137897471,3987464733,1155485997,2536824880,2998553209,2648147189,2681821845,2},{3344805947,411892603,4126656246,2211517675,2444913124,957967558,1038021382,4082245269,1767355398,1736798769,10},{3802521073,3267053531,1313646101,2324872666,878940337,3215631351,2931920803,4200923446,324319828,1073506513,41},{2654567614,1568808025,1803729542,2143384822,1658736425,192485054,1968155916,2580905691,2996803246,2366165782,163},{2560754697,2732109758,2650989258,3065464363,1119140648,1320459588,2818622314,274089733,1416601562,2113969709,648},{1429470319,2031880934,3023721394,1497346884,3095305271,698965458,2481352053,4125722246,3087616259,1941794290,2571},{1184856486,1823601604,2177114912,1188216408,321207596,4169904552,1298722721,2792835748,1750494046,137661912,10197},{593626344,3685718606,932835303,4281953533,3355177948,15176347,4132811439,1667095290,2027158372,348096588,40438},{2762201132,270311472,1739761745,3323556446,1688792644,4252294308,98283754,45888612,1013106595,4157530014,160371},{3538598781,1630328471,2324233659,2623719054,3542209653,833501619,3225441426,2426749849,342949796,919573965,636044},{618700117,1847361613,2568402629,3402135662,4069406530,3440726719,1961879249,1816107549,1163097643,861392142,2522707},{2616807824,290482935,4008503304,2827388725,3398823662,41448142,888703054,2313506850,1710980580,1436672924,10006146},{905330484,1850737061,1755710640,293093431,2890512416,1845155700,4293226377,1367354510,759724617,2153923292,39690547},{2000560120,887237321,1040273567,1259018161,97219236,4276904417,1725515412,2870030510,2879450930,3189702845,157444445},{863642990,954603462,536622170,3252710478,3940502922,1729125146,1554480730,1290181440,1973587814,248555840,624579026},{1697327337,2918819084,150398406,3763881191,2636440703,4265356736,2157835805,1468367803,3848765537,59446342,2477804464},{2446323117,1333533671,2168747137,2854032017,3081391650,4183505187,3650047026,188779407,526016429,2761793340,1240348821,2},{1300231750,3902915121,1981986679,3427190560,3237911263,3291691015,562702363,3149480449,2579229057,19020837,347055068,9},{3657932198,488720328,1446344547,3834564368,1480352990,2827046885,2880609475,697749222,2257195171,3354404202,127861599,36},{3397923977,2798002524,301001927,2304309288,1687826763,2483601671,1779363633,1352057091,713809587,2696685452,4127204450,142},{4028816566,2408052650,1213680384,4256359194,3002614222,1364230970,783390155,4126636361,832523803,2282722679,1171138251,567},{1736176841,397389969,1228600389,1516725449,2895163479,2150566846,2811167753,294595860,3564441822,1721701828,205228753,2251},{2429761274,984698965,4108659942,1199674335,293635739,625424232,948286406,3972991993,1611407721,1500862,4154934097,8932},{3222210919,690114320,50448257,2804373465,1017961958,2039183893,489159216,1151280382,158773765,2768634720,2995763167,35450},{375716695,3859193991,896415991,2993529817,3509832398,1871422233,1586062355,668318591,3165286699,495636988,3108898623,140692},{3085768643,3180394296,2124249810,1205857906,3158086867,3386222583,3793549621,3819173062,3911540842,1904718767,287398360,558388},{3435903375,4291098692,493489606,406838170,2190529579,2074994943,759798382,4196166923,3215154043,3785784988,2520590895,2216246},{3359148995,1436143251,1921872544,3037272504,3281484062,2051801502,1168216991,762202114,1408033153,2299479341,378749039,8796650},{2192988308,3067744296,1930751395,548234159,829700582,3436686196,2247851925,784563272,3717975929,908149877,1580872919,34916738},{3007043623,975843659,2616296461,3737306179,3684324109,3267538666,421308555,1472776780,1635862811,1071292237,1068791155,138601192},{2821316210,1748725430,2412011903,2527125975,948281510,391305600,772588344,3276862062,1944460202,2748703689,856637215,550195511},{4052977779,3163937748,3036712795,1138645612,501033727,4264799249,1380676331,3187355932,1832139079,645165555,1337462030,2184156409},{4201727360,2754890041,1042005963,1322883592,245155897,3538921510,886161692,1902765029,2170171535,1392634951,192228728,81019411,2},{1199257909,273544693,1994261149,3010295901,1839507415,77097517,1408801718,459303161,1544392329,3025296585,2726440504,64657343,8},{2102743037,2393063500,876912794,2198839926,3912872240,4095736174,2637471038,2384888107,503769424,4041934301,2348599738,3528755911,31}};\n\nint main () {\n int n, M;\n scanf(\"%d %d\", &n, &M);\n ull v = 0;\n for (int j = 12; j >= 0; j--) {\n v = (v<<32)|ans[n][j];\n v %= M;\n }\n printf(\"%lld\\n\", v);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "bde8d4edd58b9eb1f47331c65ef64a99", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "GNU C11", "source_code": "#include \nchar F[8][8];\nint D[8];\nint sS[8];\nint dS[8];\nvoid mS(int s[], int d[], int o, int t)\n{\n int i, j, k;\n int c = (o + t) / 2;\n if (o < c)\n {\n mS(d, s, o, c);\n }\n if (c + 1 < t)\n {\n mS(d, s, c + 1, t);\n }\n i = o;\n j = c + 1;\n k = o;\n while (i <= c && j <= t)\n {\n if (D[s[i]] < D[s[j]])\n {\n d[k] = s[i];\n i++;\n }\n else\n {\n d[k] = s[j];\n j++;\n }\n k++;\n }\n while (i <= c)\n {\n d[k] = s[i];\n i++;\n k++;\n }\n while (j <= t)\n {\n d[k] = s[j];\n j++;\n k++;\n }\n}\nint main()\n{\n int i, j;\n int t;\n int c;\n int n, m;\n int a, b;\n int s, d;\n int max;\n int min;\n scanf(\"%d %d\", &n, &m);\n for (i = 1; i <= n; i++)\n {\n D[i] = 0;\n }\n for (i = 1; i <= n; i++)\n {\n for (j = 1; j <= n; j++)\n {\n F[i][j] = 0;\n }\n }\n for (i = 0; i < m; i++)\n {\n scanf(\"%d %d\", &a, &b);\n F[a][b] = 1;\n D[a]++;\n F[b][a] = 1;\n D[b]++;\n }\n if (n == 7)\n {\n for (t = 1; t <= n; t++)\n {\n sS[t] = t;\n }\n for (t = 1; t <= n; t++)\n {\n dS[t] = t;\n }\n mS(sS, dS, 1, n);\n s = 1;\n d = 7;\n for (t = 5; t > 0; t--)\n {\n if (D[dS[d]] > t)\n {\n m -= D[dS[s]] - 1;\n for (c = 1; c < 8; c++)\n {\n if (F[dS[s]][c])\n {\n D[c]--;\n }\n }\n s++;\n }\n for (c = 1; c < 8; c++)\n {\n if (F[dS[d]][c])\n {\n D[c]--;\n }\n }\n d--;\n if (s <= d)\n {\n break;\n }\n }\n }\n printf(\"%d\", m);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ef28ac49348dba26a23ed028de203a22", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n\n#define W_L 1\n#define W_K 2\n#define B_K -4\n\nvoid set_p(int board[8][8]){\n int i,j,k,l;\n\n for(i = 0; i<8; i++)\n for(j = 0; j<8; j++)\n\t if(!(board[i][j]>0 || board[i][j]==B_K))\n\t board[i][j]=0;\n\n for(i = 0; i<8; i++)\n for(j = 0; j<8; j++)\n\t if(board[i][j]>0){\n\t if(board[i][j]==W_L){\n\t for(k = j-1; k>=0 && board[i][k]<=0;k--)\n\t\t board[i][k]=-1;\n\t for(k = j+1; k<8 && board[i][k]<=0; k++)\n\t\t board[i][k]=-1;\n\t for(k = i-1; k>=0 && board[k][j]<=0;k--)\n\t\t board[k][j]=-1;\n\t for(k = i+1; k<8 && board[k][j]<=0; k++)\n\t\t board[k][j]=-1;\n\t } else if(board[i][j]==W_K) {\n\t for(k = i-1; k<=i+1; k++)\n\t\t for(l = j-1; l<=j+1; l++)\n\t\t if(k>=0 && k<8 && l>= 0 && l<8 && board[k][l]<=0)\n\t\t board[k][l]=-1; \n\t }\n\t }\n\n}\n\nvoid cpy_board(int dest[8][8], int source[8][8]){\n int i,j;\n for(i = 0; i<8; i++)\n for(j = 0; j<8; j++)\n\t dest[i][j] = source[i][j];\n}\n\nint main(){\n int x,y;\n char _x;\n int i, j;\n int other = 0;\n int board[8][8];\n int temp_board[8][8];\n\n for(i = 0; i<8; i++)\n for(j = 0; j<8; j++)\n\t board[i][j] = 0;\n\n scanf(\"%c%d \",&_x,&y);\n x = _x-'a';\n y--;\n board[x][y] = W_L;\n scanf(\"%c%d \",&_x,&y);\n x = _x-'a';\n y--;\n board[x][y] = W_L;\n scanf(\"%c%d \",&_x,&y);\n x = _x-'a';\n y--;\n board[x][y] = W_K;\n scanf(\"%c%d\",&_x,&y);\n x = _x-'a';\n y--;\n board[x][y] = B_K;\n\n set_p(board);\n\n if(board[x][y] == B_K)\n printf(\"OTHER\\n\");\n else {\n other = 0;\n for(i = x-1; i<=x+1; i++)\n\t for(j = y-1; j<=y+1; j++){\n\t if(i>=0 && i<8 && j>=0 && j<8)\n\t if(board[i][j]==0)\n\t\t other = 1;\n\t if(i>=0 && i<8 && j>=0 && j<8 && board[i][j]==W_L){\n\t cpy_board(temp_board, board);\n\t temp_board[x][y]=0;\n\t temp_board[i][j]=B_K;\n\t set_p(temp_board);\n\t other = other || (temp_board[i][j]==B_K);\n\t }\n\t }\n if(other)\n\t printf(\"OTHER\\n\");\n else\n\t printf(\"CHECKMATE\\n\");\n\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8414b7b5b827ca920f6dc4ad4d636894", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t10\n\nchar ss[][2] = { \"B\", \"C\", \"D\", \"F\", \"H\", \"I\", \"K\", \"N\", \"O\", \"P\", \"S\", \"U\", \"V\", \"W\", \"Y\" };\nchar tt[102][4] = { \"AC\", \"AG\", \"AL\", \"AM\", \"AR\", \"AS\", \"AT\", \"BA\", \"BE\", \"BH\", \"BI\", \"BK\", \"BR\", \"CA\", \"CD\", \"CE\", \"CF\", \"CL\", \"CM\", \"CN\", \"CO\", \"CR\", \"CS\", \"CU\", \"DB\", \"DS\", \"DY\", \"ER\", \"ES\", \"EU\", \"FE\", \"FL\", \"FM\", \"FR\", \"GD\", \"GA\", \"GE\", \"AU\", \"HE\", \"HF\", \"HO\", \"HS\", \"HG\", \"IN\", \"IR\", \"KR\", \"LA\", \"LR\", \"LI\", \"LU\", \"LV\", \"MD\", \"MG\", \"MN\", \"MO\", \"MT\", \"NA\", \"NB\", \"ND\", \"NE\", \"NI\", \"NO\", \"NP\", \"OG\", \"OS\", \"PA\", \"PB\", \"PD\", \"PM\", \"PO\", \"PT\", \"PU\", \"PR\", \"RA\", \"RB\", \"RE\", \"RF\", \"RG\", \"RH\", \"RN\", \"RU\", \"SB\", \"SC\", \"SE\", \"SI\", \"SG\", \"SM\", \"SN\", \"SR\", \"TA\", \"TB\", \"TC\", \"TE\", \"TH\", \"TI\", \"TL\", \"TM\", \"XE\", \"YB\", \"ZN\", \"ZR\" };\n\nint elemental1(char c) {\n\tint i;\n\n\tfor (i = 0; i < 15; i++)\n\t\tif (ss[i][0] == c)\n\t\t\treturn 1;\n\treturn 0;\n}\n\nint elemental2(char c1, char c2) {\n\tint i;\n\n\tfor (i = 0; i < 101; i++)\n\t\tif (tt[i][0] == c1 && tt[i][1] == c2)\n\t\t\treturn 1;\n\treturn 0;\n}\n\nint elemental3(char c1, char c2, char c3) {\n\treturn c1 == 'U' && c2 == 'U' && (c3 == 'T' || c3 == 'P' || c3 == 'S');\n}\n\nint main() {\n\tstatic char cc[N + 1];\n\tstatic int dp[N + 1];\n\tint n, i;\n\n\tscanf(\"%s\", cc), n = strlen(cc);\n\tdp[0] = 1;\n\tfor (i = 0; i < n; i++)\n\t\tif (dp[i]) {\n\t\t\tif (elemental1(cc[i]))\n\t\t\t\tdp[i + 1] = 1;\n\t\t\tif (i + 1 < n && elemental2(cc[i], cc[i + 1]))\n\t\t\t\tdp[i + 2] = 1;\n\t\t}\n\tprintf(dp[n] ? \"YES\\n\" : \"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8ab1c16bb3aa14922e06c7764f5863ca", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nconst i32 mod = 1000000007;\n\ni32 inv (i32 a) {\n i32 t = 1;\n while (a > 1) {\n t = (i64) t * (mod - mod / a) % mod;\n a = mod % a;\n }\n return t;\n}\n\ni32 mod_pow (i32 r, i32 n) {\n i32 t = 1;\n i32 s = r;\n while (n > 0) {\n if (n & 1) t = (i64) t * s % mod;\n s = (i64) s * s % mod;\n n >>= 1;\n }\n return t;\n}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n#define ABS(a) ((a)>(0)?(a):-(a))\n\nvoid matmul (i32 *c, i32 *a, i32 *b, i32 n) {\n static i32 *tmp = NULL;\n if (tmp == NULL) {\n tmp = (i32 *) calloc (n * n, sizeof (i32));\n }\n memset (tmp, 0, sizeof (i32) * n * n);\n for (i32 i = 0; i < n; ++i) {\n for (i32 k = 0; k < n; ++k) {\n for (i32 j = 0; j < n; ++j) {\n\ttmp[i * n + j] = (tmp[i * n + j] + (i64) a[i * n + k] * b[k * n + j]) % mod;\n }\n }\n }\n memcpy (c, tmp, sizeof (i32) * n * n);\n}\n\nvoid run (void) {\n i32 n = read_int();\n i32 k = read_int();\n i32 *a = (i32 *) calloc (n, sizeof (i32));\n i32 cnt[2] = {0, 0};\n for (i32 i = 0; i < n; ++i) {\n a[i] = read_int();\n cnt[a[i]]++;\n }\n if (cnt[0] == 0 || cnt[1] == 0) {\n puts(\"1\");\n return;\n }\n i32 d = 0;\n for (i32 i = 0; i < cnt[0]; ++i) {\n d += a[i];\n }\n const i32 m = MIN(cnt[0], cnt[1]) + 1;\n i32 *t = (i32 *) calloc (m * m, sizeof (i32));\n i32 *s = (i32 *) calloc (m * m, sizeof (i32));\n for (i32 i = 0; i < m; ++i) {\n t[i * m + i] = 1;\n s[i * m + i] = cnt[0] * (cnt[0] - 1) / 2 + cnt[1] * (cnt[1] - 1) / 2 + (cnt[0] - i) * i + i * (cnt[1] - i);\n if (i + 1 < m) {\n s[i * m + i + 1] = (cnt[0] - i) * (cnt[1] - i);\n }\n if (i - 1 >= 0) {\n s[i * m + i - 1] = i * i;\n }\n }\n i32 p = inv (n * (n - 1) / 2);\n for (i32 i = 0; i < m * m; ++i) {\n s[i] = (i64) s[i] * p % mod;\n }\n while (k > 0) {\n if (k & 1) matmul (t, t, s, m);\n matmul (s, s, s, m);\n k >>= 1;\n }\n i32 ans = t[d * m + 0];\n print_int (ans);\n puts(\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2933769c6fb5d16113914a20253427f4", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0} {"lang": "GNU C11", "source_code": "#include \n#include\n#include \n\nint main() {\n \n \n int n,x,y,i,flag=0,u , j = 0 ;\n scanf (\"%d\" , &n);\n char s[n];\n scanf (\"%s\" ,s);\n char arr[n];\n x=-1; y=-1;\n for(i=0;i=x){\n x=u;\n arr[j] ='0';\n j++;\n }\n else if(u>=y)\n {\n arr[j] = '1';\n j++;\n y=u;\n }\n else\n {\n flag=1;\n i=n;\n }\n }\n if(flag==1){\n printf(\"NO\\n\");\n }\n else\n {\n printf(\"YES\\n\");\n for ( i = 0 ; i < n ; i++)\n printf(\"%c\" , arr[i]);\n }\n }\n \n ", "lang_cluster": "C", "compilation_error": false, "code_uid": "299c678db5cddfaf3dbfce8b4b6713b6", "src_uid": "9bd31827cda83eacfcf5e46cdeaabe2b", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n\nbool reversed(char c, char t)\n{\n return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');\n}\n\nchar reverse(char c)\n{\n if (c == 'S')\n return 'N';\n if (c == 'W')\n return 'E';\n if (c == 'N')\n return 'S';\n if (c == 'E')\n return 'W';\n return '\\0';\n}\n\nint main()\n{\n int n;\n assert(scanf(\"%d\", &n) == 1);\n n--;\n char* s = malloc(sizeof(char) * (n + 1));\n char* t = malloc(sizeof(char) * (n + 1));\n assert(scanf(\"%s\", s));\n assert(scanf(\"%s\", t));\n if (reversed(s[n - 1], t[n - 1]))\n printf(\"NO\\n\");\n else\n {\n int i = 0;\n int j = 0;\n int ilast = 0;\n int op;\n while (j < n || i < n)\n {\n for (; i < n; i++)\n {\n if (j < n && t[j] == s[i])\n j++;\n else if (j > 0 && reverse(t[j - 1]) == s[i])\n j--;\n }\n if (j == n && i == n)\n {\n printf(\"YES\\n\");\n return 0;\n }\n for (; j < n; j++)\n {\n if (i < n && t[j] == s[i])\n i++;\n else if (i > 0 && reverse(s[i - 1]) == t[j])\n i--;\n }\n op += 2 * n;\n //if (op >= 1e8)\n // break;\n if (ilast == i)\n break;\n ilast = i;\n }\n if (j == n && i == n)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "895baf4ae3970d78694ad25af428a06a", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n\nint Input;\nint Ans[70000];\nint A, B, i, x, y, Test, FAns;\n\nint QS(int *A, int *B){\n if (*A>*B) return 1;\n if (*A<*B) return -1;\n return 0;\n}\n\nint main(){\n while(~scanf(\"%d\", &Input)){\n FAns = 0;\n \n for (A=0; A<10; A++) for (B=0; B<10; B++) for (i=0; i<1024; i++){\n Test = 0;\n x = i;\n while(x){\n Test *= 10;\n if (x&1) Test += A;\n else Test += B;\n x /= 2;\n }\n if (Test>0) if (Test<=Input){\n Ans[FAns] = Test;\n FAns++;\n }\n }\n \n qsort(Ans, FAns, sizeof(Ans[0]), QS);\n \n if (Input==1000000000){\n Ans[FAns] = Input;\n FAns++;\n }\n \n if (FAns<=1){\n printf(\"%d\\n\", FAns);\n continue;\n }\n \n for (i=FAns-1; i; i--) if (Ans[i]==Ans[i-1]) FAns--;\n \n printf(\"%d\\n\", FAns);\n }\n \n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "be7933da022333eea04af8b85c8f3417", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "GNU C11", "source_code": "#include\nlong long int power(long long int a,long long int b)\n{ \n long long int res=1;\n while(b!=0)\n {\n if(b&1)\n res=res*a;\n a=a*a;\n b=b/2;\n }\n return res;\n}\nint main()\n{long long int m;\n scanf(\"%lld\",&m);\n long long int res;\n res=(2*4*3*power(4,m-3))+(4*3*3*power(4,n-4));\n printf(\"%lld\\n\",res);\n \n}", "lang_cluster": "C", "compilation_error": true, "code_uid": "f77bcc10d1b8a57bd48fa9baeee41ae3", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n#include \n#define MAXN 55\nlong n,ls;\nchar s[MAXN]={'\\0'};\nlong a[MAXN]={0},p[MAXN][10]={0};\nlong long f[MAXN][10]={0},ans=0;\nvoid dfs(long now,long b)\n{\n if(p[now][b]) return;\n p[now][b]=1;\n if(now==n-1)\n {\n if(((a[now+1]+b)&1)) f[now][b]=2;\n else f[now][b]=1;\n }\n else\n {\n if(((a[now+1]+b)&1))\n {\n dfs(now+1,((a[now+1]+b)>>1));\n dfs(now+1,((a[now+1]+b)>>1)+1);\n f[now][b]=f[now+1][((a[now+1]+b)>>1)]+f[now+1][((a[now+1]+b)>>1)+1];\n }\n else\n {\n dfs(now+1,((a[now+1]+b)>>1));\n f[now][b]=f[now+1][((a[now+1]+b)>>1)];\n }\n }\n return;\n}\nint main()\n{\n long i,j,k;\n gets(s);ls=strlen(s)-1;if(s[ls]=='\\n') s[ls--]='\\0';\n n=ls+1;\n for(i=1;i<=n;i++) a[i]=s[i-1]-'0';\n for(i=0;i<=9;i++) \n {dfs(1,i);ans+=f[1][i];}\n for(i=2;i<=n;i++)\n if(((a[i-1]+a[i])>>1)!=a[i] && (((a[i-1]+a[i])>>1)+1)!=a[i])\n break;\n if(i==n+1) ans--; \n printf(\"%I64d\\n\",ans);\n return(0);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c514a749046e96a7521149361bb8a8b2", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N 2000000\n#define MOD 1000000007\n\nint cnt[N + 1];\nint lcm[N + 1];\nint maxp[N + 1];\n\nint max(int x, int y) {\n return x > y ? x : y;\n}\n\nint main(void) {\n int n;\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n int p;\n scanf(\"%d\", &p);\n cnt[p]++;\n }\n for (int i = 0; i <= N; i++) {\n maxp[i] = i;\n }\n for (int i = 2; i <= N; i++) {\n if (maxp[i] == i) {\n for (int j = i * 2; j <= N; j += i) {\n maxp[j] = i;\n }\n }\n }\n for (int i = 0; i <= N; i++) {\n if (cnt[i] == 1) {\n lcm[i] = max(lcm[i], 1);\n } else if (cnt[i] >= 2) {\n lcm[i] = max(lcm[i], 1);\n int x = i - 1;\n while (x != 1) {\n int p = maxp[x];\n int e = 0;\n while (x % p == 0) {\n x /= p;\n e++;\n }\n lcm[p] = max(lcm[p], e);\n }\n }\n }\n long long ans = 1;\n for (int i = 0; i <= N; i++) {\n for (int j = 0; j < lcm[i]; j++) {\n ans *= i;\n ans %= MOD;\n }\n }\n printf(\"%lld\\n\", ans);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "40a4b785d4734c86437444957006a88d", "src_uid": "816a82bee65cf79ba8e4d61babcd0301", "difficulty": 2900.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n\tint i;\n\tdouble x,y,z;\n\tdouble a[9];\n\tfor(i=1;i<=8;i++) a[i] = -1e100;\n\tchar count[9][10]={\"x^y^z\",\n \"x^z^y\",\n\t\t\t\t\t \"(x^y)^z\",\n\t\t\t\t\t \"y^x^z\",\n\t\t\t\t\t \"y^z^x\",\n\t\t\t\t\t \"(y^x)^z\", \n\t\t\t\t\t \"z^x^y\",\n\t\t\t\t\t \"z^y^x\",\n\t\t\t\t\t \"(z^x)^y\"} ;\n\tint max;\n\tscanf(\"%lf%lf%lf\",&x,&y,&z);\n\tif(x<1&&y<1&&z<1)\n\t{ \n\ta[0]=pow(y,z)*log(x);\n\ta[1]=pow(z,y)*log(x);\n\ta[2]=y*z*log(x);\n\ta[3]=pow(x,z)*log(y);\n\ta[4]=pow(z,x)*log(y);\n\ta[5]=x*z*log(y);\n\ta[6]=pow(x,y)*log(z);\n\ta[7]=pow(y,x)*log(z);\n\ta[8]=x*y*log(z);\n\t}\n\telse\n\t{\n\tif(x>1)\n\t\t{\n\t\t\ta[0] = z*log(y)+log(log(x));\n\t\t\ta[1] = y*log(z)+log(log(x));\n\t\t\ta[2] = log(y)+log(z)+log(log(x));\n\t\t}\n\t\tif(y>1)\n\t\t{\n\t\t\ta[3] = z*log(x)+log(log(y));\n\t\t\ta[4] = x*log(z)+log(log(y));\n\t\t\ta[5] = log(x)+log(z)+log(log(y));\n\t\t}\n\t\tif(z>1)\n\t\t{\n\t\t\ta[6] = y*log(x)+log(log(z));\n\t\t\ta[7] = x*log(y)+log(log(z));\n\t\t\ta[8] = log(x)+log(y)+log(log(z));\n\t\t}\n\t} \n\tfor(i=1,max=0;i<=8;i++)\n\t{\n\t\tif(a[i]>a[max]+1E-6)max=i;\n\t}\n\tprintf(\"%s\\n\",count[max]);\n} \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "1d4e070704e10fddac786fbdd41e925d", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c", "difficulty": 2400.0} {"lang": "GNU C11", "source_code": "#include \r\n#include\r\ntypedef long long lol;\r\n\r\nint main()\r\n{\r\n lol n, M = 998244353;\r\n scanf(\"%lld\",&n);\r\n lol arr[n+1],id=2;\r\n lol pr[1000000];\r\n pr[0]=2;\r\n pr[1]=3;\r\n lol i,j,k,p,ct,i1;\r\n arr[1]=1;\r\n for(i=2;i<=n;i++)\r\n {\r\n p=0;\r\n while((pi)\r\n {\r\n arr[i]=2;\r\n pr[id]=i;\r\n id++;\r\n continue;\r\n }\r\n p = pr[p];\r\n ct = 0;\r\n i1=i;\r\n while(i1%p==0)\r\n {\r\n ct++;\r\n i1/=p;\r\n }\r\n arr[i] = arr[i1]*(ct+1);\r\n }\r\n lol ex = 1;\r\n lol ans = arr[n]%M, a1;\r\n for(i=1;i\r\nint main() {\r\n\tint n;\r\n\tscanf(\"%d\", &n);\r\n\tunsigned long long ans = 6;\r\n\tunsigned long long pow = 16;\r\n\r\n\tfor(int i = 1; i < n; i++) {\r\n\t\tans *= pow;\r\n\t\tans %= 1000000007;\r\n\t\tpow *= pow;\r\n\t\tpow %= 1000000007;\r\n\t}\r\n\r\n\tprintf(\"%llu\\n\", ans);\r\n\r\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "f1f32657419194d24881b4362ed541db", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "GNU C", "source_code": "#include \n\n#define mul(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y1))\n\nstruct case1\n{\n long long x,y;\n}dian[5][100006]={0},con[100006]={0},vec[5]={0};\n\nlong long tot[5]={0};\nlong long st[5]={0};\n\nint main()\n{\n long long i,j;\n long long cur[5]={0};\n long long x,y;\n long long o=0;\n long long q;\n long long l,r,mid;\n \n for(i=1;i<=3;i++)\n {\n scanf(\"%I64d\",&tot[i]);\n st[i]=1;\n for(j=1;j<=tot[i];j++)\n {\n scanf(\"%I64d%I64d\",&dian[i][j].x,&dian[i][j].y);\n dian[i][j].x*=3;\n dian[i][j].y*=3;\n dian[i][j+tot[i]]=dian[i][j];\n }\n for(j=2;j<=tot[i];j++)\n if(dian[i][j].x0)\n x=vec[i].x,y=vec[i].y;\n for(i=1;i<=3;i++)\n if(mul(vec[i].x,vec[i].y,x,y)==0)\n cur[i]++;\n }\n \n scanf(\"%I64d\",&q);\n for(;q;q--)\n {\n scanf(\"%I64d%I64d\",&x,&y);\n x*=3;\n y*=3;\n \n if(mul(x-con[1].x,y-con[1].y,con[2].x-con[1].x,con[2].y-con[1].y)>0||mul(x-con[1].x,y-con[1].y,con[o].x-con[1].x,con[o].y-con[1].y)<0)\n goto loop;\n \n for(l=3,r=o;l0)\n r=mid;\n else\n l=mid+1;\n }\n if(r>2)\n if(mul(x-con[r].x,y-con[r].y,con[r-1].x-con[r].x,con[r-1].y-con[r].y)>=0)\n {\n printf(\"YES\\n\");\n continue;\n }\n loop:\n printf(\"NO\\n\");\n }\n \n return 0;\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9b791092a62d43d1d6414a4bc1d5fc83", "src_uid": "a764daf8e19e48a0735811a4f67485c3", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define N\t400000\n#define INF\t0x3f3f3f3f3f3f3f3fLL\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\nlong long max(long long a, long long b) { return a > b ? a : b; }\n\nvoid srand_() {\n\tstruct timeval tv;\n\n\tgettimeofday(&tv, NULL);\n\tsrand(tv.tv_sec ^ tv.tv_usec);\n}\n\nint rand_(int n) {\n\treturn (rand() * 76543LL + rand()) % n;\n}\n\nstruct V {\n\tlong long x, y;\n} vv[N + 1];\n\nint compare(const void *a, const void *b) {\n\tstruct V *u = (struct V *) a;\n\tstruct V *v = (struct V *) b;\n\n\treturn u->x == v->x ? 0 : u->x < v->x ? -1 : 1;\n}\n\nvoid sort(struct V *vv, int n) {\n\tint i;\n\n\tfor (i = 0; i < n; i++) {\n\t\tint j = rand_(i + 1);\n\t\tstruct V tmp;\n\n\t\ttmp = vv[i], vv[i] = vv[j], vv[j] = tmp;\n\t}\n\tqsort(vv, n, sizeof *vv, compare);\n}\n\nint main() {\n\tint t;\n\n\tsrand_();\n\tscanf(\"%d\", &t);\n\twhile (t--) {\n\t\tstatic long long gg[N + 1];\n\t\tlong long len, k, lower, upper, lmax, rmin, y, ans;\n\t\tint n, m, i;\n\n\t\tscanf(\"%lld%d%lld\", &len, &n, &k);\n\t\tfor (i = 0; i < n; i++)\n\t\t\tscanf(\"%lld\", &gg[i]);\n\t\tgg[n] = len;\n\t\tfor (i = n; i >= 1; i--)\n\t\t\tgg[i] -= gg[i - 1];\n\t\tlower = 1;\n\t\tupper = len + 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tupper = min(upper, gg[i] + 1);\n\t\twhile (upper - lower > 1) {\n\t\t\tlong long l = (lower + upper) / 2, k_;\n\n\t\t\tk_ = k;\n\t\t\tfor (i = 0; i <= n; i++)\n\t\t\t\tif ((k_ -= gg[i] / l - 1) <= 0)\n\t\t\t\t\tbreak;\n\t\t\tif (k_ <= 0)\n\t\t\t\tlower = l;\n\t\t\telse\n\t\t\t\tupper = l;\n\t\t}\n\t\tlmax = lower;\n\t\tlower = 0, upper = len;\n\t\twhile (upper - lower > 1) {\n\t\t\tlong long r = (lower + upper) / 2, k_;\n\n\t\t\tk_ = k;\n\t\t\tfor (i = 0; i <= n; i++)\n\t\t\t\tif ((k_ -= (gg[i] + r - 1) / r - 1) < 0)\n\t\t\t\t\tbreak;\n\t\t\tif (k_ >= 0)\n\t\t\t\tupper = r;\n\t\t\telse\n\t\t\t\tlower = r;\n\t\t}\n\t\trmin = upper;\n\t\t/* lmax <= rmin must hold */\n\t\tm = 0;\n\t\tfor (i = 0; i <= n; i++) {\n\t\t\tint kmin = (gg[i] + rmin - 1) / rmin - 1;\n\t\t\tint kmax = gg[i] / lmax - 1;\n\n\t\t\tif (kmin > kmax) {\t/* kmin == kmax + 1 */\n\t\t\t\tstruct V *v = &vv[m++];\n\n\t\t\t\tv->x = lmax - gg[i] / (kmin + 1);\n\t\t\t\tv->y = (gg[i] + kmax) / (kmax + 1) - rmin;\n\t\t\t}\n\t\t}\n\t\tsort(vv, m);\n\t\tans = INF;\n\t\ty = 0;\n\t\tfor (i = m - 1; i >= 0; i--) {\n\t\t\tans = min(ans, rmin - lmax + vv[i].x + y);\n\t\t\ty = max(y, vv[i].y);\n\t\t}\n\t\tans = min(ans, rmin - lmax + y);\n\t\tprintf(\"%lld\\n\", ans);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9de21b25c5d0a4581d1cbb94f7da7902", "src_uid": "37d912c36aedea1b8f8e78a849062d90", "difficulty": 3300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long k, pa, pb, inv, dp[1010][1010];\n\nlong long expo(long long x, long long n){\n x %= MOD;\n long long res = 1;\n\n while (n){\n if (n & 1) res = (res * x) % MOD;\n x = (x * x) % MOD;\n n >>= 1;\n }\n\n return (res % MOD);\n}\n\nlong long F(int a, int c){\n if (c >= k) return c;\n if (dp[a][c] != -1) return dp[a][c];\n\n long long res = 0, loop = 0;\n\n if (a == 0){\n res = pa * F(a + 1, c) % MOD;\n loop += pb;\n res = res * expo(MOD - loop, MOD - 2) % MOD;\n }\n else if ((a + c) >= k){\n loop += pa;\n res = pb * F(a, c + a) % MOD;\n res = (res + 1) * expo(MOD - loop, MOD - 2) % MOD;\n }\n else{\n res += pa * F(a + 1, c);\n res += pb * F(a, c + a);\n res %= MOD;\n }\n\n return (dp[a][c] = res);\n}\n\nint main(){\n while (scanf(\"%lld %lld %lld\", &k, &pa, &pb) != EOF){\n memset(dp, -1, sizeof(dp));\n\n inv = expo(pa + pb, MOD - 2);\n pb = pb * inv % MOD;\n pa = pa * inv % MOD;\n printf(\"%lld\\n\", (F(0, 0) - 1 + MOD) % MOD );\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "6d04d3d3aecaa90ddce728ffbc615dcc", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t100000\n#define MD\t1000000007\n\nint ff[N], gg[N];\nint d_, x_, y_;\n\nvoid gcd_(int a, int b) {\n\tif (b == 0) {\n\t\td_ = a;\n\t\tx_ = 1, y_ = 0;\n\t} else {\n\t\tint tmp;\n\n\t\tgcd_(b, a % b);\n\t\ttmp = x_ - a / b * y_, x_ = y_, y_ = tmp;\n\t}\n}\n\nint inv(int a, int b) {\n\tgcd_(a, b);\n\treturn x_;\n}\n\nvoid init(int n) {\n\tint i, f;\n\n\tfor (i = 0, f = 1; i < n; i++) {\n\t\tgg[i] = inv(ff[i] = f, MD);\n\t\tf = (long long) f * (i + 1) % MD;\n\t}\n}\n\nint choose(int n, int k) {\n\treturn n < k ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nint main() {\n\tstatic int aa[N + 2], bb[N + 2], cc[N + 2];\n\tint f, w, h, n, i, j, p, q, ans;\n\n\tscanf(\"%d%d%d\", &f, &w, &h);\n\tif (f == 0) {\n\t\tprintf(\"%d\\n\", w > h);\n\t\treturn 0;\n\t}\n\tif (w == 0) {\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\tn = f > w ? f : w;\n\tinit(n);\n\tfor (i = 1; i <= f; i++)\n\t\taa[i] = choose(f - 1, i - 1);\n\tfor (j = 1; j <= w; j++)\n\t\tbb[j] = choose(w - 1, j - 1);\n\tfor (j = 1; (h + 1) * j <= w; j++)\n\t\tcc[j] = choose(w - h * j - 1, j - 1);\n\tp = q = 0;\n\tfor (i = 1; i <= n; i++) {\n\t\tp = (p + aa[i] * (cc[i] * 2LL + cc[i - 1] + cc[i + 1])) % MD;\n\t\tq = (q + aa[i] * (bb[i] * 2LL + bb[i - 1] + bb[i + 1])) % MD;\n\t}\n\tif (p < 0)\n\t\tp += MD;\n\tif (q < 0)\n\t\tq += MD;\n\tans = (long long) p * inv(q, MD) % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "b5239426b0fbe6381229b76974b4c8ea", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "const int d1[]={0};\nconst int d2[]={2,1};\nconst int d4[]={32,30,80,109};\nconst int d8[]={6824,59808,147224,415870,1757896,1897056,4898872,7593125};\nconst int d16[]={776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593};\nconst int d32[]={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};\nconst int d64[]={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};\nconst int d128[]={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};\nconst int d256[]={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};\nmain(n,k){\n\tscanf(\"%d%d\",&n,&k);--k;\n\tprintf(\"%d\\n\",n==1?d1[k]:\n\t\tn==2?d2[k]:\n\t\tn==4?d4[k]:\n\t\tn==8?d8[k]:\n\t\tn==16?d16[k]:\n\t\tn==32?d32[k]:\n\t\tn==64?d64[k]:\n\t\tn==128?d128[k]:\n\t\td256[k]);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "20f8f1028051ba00b8c99f85e7008396", "src_uid": "cfe19131644e5925e32084a581e23286", "difficulty": 2700.0} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nlong long gcd(long long a, long long b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nint main() {\n\tstatic char cc[1048576], *s = cc;\n\tlong long x, y;\n\n\tscanf(\"%lld%lld\", &x, &y);\n\tif (gcd(x, y) != 1) {\n\t\tprintf(\"Impossible\\n\");\n\t\treturn 0;\n\t}\n\twhile (x > 1 || y > 1) {\n\t\tlong long k;\n\t\tchar c;\n\n\t\tif (x > y) {\n\t\t\tk = x / y;\n\t\t\tif (y == 1)\n\t\t\t\tk--;\n\t\t\tx %= y;\n\t\t\tc = 'A';\n\t\t} else {\n\t\t\tk = y / x;\n\t\t\tif (x == 1)\n\t\t\t\tk--;\n\t\t\ty %= x;\n\t\t\tc = 'B';\n\t\t}\n\t\ts += sprintf(s, \"%lld%c\", k, c);\n\t}\n\tprintf(\"%s\\n\", cc);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2d58e30a7204dc9228ae86f322e736f2", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define uLL unsigned long long\n#define LL long long\nuLL exgcd64(uLL a,uLL b,uLL *x,uLL *y)\n{\n\tstatic uLL gcd;\n\tif (a==0)\n\t{\n\t\t*x=0;*y=1;\n\t\treturn b;\n\t}\n\telse\n\t{\n\t\tgcd=exgcd64(b%a,a,y,x);\n\t\t*x-=(b/a)*(*y)+b;\n\t\t*y+=a;\n\t\treturn gcd;\n\t}\n}\nint main()\n{\n\tfreopen(\"in.in\",\"r\",stdin);\n\tLL i,j,k,n,m,a,b,c,d,x,y,vx,vy;\n\tscanf(\"%lld%lld%lld%lld%lld%lld\",&n,&m,&x,&y,&vx,&vy);\n\tif ((vx==0)||(vy==0))\n\t{\n\t\tif (vx==0)\n\t\t{\n\t\t\tif ((x==0)||(x==n))\n\t\t\t{\n\t\t\t\tif (vy<0) {printf(\"%lld 0\\n\",x);}\n\t\t\t\telse {printf(\"%lld %lld\\n\",x,m);}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t}\n\t\t}\n\t\tif (vy==0)\n\t\t{\n\t\t\tif ((y==0)||(y==m))\n\t\t\t{\n\t\t\t\tif (vx<0) {printf(\"0 %lld\\n\",y);}\n\t\t\t\telse {printf(\"%lld %lld\\n\",n,y);}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (vx<0)\n\t\t{\n\t\t\tx=n-x;\n\t\t}\n\t\tif (vy<0)\n\t\t{\n\t\t\ty=m-y;\n\t\t}\n\t\t//printf(\"%lld %lld %lld %lld\\n\",n,m,x,y);\n\t\tc=exgcd64(m,n,&a,&b);\n\t\td=x-y;\n\t\tif (d<0) {d=(d%m+m)%m;}\n\t\tif (d%c!=0) {printf(\"-1\\n\");}\n\t\telse\n\t\t{\n\t\t\tc=(d/c)*(b/c)%(m/c);\n\t\t\tif (c==0) {c+=m/c;}\n\t\t\td=(c*n-(x-y))/m;\n\t\t\t//printf(\"%lld %lld %lld %lld\\n\",c,d,n,m);\n\t\t\tc=c&1;d=d&1;\n\t\t\tif (vx<0) {c=c^1;}\n\t\t\tif (vy<0) {d=d^1;}\n\t\t\tc=c*n;d=d*m;\n\t\t\tprintf(\"%lld %lld\\n\",c,d);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "a683429ddb77a3671cd4f27ec17043d8", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "#include \n\nlong long power_mod (long long a, long long b, long long mod_num) {\n long long ans = 1LL;\n \n if (b > 0LL) {\n ans = power_mod(a, b/2LL, mod_num);\n ans = (ans * ans) % mod_num;\n if (b%2LL == 1LL) {\n ans = (ans * a) % mod_num;\n }\n }\n \n return ans;\n}\n\nint main () {\n int n = 0;\n int k = 0;\n \n int res = 0;\n \n long long ans = 0LL;\n long long mod_num = 1000000007LL;\n \n long long fact[100001] = {};\n long long invf[100001] = {};\n \n res = scanf(\"%d\", &n);\n res = scanf(\"%d\", &k);\n \n if (n <= k) {\n printf(\"%lld\\n\", power_mod(2LL, (long long)n, mod_num));\n return 0;\n }\n \n fact[0] = 1LL;\n for (int i = 0; i < n; i++) {\n fact[i+1] = fact[i];\n fact[i+1] *= (long long) (i+1);\n fact[i+1] %= mod_num;\n }\n \n invf[n] = power_mod(fact[n], mod_num-2LL, mod_num);\n for (int i = n; i > 0; i--) {\n invf[i-1] = invf[i];\n invf[i-1] *= (long long)i;\n invf[i-1] %= mod_num;\n }\n \n for (int i = 0; i <= k; i++) {\n long long tmp = invf[i];\n tmp = (tmp*invf[n-i])%mod_num;\n ans = (ans+tmp)%mod_num;\n }\n \n ans = (ans*fact[n])%mod_num;\n printf(\"%lld\\n\", ans);\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4490b734a59caf875c0ba64f4ef2d97e", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define N\t500\n#define N_\t(1 << 9)\t/* N_ = pow2(ceil(log2(N))) */\n#define INF\t0x3f3f3f3f3f3f3f3fLL\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\n\nint *oh[N][N], *ot[N][N], *ox[N][N], oo[N][N];\n\nvoid link(int i, int j, int h, int t, int x) {\n\tint o = oo[i][j]++;\n\n\tif (o >= 2 && (o & o - 1) == 0) {\n\t\toh[i][j] = (int *) realloc(oh[i][j], o * 2 * sizeof *oh[i][j]);\n\t\tot[i][j] = (int *) realloc(ot[i][j], o * 2 * sizeof *ot[i][j]);\n\t\tox[i][j] = (int *) realloc(ox[i][j], o * 2 * sizeof *ox[i][j]);\n\t}\n\toh[i][j][o] = h, ot[i][j][o] = t, ox[i][j][o] = x;\n}\n\nlong long *st_, *lz_; int h_, n_;\n\nvoid put(int i, long long x) {\n\tst_[i] += x;\n\tif (i < n_)\n\t\tlz_[i] += x;\n}\n\nvoid pus(int i) {\n\tif (lz_[i]) {\n\t\tput(i << 1, lz_[i]), put(i << 1 | 1, lz_[i]);\n\t\tlz_[i] = 0;\n\t}\n}\n\nvoid pul(int i) {\n\tif (!lz_[i])\n\t\tst_[i] = min(st_[i << 1], st_[i << 1 | 1]);\n}\n\nvoid push(int i) {\n\tint h;\n\n\tfor (h = h_; h > 0; h--)\n\t\tpus(i >> h);\n}\n\nvoid pull(int i) {\n\twhile (i > 1)\n\t\tpul(i >>= 1);\n}\n\nvoid update(int l, int r, long long x) {\n\tint l_ = l += n_, r_ = r += n_;\n\n\tpush(l_), push(r_);\n\tfor ( ; l <= r; l >>= 1, r >>= 1) {\n\t\tif ((l & 1) == 1)\n\t\t\tput(l++, x);\n\t\tif ((r & 1) == 0)\n\t\t\tput(r--, x);\n\t}\n\tpull(l_), pull(r_);\n}\n\nvoid update1(int i, long long x) {\n\tpush(i += n_);\n\tst_[i] = x;\n\tpull(i);\n}\n\nlong long query(int l, int r) {\n\tlong long x;\n\n\tpush(l += n_), push(r += n_);\n\tx = INF;\n\tfor ( ; l <= r; l >>= 1, r >>= 1) {\n\t\tif ((l & 1) == 1)\n\t\t\tx = min(x, st_[l++]);\n\t\tif ((r & 1) == 0)\n\t\t\tx = min(x, st_[r--]);\n\t}\n\treturn x;\n}\n\nint main() {\n\tstatic long long xx[N][N], st[N][N_ * 2], lz[N][N_ * 2], sti[N_ * 2], lzi[N_ * 2];\n\tint n, m, k, i, j;\n\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < m; j++) {\n\t\t\toh[i][j] = (int *) malloc(2 * sizeof *oh[i][j]);\n\t\t\tot[i][j] = (int *) malloc(2 * sizeof *ot[i][j]);\n\t\t\tox[i][j] = (int *) malloc(2 * sizeof *ox[i][j]);\n\t\t}\n\twhile (k--) {\n\t\tint d, t, x;\n\t\tint meet1, meet2, meet3, meet4;\n\n\t\tscanf(\"%d%d%d%d%d\", &i, &j, &d, &t, &x);\n\t\tmeet1 = meet2 = meet3 = meet4 = 0;\n\t\tif (i + j >= t && (i + j) % 4 == t % 4)\n\t\t\txx[i][j] += x, meet1 = 1;\n\t\tif (i + j >= t && (i + j) % 4 == (t + 1) % 4)\n\t\t\txx[i + d][j - d] += x, meet2 = 1;\n\t\tif (i + j + d >= t && (i + j + d) % 4 == (t + 2) % 4)\n\t\t\txx[i + d][j] += x, meet3 = 1;\n\t\tif (i + j + d >= t && (i + j + d) % 4 == (t + 2) % 4)\n\t\t\txx[i][j + d] += x, meet4 = 1;\n\t\tif (meet1 && meet3)\n\t\t\tlink(i + d, j, i, 0, x);\n\t\tif (meet1 && meet4)\n\t\t\tlink(i, j + d, j, 1, x);\n\t\tif (meet2 && meet3)\n\t\t\tlink(i + d, j, j - d, 1, x);\n\t}\n\th_ = 0;\n\twhile (1 << h_ < n || 1 << h_ < m)\n\t\th_++;\n\tn_ = 1 << h_;\n\tfor (i = 0; i < n; i++) {\n\t\tmemset(sti, 0, n_ * 2 * sizeof *sti);\n\t\tmemset(lzi, 0, n_ * 2 * sizeof *lzi);\n\t\tfor (j = 0; j < m; j++) {\n\t\t\tint o;\n\t\t\tlong long x;\n\n\t\t\tfor (o = 0; o < oo[i][j]; o++) {\n\t\t\t\tint h = oh[i][j][o], t = ot[i][j][o], x = ox[i][j][o];\n\n\t\t\t\tif (t == 0)\n\t\t\t\t\tst_ = st[j], lz_ = lz[j], update(0, h, -x);\n\t\t\t\telse\n\t\t\t\t\tst_ = sti, lz_ = lzi, update(0, h, -x);\n\t\t\t}\n\t\t\tif (i == 0 && j == 0)\n\t\t\t\tx = 0;\n\t\t\telse {\n\t\t\t\tx = INF;\n\t\t\t\tif (i > 0)\n\t\t\t\t\tst_ = st[j], lz_ = lz[j], x = min(x, query(0, i - 1));\n\t\t\t\tif (j > 0)\n\t\t\t\t\tst_ = sti, lz_ = lzi, x = min(x, query(0, j - 1));\n\t\t\t}\n\t\t\tst_ = st[j], lz_ = lz[j], update1(i, x), update(0, i, xx[i][j]);\n\t\t\tst_ = sti, lz_ = lzi, update1(j, x), update(0, j, xx[i][j]);\n\t\t}\n\t}\n\tst_ = st[m - 1], lz_ = lz[m - 1];\n\tprintf(\"%lld\\n\", query(n - 1, n - 1));\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e95c5d5ac506b6553693e941922568db", "src_uid": "b11cb0c2bf23bf4b4e6f6af61af9c290", "difficulty": 2600.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tstatic char cc[100001], s[100001], t[100001];\n\tstatic int kk[10], kk_[10];\n\tint n, ns, nt;\n\tint h, i, d, d_, k, k_, k0;\n\tint max, kmax, dmax;\n\n\tscanf(\"%s\", cc);\n\tn = strlen(cc);\n\tk0 = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tkk[cc[i] - '0']++;\n\t\tif (cc[i] == '0')\n\t\t\tk0++;\n\t}\n\tmax = kmax = dmax = -1, k = 0;\n\twhile (kk[0] >= 0) {\n\t\tfor (d = 0; d <= 9; d++)\n\t\t\tkk_[d] = kk[d];\n\t\tif (max < k) {\n\t\t\tmax = kmax = k;\n\t\t\tdmax = -1;\n\t\t}\n\t\tfor (d = 1; d <= 9; d++)\n\t\t\tif (kk[d] > 0 && kk_[10 - d] > 0) {\n\t\t\t\tkk[d]--, kk_[10 - d]--;\n\t\t\t\tk_ = 0;\n\t\t\t\tfor (d_ = 0; d_ <= 9; d_++)\n\t\t\t\t\tk_ += kk[d_] < kk_[9 - d_] ? kk[d_] : kk_[9 - d_];\n\t\t\t\tkk[d]++, kk_[10 - d]++;\n\t\t\t\tif (max < k + 1 + k_) {\n\t\t\t\t\tmax = k + 1 + k_;\n\t\t\t\t\tkmax = k;\n\t\t\t\t\tdmax = d;\n\t\t\t\t}\n\t\t\t}\n\t\tkk[0]--;\n\t\tk++;\n\t}\n\tns = nt = 0;\n\tkk[0] = kk_[0] = k0 - kmax;\n\tif (dmax >= 0) {\n\t\tkk[dmax]--, kk_[10 - dmax]--;\n\t\tfor (d_ = 0; d_ <= 9; d_++) {\n\t\t\tfor (h = kk[d_]; h < kk_[9 - d_]; h++)\n\t\t\t\tt[nt++] = 9 - d_ + '0';\n\t\t\tfor (h = kk_[9 - d_]; h < kk[d_]; h++)\n\t\t\t\ts[ns++] = d_ + '0';\n\t\t}\n\t\tfor (d_ = 0; d_ <= 9; d_++)\n\t\t\tfor (h = 0; h < kk[d_] && h < kk_[9 - d_]; h++) {\n\t\t\t\ts[ns++] = d_ + '0';\n\t\t\t\tt[nt++] = 9 - d_ + '0';\n\t\t\t}\n\t\ts[ns++] = dmax + '0';\n\t\tt[nt++] = 10 - dmax + '0';\n\t} else\n\t\tfor (d_ = 0; d_ <= 9; d_++) {\n\t\t\tfor (h = 0; h < kk[d_]; h++)\n\t\t\t\ts[ns++] = d_ + '0';\n\t\t\tfor (h = 0; h < kk_[d_]; h++)\n\t\t\t\tt[nt++] = d_ + '0';\n\t\t}\n\tfor (h = 0; h < kmax; h++)\n\t\ts[ns++] = t[nt++] = '0';\n\tprintf(\"%s\\n\", s);\n\tprintf(\"%s\\n\", t);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2d26ffd79fe79ba0c2ec43efdda6ae54", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar s[101];\nint k, n, i, j, x, ok[30];\n\nvoid read(){\n\tscanf(\"%d%s\", &k, s);\n}\n\nint process(){\n\tn = strlen(s);\n\tx=n/2;\n\tfor(i=0, j=n-1;i=0&&i>=0;x--){\n\t\t\n\t\tif(s[x]=='?'){\n\t\t\twhile(i>0&&ok[i])--i;\n\t\t\ts[x]=s[n-x-1]='a'+i;\n\t\t\tok[s[x]-'a']=1;\n\t\t}\n\t}\n\tfor(i=0;i\n#include \n#include \n\n#define LEN 78777\n#define MAX 1000010\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))\n#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))\n#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))\n\nint p, x, y, prime[LEN];\nunsigned int ar[(MAX >> 6) + 5] = {0};\n\nvoid sieve(){\n int i, j, k;\n setbit(ar, 0), setbit(ar, 1);\n\n for (i = 3; (i * i) < MAX; i += 2){\n if (!chkbit(ar, i)){\n k = i << 1;\n for (j = (i * i); j < MAX; j += k) setbit(ar, j);\n }\n }\n\n p = 0;\n prime[p++] = 2;\n for (i = 3; i < MAX; i += 2){\n if (isprime(i)) prime[p++] = i;\n }\n}\n\nint expo(int a, int b){\n int res = 1;\n\n while (b){\n if (b & 1) res = (long long)res * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return res;\n}\n\nint mobius(int n){\n if (n == 1) return 1;\n\n int i, j, x, counter = 0;\n for (i = 0; i < p; i++){\n if (prime[i] * prime[i] > n) break;\n for (j = 0; (n % prime[i]) == 0; j++, n /= prime[i]) {}\n if (j > 1) return 0;\n counter += (j == 1);\n }\n\n return (counter & 1) ? 1 : -1;\n}\n\nint count(int n, int d){\n return (mobius(d) * expo(2, (n / d) - 1) + MOD) % MOD;\n}\n\nint solve(int x, int y){\n int d, n, res = 0;\n if ((y % x) != 0) return 0;\n\n n = y / x;\n for (d = 1; d * d <= n; d++){\n if (n % d == 0){\n res = (res + count(n, d)) % MOD;\n if ((n / d) != d) res = (res + count(n, n / d)) % MOD;\n }\n }\n\n return res;\n}\n\nint main(){\n sieve();\n scanf(\"%d %d\", &x, &y);\n printf(\"%d\\n\", solve(x, y));\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "e9346b55ef91b05a019d76dcdd27e72e", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint determine(int *guesses, int *bulls, int *cows, int n);\nbool is_solution(int *K, int *guesses, int *bulls, int *cows, int n);\nbool fits(int *K, int guess, int bulls, int cows);\n\nint main() {\n\tint n = 0, k = 0, result = 0;\n\tint *guesses = NULL;\n\tint *bulls = NULL;\n\tint *cows = NULL;\n\t\n\tscanf(\"%d\", &n);\n\t\n\tguesses = calloc(n, sizeof(int));\n\tbulls = calloc(n, sizeof(int));\n\tcows = calloc(n, sizeof(int));\n\t\n\tfor(k=0; k\n#define P 1000000007\nint n,i,j;__int64 t=1,s;\nint main(){\n scanf(\"%d\",&n);\n for(i=1;i<=n;++i)t=t*i%P;\n for(j=P-3,s=t;j;j>>=1,s=s*s%P)\n if(j&1)t=t*s%P;\n for(i=n;i\n#include\n#define modd 1000000007\nlong long fast_expo(long long a,long long b)\n{\n long long res=1;\n while(b>0)\n {\n if(b&1)\n res=(res*a)%modd;\n a=(a*a)%modd;\n b=b>>1;\n }\n return res;\n}\nint main()\n{\n long long fact[200001];\n int i,n;\n fact[0]=1;\n for(i=1;i<200001;i++){\n fact[i]=(fact[i-1]*i)%modd;\n // printf(\"fact[%d] = %d \\n\",i, fact[i]);\n }\n while(scanf(\"%d\",&n)==1)\n {\n long long ans=(fact[(n<<1)-1]*((fast_expo(fact[n],modd-2)*fast_expo(fact[n-1],modd-2))%modd))%modd;\n ans=(ans<<1)-n;\n if(ans<0)\n printf(\"%I64d\\n\",(ans+modd)%modd);\n else printf(\"%I64d\\n\",ans%modd);\n }\n return 0;\n}\n\n\n\n\n\n\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c849aa19cba1296eabde08cd1995688e", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\nlong long int n,p,way;\np=10;\nscanf(\"%I64d\",&n);\nn=n*2;\nwhile(n%p!=n) p=p*10;\np=p/10;\nn=n/2;\nif(p==1) way=n*(n-1)/2;\nelse if(n%p<=p/2-1) way=(1+n/p)*(n%p)*(n/p)+(p/2-n%p)*(n/p)*(n/p);\nelse if(n%p<=p-2) way=(n%p-p/2+1)*(n/p+1)*(n/p+1)+(p-2-n%p)*(n/p)*(n/p+1)+(n/p)*(n/p);\nelse way=(n/p+1)*(n/p)+(p/2-1)*(n/p+1)*(n/p+1);\nprintf(\"%I64d\",way);\nreturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "077180d62d14ed617443c94417afe64e", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\n\nint num[11],val[11];\n\n__int64 dp[30000][100];\n\nint main()\n{\n __int64 n;int m;\n int i,j,k;\n scanf(\"%I64d%d\",&n,&m);\n while(n)\n {\n num[n%10]++;n/=10;\n }\n val[0] = 1;\n for(i=1;i<=10;i++)\n val[i] = val[i-1]*(num[i-1]+1);\n dp[0][0] = 1;\n for(i=0;i=num[j])\n continue;\n for(k=0;k\n#include \n\n#define N\t1000000\n#define M\t1000000\n#define K\t20\n\nint aa[N + 1], kk[N + 1];\n\nvoid init() {\n\tint a, b, b_, k;\n\n\tfor (a = 2; a <= N; a++) {\n\t\tif (aa[a])\n\t\t\tcontinue;\n\t\tb = 1, b_ = N / a, k = 0;\n\t\twhile (b <= b_) {\n\t\t\tb *= a, k++;\n\t\t\taa[b] = a, kk[b] = k;\n\t\t}\n\t}\n}\n\nint main() {\n\tstatic char used[M * K + 1];\n\tstatic int cc[K + 1];\n\tint n, m, a, b, b_, j, k, cnt;\n\tlong long ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &m);\n\tcnt = 0;\n\tfor (k = 1; k <= K; k++) {\n\t\tfor (j = 1; j <= m; j++)\n\t\t\tif (!used[j * k])\n\t\t\t\tused[j * k] = 1, cnt++;\n\t\tcc[k] = cnt;\n\t}\n\tans = 1;\n\tfor (a = 2; a <= n; a++)\n\t\tif (aa[a] == a) {\n\t\t\tb = 1, b_ = n / a, k = 0;\n\t\t\twhile (b <= b_)\n\t\t\t\tb *= a, k++;\n\t\t\tans += cc[k];\n\t\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "3d4aad60438286f8e85b5f8e991eab6c", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "#include \n\n#define M\t100\n#define MD\t1000000007\n\nvoid mult(int aa[][M], int bb[][M], int cc[][M], int m) {\n\tint i, j, k;\n\n\tfor (i = 0; i < m; i++) {\n\t\tint *ci = cc[i];\n\n\t\tfor (j = 0; j < m; j++)\n\t\t\tci[j] = 0;\n\t\tfor (k = 0; k < m; k++) {\n\t\t\tint *bk = bb[k], a = aa[i][k];\n\n\t\t\tfor (j = 0; j < m; j++)\n\t\t\t\tci[j] = (ci[j] + (long long) a * bk[j]) % MD;\n\t\t}\n\t}\n}\n\nvoid power(int aa[][M], int pp[][M], int tt[][M], int m, long long k) {\n\tif (k == 0) {\n\t\tint i, j;\n\n\t\tfor (i = 0; i < m; i++)\n\t\t\tfor (j = 0; j < m; j++)\n\t\t\t\tpp[i][j] = i == j;\n\t\treturn;\n\t}\n\tif (k % 2 == 0) {\n\t\tpower(aa, tt, pp, m, k / 2);\n\t\tmult(tt, tt, pp, m);\n\t} else {\n\t\tpower(aa, pp, tt, m, k / 2);\n\t\tmult(pp, pp, tt, m);\n\t\tmult(tt, aa, pp, m);\n\t}\n}\n\nint main() {\n\tstatic int aa[M][M], pp[M][M], tt[M][M];\n\tlong long n;\n\tint m, i, j, ans;\n\n\tscanf(\"%lld%d\", &n, &m);\n\tif (n < m) {\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\tfor (i = 0; i < m - 1; i++)\n\t\taa[i][i + 1] = 1;\n\taa[m - 1][0] = aa[m - 1][m - 1] = 1;\n\tpower(aa, pp, tt, m, n - m + 1);\n\tans = 0;\n\tfor (j = 0; j < m; j++)\n\t\tans = (ans + pp[m - 1][j]) % MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "886c64f1e06286fafef916db323c356e", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "#include\nint comp(const void * a,const void * b)\n{\n return (*(int*)a - *(int*)b);\n}\nint main()\n{\n int n,m,i,j,arr[10000],k,xx,xy,l,z,p,pp=0,qq=0;\n scanf(\"%d %d\",&n,&k);\n for(i=0;i=k)\n break;\n if(arr[i]==arr[j])\n m++;\n else{\n xy=arr[j];\n p=0;\n while(xy>arr[i]){\n xy/=2;\n p++;\n }\n if(xy==arr[i]){\n m++;\n l+=p;\n }\n }\n }\n if(i==0 && m>=k){\n xx=l;\n qq++;\n\n }\n else if((xx>l && m>=k)|| (qq==0)){\n xx=l;\n qq++;\n }\n if(i==z){\n pp=0;l=0;\n for(i=0;i0){\n arr[i]/=2;\n l++;\n }\n }\n pp=l;\n if(pp\nlong long int n, k, M, D;\n\nlong long int max(long long int a, long long int b)\n{\n\tif (a > b)\n\t\treturn a;\n\treturn b;\n}\n\nint main()\n{\n\tscanf(\"%I64d %I64d %I64d %I64d\", &n, &k, &M, &D);\n\tlong long int ans = M;\n\tfor (long long int i = D; i >= 2; i--)\n\t{\n\t\tif (n/i < k)\n\t\t\tcontinue;\n\t\tlong long int beg = 1, end = M;\n\t\t\n\t\twhile (beg <= end)\n\t\t{\n\t\t\tlong long int mid = (beg+end)/2;\n\t\t\tlong long int num = n/mid;\n\t\t\t//printf(\"%d, %d, %d\\n\", i, mid, num);\n\t\t\tif (num < k*(i-1)+1)\n\t\t\t{\n\t\t\t\tend = mid-1;\n\t\t\t}\n\t\t\telse if (i == D && num >= k*i+1)\n\t\t\t{\n\t\t\t\tbeg = mid+1;\n\t\t\t}\n\t\t\telse if (num >= k*(i-1)+1)\n\t\t\t{\n\t\t\t\tans = max(ans, (i)*mid);\n\t\t\t\tbeg = mid+1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tbeg = mid+1;\n\t\t\t\tans = max(ans, (i)*mid);\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%I64d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "90ffee8a013a48df3d1a2957e83814a9", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#define maxn 210\n\nint p[maxn], num[maxn], bef[maxn][maxn], vis[maxn], an[4];\n\nint min(int a, int b, int c){\n\ta = a < b ? a : b;\n\treturn a < c ? a : c;\n}\n\nint gao(int start, int n){\n\tint finish = 0, ans = 0, f = 0, now, flag = 0, i, j;\n\tmemset(vis, 0, sizeof(vis));\n\twhile(finish != n){\n\t\tfor(now = 1; now <= 3; now++){\n\t\t\tif(now == start){\n\t\t\t\tflag = 1;\n\t\t\t}\n\t\t\tif(flag == 1){\n\t\t\t\tfor(i = 1; i <= n; i++){\n\t\t\t\t\tif(p[i] == now){\n\t\t\t\t\t\tif(!num[i] && !vis[i]){\n\t\t\t\t\t\t\tans++; \n\t\t\t\t\t\t\t//printf(\"+\");//\n\t\t\t\t\t\t\tvis[i] = 1;\n\t\t\t\t\t\t\tfinish++;\n\t\t\t\t\t\t\t//printf(\"%d \", i);//\n\t\t\t\t\t\t\ti = 0;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tf = 0;\n\t\t\t\t\t\t\tfor(j = 1; j <= num[i]; j++){ \n\t\t\t\t\t\t\t\tif(!vis[bef[i][j]]){\n\t\t\t\t\t\t\t\t\tf = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(f == 0 && !vis[i]){\n\t\t\t\t\t\t\t\tans++;\n\t\t\t\t\t\t\t\t//printf(\"+\");// \n\t\t\t\t\t\t\t\tvis[i] = 1;\n\t\t\t\t\t\t\t\tfinish++;\n\t\t\t\t\t\t\t\t//printf(\"%d \", i);//\n\t\t\t\t\t\t\t\ti = 0;\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}\t\t\n\t\t\t}\n\t\t\tif(flag == 1 && finish != n){\n\t\t\t\tans++;\n\t\t\t\t//printf(\"(+)\");//\n\t\t\t}\n\t\t}\t\t\n\t}\n\t//printf(\"\\n\");//\n\treturn ans;\n}\n\nint main(void){\n\tint n, i, j, ans;\n\tscanf(\"%d\", &n);\n\tfor(i = 1; i <= n; i++){\n\t\tscanf(\"%d\", &p[i]);\n\t}\n\tfor(i = 1; i <= n; i++){\n\t\tscanf(\"%d\", &num[i]);\n\t\tfor(j = 1; j <= num[i]; j++){\n\t\t\tscanf(\"%d\", &bef[i][j]);\n\t\t}\n\t}\n\t\n\tfor(i = 1; i <= 3; i++){\n\t\tan[i] = gao(i, n);\n\t\t//printf(\"%d\\n\", an[i]);//\n\t}\n\tans = min(an[1], an[2], an[3]);\n\tprintf(\"%d\", ans);\n\treturn 0;\n} \n", "lang_cluster": "C", "compilation_error": false, "code_uid": "2e5024059a07ca82eae3cf9826090ceb", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n, m, i;\n double p = 0, q = 0;\n double pi = acos(-1);\n double x = (1 + sqrt(5)) / 2;\n \n scanf(\"%d\", &n);\n \n m = 4 * (n - 1) + 5;\n \n printf(\"%d\\n\", m);\n \n for (i = 0; i < n; i++) {\n if (i == 0) printf(\"%.12lf %.12lf\\n\", p, q);\n \n printf(\"%.12lf %.12lf\\n\", p + 10 * x, q);\n printf(\"%.12lf %.12lf\\n\", p + 5 * x, 10 * cos(54 * pi / 180));\n printf(\"%.12lf %.12lf\\n\", p + 10 * cos(72 * pi / 180), -10 * sin(72 * pi / 180));\n printf(\"%.12lf %.12lf\\n\", p + 10 * x - 10 * cos(72 * pi / 180), -10 * sin(72 * pi / 180));\n \n p += 10 * x;\n }\n \n for (i = 0; i < n; i++) {\n if (i == 0) {\n printf(\"1\");\n } else {\n printf(\"%d\", i * 4 - 2);\n }\n \n printf(\" %d %d %d %d\\n\", i * 4 + 2, i * 4 + 3, i * 4 + 4, i * 4 + 5);\n }\n \n printf(\"1\");\n \n for (i = 0; i < n; i++) printf(\" %d\", i * 4 + 2);\n \n for (i = n - 1; i >= 0; i--) {\n printf(\" %d %d %d\", i * 4 + 4, i * 4 + 3, i * 4 + 5);\n \n if (i == 0) {\n printf(\" 1\");\n } else {\n printf(\" %d\", i * 4 - 2);\n }\n }\n \n puts(\"\");\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "99d8def53dc28a34656bbc6c9a785921", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint cmp(const void *a,const void *b) {\n\tlong long a1=*(long long *)a,b1=*(long long *)b;\n\tif (a1b1) return 1; else return 0;\n}\n\nlong long a[64][4];\nint n,m,p;\nlong long dp[64][64][128];\nint pre[64][64][64];\nlong long r[54][2];\n\nint main() {\n\tint i,j,k,l;\n\tscanf(\"%d %d %d\",&n,&m,&p);\n\tfor(i=0;ia[l][0]) {\n\t\t\tif (a[j][1]+k>p && a[j][1]+k-p>=a[l][1] && a[j][1]+k-p<=a[l][2]) {\n\t\t\t\tlong long t=dp[i-1][l][a[j][1]+k-p-a[l][1]];\n\t\t\t\tif (t>=0) {\n\t\t\t\t\tt+=a[j][1]+k;\n\t\t\t\t\tif (t>dp[i][j][k]) dp[i][j][k]=t,pre[i][j][k]=l<<8|(a[j][1]+k-p-a[l][1]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ((a[j][1]+k)%p==0 && (a[j][1]+k)/p>=a[l][1] && (a[j][1]+k)/p<=a[l][2]) {\n\t\t\t\tlong long t=dp[i-1][l][(a[j][1]+k)/p-a[l][1]];\n\t\t\t\tif (t>=0) {\n\t\t\t\t\tt+=a[j][1]+k;\n\t\t\t\t\tif (t>dp[i][j][k]) dp[i][j][k]=t,pre[i][j][k]=l<<8|((a[j][1]+k)/p-a[l][1]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tk=l=0;\n\tfor(i=0;idp[n-1][k][l]) k=i,l=j;\n\tif (dp[n-1][k][l]<0) {\n\t\tputs(\"NO\");\n\t\treturn 0;\n\t}\n\tputs(\"YES\");\n\tfor(i=n-1;i>=0;i--) {\n\t\tr[i][0]=a[k][3]+1;\n\t\tr[i][1]=a[k][1]+l;\n\t\tj=pre[i][k][l];\n\t\tk=j>>8;\n\t\tl=j&255;\n\t}\n\tfor(i=0;i\n\n#define N\t50\n#define T\t2500\n#define MD\t1000000007\n\nint dp[N + 1][N + 1][N + 1], dq[N + 1][N + 1][N + 1][3];\n\nvoid init(int na, int nb, int nc) {\n\tint ma, mb, mc, x0, x1, x2;\n\n\tfor (ma = 0; ma <= na; ma++)\n\t\tfor (mb = 0; mb <= nb; mb++)\n\t\t\tfor (mc = 0; mc <= nc; mc++) {\n\t\t\t\tx0 = ma > 0 ? (long long) dq[ma - 1][mb][mc][0] * ma % MD : 0;\n\t\t\t\tx1 = mb > 0 ? (long long) dq[ma][mb - 1][mc][1] * mb % MD : 0;\n\t\t\t\tx2 = mc > 0 ? (long long) dq[ma][mb][mc - 1][2] * mc % MD : 0;\n\t\t\t\tif (ma == 0 && mb == 0 && mc == 0) {\n\t\t\t\t\tdp[ma][mb][mc] = 1;\n\t\t\t\t\tdq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tdp[ma][mb][mc] = ((long long) x0 + x1 + x2) % MD;\n\t\t\t\t\tdq[ma][mb][mc][0] = (x1 + x2) % MD;\n\t\t\t\t\tdq[ma][mb][mc][1] = (x0 + x2) % MD;\n\t\t\t\t\tdq[ma][mb][mc][2] = (x0 + x1) % MD;\n\t\t\t\t}\n\t\t\t}\n}\n\nvoid solve1(int *aa, int t, int n, int da[][N + 1]) {\n\tint i, s, m, a;\n\n\tfor (s = 0; s <= t; s++)\n\t\tfor (m = 0; m <= n; m++)\n\t\t\tda[0][0] = 0;\n\tda[0][0] = 1;\n\tfor (i = 0; i < n; i++) {\n\t\ta = aa[i];\n\t\tfor (s = t; s >= a; s--)\n\t\t\tfor (m = 1; m <= n; m++)\n\t\t\t\tda[s][m] = (da[s][m] + da[s - a][m - 1]) % MD;\n\t}\n}\n\nvoid solve2(int *aa, int *bb, int t, int na, int nb, int dab[][N + 1][N + 1]) {\n\tstatic int da[T + 1][N + 1];\n\tint i, b, s, ma, mb;\n\n\tsolve1(aa, t, na, da);\n\tfor (s = 0; s <= t; s++)\n\t\tfor (ma = 0; ma <= na; ma++) {\n\t\t\tdab[s][ma][0] = da[s][ma];\n\t\t\tfor (mb = 1; mb <= nb; mb++)\n\t\t\t\tdab[s][ma][mb] = 0;\n\t\t}\n\tfor (i = 0; i < nb; i++) {\n\t\tb = bb[i];\n\t\tfor (s = t; s >= b; s--)\n\t\t\tfor (ma = 0; ma <= na; ma++)\n\t\t\t\tfor (mb = 1; mb <= nb; mb++)\n\t\t\t\t\tdab[s][ma][mb] = (dab[s][ma][mb] + dab[s - b][ma][mb - 1]) % MD;\n\t}\n}\n\nint main() {\n\tstatic int aa[N], bb[N], cc[N], dab[T + 1][N + 1][N + 1], dc[T + 1][N + 1];\n\tint n, na, nb, nc, t, tab, tc, ma, mb, mc, xab, xc, ans;\n\n\tscanf(\"%d%d\", &n, &t);\n\tna = nb = nc = 0;\n\twhile (n--) {\n\t\tint a, g;\n\n\t\tscanf(\"%d%d\", &a, &g);\n\t\tif (g == 1)\n\t\t\taa[na++] = a;\n\t\telse if (g == 2)\n\t\t\tbb[nb++] = a;\n\t\telse\n\t\t\tcc[nc++] = a;\n\t}\n\tinit(na, nb, nc);\n\tsolve1(cc, t, nc, dc);\n\tsolve2(aa, bb, t, na, nb, dab);\n\tans = 0;\n\tfor (tab = 0; tab <= t; tab++) {\n\t\ttc = t - tab;\n\t\tfor (ma = 0; ma <= na; ma++)\n\t\t\tfor (mb = 0; mb <= nb; mb++)\n\t\t\t\tif ((xab = dab[tab][ma][mb]))\n\t\t\t\t\tfor (mc = 0; mc <= nc; mc++)\n\t\t\t\t\t\tif ((xc = dc[tc][mc]))\n\t\t\t\t\t\t\tans = (ans + (long long) xab * xc % MD * dp[ma][mb][mc]) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "9469218b1527238f06f4e9b4c824f02c", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n#include \n\n#define N\t30\n#define T\t(30 * 31 / 2)\n#define NU\t(N * T)\n#define NV\t(NU * 3)\n\nchar *strndup_(char *s, int n) {\n\tchar *s_ = malloc(n + 1);\n\n\tstrncpy(s_, s, n);\n\ts_[n] = 0;\n\treturn s_;\n}\n\nstruct V {\n\tchar *s;\n\tint i, h;\n} vv_[NV], *vv[NV];\n\nint compare(const void *a, const void *b) {\n\tstruct V *u = *(struct V **) a;\n\tstruct V *v = *(struct V **) b;\n\tint mu = strlen(u->s), mv = strlen(v->s);\n\tint c;\n\n\tif (mu != mv)\n\t\treturn mu - mv;\n\tc = strcmp(u->s, v->s);\n\treturn c != 0 ? c : u->i - v->i;\n}\n\nint score(char *s) {\n\tint n = strlen(s), i;\n\tint sum, max;\n\n\tsum = max = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tint a = s[i] - 'a' + 1;\n\n\t\tsum += a;\n\t\tif (max < a)\n\t\t\tmax = a;\n\t}\n\treturn sum * max;\n}\n\nint xx[NU + 1];\nchar ww[NU + 1];\nint ss[NU + 1], tt[NU + 1];\n\nvoid push(int p, int i) {\n\tint s = tt[i] + xx[i], t = ss[i];\n\n\tif (!ww[p]) {\n\t\tif (!ww[i])\n\t\t\tww[p] = 1, ss[p] = s, tt[p] = t;\n\t\telse if (ss[p] < s || ss[p] == s && tt[p] > t)\n\t\t\tss[p] = s, tt[p] = t;\n\t} else if (!ww[i] && (ss[p] < s || ss[p] == s && tt[p] > t))\n\t\tss[p] = s, tt[p] = t;\n}\n\nint main() {\n\tstatic int pp[NU + 1], qq[NU + 1];\n\tint n, nv, k, i;\n\n\tscanf(\"%d\", &n);\n\tnv = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tstatic char s[32];\n\t\tint m, l, r;\n\n\t\tscanf(\"%s\", s), m = strlen(s);\n\t\tfor (l = 0; l < m; l++)\n\t\t\tfor (r = l; r < m; r++) {\n\t\t\t\tstruct V *v, *p, *q;\n\t\t\t\tchar *t = strndup_(s + l, r - l + 1);\n\n\t\t\t\tv = vv[nv] = &vv_[nv], nv++;\n\t\t\t\tv->s = t, v->i = i;\n\t\t\t\tp = vv[nv] = &vv_[nv], nv++;\n\t\t\t\tp->s = strndup_(t + 1, r - l), p->i = -1;\n\t\t\t\tq = vv[nv] = &vv_[nv], nv++;\n\t\t\t\tq->s = strndup_(t, r - l), q->i = -1;\n\t\t\t}\n\t}\n\tqsort(vv, nv, sizeof *vv, compare);\n\tk = 0;\n\tfor (i = 0; i < nv; ) {\n\t\tchar *s = vv[i]->s;\n\t\tint x, j;\n\n\t\tfor (j = i; j < nv && strcmp(vv[j]->s, s) == 0; j++)\n\t\t\tvv[j]->h = k;\n\t\tx = score(s);\n\t\twhile (i < j) {\n\t\t\tif (vv[i]->i != -1 && (i + 1 == j || vv[i]->i != vv[i + 1]->i))\n\t\t\t\tx++;\n\t\t\ti++;\n\t\t}\n\t\txx[k++] = x;\n\t}\n\tfor (i = 0; i < nv; i += 3) {\n\t\tstruct V *v = &vv_[i + 0];\n\t\tstruct V *p = &vv_[i + 1];\n\t\tstruct V *q = &vv_[i + 2];\n\n\t\tpp[v->h] = p->h;\n\t\tqq[v->h] = q->h;\n\t}\n\tfor (i = k - 1; i > 0; i--) {\n\t\tpush(pp[i], i);\n\t\tpush(qq[i], i);\n\t}\n\tprintf(ww[0] ? \"First\\n\" : \"Second\\n\");\n\tprintf(\"%d %d\\n\", ss[0], tt[0]);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "97b8052a3b57c28016430975621d641f", "src_uid": "d0f8976d9b847f7426dc56cb59b5b5b9", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include \n#include \n#define M 1000000009\n\ntypedef long long LL;\nint n,m,sz,son[110][4],fail[110],term[110],par[110],l[110];\nLL f[1010][110][20];\nvoid init(int u,int d);\nLL dp(int i,int u,int o);\n\nint main(void)\n{\n //freopen(\"gene.in\",\"r\",stdin);\n //freopen(\"gene.out\",\"w\",stdout);\n scanf(\"%d%d\",&n,&m);\n memset(son,0,sizeof(son));\n memset(term,0,sizeof(term));\n sz=1; l[1]=0;\n int i,j,u,t;\n char str[20];\n for(i=1;i<=m;i++)\n {\n scanf(\"%s\",str);\n for(u=1,j=0;str[j];j++)\n {\n if(str[j]=='A') t=0;\n else if(str[j]=='C') t=1;\n else if(str[j]=='G') t=2;\n else t=3;\n if(!son[u][t])\n {\n l[++sz]=l[u]+1;\n son[u][t]=sz;\n }\n par[son[u][t]]=u;\n u=son[u][t];\n }\n term[u]=1;\n }\n memset(fail,-1,sizeof(fail));\n fail[1]=0;\n for(i=0;i<4;i++)\n fail[son[1][i]]=1;\n init(1,-1);\n memset(f,-1,sizeof(f));\n printf(\"%I64d\\n\",dp(0,1,0));\n return 0;\n}\n\nvoid init(int u,int d)\n{\n int i,v;\n if(fail[u]<0)\n for( fail[u]=1,v=fail[par[u]] ; v ; v=fail[v] )\n if(son[v][d])\n {\n fail[u]=son[v][d];\n break;\n }\n for(i=0;i<4;i++)\n if(son[u][i])\n init(son[u][i],i);\n}\n\nLL dp(int i,int u,int o)\n{\n if(f[i][u][o]>=0) return f[i][u][o];\n else if(i==n)\n return f[i][u][o] = o ? 0 : 1;\n f[i][u][o]=0;\n int j,v,w,t;\n for(j=0;j<4;j++)\n {\n for( w=0,v=u ; v&&l[v]>=o ; v=fail[v] )\n if(son[v][j])\n {\n w=son[v][j];\n break;\n }\n if(w)\n {\n for(t=w;l[t]>=o+1;t=fail[t])\n if(term[t]) break;\n f[i][u][o] = ( f[i][u][o] + dp(i+1,w,l[t]\n#include \n\ndouble p[1001][1001];\nint pb[1001][1001];\n\ndouble count(int w, int b) {\n\tif (w < 0 || b < 0)\n\t\treturn 0;\n\n\tif (w == 0 && b == 0) \n\t\treturn 0.0 ;\n\telse if (w == 1 && b == 0)\n\t\treturn 1.0;\n\telse if (w == 0 && b == 1)\n\t\treturn 0;\n\n\tif (pb[w][b])\n\t\treturn p[w][b];\n\n\tdouble pp = 0;\n\tif (w+b-2 > 0) {\n\t\tpp += 1.*w/(w+b-2)*count(w-1, b-2);\n\t\tpp += 1.*(b-2)/(w+b-2)*count(w, b-3);\n\t}\n\n\tp[w][b] = 1.*w/(w+b) + 1.*b/(w+b)*(b-1)/(w+b-1)*pp;\n\tpb[w][b] = 1;\n\n//\tprintf(\"w = %d b = %d -> %lf\\n\", w, b, p[w][b]);\n\n\treturn p[w][b];\n}\n\nint main() {\n\tint w, b; scanf(\"%d%d\", &w, &b);\n\n\tmemset(pb, 0, sizeof(pb));\n\tprintf(\"%.10lf\", count(w, b));\n\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ddc0d2dd05287242b97f7b44a01f79e9", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\nlong long f[23],n,s,sum;\nlong long power(long long a, long long b, long long MOD) {\nlong long x = 1, y = a; \n while(b > 0) {\n if(b%2 == 1) {\n x=(x*y);\n if(x>MOD) x%=MOD;\n }\n y = (y*y);\n if(y>MOD) y%=MOD;\n b /= 2;\n \n }\n return x;\n}\n \nlong long modInverse(long long a,long long m) {\n return power(a,m-2,m);\n}\n\nlong long binomialCoeff(long long n, long long k)\n{\n long long i,res = 1;\n if (k >( n - k))\n k = n - k;\t\n for ( i = 0; i < k; ++i)\n {\n res =(res* ((n - i)%1000000007))%1000000007;\n res =(res* modInverse((i + 1),1000000007))%1000000007;\n }\n\n return res;\n}\nvoid recursion(long long i,long long pow,int fac){\n\tif(pow>s)\treturn;\n\tif(i==n+1){\n\t\tsum=(sum+fac*binomialCoeff(n+s-pow-1,s-pow))%1000000007;\n\t\treturn;\n\t}\n\trecursion(i+1,pow,fac);\n\trecursion(i+1,pow+f[i]+1,fac*-1);\n}\nint main(){\n\tlong long i,j,k,l;\n\tscanf(\"%lld %lld\",&n,&s);\n\tfor(i=1;i<=n;i++)\tscanf(\"%lld\",&f[i]);\n\trecursion(1,0,1);\n\tsum=(sum+1000000007)%1000000007;\n\tprintf(\"%lld\\n\",sum);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c889985a0201e7854b2cdc75217d71c4", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\n#define DUBEG 0\n#define OFFSET 1200000\n#define TOOBIG 24000000\n\nint vals[51], n, smol[51], larg[51], bitc[1<<24], possib[25][(OFFSET<<1) + 1], ansar[2][51];\n\nint cmpfn(const void *_a, const void *_b){\n int *a, *b;\n a = (int *)_a;\n b = (int *)_b;\n return (*a) - (*b);\n}\n\nint get_sum(int mask, int *ar){\n int a, b, i;\n a = b = 0;\n for(i = 0;i < n - 1;i++)if(mask&(1<= 0;j--){\n possib[i][j] = possib[i][j] ? (j - OFFSET) : prev;\n prev = possib[i][j];\n }\n }\n int best, besti;\n best = TOOBIG;\n for(i = 0;i < (1<<(n - 1));i++){\n int reqbits, diff;\n diff = -get_larg(i);\n reqbits = n - 1 - bitc[i];\n if(possib[reqbits][diff + OFFSET] != TOOBIG)if(best > possib[reqbits][diff + OFFSET] - diff){\n\tbest = possib[reqbits][diff + OFFSET] - diff;\n\tbesti = i;\n }\n }\n\n //derive ansar from besti\n int prefil = 0;\n for(i = 0;i < n - 1;i++){\n if(besti&(1<\n\n#define N\t1024\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint query(int i) {\n\tif (i == -1) {\n\t\tprintf(\"R\\n\"), fflush(stdout);\n\t\treturn 0;\n\t} else {\n\t\tstatic char s[2];\n\n\t\tprintf(\"? %d\\n\", i + 1), fflush(stdout);\n\t\tscanf(\"%s\", s);\n\t\treturn s[0] == 'N';\n\t}\n}\n\nint ii_[N], cnt1_;\n\nint solve(int *ii, int cnt1, int *jj, int cnt2, int k) {\n\tint h, g, cnt2_;\n\n\tif (cnt2 == 0) {\n\t\tfor (h = 0; h < cnt1; h++)\n\t\t\tii_[cnt1_++] = ii[h];\n\t\treturn 0;\n\t}\n\tfor (h = 0; h < cnt1; h++)\n\t\tquery(ii[h]);\n\tcnt2_ = 0;\n\tfor (h = 0; h < cnt2; h++) {\n\t\tint j = jj[h];\n\n\t\tif (query(j))\n\t\t\tjj[cnt2_++] = j;\n\t}\n\tfor (h = 0; h < cnt1 - 1; h++) {\n\t\tint i = ii[h];\n\n\t\tif (h == 0)\n\t\t\tfor (g = 0; g < k * 2 + 1 - cnt1 - cnt2; g++)\n\t\t\t\tquery(ii[cnt1 - 1]);\n\t\tif (query(i))\n\t\t\tii_[cnt1_++] = i;\n\t}\n\tii_[cnt1_++] = ii[cnt1 - 1];\n\tquery(-1);\n\treturn cnt2_;\n}\n\nint main() {\n\tstatic int ii[N], jj[N];\n\tint n, k, g, cnt1, cnt2;\n\n\tscanf(\"%d%d\", &n, &k);\n\tcnt1 = 0;\n\tfor (g = 0; g < n / k; g++) {\n\t\tint l = g * k, r = (g + 1) * k, h, i;\n\n\t\tcnt2 = 0;\n\t\tfor (i = l; i < r; i++)\n\t\t\tif (query(i))\n\t\t\t\tjj[cnt2++] = i;\n\t\tquery(-1);\n\t\tcnt1_ = 0;\n\t\tfor (h = 0; h < cnt1; h += k)\n\t\t\tcnt2 = solve(ii + h, min(cnt1 - h, k), jj, cnt2, k);\n\t\tcnt1 = 0;\n\t\tfor (h = 0; h < cnt1_; h++)\n\t\t\tii[cnt1++] = ii_[h];\n\t\tfor (h = 0; h < cnt2; h++)\n\t\t\tii[cnt1++] = jj[h];\n\t}\n\tprintf(\"! %d\\n\", cnt1), fflush(stdout);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "341bf2612a576595490c9f3597dd8892", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define K\t1000000\n#define L_\t21\t/* L_ = ceil(log2(K * 2 + 1)) */\n#define N_\t(1 << L_)\n#define MD\t998244353\n\nlong long power(long long a, int k) {\n\tlong long p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * a % MD;\n\t\ta = a * a % MD;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint inv(int a) {\n\treturn a == 1 ? 1 : (long long) inv(a - MD % a) * (MD / a + 1) % MD;\n}\n\nint vv[K + 1], ff[K + 1], gg[K + 1];\nint *wu[L_ + 1], *wv[L_ + 1];\n\nvoid init() {\n\tint i, l, u, v;\n\n\tff[0] = gg[0] = 1;\n\tfor (i = 1; i <= K; i++) {\n\t\tvv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;\n\t\tff[i] = (long long) ff[i - 1] * i % MD;\n\t\tgg[i] = (long long) gg[i - 1] * vv[i] % MD;\n\t}\n\tu = power(3, MD - 1 >> L_), v = power(u, MD - 2);\n\tfor (l = L_; l > 0; l--) {\n\t\tint n = 1 << l - 1;\n\n\t\twu[l] = (int *) malloc(n * sizeof *wu[l]);\n\t\twv[l] = (int *) malloc(n * sizeof *wv[l]);\n\t\twu[l][0] = wv[l][0] = 1;\n\t\tfor (i = 1; i < n; i++) {\n\t\t\twu[l][i] = (long long) wu[l][i - 1] * u % MD;\n\t\t\twv[l][i] = (long long) wv[l][i - 1] * v % MD;\n\t\t}\n\t\tu = (long long) u * u % MD, v = (long long) v * v % MD;\n\t}\n}\n\nint choose(int n, int k) {\n\treturn k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nvoid ntt_(int *aa, int l, int inverse) {\n\tif (l > 0) {\n\t\tint n = 1 << l, m = n >> 1, i, j, *ww = inverse ? wv[l] : wu[l];\n\n\t\tntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);\n\t\tfor (i = 0; (j = i + m) < n; i++) {\n\t\t\tint a = aa[i], b = (long long) aa[j] * ww[i] % MD;\n\n\t\t\tif ((aa[i] = a + b) >= MD)\n\t\t\t\taa[i] -= MD;\n\t\t\tif ((aa[j] = a - b) < 0)\n\t\t\t\taa[j] += MD;\n\t\t}\n\t}\n}\n\nvoid ntt(int *aa, int l_, int inverse) {\n\tint n = 1 << l_, i, j;\n\n\tfor (i = 1, j = 0; i < n; i++) {\n\t\tint b, tmp;\n\n\t\tb = n >> 1;\n\t\twhile ((j ^= b) < b)\n\t\t\tb >>= 1;\n\t\tif (i < j)\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tntt_(aa, l_, inverse);\n}\n\nint main() {\n#if 0\n\tstatic int dp[11][11], dq[11][11];\n\tint n = 10, l = 3, i, j, k;\n\n\tinit();\n\tdp[0][0] = 1, dq[0][0] = 0;\n\tfor (i = 1; i <= n; i++) {\n\t\tfor (j = i; j <= n; j++)\n\t\t\tfor (k = 0; k <= j; k++) {\n\t\t\t\tdp[i][j] = (dp[i][j] + (long long) dp[i - 1][k] * choose(j, k)) % MD;\n\t\t\t\tdq[i][j] = (dq[i][j] + (long long) dq[i - 1][k] * choose(j, k) + (long long) dp[i - 1][k] * choose(j, k) % MD * choose(j - k, l)) % MD;\n\t\t\t}\n\t\tprintf(\"(%d %d)\\n\", dp[i][i], dq[i][i]);\n\t}\n\t/* guess: (# of more-equal arrays with a_1 = a_2 = ... = a_l) == (n + 1)^(n - l) */\n#else\n\tstatic int aa[N_], bb[N_];\n\tint n, k, n_, l_, i, v, f, p, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tl_ = 0;\n\twhile (1 << l_ <= k + k)\n\t\tl_++;\n\tn_ = 1 << l_;\n\tfor (i = 0; i <= k; i++)\n\t\taa[i] = (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD;\n\tfor (i = 0; i <= k; i++)\n\t\tbb[i] = power(i, k) * gg[i] % MD;\n\tntt(aa, l_, 0), ntt(bb, l_, 0);\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = (long long) aa[i] * bb[i] % MD;\n\tntt(aa, l_, 1);\n\tv = inv(n_);\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = (long long) aa[i] * v % MD;\n\tans = 0;\n\tf = 1, p = power(n + 1, n), v = inv(n + 1);\n\tfor (i = 1; i <= k; i++) {\n\t\tf = (long long) f * (n - i + 1) % MD;\n\t\tp = (long long) p * v % MD;\n\t\tans = (ans + (long long) aa[i] * f % MD * p) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n#endif\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "98c1806d6ad20c4b3b7444883d524727", "src_uid": "bc57a69c39c6e74d6d81a9c504104809", "difficulty": 3300.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\ntypedef long long int lli;\n\n#define TRUE (1==1)\n#define FALSE (!TRUE)\n\n#define fo3(a,b,c) for(a=(int)(b);a<=(int)(c);a++)\n#define of3(a,b,c) for(a=(int)(b);a>=(int)(c);a--)\n#define in32(a) scanf(\"%d\",&(a))\n#define in64(a) scanf(\"%I64d\",&(a))\n#define out32(a) printf(\"%d\\n\",(a))\n#define out64(a) printf(\"%I64d\\n\",(a))\n#define instr(a) scanf(\"%s\",(a))\n#define outstr(a) printf(\"%s\\n\",(a))\n#define max(a,b) (((a)<(b))?(b):(a))\n#define min(a,b) (((a)>(b))?(b):(a))\n\nlli gcd(lli a, lli b) {\n return (b == 0) ? a : gcd(b, a % b);\n}\nlli lcm(lli a, lli b) {\n lli g = gcd(a, b);\n return a * (b / g);\n}\n\nint facts(lli val, lli * arr, int st) {\n if (val == 1) {\n arr[0] = 1;\n return 1;\n }\n int i = st,k;\n while (i * i <= val) {\n if (val % i == 0) {\n int pow = 0;\n while (val % i == 0) {\n pow ++;\n val/=i;\n }\n int cur = facts(val,arr,i+1);\n int res = cur * (pow + 1);\n fo3(k,cur,res-1)\n arr[k] = arr[k-cur]*i;\n return res;\n }\n i++;\n }\n arr[0] = 1;\n arr[1] = val;\n return 2;\n}\n\n#define MOD 1000000007\n#define SENT -1\nlli memo[1010][1010];\n\nlli rec(int a, int b) {\n if (a == 0 && b == 0)\n return 0;\n if (a < 0)\n return 0;\n if (b < 0)\n return 0;\n if (a < b)\n return 0;\n if (memo[a][b] != SENT)\n return memo[a][b];\n int ret = 0;\n if ((a+b)&1)\n ret = 1;\n ret += rec(a-1,b);\n ret += rec(a,b-1);\n while(ret>=MOD)\n ret-=MOD;\n memo[a][b] = ret;\n return ret;\n}\n\nint main(void)\n{\n int n,i,j;\n in32(n);\n fo3(i,0,n)\n fo3(j,0,n)\n memo[i][j] = SENT;\n out64(rec(n,n));\n return EXIT_SUCCESS;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "6a618a86b2b51df36d17374402820664", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t52\n#define K\t(N * 9)\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nvoid carry(int *aa, int n) {\n\tint i;\n\n\tfor (i = 0; i < n; i++)\n\t\tif (aa[i] >= 10)\n\t\t\taa[i + 1] += aa[i] / 10, aa[i] %= 10;\n\t\telse if (aa[i] < 0)\n\t\t\taa[i + 1] -= (-aa[i] + 9) / 10, aa[i] = (aa[i] % 10 + 10) % 10;\n}\n\nint main() {\n\tstatic char aa[N + 1];\n\tstatic int bb[N + 1], dp[K * 2 + 1], dq[K * 2 + 1], dp_[K * 2 + 1], dq_[K * 2 + 1];\n\tint n, i, j, k, ans;\n\tchar tmp;\n\n\tscanf(\"%s\", aa), n = strlen(aa);\n\tfor (i = 0; i < n; i++)\n\t\taa[i] -= '0';\n\tfor (i = 0, j = n - 1; i < j; i++, j--)\n\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\tn += 2;\n\tmemset(dp, 0x3f, (K * 2 + 1) * sizeof *dp), memset(dq, 0x3f, (K * 2 + 1) * sizeof *dq); \n\tdp[K] = 0;\n\tfor (i = n - 2; i >= 0; i--) {\n\t\tmemset(dp_, 0x3f, (K * 2 + 1) * sizeof *dp_), memset(dq_, 0x3f, (K * 2 + 1) * sizeof *dq_); \n\t\tfor (k = 0; k <= K * 2; k++) {\n\t\t\tint x;\n\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = aa[j] + k - K;\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dp[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdp_[k - d] = min(dp_[k - d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdq_[k - d] = min(dq_[k - d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = -bb[j];\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dq[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tbb[0]--;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdq_[k + d] = min(dq_[k + d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdp_[k + d] = min(dp_[k + d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmemcpy(dp, dp_, (K * 2 + 1) * sizeof *dp_), memcpy(dq, dq_, (K * 2 + 1) * sizeof *dq_); \n\t}\n\tans = INF;\n\tfor (k = 0; k <= K * 2; k++)\n\t\tif ((aa[0] + k - K) % 10 == 0)\n\t\t\tans = min(ans, dp[k]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8d8fa39f2c241e94dcd3eccb2f4fadce", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t200000\n#define MD\t998244353\n\nlong long power(int a, int k) {\n\tlong long p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k >> 1);\n\tp = p * p % MD;\n\tif (k & 1)\n\t\tp = p * a % MD;\n\treturn p;\n}\n\nint ff[N + 1], gg[N + 1];\n\nvoid init() {\n\tint i, f;\n\n\tf = 1;\n\tfor (i = 0; i <= N; i++) {\n\t\tgg[i] = power(ff[i] = f, MD - 2);\n\t\tf = (long long) f * (i + 1) % MD;\n\t}\n}\n\nint ch(int n, int k) {\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nint main() {\n\tint n, c, ans;\n\tlong long k;\n\n\tinit();\n\tscanf(\"%d%lld\", &n, &k);\n\tans = 0;\n\tif (k == 0)\n\t\tans = ff[n];\n\telse if (k < n) {\n\t\tint x;\n\n\t\tx = 0;\n\t\tfor (c = n - k; c >= 0; c--)\n\t\t\tx = (x + ((n - k - c) % 2 == 0 ? 1 : -1) * (ch(n - k, c) * power(c, n))) % MD;\n\t\tans = (long long) ch(n, n - k) * x * 2 % MD;\n\t\tif (ans < 0)\n\t\t\tans += MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "bda0972b573e440b0825877c6edca8c0", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nchar str[77];\nint n, vmax, kmax, xmax, ar[77], dp[77][77][77][3];\n\nint fill(char visited[77], int c, int d){\n\tint i, x = 0;\n\tfor (i = 0; i < n; i++){\n\t\tif (ar[i] == d){\n\t\t\tif (x == c) return i;\n\t\t\tx++;\n\t\t\tvisited[i] = 1;\n\t\t}\n\t}\n\treturn n;\n}\n\nint swap_count(int index, char visited[77]){\n\tint i, res = 0;\n\tfor (i = 0; i < index; i++){\n\t\tif (!visited[i]) res++;\n\t}\n\treturn res;\n}\n\nint F(int v, int k, int x, int l){\n\tif (v == vmax && k == kmax && x == xmax) return 0;\n\tif (dp[v][k][x][l] != -1) return dp[v][k][x][l];\n\t\n\tchar visited[77] = {0};\n\tint a, b, c, r, res = 1 << 20;\n\ta = fill(visited, v, 0);\n\tb = fill(visited, k, 1);\n\tc = fill(visited, x, 2);\n\t\n\tif (v != vmax){\n\t\tr = F(v + 1, k, x, 0) + swap_count(a, visited);\n\t\tif (r < res) res = r;\n\t}\n\tif (k != kmax && l != 0){\n\t\tr = F(v, k + 1, x, 1) + swap_count(b, visited);\n\t\tif (r < res) res = r;\n\t}\n\tif (x != xmax){\n\t\tr = F(v, k, x + 1, 2) + swap_count(c, visited);\n\t\tif (r < res) res = r;\n\t}\n\t\n\treturn (dp[v][k][x][l] = res);\n}\n\nint main(){\n\tint i, res;\n\t\n\twhile (scanf(\"%d\", &n) != EOF){\n\t\tscanf(\"%s\", str);\n\t\tfor (i = 0; i < n; i++){\n\t\t\tar[i] = 2;\n\t\t\tif (str[i] == 'V') ar[i] = 0;\n\t\t\tif (str[i] == 'K') ar[i] = 1;\n\t\t\tvmax += (ar[i] == 0);\n\t\t\tkmax += (ar[i] == 1);\n\t\t\txmax += (ar[i] == 2);\n\t\t}\n\t\t\n\t\tmemset(dp, -1, sizeof(dp));\n\t\tres = F(0, 0, 0, 2);\n\t\tprintf(\"%d\\n\", res);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "ecc3dbb6aaf9194fcddb18e7024a0d2c", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0} {"lang": "GNU C11", "source_code": "#include \n\n#define MOD 998244353LL\n\nlong long f[200001];\n\nlong long power(long long x, long long n){\n long long res;\n if(n==0){\n return 1;\n }\n if(n==1){\n return x%MOD;\n }\n\n res=power(x, n/2);\n res%=MOD;\n res*=res;\n res%=MOD;\n if(n & 1LL){\n res*=x;\n res%=MOD;\n }\n return res%MOD;\n}\n\nlong long fibo(){\n int i;\n for(i=3; i<=200000; ++i){\n f[i]=f[i-2]+f[i-1];\n f[i]%=MOD;\n }\n}\n\nint main(void){\n long long N, res;\n\n scanf(\"%lld\", &N);\n if(N==1){\n printf(\"%lld\", power(2, MOD-2)%MOD);\n return 0;\n }\n else if(N==2){\n printf(\"%lld\", power(4, MOD-2)%MOD);\n return 0;\n }\n f[1]=f[2]=1;\n fibo();\n \n res=((f[N]%MOD)*(power(power(2, N)%MOD, MOD-2)%MOD))%MOD;\n //(2*N-5)/2^N\n printf(\"%lld\", res);\n\n return 0;\n}\n\n/*\nx^MOD == x (mod MOD)\nx^(MOD-1) == 1 (mod MOD)\nx * x^(MOD-2) == 1 (mod MOD)\n\n2*N-5 mod MOD * (2^N)^-1 mod MOD\n*/", "lang_cluster": "C", "compilation_error": false, "code_uid": "fb77f4215d3361e2b1f5665151b4375f", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint n, sum;\nint a[16];\nint b[4][4];\n\nint cmp(const void *a, const void *b)\n{\n return *((int *)a) - *((int *)b);\n}\n\nint dfs(int x, int y, int z)\n{\n int p, q, i, j;\n \n if (x == n && y == 0) return 1;\n \n p = x;\n q = y + 1;\n \n if (q == n) {\n p = x + 1;\n q = 0;\n }\n \n for (i = 0; i < n * n; i++) {\n if ((z >> i) & 1) continue;\n \n if (x == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][y];\n \n if (s + a[i] != sum) continue;\n }\n \n if (y == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[x][j];\n \n if (s + a[i] != sum) continue;\n }\n \n if (x == n - 1 && y == 0) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][n - j - 1];\n \n if (s + a[i] != sum) continue;\n }\n \n if (x == n - 1 && y == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][j];\n \n if (s + a[i] != sum) continue;\n }\n \n b[x][y] = a[i];\n \n if (dfs(p, q, z | (1 << i)) == 1) return 1;\n \n for (j = i + 1; j < n * n; j++) {\n if (a[i] != a[j]) break;\n }\n \n i = j - 1;\n }\n \n return -1;\n}\n\nint main()\n{\n int i, j;\n \n scanf(\"%d\", &n);\n \n for (i = 0; i < n * n; i++) {\n scanf(\"%d\", &a[i]);\n \n sum += a[i];\n }\n \n sum /= n;\n \n printf(\"%d\\n\", sum);\n \n qsort(a, n * n, sizeof(int), cmp);\n \n dfs(0, 0, 0);\n \n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n if (j > 0) putchar(' ');\n \n printf(\"%d\", b[i][j]);\n }\n \n puts(\"\");\n }\n \n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a1c3351292a71d65ede6ed9df2797230", "src_uid": "7c806fb163aaf23e1eef3e6570aea436", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "f[111111], g[111111], p = 1e9 + 7;\nmain(n, m, i, j) {\n\tscanf(\"%d%d\", &n, &m);\n\tif (n > m) i = n, n = m, m = i;\n\tf[1] = g[1] = 1;\n\tfor (i = 2; i <= m + 1; i++)\n\t\tf[i] = (g[i - 1] + g[i - 2]) % p, g[i] = (f[i - 1] + f[i - 2]) % p;\n\tprintf(\"%lld\", (1ll * f[m + 1] + g[m + 1] + f[n + 1] + g[n + 1] + p - 2) % p);\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "60c4e250d8097dc26d61d6fedd4a4c1d", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "GNU C11", "source_code": "#include \n#include \n#define ll int64_t\n\n\nstruct pr\n{\n ll f, s;\n} a[100001], b[100001];\n\nint cmp(const void* p1, const void* p2)\n{\n ll d = - ((const struct pr*)p1)->f + ((const struct pr*)p2)->f;\n if (d) return d < 0 ? -1 : 1;\n return ((const struct pr*)p1)->s - ((const struct pr*)p2)->s > 0 ? 1 : -1;\n}\n\nint main()\n{\n int n, m; ll d;\n scanf(\"%d%d%I64d\", &n, &m, &d);\n for(int i = 0; i < n; ++i)\n {\n scanf(\"%I64d%I64d\", &(a[i].f), &(a[i].s));\n }\n for(int i = 0; i < m; ++i)\n {\n scanf(\"%I64d%I64d\", &(b[i].f), &(b[i].s));\n }\n qsort(a, n, sizeof(struct pr), cmp);\n qsort(b, m, sizeof(struct pr), cmp);\n for(int i = 1; i < n; ++i)\n {\n a[i].f += a[i-1].f;\n a[i].s += a[i-1].s;\n }\n for(int i = 1; i < m; ++i)\n {\n b[i].f += b[i-1].f;\n b[i].s += b[i-1].s;\n }\n int i = 0, j = 0;\n if (a[0].s + b[0].s > d)\n {\n printf(\"0\");\n return 0;\n }\n while(i < n && a[i].s + b[0].s <= d) ++i;\n ll ans = 0;\n while(j < m && i >= 0)\n {\n if (i < n && a[i].s + b[j].s <= d)\n {\n if (a[i].f + b[j].f > ans) ans = a[i].f + b[j].f;\n ++j;\n }\n else --i;\n }\n printf(\"%I64d\", ans);\n return 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "a9e360b8cbc92e8352567d0cc4e9c84c", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nlong long a[1000006]={0};\nlong long b[3][3]={0};\nlong long c[3][3]={0};\nlong long d[3][3]={0};\n\nvoid mul(long long y,long long n,long long p)\n{\n long long i,j,k;\n \n memset(c,0,sizeof(c));\n for(i=0;i>=1)\n {\n if(y&1)\n {\n for(i=0;i\n#include \n\n#define N\t20000\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\nint max(int a, int b) { return a > b ? a : b; }\n\nlong long dot2(int x1, int y1, int x2, int y2) {\n\treturn (long long) x1 * x2 + (long long) y1 * y2;\n}\n\nlong long cross2(int x1, int y1, int x2, int y2) {\n\treturn (long long) x1 * y2 - (long long) x2 * y1;\n}\n\nint xx[N + 1], yy[N + 1];\n\nlong long cross(int i, int j, int k) {\n\treturn cross2(xx[j] - xx[i], yy[j] - yy[i], xx[k] - xx[i], yy[k] - yy[i]);\n}\n\nint aa[N + 1], dp[N + 1], dq[N + 1];\n\nvoid solve(int l, int r) {\n\tstatic int qu[N + 1], qq[N + 1], pp[N + 1];\n\tint m, h, i, j, q, p, cnt;\n\n\tif (r - l == 1)\n\t\treturn;\n\tm = (l + r) / 2;\n\tsolve(l, m);\n\tsolve(m, r);\n\tq = 0;\n\tfor (i = m - 1; i >= l; i--)\n\t\tqq[i] = q = max(q, aa[i]);\n\tp = 0;\n\tfor (i = m; i < r; i++)\n\t\tpp[i] = p, p = max(p, aa[i]);\n\tcnt = 0;\n\tfor (j = m, i = m - 1, h = 0; j < r; j++) {\n\t\twhile (i >= l && qq[i] <= pp[j]) {\n\t\t\txx[i] = i, yy[i] = dp[i];\n\t\t\twhile (cnt >= 2 && cross(qu[cnt - 2], qu[cnt - 1], i) >= 0)\n\t\t\t\tcnt--;\n\t\t\tqu[cnt++] = i;\n\t\t\tif (h >= cnt - 2)\n\t\t\t\th = cnt - 1;\n\t\t\ti--;\n\t\t}\n\t\twhile (h > 0 && dot2(xx[qu[h]], yy[qu[h]], pp[j], -1) < dot2(xx[qu[h - 1]], yy[qu[h - 1]], pp[j], -1))\n\t\t\th--;\n\t\tif (cnt)\n\t\t\tdq[j] = min(dq[j], pp[j] * j - dot2(xx[qu[h]], yy[qu[h]], pp[j], -1));\n\t}\n\tcnt = 0;\n\tfor (j = r - 1, i = l, h = 0; j >= m; j--) {\n\t\twhile (i < m && qq[i] > pp[j]) {\n\t\t\txx[i] = qq[i], yy[i] = dp[i] - qq[i] * i;\n\t\t\tif (cnt && xx[qu[cnt - 1]] == xx[i]) {\n\t\t\t\tif (yy[qu[cnt - 1]] > yy[i])\n\t\t\t\t\tcnt--;\n\t\t\t\telse {\n\t\t\t\t\ti++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\twhile (cnt >= 2 && cross(qu[cnt - 2], qu[cnt - 1], i) >= 0)\n\t\t\t\tcnt--;\n\t\t\tqu[cnt++] = i;\n\t\t\tif (h >= cnt - 2)\n\t\t\t\th = cnt - 1;\n\t\t\ti++;\n\t\t}\n\t\twhile (h > 0 && dot2(xx[qu[h]], yy[qu[h]], -j, -1) < dot2(xx[qu[h - 1]], yy[qu[h - 1]], -j, -1))\n\t\t\th--;\n\t\tif (cnt)\n\t\t\tdq[j] = min(dq[j], -dot2(xx[qu[h]], yy[qu[h]], -j, -1));\n\t}\n}\n\nint main() {\n\tint n, k, i;\n\n\tscanf(\"%d%d\", &n, &k);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tmemset(dp, 0x3f, (n + 1) * sizeof *dp), dp[0] = 0;\n\twhile (k--) {\n\t\tmemset(dq, 0x3f, (n + 1) * sizeof *dq);\n\t\tsolve(0, n + 1);\n\t\tmemcpy(dp, dq, (n + 1) * sizeof *dp);\n\t}\n\tprintf(\"%d\\n\", dp[n]);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7df7579a75c045d24f2b9c8fb42a16db", "src_uid": "f42faaaa88628748a8da49111936be00", "difficulty": 3000.0} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint tree[4*3000][4*3000], node;\nlong long g, x, y, z;\n#define MAXINT 0x7fffffff\n\nint nextg(){\n\tint ret=g;\n\tg=(g*x+y)%z;\n\treturn ret;\n}\n\nint min(int a, int b){\n\treturn a\n\n#define N\t10\n\nint main() {\n\tstatic int aa[N];\n\tint n, i, max;\n\n\tscanf(\"%d\", &n);\n\tmax = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &aa[i]);\n\t\tif (max < aa[i])\n\t\t\tmax = aa[i];\n\t}\n\tprintf(\"%d\\n\", max ^ aa[n - 1]);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "fecfdcf8b5fe3077b08d8be057918246", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "GNU C", "source_code": "#include\n#include\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\nlong long int sort(long long int a[] , int n){\n long long int tmp = 0;\n for(ll i = 1 ; i < n ; i++)\n {\n for(ll j = i ; j < n ; j++){\n if(a[i] > a[j]){\n tmp = a[j];\n a[j] = a[i];\n a[i] = tmp;\n }\n }\n\n }\n}\n\nlong long int min(long long int a , long long int b){\n if(a > b)\n return b;\n return a;\n}\n#define For(i, n) for(i=0;i<(n);++i)\n#define ForL(i, m, n) for(i=(m);i<(n);++i)\n\n#define Clear(X) memset( (X), 0, sizeof( (X) ) )\n#define Fill(X) memset( (X), -1, sizeof( (X) ) )\n\n#define ArraySize(X) (sizeof(X)/sizeof(X[0]))\n\n\n\nvoid _main();\n\nint main() {\n // COUNTER CODE STARTS HERE\n _main();\n // COUNTER CODE ENDS HERE\n\n return 0;\n}\n\n// ACTUAL CODE STARTS BELOW\n\nll a, b, c, l;\nll ans = 0;\n\nll exclude(ll a, ll b, ll c, ll r) {\n if (a < b + c) return 0;\n ll v = min(r, a - b - c);\n return ((v + 1) * (v + 2)) >> 1;\n\n}\n\nvoid _main() {\n scanf(\"%d %d %d %d\", &a , &b , &c , &l);\n for (ll i = 0; i <= l; ++i) {\n ans += (((i + 1) * (i + 2)) >> 1);\n }\n\n for (ll i = 0; i <= l; ++i) {\n ans -= exclude(a + i, b, c, l - i);\n ans -= exclude(b + i, a, c, l - i);\n ans -= exclude(c + i, b, a, l - i);\n }\n printf(\"%I64d\\n\", ans);\n}\n\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a823af4ce0bef253f52157deaa4f6f92", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define N\t200100\n#define MD\t1000000007\n\nint main() {\n\tstatic int dp[N + 1], dq[N + 1], tmp[N + 1];\n\tint a, b, k, t, n, m, i, j, sum;\n\n\tscanf(\"%d%d%d%d\", &a, &b, &k, &t);\n\tn = a + k * 2 * t;\n\tm = b + k * 2 * t;\n\tdp[a] = 1;\n\tdq[b] = 1;\n\twhile (t-- > 0) {\n\t\tsum = 0;\n\t\tfor (i = 0; i <= n; i++) {\n\t\t\ttmp[i] = sum = (sum + dp[i]) % MD;\n\t\t\tif (i >= k * 2)\n\t\t\t\tsum = (sum - dp[i - k * 2] + MD) % MD;\n\t\t}\n\t\tmemcpy(dp, tmp, (n + 1) * sizeof *tmp);\n\t\tsum = 0;\n\t\tfor (j = 0; j <= m; j++) {\n\t\t\ttmp[j] = sum = (sum + dq[j]) % MD;\n\t\t\tif (j >= k * 2)\n\t\t\t\tsum = (sum - dq[j - k * 2] + MD) % MD;\n\t\t}\n\t\tmemcpy(dq, tmp, (m + 1) * sizeof *tmp);\n\t}\n\tfor (j = 1; j <= m; j++)\n\t\tdq[j] = (dq[j] + dq[j - 1]) % MD;\n\tsum = 0;\n\tfor (i = 1; i <= n; i++)\n\t\tsum = (sum + (long long) dp[i] * dq[i - 1 < m ? i - 1 : m] % MD) % MD;\n\tprintf(\"%d\\n\", sum);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "0694b664fccf0d6baaa5578afd70bb5c", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "GNU C11", "source_code": "/* \ufffd\ufffd\ufffd\ufffd\u02af\u0377\ufffd\ufffd\n[O]\ufffd\ufffdA\ufffd\ufffd\ufffd\u04ee\ufffd\u0134\ufffd\ufffd\ufffd \n[] \ufffd\ufffdA\ufffd\ufffd\ufffd\ufffd\u04ee\ufffd\u0134\ufffd\ufffd\ufffd\n\n1.\u02af\u0377\n2.\ufffd\ufffd\ufffd\ufffd\n3.\ufffd\ufffd \n*/\n#include\nint main()\n{\n\tint n,a1,a2,a3,b1,b2,b3,maxwin1,maxwin2,maxwin3,maxwin,minwin1,minwin2,minwin3,minwin4,minwin;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d%d%d\",&a1,&a2,&a3);\n\tscanf(\"%d%d%d\",&b1,&b2,&b3);\n\t/**maxwin**/\n\t/*a1 beats b2*/\n\tif(a1>b2)\n\t\tmaxwin1=b2;\n\telse\n\t\tmaxwin1=a1;\n\t/*a2 beats b3*/\n\tif(a2>b3)\n\t\tmaxwin2=b3;\n\telse\n\t\tmaxwin2=a2;\n\t/*a3 beats b1*/\n\tif(a3>b1)\n\t\tmaxwin3=b1;\n\telse\n\t\tmaxwin3=a3;\n\t\n\tmaxwin=maxwin1+maxwin2+maxwin3;\n\t\n\t/*minwin**/\n\t/*a1 cannot beat b1 b3*/\n\tif(a1-b1-b3<0)\n\t\tminwin1=0;\n\telse\n\t\tminwin1=a1-b1-b3;\n\t/*a2 cannot beat b1 b2*/\n\tif(a2-b1-b2<0)\n\t\tminwin2=0;\n\telse\n\t\tminwin2=a2-b1-b2;\n\t/*a3 cannot beat b2 b3*/\n\tif(a3-b2-b3<0)\n\t\tminwin3=0;\n\telse\n\t\tminwin3=a3-b2-b3;\n\t\t\n\tminwin=minwin1+minwin2+minwin3;\n\tprintf(\"%d %d\\n\",minwin,maxwin);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7fcc4f0ef38f0877f9985590bff7e199", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nlong long i,a[200000],x,n,k;\nlong long w;\n\nint main()\n{\n scanf(\"%I64d\", &n);\n k=100;\n for(i=0; in/2)printf(\"Bob\\n\");\n else printf(\"Alice\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7e3623b24bc99fc19076c0f72cc1671f", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n#define eps 1e-8\n#define oo 9000000000000000000LL\n#define pi 3.14159265359\n#define zero(a) (abb(a)<=eps)\n#define lowbit(a) ((a)&(-(a)))\n#define abb(a) ((a)>0?(a):(-(a)))\n#define min(a,b) ((a)<(b)?(a):(b))\n#define max(a,b) ((a)>(b)?(a):(b))\n#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))\n#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))\n#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))\n\nlong long s[19]={0},f[40][19][19]={0};\nlong last[40][19][19]={0};\nchar str[40]={'\\0'},ans[40]={'\\0'};\n\nint main()\n{\n long i,j,k,l;\n scanf(\"%ld\\n\",&l);\n gets(str+1);\n s[1]=1;\n for (i=2;i<=l;i++)\n s[i]=s[i-1]*10;\n for (i=0;i<=2*l;i++)\n for (j=0;j<=l;j++)\n for (k=0;k<=l;k++)\n f[i][j][k]=-oo;\n f[2*l+1][0][0]=0;\n for (i=2*l;i>=1;i--)\n for (j=0;j<=l;j++)\n for (k=0;k<=l;k++)\n {\n if (j>0)\n {\n f[i][j][k]=f[i+1][j-1][k]+s[j]*(str[i]-'0');\n last[i][j][k]=0;\n }\n if (k>0&&f[i+1][j][k-1]+s[k]*(str[i]-'0')>f[i][j][k])\n {\n f[i][j][k]=f[i+1][j][k-1]+s[k]*(str[i]-'0');\n last[i][j][k]=1;\n }\n }\n j=k=l;\n for (i=1;i<=2*l;i++)\n if (last[i][j][k])\n {\n printf(\"H\");\n k--;\n }\n else\n {\n printf(\"M\");\n j--;\n }\n printf(\"\\n\");\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "a4b1bbe35fe7196e9c1d4df4d3aaa379", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88", "difficulty": 2400.0} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int array[1001], n, c, d, e,swap;\n scanf(\"%d\", &n);\n for (c = 0; c < n; c++)\n scanf(\"%d\", &array[c]);\n\n for (c = 0 ; c < ( n - 1 ); c++)\n {\n for (d = 0 ; d < n - c - 1; d++)\n {\n if (array[d] > array[d+1])\n {\n swap = array[d];\n array[d] = array[d+1];\n array[d+1] = swap;\n }\n }\n }\n\n for(e=0;e<1000006;e++)\n printf(\"\");\n for(e=0;e<1006;e++)\n printf(\"\");\n \n\n\n\n\n printf(\"%d\",array[0]);\n for ( c = 1 ; c < n ; c++ )\n printf(\" %d\", array[c]);\n\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "33c6403854ce6e1bdcf7b94fd22c8a53", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include \n\nint query(long long i) {\n\tint x;\n\n\tprintf(\"? %lld\\n\", i), fflush(stdout);\n\tscanf(\"%d\", &x);\n\treturn x;\n}\n\nint main() {\n\tint t;\n\n\tscanf(\"%d\", &t);\n\twhile (t--) {\n\t\tlong long n, m, l, r, c;\n\t\tint turn;\n\n\t\tscanf(\"%lld\", &n);\n\t\tl = 0;\n\t\tfor (m = n - 1; m > 0; m /= 4)\n\t\t\tl -= (m + 1) / 2;\n\t\tl = 1 - l, r = l, m = n - 1, turn = 0;\n\t\tquery(r);\n\t\tc = 1;\n\t\tfor (m = n - 1; m > 0; m /= 2, turn ^= 1)\n\t\t\tif (turn == 0) {\n\t\t\t\tif (query(l -= (m + 1) / 2))\n\t\t\t\t\tr -= (m + 1) / 2, m--;\n\t\t\t\telse\n\t\t\t\t\tc += (m + 1) / 2;\n\t\t\t} else {\n\t\t\t\tif (query(r += (m + 1) / 2))\n\t\t\t\t\tl += (m + 1) / 2, m--;\n\t\t\t\telse\n\t\t\t\t\tc += (m + 1) / 2;\n\t\t\t}\n\t\tprintf(\"= %lld\\n\", c), fflush(stdout);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "8b4df3efd89887732699d45c0bc40cdf", "src_uid": "5a374c06b44a843233d9cf64a38c7e55", "difficulty": 2700.0} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tint a, b, n, p, k, k_, cnt, lower, upper, l, r;\n\n\tscanf(\"%d%d\", &a, &b);\n\tn = a + b;\n\tcnt = 0;\n\tfor (p = 1; p <= (k = n / p); p++)\n\t\tif (a / k >= a % k && a % k <= n % p)\n\t\t\tcnt++;\n\tk_ = k;\n\tfor (k = 1; k <= k_; k++)\n\t\tif (a / k >= a % k) {\n\t\t\tlower = 0, upper = n + 1;\n\t\t\twhile (upper - lower > 1) {\n\t\t\t\tp = (lower + upper) / 2;\n\t\t\t\tif (a % k <= n - (long long) k * p)\t/* n % p = n - k * p */\n\t\t\t\t\tlower = p;\n\t\t\t\telse\n\t\t\t\t\tupper = p;\n\t\t\t}\n\t\t\tr = lower;\n\t\t\tlower = 0, upper = n + 1;\n\t\t\twhile (upper - lower > 1) {\n\t\t\t\tp = (lower + upper) / 2;\n\t\t\t\tif (n / p <= k)\n\t\t\t\t\tupper = p;\n\t\t\t\telse\n\t\t\t\t\tlower = p;\n\t\t\t}\n\t\t\tl = p = upper;\n\t\t\tcnt += l <= r ? r - l + 1 : 0;\n\t\t}\n\tprintf(\"%d\\n\", cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "31b2c6a103608bae41f0d04a550686e8", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define MOD 2520\nint a[30],index[MOD+10];\n__int64 dps[23][2550][50];\n\nvoid init(){\n int i,k=1;\n for(i=1;i<=MOD;i++){\n if(MOD%i==0)\n index[i]=k++;\n }\n k--;\n}\nint gcd(int a , int b)\n{\n return b == 0 ? a : gcd(b , a % b);\n}\n\nint lcm(int a, int b)\n{\n return a / gcd(a,b) * b;\n}\n__int64 dp(int pos,int sum,int mod,int doing){\n int i,tem,max,nowsum,nowmod;\n __int64 result=0;\n if(pos==-1){\n return sum%mod==0;\n }\n if(doing==0 && dps[pos][sum][index[mod]]!=-1)\n return dps[pos][sum][index[mod]];\n\n if(doing)\n max=a[pos];\n else\n max=9;\n\n for(i=0;i<=max;i++){\n nowsum=0;\n nowsum=(sum*10+i)%MOD;\n nowmod=0;\n nowmod=mod;\n if(i)\n nowmod=lcm(mod,i);\n if(doing && i==max){\n result+=dp(pos-1,nowsum,nowmod,1);\n }\n else{\n result+=dp(pos-1,nowsum,nowmod,0);\n }\n\n }\n if(!doing){\n dps[pos][sum][index[mod]]=result;\n }\n\n}\n__int64 cal(__int64 num){\n __int64 tem;\n int i;\n tem=num;\n i=1;\n while(tem){\n a[i++]=tem%10;\n tem/=10;\n }\n dp(i-1,0,1,1);\n}\nint main()\n{\n int t,T;\n __int64 l,r,i,j,k;\n scanf(\"%d\",&T);\n init();\n for(t=1;t<=T;t++){\n for(i=0;i<=22;i++)\n for(j=0;j<=2540;j++)\n for(k=0;k<=49;k++)\n dps[i][j][k]=-1;\n scanf(\"%I64d %I64d\",&l,&r);\n printf(\"%I64d\\n\",cal(r)-cal(l-1));\n }\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "70d8e0e9512ca8b6f3f126b52487b48f", "src_uid": "37feadce373f728ba2a560b198ca4bc9", "difficulty": 2500.0} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nconst i32 mod = 1000000007;\n\ni32 inv (i32 a) {\n i32 t = 1;\n while (a > 1) {\n t = (i64) t * (mod - mod / a) % mod;\n a = mod % a;\n }\n return t;\n}\n\nvoid run (void) {\n const i32 n = read_int();\n i32 *factor = (i32 *) calloc (n + 1, sizeof (i32));\n for (i32 i = 1; i <= n; ++i) {\n factor[i] = i;\n }\n for (i32 i = 2; i * i <= n; ++i) {\n if (factor[i] < i) continue;\n for (i32 j = i * i; j <= n; j += i) {\n factor[j] = i;\n }\n }\n i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));\n dp[1] = 0;\n for (i32 i = 2; i <= n; ++i) {\n i32 f[64];\n f[0] = 1;\n i32 len = 1;\n i32 t = i;\n while (t > 1) {\n i32 p = factor[t];\n while (t % p == 0) {\n\tt /= p;\n }\n for (i32 j = 0; j < len; ++j) {\n\tf[j + len] = f[j] * p;\n }\n len *= 2;\n }\n if (f[len - 1] != i) {\n dp[i] = dp[f[len - 1]];\n continue;\n }\n i32 prob[64];\n for (i32 j = 0; j < len; ++j) {\n prob[j] = (i64) (n / f[j]) * inv(n) % mod;\n }\n for (i32 j = len - 1; j >= 0; --j) {\n for (i32 k = j - 1; k >= 0; --k) {\n\tif ((j & k) == k) {\n\t prob[k] = (prob[k] - prob[j] + mod) % mod;\n\t}\n }\n }\n i32 local = 1;\n for (i32 j = 0; j < len - 1; ++j) {\n local = (local + (i64) prob[j] * dp[f[j]]) % mod;\n }\n dp[i] = local * inv((1 - prob[len - 1] + mod) % mod) % mod;\n }\n i32 ans = 1;\n for (i32 i = 1; i <= n; ++i) {\n ans = (ans + (i64)dp[i] * inv(n)) % mod;\n }\n print_int(ans);\n puts(\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "061f49062f0f0d820f8311518f359eab", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include \n#include \ntypedef long long ll;\nint left[10];\nint n;\nchar seen[3628800];\n\nll fact[21];\n\n/* must be called before using rank/unrank */\nvoid initfact() {\n int i;\n fact[0]=1;\n for(i=1;i<21;i++) fact[i]=fact[i-1]*i;\n}\n\nll permbtr(int n,int *p,int *q) {\n int s,t;\n if(n<2) return 0;\n s=p[n-1]; p[n-1]=p[q[n-1]]; p[q[n-1]]=s;\n t=q[s]; q[s]=q[n-1]; q[n-1]=t;\n return s+n*permbtr(n-1,p,q);\n}\n\n/* return rank of permutation\n n: number of elements\n *p: permutation to rank */\n/* warning, *p is destroyed! */\nll permutationrank2(int n,int *p) {\n int i,q[16];\n for(i=0;i1) two++;\n if(pre[n][two]>-1) {\n printf(\"%d\\n\",pre[n][two]);\n return 0;\n }\n \n memset(seen,0,sizeof(seen));\n btr();\n for(i=0;i<3628800;i++) z+=seen[i];\n printf(\"%d\\n\",z);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "92d7a8710cb7f65aad9d1c4fb0135ed4", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0} {"lang": "GNU C", "source_code": "#include \n\n#define MAX 1000010\n\nint p, primes[78777], flag[MAX];\n\nvoid Sieve(){\n int i, j, d;\n\n flag[2] = 1;\n for (i = 3; i < MAX; i++, i++) flag[i] = 1;\n for (i = 3; i < 1001;){\n d = i << 1;\n for (j = (i * i); j < MAX; j += d) flag[j] = 0;\n do{\n i++;\n }while (!flag[++i]);\n }\n\n for (i = 0; i < MAX; i++){\n if (flag[i]) primes[p++] = i;\n }\n}\n\nint isPrime(long long x){\n int i;\n for (i = 0; ; i++){\n long long y = primes[i];\n if ((y * y) > x) return 1;\n if ((x % y) == 0) return 0;\n }\n}\n\nint F(int i, long long a){\n if (a == 1) return 1;\n long long y = primes[i];\n if ((y + 1) > a) return 0;\n\n if (((y * y) + 1) > a){\n if (isPrime(a - 1)) return 1;\n return 0;\n }\n\n long long x = 1;\n int res = F(i + 1, a);\n\n for (; ;){\n x *= y;\n if ((x + 1) > a) break;\n\n if ((a % (x + 1)) == 0) res = res + F(i + 1, a / (x + 1));\n }\n return res;\n}\n\nint Solve(long long a){\n if (a < 5) return (a != 2);\n return F(0, a);\n}\n\nint main(){\n Sieve();\n long long a;\n while (scanf(\"%I64d\", &a) != EOF) printf(\"%d\\n\", Solve(a));\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "7921ed6ab36d4fefe8cbb33109ca6cbe", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0} {"lang": "GNU C", "source_code": "#include \n#include \n\n\n\nint main()\n{\n\tlong long int n;\n\n\tscanf(\"%I64d\", &n);\n\n\n\tlong long int a[] = { 0,4,10,20,35,56,83,116,155,198,244,292 };\n\n\tif (n < 12)\n\t\tprintf(\"%d\", a[n]);\n\telse\n\t\tprintf(\"%I64d\", a[11] + (n - 11) * 49);\n\n\treturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "79a5a4557490f0935e8af790a986e0f5", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "GNU C", "source_code": "#include\nint main()\n{\ndouble n,m;\nwhile(scanf(\"%lf%lf\",&n,&m)!=EOF)\nprintf(\"%.16lf\\n\",1.0/n+((n-1)*(m-1))/(n*(n*m-1)));\nreturn 0;\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "15a7dfc6ae1e80a19d9a42c7cbddddcd", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "GNU C", "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}", "lang_cluster": "C", "compilation_error": false, "code_uid": "9e11494ff99feaa9e2ff6061a7b9961f", "src_uid": "af8d46722e1bd8f7392e5596eaf4def8", "difficulty": 3000.0} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i\n#include\n\nint main()\n{\n\tint t,n,l,k,d[200],a[200],flag,i,tmr,temp;\n\tscanf(\"%d\",&t);\n\twhile(t--)\n\t{\n\t\tscanf(\"%d %d %d\",&n,&k,&l);\n\t\tfor(i=0;il)\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t\t// printf(\"%d-%d\\n\",d[i],i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if(d[i]+k>l)\n\t\t\t{\n\t\t\t\tif(i==0 || tmr==1000)\n\t\t\t\t{\n\t\t\t\t\ta[i]=l;\n\t\t\t\t\ttmr=l-d[i];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(tmr>0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp=a[i-1]-d[i-1];\n\t\t\t\t\t\ta[i]=d[i]+temp-1;\n\t\t\t\t\t\tif(a[i]<=l)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmr=tmr-1;\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\ttemp=l-a[i];\n\t\t\t\t\t\t\ttmr=tmr-temp;\n\t\t\t\t\t\t\ta[i]=l;\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\tif(a[i-1]+1>l)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\t\t// printf(\"hi\\n\");\n\t\t\t\t\t\t\tbreak;\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\ta[i]=d[i]-tmr+1;\n\t\t\t\t\t\t\ttmr=tmr-1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(tmr==-k)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmr=k;\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(flag==1)\n\t\t{\n\t\t\tprintf(\"No\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"Yes\\n\");\n\t\t}\n\t}\n}", "lang_cluster": "C", "compilation_error": false, "code_uid": "ea90c66eec9674f87e8c8ddb496c0a9f", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint dots[][5] = {\n\t{ 1, 0, 0, 1, 0 }, { 1, 1, 0, 2, 0 }, { 2, 0, 0, 1, 1 }, { 2, 1, 0, 1, 2 },\n\t{ 1, 1, 0, 1, 1 }, { 2, 1, 0, 2, 1 }, { 2, 2, 0, 2, 2 }, { 1, 2, 0, 2, 1 },\n\t{ 1, 1, 0, 1, 1 }, { 1, 2, 0, 1, 2 }, { 1, 0, 1, 2, 0 }, { 1, 1, 1, 3, 0 },\n\t{ 2, 0, 1, 2, 1 }, { 2, 1, 1, 2, 2 }, { 1, 1, 1, 2, 1 }, { 2, 1, 1, 3, 1 },\n\t{ 2, 2, 1, 3, 2 }, { 1, 2, 1, 3, 1 }, { 1, 1, 1, 2, 1 }, { 1, 2, 1, 2, 2 },\n\t{ 1, 0, 2, 2, 1 }, { 1, 1, 2, 3, 1 }, { 1, 2, 1, 1, 3 }, { 2, 0, 2, 2, 2 },\n\t{ 2, 1, 2, 2, 3 }, { 1, 1, 2, 2, 2 }\n};\n\nint main() {\n\tint n;\n\n\tscanf(\"%d\", &n);\n\twhile (n--) {\n\t\tstatic int aa[5];\n\t\tint i, a;\n\n\t\tfor (i = 0; i < 5; i++)\n\t\t\tscanf(\"%d\", &aa[i]);\n\t\tfor (a = 0; a < 26; a++)\n\t\t\tif (memcmp(dots[a], aa, 5 * sizeof *aa) == 0) {\n\t\t\t\tprintf(\"%c\", a + 'a');\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "10e98e1d2665390e92c9672a1b77fb1e", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "GNU C11", "source_code": "#include\nlong long int min(long long int n,long long int k)\n{\n\tif(n=n)\n\t\t{\n\t\t\tans=k;\n\t\t\tr=k-1;\n\t\t}\n\t\telse\n\t\t\tl=k+1;\n\t}\n\tprintf(\"%lld\\n\",ans);\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "96420ed6be1d3d85a171c4819e665364", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "GNU C", "source_code": "#include \n#include \n#define mod 12345\n\nint a[27],v[27],p[1001],num[1001],mat[123][123],one[123][123],tmp[123][123];\nchar str[15];\nint s=1;\n\nvoid mi(int a)\n{\n int i,j,k;\n if (!a)\n for (i=0;i>1);\n memset(tmp,0,sizeof(tmp));\n for (i=0;i='0'&&str[j]<='9';j++)\n num[i]=num[i]*10+str[j]-'0';\n s*=num[i];\n }\n for (i=1;i<=c;i++)\n v[p[i]]*=num[i];\n for (i=0;in)\n break;\n }\n if (j>26)\n ans=(ans+mat[0][i])%mod;\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "4cf3d5f2e273991d35e8d2d1035e5077", "src_uid": "76d4684d26dac380713a566a1e277c91", "difficulty": 2400.0} {"lang": "GNU C", "source_code": "#include \n#include \n\nint low[7][7], high[7][7];\nint cost[7][7];\nint n;\nint flow[7][7];\nint inFlow[7];\nint outFlow[7];\nint minFlow = 100, maxCost = -1;\n\nint rec(int v, int to) {\n if(v == n - 1) {\n int isValid = 1;\n int i, j;\n int total = inFlow[n - 1];\n int ccost = 0;\n for(i = 0; i < n; i++) {\n for(j = i + 1; j < n; j++) {\n if(flow[i][j] < low[i][j] || flow[i][j] > high[i][j])\n isValid = 0;\n if(flow[i][j] > 0) \n ccost += flow[i][j] * flow[i][j] + cost[i][j];\n }\n if(inFlow[i] != outFlow[i] && (i > 0 && i < n - 1)) {\n isValid = 0;\n }\n }\n if(isValid) {\n if(minFlow == total) {\n if(ccost > maxCost)\n maxCost = ccost;\n } else if(minFlow > total) {\n minFlow = total;\n maxCost = ccost;\n }\n }\n } else if(to == n)\n rec(v + 1, v + 2);\n else {\n int i;\n for(i = 0; i <= high[v][to]; i++) {\n inFlow[to] += i;\n outFlow[v] += i;\n flow[v][to] = i;\n rec(v, to + 1);\n inFlow[to] -= i;\n outFlow[v] -= i;\n }\n }\n}\n\nint main() {\n scanf(\"%d\", &n);\n int i, from, to, j;\n for(i = 0; i < n * (n - 1) / 2; i++) {\n scanf(\"%d %d\", &from, &to);\n from--;\n to--;\n scanf(\"%d %d %d\", &low[from][to], &high[from][to], &cost[from][to]);\n }\n rec(0, 1);\n if(minFlow == 100)\n puts(\"-1 -1\");\n else\n printf(\"%d %d\\n\", minFlow, maxCost);\n return 0;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "66d16ecd01d6f5b639f2860befb33455", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n#define MOD 1000000007\n#define ll long long\n\nint cmpfunc(const void *a, const void *b);\nint cmp(const void *a, const void *b);\nint cmp1(const void *x, const void *y);\nvoid swap(int *a, int *b);\nint lower_bound(int a[][2], int left, int right, int *val);\nint upper_bound(int a[], int left, int right, int *val);\n\nint main(int argc, char **argv){\n int a,b,l,r;\n scanf(\"%d %d %d %d\",&a,&b,&l,&r);\n int k;\n k=(int)floor(1.0*(l-a-1)/(a+b));\n if(l>=a+1 && k*(a+b)>=r-a-b){\n printf(\"1\\n\");\n return 0;\n }\n int u,v,m,n;\n u=l/(a+b);\n v=l%(a+b);\n m=r/(a+b);\n n=r%(a+b);\n\n if(b>=a){\n if(r-l>=2*a+b-1){\n printf(\"%d\\n\",a+1);\n return 0;\n } else if(u==m){\n int xd;\n if(n>a) xd=a-v+1;\n else xd=n-v+1;\n printf(\"%d\\n\",xd);\n return 0;\n } else{\n int xd;\n if(v<=a){\n if(n>=a) xd=a+1;\n else if(a-v+1+n<=a) xd=a-v+1+n;\n else xd=a;\n }else {\n if(n>=a) xd=a+1;\n else xd=n+1;\n }\n printf(\"%d\\n\",xd);\n return 0;\n }\n }\n\n if(b=2*a+b-1){\n printf(\"%d\\n\",2*a-b);\n return 0;\n } else if(u==m){\n int xd;\n if(n>a) xd=a-v+1;\n else xd=n-v+1;\n printf(\"%d\\n\",xd);\n return 0;\n } else{\n int xd;\n if(v=a) xd=2*a-b;\n else if(a-v+1+n<=a) xd=a-v+1+n;\n else if(n>=b && v<=b) xd=a+n-b;\n else xd=a;\n } else {\n if(n>=a) xd=a+1;\n else xd=n+1;\n }\n printf(\"%d\\n\",xd);\n return 0;\n }\n }\n return 0;\n}\n\nvoid swap(int *a, int *b) {\n int tmp = *a;\n *a = *b;\n *b = tmp;\n}\n\n// ascending order\nint cmpfunc(const void *a, const void *b) { return (*(int *)a - *(int *)b); }\n\nint cmp(const void *x, const void *y) {\n const int *a = (const int *)x;\n const int *b = (const int *)y;\n if (a[0] == b[0])\n return a[1] - b[1];\n else\n return a[0] - b[0];\n}\n\nint cmp1(const void *x, const void *y) {\n const int *a = (const int *)x;\n const int *b = (const int *)y;\n if (a[1] == b[1])\n return a[0] - b[0];\n else\n return a[1] - b[1];\n}\n\nint lower_bound(int a[][2], int left, int right, int *val) {\n int middle;\n while (left < right) {\n middle = left + (right - left) / 2;\n if (a[middle][0] == *val)\n return middle;\n else if (a[middle][0] < *val)\n left = middle + 1;\n else\n right = middle;\n }\n if (a[left][0] <= *val)\n return left;\n else\n return left - 1;\n}\n\nint upper_bound(int a[], int left, int right, int *val) {\n int middle;\n while (left < right) {\n middle = left + (right - left) / 2;\n if (a[middle] == *val)\n return middle;\n else if (a[middle] < *val)\n left = middle + 1;\n else\n right = middle;\n }\n if (a[left] >= *val)\n return left;\n else\n return left + 1;\n}\n", "lang_cluster": "C", "compilation_error": false, "code_uid": "c2fa49411e0d2cccc70b31868bdbd383", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\tlong n,m,f[100][100];\n\tint i,j,k,t,a[100],b[100];\n\tscanf(\"%ld%ld\",&n,&m);\n\tfor(i=0;if[i][t]+f[t+1][j]) f[i][j]=f[i][t]+f[t+1][j];\n\t\t}\n\t }\n if(m<=4) printf(\"%ld\",f[0][n*m-1]);\n\telse{\n\t\tfor(i=t=0;i<2*n;i++) if(f[i][i+2*n-1]