{"lang": "GNU C", "source_code": "#include\nmain()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n%2==0)\n\tprintf(\"%d\",(n+2)/2);\n\telse\n\tprintf(\"%d\",(n+1)/2);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "a7f9e789f47aebdaa84afc9b19222492", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n int n,a,b,i,m,sum;\n scanf(\"%d %d %d\",&n,&a,&b);\n if(b>=0)\n {\n m=a;\n for(i=1; i<=b; i++) {\n m++;\n if(m>n)\n m=1;\n }\n printf(\"%d\",m);\n }\n else\n {\n m=a;\n for(i=1;i<=abs(b);i++)\n {\n m--;\n if(m==0)\n m=n;\n }printf(\"%d\",m);\n }\n }\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "0ce94c11f36281e22f8841720f809786", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n\nint main(){\n int a,b,c,sum,min,k;\n scanf(\"%d %d %d\", &a,&b,&c);\n sum=0;\n k=0;\n while (k!=1)\n {if (((c-1)<=b)&&((c-2)<=a))\n \t {\n\t\tsum= 3*c-3;\n\t\tk=1;\n \t }\n else \n\t {\n\t\tc=c-1;\n \t }\n }\n printf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "f342bde10c4af783fa4113510a5fdfe7", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nint compare (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\nint main()\n{\n int a=0,b=0,n,i,t,val1=0,val2=0,ch=0;\n scanf(\"%d\",&n);\n for(i=0;i=2)&&(a%2==0))\n printf(\"YES\");\n else\n printf(\"NO\");\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "79dca68be41fc49d9744ae4553079a3f", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n\t{int x,y,i,j;\n\t char a[102],b[102];\n\tint c[102]; \n\t \n \tscanf(\"%s\",a);\n scanf(\"%s\",b);\n j=strlen(a);\n\t\n for(i=0;i\n\nint main (void){\n int n,k,j,h; //n:nro de examenes; k:sumatoria de puntajes\n\n scanf(\"%d %d\",&n,&k);\n j= n*2;\n h= 0;\n if(j>k){\n j=0;\n printf(\"%d\", j);\n }else if (j0){\n printf(\"%d\", n);\n }else{\n j=0;\n printf(\"%d\", j);\n }\n }else{\n printf(\"%d\", n);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "0afff899ddbf54fcb19c9b74cbf20b59", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define N 40\n\nlong long a[N][N];\n\nlong long solve( int n, int h )\n{\n int i, o, p, j, k;\n if (a[n][h] >=0 ) return(a[n][h]);\n if (h>n)\n {\n a[n][h] = 0;\n return( a[n][h] );\n } \n if (((n==1) && (h==1)) || ((n==0)&&(h==0)))\n {\n a[n][h] = 1;\n return( a[n][h] );\n } \n\n if (h==0) \n {\n a[n][h] = 0;\n return( a[n][h] );\n }\n \n a[n][h] = 0;\n for (i=0;i<=n-1;++i)\n for (j=0;j<=h-2;++j)\n a[n][h] += solve(i, h-1) * solve(n-i-1, j);\n a[n][h] *= 2;\n for (i=0;i<=n-1;++i)\n a[n][h] += solve(i, h-1) * solve(n-i-1, h-1);\n \n return( a[n][h] );\n} \n\nvoid shu_chu( long long t )\n{\n int a[100], i = 0, o;\n while (t!= 0)\n {\n a[i] = (int)(t%10);\n t = t/10;\n ++i;\n }\n while(i>0)\n {\n --i;\n printf( \"%d\", a[i] );\n }\n}\n\nmain()\n{\n// freopen( \"input.dat\", \"r\", stdin );\n \n int i, o, p, j, k, n, m, h;\n scanf( \"%d %d\", &n, &h );\n for(i=0;i\nint main() {\n int a, b, c, d, x, y, i, j;\n scanf(\"%d%d%d%d\", &a,&b,&c,&d);\n int max = a;\n if(c\nint main()\n{\nint n,x,v;\nscanf(\"%d\",&v);\nn=v;\nx=n-1;\nwhile((x0))\n{\nif((n%x)!=0)\n{\nn=n-x;\n}\nx--;\n}\n\nprintf(\"%d\",n);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "d2cf1428e41023f7772356ffe5e601f1", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include \n\nint cmp(const void *a, const void *b)\n{\n\treturn *(int *)a - *(int *)b;\n}\n\nlong long int min(long long int a, long long int b)\n{\n\tif(ab)\n\t\treturn a;\n\treturn b;\n}\n\n\nint main()\n{\t\n\tlong long int n,a,b,c,d;\n\tlong long int ans=0,i,p,q,r,s,t,u,v,w,y;\n\tscanf(\"%lld%lld%lld%lld%lld\",&n,&a,&b,&c,&d);\n\tq=c+a;\n\tr=c+d;\n\ts=b+d;\t\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tp=a+b+i;\n\t\tt=p-q;\n\t\tu=p-r;\n\t\tv=p-s;\n\t\tw = min(t,min(u,v));\n\t\ty = max(t,max(u,v));\n\n\t\tif(w>=1 && y<=n)\n\t\t{\n\t\t\tans+=n;\n\t\t}\n\n\t}\n\tprintf(\"%lld\\n\",ans );\n\n\treturn 0;\t\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "b61a00439b69e0fa083cc9f5f998d18b", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int x,y,z,i,j;\n int a[3][3];\n for(i=0;i<=2;i++)\n for(j=0;j<=2;j++)\n scanf(\"%d\",&a[i][j]);\n y=(a[2][0]+a[2][1]+a[0][1]+a[0][2]-a[1][0]-a[1][2])/2;\n x=a[2][0]+a[2][1]-y;\n z=a[1][0]+a[1][2]-x;\n a[0][0]=x;\n a[1][1]=y;\n a[2][2]=z;\n for(i=0;i<=2;i++)\n {\n for(j=0;j<=2;j++)\n printf(\"%d \",a[i][j]);\n printf(\"\\n\");\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "451f1f98e7dccb514b975b54667c2063", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint x,y,i,b;\n\tlong long int a=1;\n\tscanf(\"%d %d\",&x,&y);\n\tif(x>y){\n\t\tb=x;\n\t\tx=y;\n\t\ty=b;\n\t}\n\tfor(i=1;i<=x;i++){\n\t\ta=i*a;\n\t}\n\tprintf(\"%lld\",a);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "191d676598d4f7374806cd1b5a0c1b65", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n\n int main(){\n long long A,B,g,y,BALL;\n \n scanf(\"%lld %lld\",&A,&B);\n scanf(\"%lld %lld %lld\",&y,&g,&BALL);\n A=A-(y*2+g);\n B=B-(BALL*3+g);\n if ((A)>=0)\n A=0;\n else A=-A; \n if ((B)>0)\n B=0;\n else B=-B;\n printf(\"%lld\", A+B);\n \n \n \n return 0;\n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "51d10df737fca35e18cea2dafc4085a1", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAX 200010\n#define MOD 1000000007\n\nint n, m, h, sum[1010], dp[MAX][2];\n\nvoid Pregenerate(){\n int i, j, l, res, x = 0;\n for (i = h; i >= 0; i--){\n sum[i] = x;\n x += i;\n }\n\n for (l = 0; l <= h; l++){\n for (i = n; i >= 0; i--){\n j = sum[l] - i;\n if (i > sum[l]) continue;\n if (j > m) continue;\n\n\n if (!l) res = 1;\n else{\n res = 0;\n if ((i + l) <= n) res = res + dp[i + l][(l - 1) & 1];\n if ((j + l) <= m) res = res + dp[i][(l - 1) & 1];\n }\n\n if (res >= MOD) res -= MOD;\n dp[i][l & 1] = res;\n }\n }\n}\n\nint main(){\n int i, j;\n\n while (scanf(\"%d %d\", &n, &m) != EOF){\n for (h = 0; h <= 1000; h++){\n int x = (h * (h + 1)) >> 1;\n if (x > (n + m)){\n h--;\n break;\n }\n }\n\n Pregenerate();\n int res = dp[0][h & 1];\n printf(\"%d\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "cefe7915f525f4d9f914332da1b12fc1", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tint M,N,min,max;\n\tscanf(\"%d%d\",&N,&M);\n\tif(M==0 && N==0)\n\t\tprintf(\"0 0\\n\");\n\telse if(N==0)\n\t\tprintf(\"Impossible\\n\");\n\telse {\n\t\tif(M==0) {\n\t\t\tmin=N;\n\t\t\tmax=N;\n\t\t}\n\t\telse {\n\t\t\tif(N>=M) {\n\t\t\t\tmin=N;\n\t\t\t\tmax=N+M-1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmin=M;\n\t\t\t\tmax=N+M-1;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d %d\\n\",min,max);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "b1fab36f65f374592ad1380178193a98", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\nint main()\r\n{\r\n int n;\r\n scanf(\"%d\", &n);\r\n for (int i = 0; i < n; i++)\r\n {\r\n int key, doors[3], i;\r\n scanf(\"%d\", &key);\r\n scanf(\"%d %d %d\", &doors[0], &doors[1], &doors[2]);\r\n for (i = 0; i < 3; i++)\r\n {\r\n int index = key;\r\n if (doors[index - 1] == 0)\r\n {\r\n if (i == 2)\r\n printf(\"YES\\n\");\r\n else\r\n printf(\"NO\\n\");\r\n break;\r\n }\r\n else if (doors[index - 1] == 1)\r\n key = 1;\r\n else if (doors[index - 1] == 2)\r\n key = 2;\r\n else\r\n key = 3;\r\n }\r\n }\r\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "f5b5505b740f8ae4648d5d8834446345", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nchar a[20];\nint i,sum=0,flag=0;\nwhile((scanf(\"%s\",&a))!=-1)\n{\n for(i=0;a[i]!='\\0';i++)\n{\n if(a[i]=='4'||a[i]=='7')\n {\n sum++;\n }\n}\nif(sum==0)\n{\n flag=1;\n}\n\nelse\n{\n while(1)\n {\n if(sum%10!=4&&sum%10!=7)\n {\n flag=1;break;\n }\n sum=sum/10;\n if(sum==0)\n {\n break;\n }\n\n }\n}\nif(flag==0)\n{\n printf(\"YES\\n\");\n}\n\n else\n {\n printf(\"NO\\n\");\n }sum=0;flag=0;\n}\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "682ca478cd6b24f1a7a86d870cfd07a1", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/* Problem: 415A - Mashmokh and Lights */\n/* Solver: Gusztav Szmolik */\n\n#include \n\nint main ()\n {\n unsigned short n;\n unsigned short m;\n unsigned short i;\n unsigned short l[100];\n unsigned short b;\n unsigned short j;\n \n if (scanf(\"%hu %hu\",&n,&m) != 2)\n return -1;\n if (n < 1 || n > 100 || m < 1 || m > 100)\n return -1;\n for (i = 0; i < n; i++)\n l[i] = 0;\n for (i = 0; i < m; i++)\n {\n if (scanf(\"%hu\",&b) != 1)\n return -1;\n if (b < 1 || b > n)\n return -1;\n for (j = b-1; j < n && !l[j]; j++)\n l[j] = b;\n }\n if (!l[0])\n return -1;\n for (i = 0; i < n; i++)\n printf ((i ? \" %hu\" : \"%hu\"),l[i]);\n printf (\"\\n\");\n return 0;\n }\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "eb1797326941df977bbc0d198ee885cf", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#define pi(a) printf(\"%d\",a);\n#define s(t) scanf(\"%d\",&t)\n#define s2(t,u) scanf(\"%d%d\",&t,&u)\n#define rep(i, N) for(int k=i;kb[k])\n \t{\n \t\tc1+=a[k]-b[k]; \n }\n else if(b[k]>a[k])\n c2+=b[k]-a[k]; \n if(c1%2!=0||c2%2!=0)\n\t{\n\tprintf(\"-1\");\n\tre;\n}\n\n}\nif(c1==0&&c2==0)\n{\n\tprintf(\"0\");\n\tre;\n}\nif(c1==c2)\n{\n\tif(c1/2==0||c1%2!=0)\n\tprintf(\"-1\");\n\t if(c1%2==0)\n\tpi(c1/2);\n\t\n\t\n\t\n}\nelse\nprintf(\"-1\");\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "2ea25cb9c5d16cec7f842c2f92d27d0d", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n#include\nint main()\n{\n int n,j,p;\n scanf(\"%d\",&n);\n char a1[n];\n scanf(\"%s\",a1);\n p=strlen(a1);\n int c=0,d=0;\n for(j=0;j\n\nint main(void)\n{\n\tint a,b,x=0,y=0,sum1,sum2,sumex=0;\n\tscanf(\"%d\",&a);\n\tscanf(\"%d\",&b);\n\n\tsum1=a+b;\n\t\n\tfor(int i=1,j=1,k=1;a!=0||b!=0||sum1!=0;)\n\t{\n\t\tif(a%10!=0) \n\t\t{\n\t\t\tx+=a%10*i;\n\t\t\ti*=10;\t\n\t\t}\n\t\t\n\t\tif(b%10!=0) \n\t\t{\n\t\t\ty+=b%10*j;\n\t\t\tj*=10;\t\n\t\t}\t\n\t\t\n\t\tif(sum1%10!=0) \n\t\t{\n\t\t\tsumex+=sum1%10*k;\n\t\t\tk*=10;\t\n\t\t}\t\n\t\t\n\t\ta/=10;\n\t\tb/=10;\n\t\tsum1/=10;\n\t}\n\n\tsum2=x+y;\n\t//printf(\"%d %d %d\",x,y,sumex);\n\t\n\tif(sumex==sum2) printf(\"YES\");\n\telse printf(\"NO\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7126fdad480094d8d8fe8e93a320f367", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main() {\n int l, r, a, ans;\n scanf(\"%d%d%d\", &l, &r, &a);\n int delta = (l > r) ? l - r : r - l;\n if (delta > a) {\n if (l > r) {\n ans = r + a;\n } else {\n ans = l + a;\n }\n } else {\n a -= delta;\n a /= 2;\n if (l > r) {\n ans = l + a;\n } else {\n ans = r + a;\n }\n }\n printf(\"%d\\n\", 2 * ans);\n\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "50f50ad2e9fbf4d97cc65fbd8444b2bb", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n \nint main(void){\n int count[1001] = {0}; //sorts the f array\n int n, m, *f, i, j, min;\n \n scanf(\" %d %d\", &n, &m);\n \n f = (int*)malloc(m*sizeof(int));\n \n for(i=0; i0; f[j]=i, count[i]--, j++)\n ;\n }\n \n min = f[n-1] - f[0];\n \n for(i=1; i<=(m-n); i++)\n if((f[n+i-1] - f[i]) < min)\n min = (f[n+i-1] - f[i]);\n \n printf(\"%d\\n\", min);\n \n return 0;\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "072a5cb2c05edb6934a73fc4626e140e", "src_uid": "7830aabb0663e645d54004063746e47f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,t,i,sum=0;\n scanf(\"%d %d\",&n,&t);\n int arr[n];\n\n\n for(i=0;i=10*(n-1)) printf(\"%d\",(t-sum)/5);\n else printf(\"-1\");\n\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "8ff97f61f6be01fc02c7863a0d47f6a5", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(void)\n{\n int i,j,n,m=0,k=0;\n char a[101];\n while((scanf(\"%d\",&n))!=EOF)\n {\n m=0;\n for(i=0;i\n\n\nint main()\n{\n int n,a[3],i;\n scanf(\"%d %d %d %d\",&n,&a[0],&a[1],&a[2]);\n\n int dp[n];\n for(i=0;i\nint main()\n{\n long long int a,n,m,i,j;\n scanf(\"%lld%lld%lld\",&n,&m,&a);\n if(n>=1&&a<=1e9&&a!=0)\n {\n if(n%a==0)\n i=n/a;\n else{\n i=n/a;\n i=i+1;\n }\n if(m%a==0)\n j=m/a;\n else{\n j=m/a;\n j=j+1;\n }\n i=i*j;\n printf(\"%lld\",i);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "0e695d98faf6e7af2e56ac277c9d5811", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,b,c,i;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tfor(i=a;i>=0;i--)\n\t{\n\t\tif(2*i<=b && 4*i<=c)\n\t\t\tbreak;\n\t}\n\tprintf(\"%d\\n\",7*i);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "31b060ff9b9d57cd8c6fa3566c8f0e2f", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n\nint main()\n{\n\tint n,p,k,s;\n\tscanf(\"%d %d %d\",&n,&p,&k);\n\tif ((p-k)<=1)\n\tprintf(\"\");\n\telse\n\tprintf(\"<<\");\n\t////////\n\tfor (int i=0;i<=k;i++)\n\t{\n\tif (i!=k)\n\t{\n\tif (p-k+i>0)\n\tprintf(\" %d\",p-k+i);\n\telse\n\tprintf(\"\");\n\t}\n\telse\n\tprintf(\" (%d)\",p);\n\t}\n\t////////////\n\tfor (int i=0;i<=k;i++)\n\t{\n\ts=p+1+i;\n\tif (s<=n)\n\t{\n\tif (i!=k)\n\tprintf(\" %d\",s);\n\t}\n\telse\n\tprintf(\"\");\n\t}\n\tif (s<=n)\n\tprintf(\" >>\");\n\telse\n\tprintf(\"\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2a4829a55323e0d8ae5a779ec8c581bf", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint x,y,x1,x2,y1,y2;\n\tscanf(\"%d %d\",&x,&y);\n\tif (x>0){\n\t\tx1=0;\n\t\ty2=0;\n\t\tif (y>0){\n\t\t\tx2=x+y;\n\t\t\ty1=x2;\n\t\t}\n\t\telse if (y<0){\n\t\t\ty1=y-x;\n\t\t\tx2=x-y;\n\t\t}\n\t}\n\telse if (x<0){\n\t\tx2=0;\n\t\ty1=0;\n\t\t\n\t\tif (y>0){\n\t\t\tx1=x-y;\n\t\t\ty2=y-x;\n\t\t}\n\t\telse if (y<0){\n\t\t\tx1=x+y;\n\t\t\ty2=x1;\n\t\t\t\n\t\t}\n\t}\n\tprintf(\"%d %d %d %d\",x1,y1,x2,y2);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "1061753fd8fa45c51d8e083564e2cee4", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n=1,k,c=0;\n scanf(\"%d\",&k);\n while(n<=1000000000){\n int s=0;\n int num=n;\n while(num!=0){\n int r = num % 10;\n s= s+r;\n num = num/10;\n }\n n++;\n if(s==10)\n {\n c++;\n }\n if(c==k){\n printf(\"%d\",n-1);\n break;\n }\n }\n\n}", "lang_cluster": "C", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "5593ffa31d212ac0eaf44b3cedc0bc1d", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define mod 998244353LL\n\ntypedef uint32_t u_int32_t;\ntypedef uint64_t u_int64_t;\n\nu_int64_t dp[2005][2005];\n\nvoid read_u_int32_t(FILE *__restrict stream, u_int32_t *__restrict nr) {\n uint8_t ch;\n *nr = 0;\n while ((ch = fgetc(stream)) && ('0' <= ch && ch <= '9')) {\n *nr *= 10;\n *nr += ch - '0';\n }\n}\n\nint main() {\n u_int32_t n, m, k;\n {\n read_u_int32_t(stdin, &n);\n read_u_int32_t(stdin, &m);\n read_u_int32_t(stdin, &k);\n }\n dp[1][0] = m;\n {\n int32_t i, j;\n for (i = 1; i <= n; ++i) {\n for (j = 0; j <= k; ++j) {\n dp[i + 1][j] += dp[i][j];\n dp[i + 1][j] %= mod;\n dp[i + 1][j + 1] += dp[i][j] * (m - 1);\n dp[i + 1][j + 1] %= mod;\n }\n }\n }\n {\n fprintf(stdout, \"%lu\", dp[n][k]);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "2856c94dc44d91d80687749028a921ab", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\"stdio.h\" \nint p(int n){ \n if(n==0) \n return 5; \n else \n return 2*p(n-1); } \nint s(int n){ \n if(n==0)\n return 5; \n else \n return p(n)+s(n-1); } \nint rest(int N){\n int i=0; \n while(i<30){ \n if((N-s(i))=0) \n\treturn N-s(i);\n else if(N<5) \n\treturn N;\n i++; }} \nint expo(int N){ \n int i=0; \n while(i<30){ \n if((N-s(i))=0) \n return i; \n else if(N<5) \n return 0; \n i++; }} \nint main(){ \n int M; \n scanf(\"%d\",&M);\nif(M>4){\n double s=5*rest(M);\n double q=p(expo(M)+1);\n double r=s/q;\n\n if(0\n#include \n\nint main()\n{\n char table[3], hands[3];\n int s = 0;\n scanf(\"%s\", table);\n\n for(int i = 0; i < 5; i++)\n {\n s = 0;\n scanf(\"%s\", hands);\n if(hands[s] == table[s] || hands[s+1] == table[s+1]) {printf(\"YES\"); return 0;}\n else continue;\n }\n printf(\"NO \");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "26edda70a1f03c06bdf532b4303586d2", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,i,l=0;\n scanf(\"%d\",&n);\n for(i=1;i\n\nint main() {\nint i,j,p,o,k;\nint flag = 0;\nint m[5][5];\nfor(i=0;i<5;i++)\n\tfor(j=0;j<5;j++)\n\tscanf(\"%d\",&m[i][j]);\nfor(i=0;i<5;i++)\n{\n\tfor(j=0;j<5;j++)\n\t{\n\t\tif(m[i][j]==1){\n\t\tflag = 1;\n\t\tbreak;\n\t\t}\n\t}\n\t\tif(flag == 1)\n\t\tbreak;\n\t\n}\n\n\tp=i-2;\n\tif(p<0)\n\tp*=-1;\n\to=j-2;\n\tif(o<0)\n\to*=-1;\n\tk= p+o;\n\tprintf(\"%d\",k);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6788053e6b71c5df5eebc3f1f610a4f0", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{ long long int m,n,i,k,c;\nscanf(\"%lld %lld\",&m,&n);\nif(m==n)\n {printf(\"YES\\n\");\n printf(\"0\");\n }\nelse\n {\n i=m; c=0;\n while(1)\n {\n i=i*m;\n c++;\n if(i>=n)\n break;\n }\n if(i==n){\n k=c;\n printf(\"YES\\n\");\n printf(\"%lld\\n\",k);}\n else\n {\n printf(\"NO\");\n }\n }\n\n return 0;\n\n }", "lang_cluster": "C", "tags": ["math"], "code_uid": "8e27822b05d06659778ac5872649e267", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int n,k,i,p=0,j,h=0,a[1005],b[1005];\n scanf(\"%d %d\",&n,&k);\n for(i=2;i=k) printf(\"YES\");\nelse printf(\"NO\");\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "460f43de12ec778f41de6533e8393984", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint A[3][3],i,j,B[3][3];\nfor(i=0;i<3;i++)\n{\nfor(j=0;j<3;j++)\n{\nA[i][j]=1;\n}\n}\nfor(i=0;i<3;i++)\n{\nfor(j=0;j<3;j++)\n{\nscanf(\"%d\",&B[i][j]);\n}\n}\nfor(i=0;i<3;i++)\n{\nfor(j=0;j<3;j++)\n{\nif(B[i][j]%2==1)\n{\nif(A[i][j]==1)\n{\nA[i][j]=0;\n}\nelse\n{\nA[i][j]=1;\n}\nif(j!=2)\n{\nif(A[i][j+1]==0)\n{\nA[i][j+1]=1;\n}\nelse\n{\nA[i][j+1]=0;\n}\n}\nif(i!=2)\n{\nif(A[i+1][j]==0)\n{\nA[i+1][j]=1;\n}\nelse\n{\nA[i+1][j]=0;\n}\n}\nif(j!=0)\n{\nif(A[i][j-1]==0)\n{\nA[i][j-1]=1;\n}\nelse\n{\nA[i][j-1]=0;\n}\n}\nif(i!=0)\n{\nif(A[i-1][j]==0)\n{\nA[i-1][j]=1;\n}\nelse\n{\nA[i-1][j]=0;\n}\n}\n}\n}\n}\nfor(i=0;i<3;i++)\n{\nfor(j=0;j<3;j++)\n{\nprintf(\"%d\",A[i][j]);\n}\nprintf(\"\\n\");\n}\nreturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9eb0145b88725f3a5534a3e0ed3f4075", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(int argc, char ** argv){\n\tint t,s,x;\n\tscanf(\"%d %d %d\",&t,&s,&x);\n\tint start=t;\n\tif(start==x){\n\t\tprintf(\"%s\", \"YES\");\n\t\treturn 0;\n\t}\n\twhile(startx){\n\t\tprintf(\"%s\",\"NO\");\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "04910b374b6cd11de800acbdb1dc5bc3", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n char c[4][4];\n int i,j;\n for(i=0; i<3; i++)\n {\n for(j=0; j<=3; j++)\n {\n scanf(\"%c\",&c[i][j]);\n }\n }\n if(c[0][0]==c[2][2] && c[0][1]==c[2][1] && c[0][2]==c[2][0] && c[1][0]==c[1][2] && c[1][1]==c[1][1] && c[1][2]==c[1][0])\n {\n printf(\"YES\\n\");\n }\n else\n printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7b28e8a79cb8aafc6c5d634821d65632", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\nint i,j=0,l;\nchar a[200];\nchar c[200];\nscanf(\"%s\",&a);\nl=strlen(a);\nfor(i=0;i\n\nint main(int argc, char* argv[])\n{\n\tint numberOfDancers, whiteSuitCost, blackSuitCost;\n\tscanf(\"%d %d %d\", &numberOfDancers, &whiteSuitCost, &blackSuitCost);\n\n\t//Getting the cheapest suit.\n\tint cheapSuitCost, cheapSuitFlag;\n\tif(whiteSuitCost < blackSuitCost)\n\t\tcheapSuitCost = whiteSuitCost;\n\telse\n\t\tcheapSuitCost = blackSuitCost;\n\t\n\tint dancers[numberOfDancers];\n\n\t//Getting dancers arrangment.\n\tint i;\n\tfor(i = 0;i < numberOfDancers;i++)\n\t\tscanf(\"%d\", &dancers[i]);\n\n\t//Buy the cheapest suit for the center dancer.\n\tint cost = 0;\n\tif(numberOfDancers % 2 != 0)\n\t{\n\t\tif(dancers[numberOfDancers/2] == 2)\n\t\t\tcost += cheapSuitCost;\n\t}\n\n\t\n\tint j;\n\tif(numberOfDancers % 2 == 0)\n\t\tj = numberOfDancers / 2;\n\telse\n\t\tj = (numberOfDancers/2) + 1;\n\n\tfor(i = (numberOfDancers/2) - 1;i >= 0;i--)\n\t{\t\n\n\t\tif(dancers[i] + dancers[j] == 1)\n\t\t{\n\t\t\tprintf(\"-1\");\n\t\t\treturn 0;\n\t\t}\n\t\telse if(dancers[i] == 2 && dancers[j] == 2)\n\t\t\tcost += (cheapSuitCost * 2);\n\t\telse if(dancers[i] == 1 && dancers[j] == 2)\n\t\t\tcost += blackSuitCost;\n\t\telse if\t(dancers[i] == 2 && dancers[j] == 1)\n\t\t\tcost += blackSuitCost;\n\t\telse if(dancers[i] == 0 && dancers[j] == 2)\n\t\t\tcost += whiteSuitCost;\n\t\telse if(dancers[i] == 2 && dancers[j] == 0)\n\t\t\tcost += whiteSuitCost;\n\n\t\tj++;\n\t}\n\n\tprintf(\"%d\", cost);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "3a5877e42d82cf633079775bc957394a", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tint n,k;\n\tscanf(\"%d %d\",&n,&k);\n\twhile(k--){\n\t\tif(n%10) n=n-1;\n\t\telse n=n/10;\n\t}\n\tprintf(\"%d\\n\",n);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f19b011c6873c3fb47da7985e814d181", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\ntypedef unsigned int u_int;\n\nint main(void){\n u_int a,b;\n u_int i,j;\n u_int an;\n unsigned long long int counta=0,countb=0;\n scanf(\"%u %u\",&a,&b);\n if(a>b){\n an=a%b;\n while(an!=0){\n counta+=an;\n countb+=a-an;\n an=(an+a)%b;\n }\n counta+=b;\n countb+=a-b;\n if(counta>countb) puts(\"Dasha\");\n else if(counta==countb) puts(\"Equal\");\n else puts(\"Masha\");\n }else{\n b+=a;\n a=b-a;\n b-=a;\n an=a%b;\n while(an!=0){\n counta+=an;\n countb+=a-an;\n an=(an+a)%b;\n }\n counta+=b;\n countb+=a-b;\n if(counta>countb) puts(\"Masha\");\n else if(counta==countb) puts(\"Equal\");\n else puts(\"Dasha\");\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "ba03253dbbb7e90047113ec8754ef144", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint i,j,l,c=0,d=0,e=0,f=0;\n\tchar s[100];\n\tscanf(\"%s\",s);\n\n\tl=strlen(s);\n\tfor(i=0;i=1)\n\t\t{\n\t\t\tif(s[i]=='e')\n\t\t\td++;\n\t\t\n\t\t\tif(d>=1)\n\t\t\t{\n\t\t\t\tif(s[i]=='l')\n\t\t\t\te++;\n\t\t\t\n\t\t\t\tif(e>=2)\n\t\t\t\t{\n\t\t\t\t\tif(s[i]=='o')\n\t\t\t\t\tf++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\t\t\n\t\t\n\t\n\tif(f>=1)\n\tprintf(\"YES\");\n\telse\n\tprintf(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "strings"], "code_uid": "b9e30bc15f0ed6704e3844e6cd92c4b4", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n# include \nint main()\n{\n char ch[100];\n scanf(\"%s\",&ch);\n int i,c1=0,c2=0;\n for(i=0;i=c2)\n printf(\"4\\n\");\n else\n printf(\"7\\n\");\n return 0;\n }", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "9273cd3454997f0b8121b40a8a00e7b4", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int s,v1,v2,t1,t2;\n scanf(\"%d\",&s);\n scanf(\"%d %d %d %d\",&v1,&v2,&t1,&t2);\n\n int ans1=v1*s+2*t1;\n int ans2=v2*s+2*t2;\n\n if(ans1ans2) printf(\"Second\\n\");\n else printf(\"Friendship\\n\");\n\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "4bfaa4395d4907385dce471b89cbf8de", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n * mike.c\n * \n * Copyright 2019 \n * \n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n * MA 02110-1301, USA.\n * \n * \n */\n\n\n#include \n#include\n\nint main(int argc, char **argv)\n{\n\tchar s[15];int a=0;\n\tscanf(\"%s\",s);\n\tint k=strlen(s);\n\tfor(int i=0;i\n\nint min (int a, int b)\n{\n\tif (a\nint main()\n{\n\tint i,j,n,k,x,a[100],b[100]={0},num,count=0,flag=0,max=-1,sum=0;\n\tscanf(\"%d%d%d\",&n,&k,&x);\n\tfor(i=0;i0)\n\t\t{\n\t\t\tif(a[count-1]==num)\n\t\t\t{\n\t\t\t\tb[count-1]++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ta[count]=num;\n\t\t\t\tb[count]++;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta[count]=num;\n\t\t\tb[count]++;\n\t\t\tcount++;\n\t\t}\n\t}\n\tfor(i=0;i=0&&k2)\n\t\t\t\t{\n\t\t\t\t\tsum+=b[j]+b[k];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tflag=1;\n\t\t\t\t}\n\t\t\t\tj--;\n\t\t\t\tk++;\n\t\t\t}\n\t\t}\n\t\tif(max\n\nlong long f(long long p, int n, int m)\n{\n if (n == 1) {\n return p;\n } else if (n % 2 == 0) {\n return f(p * p % m, n / 2, m);\n } else {\n return f(p, n - 1, m) * p % m;\n }\n}\n\nint main()\n{\n int n, m;\n long long x;\n \n scanf(\"%d %d\", &n, &m);\n \n x = f(3, n, m);\n \n printf(\"%d\\n\", (int)((x - 1 + m) % m));\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "8159fb92c4de1f51fbdea63d750d3f56", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//Bismillahirrahmanirrahim//\n#include \nlong long n,i;\nint main()\n{\nscanf(\"%lld\",&n);\nfor( i=1000000;i>1;i--)\n{\t\n\twhile(n%(i*i)==0)\n\t{\n\tn=n/i;\n\t}\n}\n\tprintf(\"%lld\",n);\nreturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "9b2a5447fdaa5892ae7a87b0f2fff77f", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nlong long int gcd(long long int x,long long int y)\n{\n\tif(x==0)\n\t{\n\t\treturn y;\n\t}\n\twhile(y!=0)\n\t{\n\t\tif(x>y)\n\t\t{\n\t\t\tx=x-y;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ty=y-x;\n\t\t}\n\t}\n\treturn x;\n}\nint main( )\n{\n\tlong long int x,y,a,b,c=0,l=0,z,i=0,k;\n\tscanf(\"%lld %lld %lld %lld\",&x,&y,&a,&b);\n\tz=gcd(x,y);\n\tl=(x*y)/z;\n\tc=(b/l)-((a-1)/l);\n\tprintf(\"%lld\\n\",c);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "df00d3063f24ee323ef812fb82ff78c5", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define true 1\n#define false 0\n\nshort is_prime(unsigned long);\nshort find_minimum_tax(unsigned long);\n\nint main()\n{\n short minimum_taxes;\n unsigned long total_taxes;\n scanf(\"%lu\",&total_taxes);\n minimum_taxes = find_minimum_tax(total_taxes);\n printf(\"%hu\\n\",minimum_taxes);\n return 0;\n}\n\n//Happens in O(root(n)) time\nshort is_prime(unsigned long n)\n{\n short prime = true;\n unsigned long i;\n\n for(i = 2; i*i <= n; i++)\n {\n if(n%i == 0)\n {\n prime = false;\n break;\n }\n }\n return prime;\n}\n\n/*If the number is prime, then only 1 has to be paid. That is the minimum possible.\nThe next minimum is 2.\nSince the Goldbach conjecture has been verified upto the limit, we can use it. Any even number is the sum of two primes.\nWe don't need to actually find the pair of primes, we just know it exists.\nIf a number is odd and composite , n = (n-2) + 2, is the only way it can be written as the sum of two primes. 2 is the only even prime number.\nThe sum of two odd numbers is another odd number. So, an even number has to be involved. If (n-2) is prime, then the minimum tax = 1+1 = 2\n\nn = n-3 + 3, and then n-3 is an even number and has minimum return 2. 3 is prime. 2+1 = 3. This is the maximum possible tax that will ever be given\nfollowing the scheme.\n\nNote - Although logically the first thing to do is check if a number is prime and return 1 if it is and then go for the other test,\nI have included it second because checking parity of number is a very quick and easy process Even numbers don't need to be subjected to primality tests.*/\nshort find_minimum_tax(unsigned long tax)\n{\n //According to Goldbach conjecture, every even number can be written as the sum of two odd primes, It has been numerically verified upto the limit given\n if( (tax%2 == 0) && (tax != 2) )\n {\n return 2;\n }\n else if(is_prime(tax))\n {\n return 1;\n }\n else\n {\n //If n-2 is prime, then n = (n - 2) + 2 is the sum of two primes. This is the only way since one summand has to be even to get an odd number\n if(is_prime(tax - 2))\n {\n return 2;\n }\n else //Then, n = (n-3) + 3. n-3 is an even number and can be written as the sum of two odd primes\n {\n return 3;\n }\n }\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "4d5262f2d6318682c20a609f2c0fc890", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() \n{\n int n,m,sum,d;\n scanf(\"%d %d\",&n,&m);\n sum=n;\n rich:\n d=n/m;\n if(d>0)\n {\n sum=sum+d;\n if(((n%m)+d)>=m)\n {\n n=(n%m)+d;\n goto rich;\n }\n }\n printf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "4ddeb8bc7010671a1fde171d9c6c2c67", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include\n int main()\n {int n,i,max=0,count=0,freq[601]={0};\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;imax)\n {max=a[i];}\n }\n \n \n for(i=0;i0) count++;\n }\n printf(\"%d\",count);\n return 0;\n }\n ", "lang_cluster": "C", "tags": ["sortings", "implementation"], "code_uid": "860658dc4f702e009ef0003cc6284b32", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\n\nint main()\n{\n int n1,n2,a1[100],a2[100];\n scanf(\"%d%d\",&n1,&n2);\n for(int i=0;i\n#include \nint min(int a, int b)\n{\n return a\nint main()\n{\nint n,m,i,first;\nlong long int sum=0;\nscanf(\"%d%d\",&n,&m);\nfor(i=1;i<=n;i++)\n{\nfirst=5-(i%5);\nif(m>=first)\n\tsum=sum+((m-first)/5) +1;\n}\nprintf(\"%lld\\n\",sum);\nreturn 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "d60dde6079f95796afb71b881c6d85ab", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int n,k,b[105],flag=0;\n char s[105];\n memset(b,0,sizeof(b));\n scanf(\"%d%d%s\",&n,&k,s);\n for(int i=0;ik)\n flag=1;\n if(flag==1) printf(\"NO\\n\");\n else printf(\"YES\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "1738902b1b63f39f8c259433c6377a27", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint findMax(int n)\n{\n\tif(n==1)\n\t\treturn 0;\n\tint i;\n\tfor(i=2; i<=n; i++)\n\t\tif(n%i==0)\n\t\t\treturn n/i+findMax(n/i);\n\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\n\tint sum=n;\n\tsum=sum+findMax(n);\n\n\tprintf(\"%d\\n\",sum);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "726863141afd440c285ea945a1263e06", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n long long N,x=0;\n scanf(\"%lld\",&N);\n while(x*(x+1)/2\n#include \n\nconst int MOD = 1000000007;\n\nint main(void) {\n int n, k, d, ans, i, j;\n scanf(\"%d%d%d\", &n, &k, &d);\n int memW[n + 1];\n int memWO[n + 1];\n for (i = 0; i <= n; i++)\n memW[i] = (memWO[i] = 0);\n memW[0] = (memWO[0] = 1);\n for (i = 0; i < n; i++)\n for (j = 1; j + i <= n && j <= k; j++){\n memW[j + i] += memW[i];\n if (memW[i + j] >= MOD)\n memW[i + j] -= MOD;\n if (j < d){\n memWO[j + i] += memWO[i];\n if (memWO[i + j] >= MOD)\n memWO[i + j] -= MOD;\n }\n }\n ans = memW[n] - memWO[n];\n if (ans < 0)\n ans += MOD;\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["dp", "implementation", "trees"], "code_uid": "b502f4e86302714b954378618b5abe4c", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main() \n {\n\tlong int n;\n\tint i,k,sum=0,dig,cnt=0;\n\tscanf (\"%ld\",&n);\n\tfor(i=n+1;;i++)\n\t{\n\t\tsum++; k=i;\n\t\twhile(k)\n\t\t{ \n if(abs(k%10)==8)\n { cnt=1; break;}\n k/=10;\n\t }\n\t if (cnt==1)\n\t break;\n\t}\n\tprintf(\"%d\",sum);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "1c2e0d5ef5ff08c38fd56bd44ed8f4df", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n\tchar str1[500000],str2[500000];\n\tint m, n;\n\tscanf(\"%d %d\", &n, &m);\n\tint i, j, k;\n\tint countRed=n, countBlue=m;\n\tstr1[0]='r';\n\tfor(i=1;i<=m+n;i++)\n\t{\n\t\tif(i%2==1)\n\t\t{\n\t\t\tif(str1[i-1]=='r')\n\t\t\t{\n\t\t\t\tif(countRed>0)\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(str1[i-1]=='b')\n\t\t\t{\n\t\t\t\tif(countBlue>0)\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(str1[i-1]=='r')\n\t\t\t{\n\t\t\t\tif(countBlue>0)\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(str1[i-1]=='b')\n\t\t\t{\n\t\t\t\tif(countRed>0)\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr1[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tstr2[0]='b';\n\tcountBlue=m;countRed=n;\n\tfor(i=1;i<=m+n;i++)\n\t{\n\t\tif(i%2==1)\n\t\t{\n\t\t\tif(str2[i-1]=='b')\n\t\t\t{\n\t\t\t\tif(countBlue>0)\n\t\t\t\t{\n\t\t\t\t\tstr2[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr2[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(str2[i-1]=='r')\n\t\t\t{\n\t\t\t\tif(countRed>0)\n\t\t\t\t{\n\t\t\t\t\tstr2[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tstr2[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(str2[i-1]=='b')\n\t\t\t{\n\t\t\t\tif(countRed>0)\n\t\t\t\t{\n\t\t\t\t\tstr2[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\tstr2[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(str2[i-1]=='r')\n\t\t\t{\n\t\t\t\tif(countBlue>0)\n\t\t\t\t{\n\t\t\t\t\tstr2[i]='b';\n\t\t\t\t\tcountBlue--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\tstr2[i]='r';\n\t\t\t\t\tcountRed--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tint count1=0, count2=0,count3=0, count4=0;\n\t//printf(\"%s %s\",str1, str2);\n\tfor(i=1;icount2)\n\t\tprintf(\"%d %d\\n\",count1, count3);\n\telse\n\t\tprintf(\"%d %d\\n\",count2, count4);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["greedy", "implementation", "games"], "code_uid": "6633a0e308856a30db2894dfaafbdf8e", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n int i, nz, no, n, x;\n scanf(\"%d\\n\", &n);\n\n nz = no = 0;\n\n for (i = 0; i < n; i++) {\n x = getchar();\n if (x == '1') {\n no++;\n } else if (x == '0') {\n nz++;\n }\n }\n\n if (no >= 1) {\n printf(\"1\");\n\n for (i = 0; i < nz; i++) {\n printf(\"0\");\n }\n } else {\n printf(\"0\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "192012e7ff513754fd274147efbe0c8e", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint a1, a2, time=0;\n\tscanf(\"%d%d\", &a1, &a2);\n\twhile(a1>0 && a2>0)\n\t{\n\t\tif(a1==1 &&a2==1)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tif(a1>a2)\n\t\t{\n\t\t\ta1-=2;\n\t\t\ta2++;\n\t\t\ttime++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta2-=2;\n\t\t\ta1++;\n\t\t\ttime++;\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n\tprintf(\"%d\\n\", time);\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n} ", "lang_cluster": "C", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "f613340a66f591a1e708f727fa5d4eb7", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include\n#include\nint check(char[],char[]);\nint main(){\nchar s[100];\n char name[10][10]={\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"};\n int i,j,k,l1,l2,c=0; \n scanf(\"%s\",&s);\nl1=strlen(s);\n for(i=0;i<5;i++)\n {\n \tl2=strlen(name[i]);\n \tfor(j=0;j\nint main()\n{\n int c, a, b, i;\n\n scanf(\"%d %d\", &a, &b);\n for(i=1;;i++) {\n a = a * 3;\n b = b * 2;\n if(a > b) {\n c = i;\n break;\n }\n }\n printf(\"%d\", c);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b3a46f35cf116b6233c03e4bec5edd5e", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint n,i,j,pos,counter;\nint criminals[100];\ncounter=0;\nscanf(\"%d%d\",&n,&pos);\nfor(i=0;i=0)&&(pos-1+j=0)&&(pos-1+j>=n)&&(criminals[pos-1-j]==1))\ncounter+=1;\nelse if((pos-1-j<0)&&(pos-1+j\n#include \n\nint main()\n{\n int n,t,k,d;\n scanf(\"%d%d%d%d\",&n,&t,&k,&d);\n int ans=((d/t)+1)*k;\n if(ans\n#include \n\nint main()\n{\n long int a,b,c;\n while(~scanf(\"%ld\",&a))\n {\n if(a>=5)\n {\n b=a/5;\n c=a%5;\n if(c!=0)\n {\n b++;\n printf(\"%ld\\n\",b);\n }\n else\n printf(\"%ld\\n\",b);\n }\n if(a<5)\n printf(\"1\\n\");\n }\n return 0;\n}\n\n\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t \t \t\t \t", "lang_cluster": "C", "tags": ["math"], "code_uid": "c35b15359281c4615c27d30d49b6f6a2", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint board[191][119];\nint main(){\n int a,b,c,d,e;\n char input[50];\n char input1[50];\n int i; int cnt=0;\n scanf(\"%s%s\",input,input1);\n board[input[0]-'a'][(input[1]-'0')-1]=1;\n board[input1[0]-'a'][(input1[1]-'0')-1]=1;\n int rook=input[0]-'a'; int rook1=(input[1]-'0')-1;\n for(i=0;i<8;i++){\n for(a=0;a<8;a++){\n if(board[i][a] != 1 && board[i+2][a+1] != 1 && board[i+2][a-1] != 1 && board[i-2][a+1] != 1 && board[i-2][a-1] != 1 && board[i-1][a+2] != 1 && board[i+1][a+2] != 1 && board[i-1][a-2] != 1 && board[i+1][a-2] != 1 && i!=rook && a!=rook1){\n cnt++;\n board[i][a]=2;\n }\n }\n }\n printf(\"%d\",cnt);\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "5d532a8095a92d553b6121c03f482bef", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a[6]={0};\n int i,j,temp=0,k1=0,k2=0,k3=0;\n for(i=0;i<6;i++)\n scanf(\"%d\",&a[i]);\n for(i=0;i<6;i++)\n {\n for(j=0;j<6;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 \n \n if(a[1]==a[2] && a[2]==a[3] && a[3]==a[4])\n {\n k1=1;\n if(a[0]==a[5])\n k2=1;\n else\n k3=1;\n }\n else if(a[2]==a[3] && a[3]==a[4] && a[4]==a[5])\n {\n k1=1;\n if(a[0]==a[1])\n k2=1;\n else\n k3=1;\n \n }\n else if(a[0]==a[1] && a[1]==a[2] && a[2]==a[3])\n {\n k1=1;\n if(a[4]==a[5])\n k2=1;\n else\n k3=1;\n }\n if(k1==1 && k2==1)\n printf(\"Elephant\\n\");\n else if(k1==1 && k3==1)\n printf(\"Bear\\n\");\n else\n printf(\"Alien\\n\");\n \n return 0;\n \n \n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f7f1ede641284536b1529bf96331f5dd", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int n,a,b,c,x,y,sum,temp;\n scanf(\"%d%d%d%d\", &n,&a,&b,&c);\n if(n==1)\n {\n printf(\"0\\n\");\n }\n\n else\n {\n if(n==2)\n {\n if(a>b)\n {\n printf(\"%d\\n\", b);\n }\n else\n {\n printf(\"%d\\n\", a);\n }\n\n }\n else\n {\n if(a<=b&&a<=c)\n {\n sum=(n-1)*a;\n }\n else if(b<=a&&b<=c)\n {\n sum=(n-1)*b;\n }\n else\n {\n if(a\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n char ch[n+1];\n scanf(\"%s\",ch);\n int cnt=0,nct=0,minus=0,sum=0;\n for(int i=0;ch[i]!='\\0';i++){\n if(ch[i]=='+'){\n sum++;\n }\n else if(ch[i]=='-'){\n sum--;\n }\n if(sum<0){\n sum=0;\n }\n }\n printf(\"%d\\n\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "dd8e9a7284e0e02aee4562166f3e8980", "src_uid": "a593016e4992f695be7c7cd3c920d1ed", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u4e09\u89d2\u5f62\u95ee\u9898\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n#include \n\nint main()\n{\n char san(int x,int y,int z);\n void maxtomin(int a[]);\n\n int a,b,c,d;\n scanf(\"%d %d %d %d\",&a,&b,&c,&d);\n int s[4]={a,b,c,d};\n maxtomin(s);\n a=s[0];b=s[1];c=s[2];d=s[3];\n if(san(a,b,c)=='y'||san(b,c,d)=='y') printf(\"TRIANGLE\");\n else if(san(a,b,c)=='d'||san(b,c,d)=='d') printf(\"SEGMENT\");\n else if(san(a,b,c)=='n'&&san(b,c,d)=='n') printf(\"IMPOSSIBLE\");\n\n return 0;\n}\n\nvoid maxtomin(int a[])\n{\n int i,j,t;\n for(i=0; i<4; i++)\n {\n for(j=i+1; j<4; j++)\n {\n if(a[i]z&&x+z>y&&z+y>x) r='y';\n else if(x+y==z||x+z==y||y+z==x) r='d';\n else r='n';\n\n return r;\n}", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "309268333399f3676db9a346308c8f72", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n, m, ans, ans2, max, dima, total;\n ans2 = 0;\n ans = 0;\n scanf(\"%d\", &n);\n total = n+1;\n while(n--){\n scanf(\"%d\", &m);\n ans = ans+m;\n }\n max = ans + 5;\n dima = total + 1;\n while(1){\n if(dima>ans && dima<=max){\n ans2++;\n }\n dima +=total;\n if(dima>max) break;\n }\n ans2 = 5 - ans2;\n printf(\"%d\\n\", ans2);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c9f10c297ded1d7c1ce1da9e16f20c8e", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n//#include\nint main()\n{\nlong long int n;\nscanf(\"%ld\",&n);\nprintf(\"%ld\",6*n*(n-1)+1);\n//getch();\nreturn(0);\n}", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "27ed7188fcc0a9fa4ccbdce53d3cb38f", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n\nint main()\n{\n int n,i,x,a[4],temp;\n scanf(\"%d%d\",&n,&x);\n a[0]=0;\n a[1]=0;\n a[2]=0;\n a[x]=1;\n if(n>6) n=n%6;\n for(i=n;i>0;i--)\n {\n if(i%2==0)\n {\n temp=a[2];\n a[2]=a[1];\n a[1]=temp;\n }\n else\n {\n temp=a[0];\n a[0]=a[1];\n a[1]=temp;\n }\n }\n if(a[0]==1) printf(\"0\");\n else if(a[1]==1) printf(\"1\");\n else if(a[2]==1) printf(\"2\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "c2ee52cbd0768849817eb708bcc70efd", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main () {\n int n;\n scanf(\"%d\", &n);\n printf(\"%d\\n\", 2*(n/3) + (n%3 != 0));\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "fb76560292d599efab4139172ca4faff", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n\nint main() {\n int nor ;\n scanf(\"%d\", &nor) ;\n int rots[nor] ;\n for(int i = 0 ; i < nor ; i++) {\n scanf(\"%d\", &rots[i]) ;\n }\n\n int lim = (1 << nor) ;\n // printf(\"%d\", lim) ;\n for(int k = 0; k < lim ; k++) {\n // printf(\"%d\",i) ;\n int i = k ;\n int sum = 0 ;\n for(int j = 0 ; j < nor ; j++) {\n // printf(\"%d\", i % 2) ;\n if(i % 2) {\n sum += rots[j] ;\n } else {\n sum -= rots[j] ;\n }\n i = i >> 1 ;\n }\n if(sum % 360 == 0) {\n printf(\"YES\") ;\n return 0 ;\n }\n }\n\n printf(\"NO\") ;\n return 0 ;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "bitmasks"], "code_uid": "06b7a7fb58df8f065ad20ae2839775c1", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n;\n scanf(\"%d\",&n);\n int i;\n int c[6];\n c[2]=0;\n c[3]=0;\n c[4]=0;\n c[5]=0;\n for(i=0;i=4.5*n,sum>=4*n+n/2,2*sum>=8*n+n,2*sum>=9*n\n if(2*sum>=9*n){\n break;\n }\n answer++;\n for(i=2;i<5;i++){\n if(c[i]>0){\n c[i]--;\n c[5]++;\n break;\n }\n }\n }\n printf(\"%d\\n\",answer);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "0d4eaa36600358f00a5595c9cd0ebaa2", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n char ch[100];\n int c=0,t=0;\n scanf(\"%s\",ch);\n int l=strlen(ch);\n for(int i=0;i=6)\n {printf(\"YES\");\n return 0;\n //break;\n } \n \n } \n if(c>=6)\n printf(\"YES\");\n else\n printf(\"NO\");\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "d5f6d2d95f2e0d0115e9eec458c02180", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\nchar e, str[101], *keyboard=\"qwertyuiopasdfghjkl;zxcvbnm,./\";\nint key, i, j;\nscanf(\" %c %s\", &e, str);\nif(e=='R')key=-1;\nelse key=1;\n\tfor(i=0; str[i]!='\\0'; i++)\n\t\tfor(j=0; keyboard[j]!='\\0'; j++)\n\t\t\tif(str[i]==keyboard[j])\n\t\t\t{\n\t\t\t\tstr[i]=keyboard[j+key];\n\t\t\t\tbreak;\n\t\t\t}\nprintf(\"%s\", str);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0c5f5785996902268cabef2ebc1f27f8", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint n, i, sum = 0;\n\tchar s[51];\n\n\tscanf (\"%d %s\", &n, s);\n\n\tfor (i = 0; i < n/2 && (s[i] == '4' || s[i] == '7'); i++)\n\t\tsum += s[i] - '0';\n\n\tif (i == n/2)\n\t\tfor (; i < n && (s[i] == '4' || s[i] == '7'); i++)\n\t\t\tsum -= s[i] - '0';\n\n\tputs (sum == 0 && i == n ? \"YES\" : \"NO\");\t\t\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2aa7915ab56fab06cfc7ee56aa8ded46", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint v[51];\nint main(){\n int n, i, aux, f, cn, s, s2;\n s=s2=0;\n scanf(\"%d\", &n);\n cn=n/2;\n for(i=0; iv[i+1]){\n aux=v[i];\n v[i]=v[i+1];\n v[i+1]=aux;\n f=0;\n }\n }\n for(i=1; i<=n; i+=2)\n s=s+abs(v[(i-1)/2]-i);\n for(i=2; i<=n; i+=2)\n s2=s2+abs(v[(i-2)/2]-i);\n if(s>s2)\n printf(\"%d\", s2);\n else\n printf(\"%d\", s);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ed1a2d330d155d04ccc924d5cb9af7d4", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,m,max,min, var,i,flag=0;\n scanf(\"%d %d %d %d\",&n,&m,&min,&max);\n var= n-m;\n int temp[m];\n //printf(\"%d\\n\",var);\n for(i=0;imax)\n {\n flag = 1;\n break;\n } //incorrect \n }\n if(flag!=1)\n {\n if(var<2 && var >0)\n {\n for(i=0;i\nint main()\n{\n int a,b,c=0,i,j,n,s,t;\n\n scanf(\"%d\",&n);\n for(i=0,s=0;i0){\n t=a-b;\n if(i>1&&s!=2){\n if(t==c){\n s=1;\n\n }\n else\n s=2;\n }\n c=t;\n }\n b=a;\n }\n if(s==1||s==0)\n printf(\"%d\\n\",(a+c));\n else\n printf(\"%d\\n\",a);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "969c045e4841c36f5699cca02be358e9", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar board[8][9] = {0}; \n\nint checkBoard() {\n int i;\n for(i = 0; i < 8; i++) {\n if(strcmp(board[i], \"BWBWBWBW\") != 0 && strcmp(board[i], \"WBWBWBWB\") != 0) \n return 0; \n } \n return 1; \n}\n\nint main() {\n int i, j;\n char row[20]; \n for(i = 0; i < 8; i++) {\n scanf(\"%s\\n\", row); \n for(j = 0; j < 8; j++) \n board[i][j] = row[j]; \n }\n\n if(checkBoard())\n printf(\"YES\");\n else \n printf(\"NO\"); \n\n return 0; \n}\n", "lang_cluster": "C", "tags": ["brute force", "strings"], "code_uid": "30a4fedebf9d8a0d4d6549271c80f66b", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,c;\n scanf(\"%d %d %d\",&a,&b,&c);\n a=a-b;\n b=c+1;\n if(a\n\n#define N\t30\n\nlong long ch[N + 1][N + 1];\n\nvoid init() {\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];\n\t}\n}\n\nint main() {\n\tint n, m, t, b, g;\n\tlong long ans;\n\n\tinit();\n\tscanf(\"%d%d%d\", &n, &m, &t);\n\tans = 0;\n\tfor (b = 4; b <= n && b < t; b++) {\n\t\tg = t - b;\n\t\tif (g <= m)\n\t\t\tans += ch[n][b] * ch[m][g];\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "9d6b9143c5e1bf16cef5aa441792180b", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n char str1[101], str2[101];\n int min=0, zero=0;\n scanf(\"%s\", str1);\n scanf(\"%s\", str2);\n int i, l = strlen(str1);\n for(i = 0; i < l; i++)\n {\n if(str1[i] >= 'A' && str1[i] <= 'Z')\n {\n str1[i] = str1[i] - 'A' + 'a';\n }\n if (str2[i] >= 'A' && str2[i] <= 'Z')\n str2[i] = str2[i] - 'A' + 'a';\n }\n /*for(i = 0; i < l; i++)\n {\n sum1 = sum1 + str1[i];\n sum2 = sum2 + str2[i];\n }*/\n for(i = 0; i < l; i++)\n {\n if(str1[i] == str2[i])\n zero++;\n else if(str1[i] < str2[i])\n {\n printf(\"-1\");\n min++;\n break;\n }\n else if(str1[i] > str2[i])\n { printf(\"1\");\n min++;\n break;\n }\n }\n if(zero >0&&min==0)\n printf(\"0\");\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "743b102a1bf5f3b251fc08cb299fbcf1", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char a,s[3],t[3];\n scanf(\"%c\",&a);\n scanf(\"%s %s\",&s,&t);\n if(s[1]==t[1]){\n if(s[0]<60&&t[0]>60)printf(\"NO\");\n else if(s[0]>60&&t[0]<60)printf(\"YES\");\n else if(s[0]<60&&s[0]>t[0])printf(\"YES\");\n else if(s[0]<60&&s[0]t[0])printf(\"NO\");\n else printf(\"YES\");\n }\n }\n else{\n if(s[1]==a)printf(\"YES\");\n else printf(\"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "04dce1ac744055f3597a12b00dbbda70", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n int r, g, bb;\n long long int a, b, c;\n \n for (;;) {\n if (scanf(\" %d %d %d\", &r, &g, &bb) != 3)\n return 0;\n if (r >= g && r >= bb) {\n a = r;\n if (g >= bb) {\n b = g;\n c = bb;\n } else {\n b = bb;\n c = g;\n }\n } else if (g >= bb) {\n a = g;\n if (r >= bb) {\n b = r;\n c = bb;\n } else {\n b = bb;\n c = r;\n }\n } else {\n a = bb;\n if (r >= g) {\n b = r;\n c = g;\n } else {\n b = g;\n c = r;\n }\n }\n if (a >= ((b + c) * 2)) {\n printf(\"%ld\\n\", (long int)(b+c));\n } else {\n printf(\"%ld\\n\", (long int)( c + ((a - c) + (b - c)) / 3) );\n }\n }\n\n return 0;\n\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "9df60d4723ddf422292947050250bb62", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int s[110],i,k=0;\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&s[i]);\n\n }\n for(i=2;i<=n;i++)\n {\n if(k==0)\n {\n\n if(s[i-1]==s[i])\n {k++;\n\n }\n else if(s[i-1]>s[i])\n {k=k+2;\n }\n }\n else if(k==1)\n {\n if(s[i-1]s[i])\n {\n k++;\n\n }\n\n }\n else if(k==2)\n {\n if(s[i-1]\n\nint main()\n{\n int r,c,i,j,count=0,maxr=0,maxc=0;\n scanf(\"%d%d\",&r,&c);\n char a[r][c];\n for(i=0;i\nint h[1000];\nint main()\n{\n\tint n,k,i,j,t,top=0,a[1000],b[1000],s=0,max;\n\tscanf(\"%d %d\",&n,&k);\n\tfor(i=0;imax)\n\t\t\t\tmax=h[j];\n\t\ttop+=max;\n\t}\n\t//if(n-top<0)\n\t//\ttop=n;\n\t//if(top<0)\n\t//\ttop=0;\n\tprintf(\"%d\",n-top);\n\n\t\n\treturn 0;\n}\t\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "5812997c438ba70bc394144c6cc3ca17", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n\n\nint sec(int *mass, int n, int a) {\n if (n == a) {\n a = 1;\n return a;\n }\n\n\n\n int box = 1;\n for (int i = 0; i < n; i++) {\n if (!(i % 2)) {\n mass[i] = box;\n box++;\n }\n }\n\n box--;\n\n for (int i = 0; i < n; i++) {\n if (i % 2) {\n mass[i] = box;\n box--;\n }\n }\n\n a--;\n\n return mass[a];\n}\n\nint main() {\n int n = 0, a = 0;\n\n\n scanf(\"%d %d\", &n, &a);\n\n\n int *mass = (int*) malloc(n * sizeof (int));\n\n sec(mass, n, a);\n\n printf(\"%d\", sec(mass, n, a));\n\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "f9e54a4d6f785d56c483bc2b1e2687de", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\tint gleft,gright,bleft,bright;\n\tint flag=0;\n\tscanf(\"%d %d\",&gleft,&gright);\n\tscanf(\"%d %d\",&bleft,&bright);\n\t\n\tif(bleft==1 && gright==1)flag=1;\n\telse if(gleft==1 && bright==1)flag=1;\n\telse if(gleft*2+3>bright && gleft <=bright+1)flag=1;\n\telse if(gright*2+3>bleft && gright <=bleft+1)flag=1;\n\t\n\tif(flag==1)printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\treturn 0;\n\t}\n ", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "c5409c3d0fca5826e2d003101473d609", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint max(int a, int b)\n{\n return a>b ? a : b;\n}\n\nint a[100], count;\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n\n int i, j, temp;\n\n for (i=0; i1)\n {\n for (i=0; icount)\n {\n ans = k;\n break;\n }\n }\n\n printf(\"%d\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6ddefdd202b3123509b11cc371f6b643", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*!\n * @file a.c\n * @version 1.0\n * @date 17/04/2014\n * @author Anton Leontiev \n *\n * @copyright\n *\n * Copyright (c) 2014, Anton Leontiev\n *\n * Redistribution and use in source and binary forms, with or without modification, are permitted\n * provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this list of\n * conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright notice, this list of\n * conditions and the following disclaimer in the documentation and/or other materials\n * provided with the distribution.\n * 3. Neither the name of Anton Leontiev nor the names of its contributors may be used\n * to endorse or promote products derived from this software without specific prior written\n * permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR\n * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n#include \n#include \n#include \n\nint main(int argc, char *argv[]) {\n\tint a, b, c, d, n, k, m, min = INT_MAX;\n\tscanf(\"%u %u %u %u %u\", &c, &d, &n, &m, &k);\n\tfor (a = 0; a <= m; a++) {\n\t\tb = n * (m - a) - k;\n\t\tb = b > 0 ? b : 0;\n\t\tif (min > a * c + b * d) min = a * c + b * d;\n\t}\n\tprintf(\"%u\\n\", min);\n\treturn EXIT_SUCCESS;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "implementation"], "code_uid": "dd7efa70220655828d50742116517ab1", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main(){\n\t\tint i;\n\t\tscanf(\"%d\",&i);\n\t\tprintf(\"25\");\n\t\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "ae3d1f11850895d2d6f7cd2ec2cd8273", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,k,l,c,d,p,nl,np,u,v,x,m,o;\n scanf(\"%d %d %d %d %d %d %d %d\",&n,&k,&l,&c,&d,&p,&nl,&np);\n u=(k*l)/nl;//need per ml of drink\n v=(c*d);//lime\n o=p/np;\n if(u<=v&&u<=o)\n x=u;\n else if(v<=u&&v<=o)\n x=v;\n else\n x=o;\n m=x/n;\n printf(\"%d\",m);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "8f5d373305a191c5f4a6e341ae1e3e92", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n int n, k;\n scanf(\"%d %d\", &n, &k);\n int a[n];\n for (int i = 0; i < n; i++){\n scanf(\"%d\", &a[i]);\n }\n int hour = k;\n for (int i = 0; i < n; i++){\n if (k % a[i] == 0 && hour > (k / a[i])){\n hour = k / a[i];\n }\n }\n printf(\"%d\",hour);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ceb94841b21d8d38685f21f45dbbe41c", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n long long k,b,t,x=1;\n int l=0,n;\n scanf(\"%lld %lld %d %lld\",&k,&b,&n,&t);\n while(xt)\n {\n l--;\n }\n printf(\"%d\",n-l);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "9eb018f1efc37e53f4e67177b0861f79", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\n int n,i;\n scanf(\"%d\",&n);\n if(n == 0)\n {\n printf(\"1\");\n }\n else\n {\n i = n%4;\n switch(i)\n {\n case 1 :\n printf(\"8\");\n break;\n case 2 :\n printf(\"4\");\n break;\n case 3 :\n printf(\"2\");\n break;\n case 0 :\n printf(\"6\");\n break;\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "81fbc0cb3c6fa3a95d82f3e118ef5759", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n/*\n * http://codeforces.com/problemset/problem/652/A\n */\nint main()\n{\n int hc = 0, ha = 0;\n scanf(\"%d %d\", &hc, &ha);\n\n int a = 0, b = 0, d = 0;\n scanf(\"%d %d\", &a, &b);\n\n hc += 8 * a;\n\n if (hc < ha && a <= b) {\n printf(\"-1\\n\");\n\n return 0;\n }\n\n while (hc < ha) {\n hc += a * 12 - b * 12;\n d += 1;\n }\n\n printf(\"%d\\n\", d);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "7590a1e1f6099d796a1d5a72d40fe1c0", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nchar arr[4][4];\n\nint boardval(char * loc)\n{\n\t\tif (*loc == '#')\n\t\t\t\treturn 1;\n\t\telse return -1;\n}\n\nint main(void)\n{\n\t\tfor (int i = 0; i < 4; i++)\n\t\t\t\tfor (int j = 0; j < 4; j++)\n\t\t\t\t\t\tscanf(\"%c \", &arr[i][j]);\n\t\t\n\t\tint sum;\n\t\tfor (int i = 0; i < 3; i++)\n\t\t\t\tfor (int j = 0; j < 3; j++){\n\t\t\t\t\t\tsum = 0;\n\t\t\t\t\t\tsum += (boardval(&arr[i][j]) + boardval(&arr[i+1][j]) + boardval(&arr[i][j+1]) + boardval(&arr[i+1][j+1]));\n\t\t\t\t\t\tif (abs(sum) >= 2){\n\t\t\t\t\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t}\n\t\t}\n\n\t\tprintf(\"NO\\n\");\n\t\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "80a27a42a6c3e6210308c10b6e6f43bb", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main()\n{\n int i,j;\n char s[600];\n scanf(\"%s\", s);\n int l=strlen(s);\n int a[26]={0};\n for(i=0;i\nint main() {\n\tint c1,c2,c3,c4,c5;\n\tscanf(\"%d %d %d %d %d\",&c1,&c2,&c3,&c4,&c5);\n\tint S=c1+c2+c3+c4+c5;\n\tif(c1==c2&&c2==c3&&c3==c4&&c4==c5&&c1==0) S=1;\n\tif(S%5!=0) printf(\"-1\");\n\telse printf(\"%d\",S/5);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e7d27339d2d18b2bf2678a7462245c2b", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint ff[] = { 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800 };\n\nint rank(int *a, int n) {\n\tint i, j, cnt, r;\n\tchar used[12] = { 0 };\n\n\tr = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tcnt = 0;\n\t\tfor (j = 1; j <= a[i]; j++)\n\t\t\tcnt += !used[j];\n\t\tr += ff[(n - i - 1) - 1] * (cnt - 1);\n\t\tused[a[i]] = 1;\n\t}\n\treturn r;\n}\n\nint main() {\n\tint i, j, n, k, k1, k2, player, end;\n\tstatic int a[11]; \n\tstatic char used[39916800];\n\n\tscanf(\"%d\", &n);\n\tscanf(\"%d\", &k1);\n\tfor (i = 0; i < k1; i++)\n\t\tscanf(\"%d\", &a[i]);\n\ta[k1] = n + 1;\n\tscanf(\"%d\", &k2);\n\tfor (i = 0; i < k2; i++)\n\t\tscanf(\"%d\", &a[k1 + i + 1]);\n\tend = 1;\n\tfor (k = 1; ; k++) {\n\t\tint r = rank(a, n + 1);\n\t\tint top1, top2;\n\n\t\tif (a[0] == n + 1) {\n\t\t\tplayer = 2;\n\t\t\tk--;\n\t\t\tbreak;\n\t\t}\n\t\tif (a[n] == n + 1) {\n\t\t\tplayer = 1;\n\t\t\tk--;\n\t\t\tbreak;\n\t\t}\n\t\tif (used[r]) {\n\t\t\tend = 0;\n\t\t\tbreak;\n\t\t}\n\t\tused[r] = 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tif (a[i] == n + 1)\n\t\t\t\tbreak;\n\t\ttop1 = a[0], top2 = a[i + 1];\n\t\tfor (j = 1; j < i; j++)\n\t\t\ta[j - 1] = a[j];\n\t\tfor (j = i + 2; j <= n; j++)\n\t\t\ta[j - 1] = a[j];\n\t\tif (top1 < top2) {\n\t\t\ta[i - 1] = n + 1;\n\t\t\ta[i] = a[i + 1]; \n\t\t\tfor (j = i + 2; j <= n; j++)\n\t\t\t\ta[j - 1] = a[j];\n\t\t\ta[n - 1] = top1;\n\t\t\ta[n] = top2;\n\t\t} else {\n\t\t\tfor (j = n - 2; j >= i; j--)\n\t\t\t\ta[j + 1] = a[j];\n\t\t\ta[i + 1] = n + 1;\n\t\t\ta[i - 1] = top2;\n\t\t\ta[i] = top1;\n\t\t}\n\t}\n\tif (end)\n\t\tprintf(\"%d %d\\n\", k, player);\n\telse\n\t\tprintf(\"-1\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "7999040003f43646804dd749d7d41d07", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b) {\n\tif (b == 0) return a;\n\treturn gcd(b, a%b);\n}\n\nint lcd(int a, int b) {\n\treturn a*b/gcd(a, b);\n}\n\nint main(void) {\n\tint a, b, c, d, max = 0;\n\tscanf(\"%d %d %d %d\", &a, &b, &c, &d);\n\t\n\tif (a*d > b*c) {\n\t\tint g = gcd(a*d - b*c, a*d);\n\t\tprintf(\"%d/%d\\n\", (a*d - b*c)/g, a*d/g);\n\t} else {\n\t\tint g = gcd(b*c - a*d, b*c);\n\t\tprintf(\"%d/%d\\n\", (b*c - a*d)/g, b*c/g);\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "232e835ce527a9c74b07259ed9c17311", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint power(int a,int b)\n{\n int i,sum=1;\n\n for(i=0;i\n#define gc getchar()\nint main(){\n long long ans = 0, P = 1e9+7, f=0, c;\n for(c=gc;c!='\\n';f=f|(c>'1'),ans=f?((ans<<1)|1)%P:((ans<<1)|(c-'0'))%P,c=gc);\n printf(\"%I64d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "530966109bfae99f4ac73513e6ceb041", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\nint m,h,a,s,r,x,y;\nchar c;\nscanf(\"%d %c %d\",&h,&c,&m);\nscanf(\"%d\",&a);\ns=a%60;\nr=a/60;\nh=h+r;\nm=m+s;\nx=m%60;\nh=h+(m/60);\ny=h%24;\nprintf(\"%02d:%02d\",y,x);\nreturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ad0dcaade5c4db809540202056b17c82", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n, x, x2;\n x2 = 0;\n scanf(\"%d\", &n);\n getchar();\n char tree[102];\n gets(tree);\n char plant[3];\n for (int i = 0; i < n; i++) {\n x = 0;\n for (int j = 0; j < n; j++) {\n if (tree[j] == tree[i] && tree[j+1] == tree[i+1]) {\n x++;\n }\n }\n if (x > x2) {\n x2 = x;\n plant[0] = tree[i];\n plant[1] = tree[i+1];\n }\n }\n printf(\"%c%c\\n\", plant[0], plant[1]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "dfe7123d75c5f4b7a0f46e63f159dc11", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,m,a,b;\n scanf(\"%d %d\",&n,&m);\n if(n==1 && m==1)\n printf(\"1\");\n else\n {\n a=m-1;\n b=n-m;\n if(a>=b)\n printf(\"%d\",m-1);\n else\n printf(\"%d\",m+1);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "8cda6f8328eaaa9801a93eed906c2344", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,n,i;\n scanf(\"%d\",&n);\n \n for (i=0;i= 3 && a % 7 != 0)\n a -= 3;\n if(a == 0 || a % 7 == 0)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "5c34e3f03d8c2485b78a32a850851985", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,d,e,f,g,n,s,t,z;\n scanf(\"%d %d %d\",&a,&b,&c);\n scanf(\"%d %d %d\",&e,&f,&g);\n scanf(\"%d\",&n);\n s=a+b+c;\n t=e+f+g;\n if(s==0)\n {\n s=0;\n }\n else if(s<=5)\n {\n s=1;\n }\n else if(s%5==0)\n {\n s=s/5;\n }\n else\n {\n s=(s/5)+1;\n }\n if(t==0)\n {\n t=0;\n }\n else if(t<=10)\n {\n t=1;\n }\n else if(t%10==0)\n {\n t=t/10;\n }\n else\n {\n t=(t/10)+1;\n }\n z=s+t;\n if(n>=z)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "22b7ae039346f95f9b905f4f0d2b9d32", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b;\n scanf(\"%d\",&a);\n for(b=1;b*10<=a;b=b*10);\n a=a-b*(a/b);\n b=b-a;\n printf(\"%d\",b);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6d658986fe2b3276ed6e0a10aff74564", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main() \n{ \n int k,i,a[10]={0}; \n char s[5]; \n scanf(\"%d\",&k); \n k=k*2; \n for(i=0;i<4;i++) \n { \n scanf(\"%s\",s); \n if(s[0]!='.') \n { \n a[s[0]-'0']++; \n } \n if(s[1]!='.') \n { \n a[s[1]-'0']++; \n } \n if(s[2]!='.') \n { \n a[s[2]-'0']++; \n } \n if(s[3]!='.') \n { \n a[s[3]-'0']++; \n } \n } \n for(i=0;i<10;i++) \n { \n if(a[i]>k) \n { \n printf(\"NO\\n\"); \n return 0; \n } \n } \n printf(\"YES\\n\"); \n return 0; \n} ", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "85ca2fd003e9c9c09d8313b482f19d89", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\ntypedef struct column_\n{\n\tint c[3];\n}column_t;\n\ntypedef struct matrix_\n{\n\tcolumn_t r[3];\n}matrix_t;\n\ntypedef struct grid_\n{\n\tmatrix_t mx;\n}grid_t;\n\nint judge(grid_t *h, int num)\n{\n\tint i = 0;\n\tfor (i = 0; i < 3; ++i)\n\t{\n\t\tif ((num == h->mx.r[i].c[0]) && (num == h->mx.r[i].c[1]) && (num == h->mx.r[i].c[2]))\n\t\t{\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tfor (i = 0; i < 3; ++i)\n\t{\n\t\tif ((num == h->mx.r[0].c[i]) && (num == h->mx.r[1].c[i]) && (num == h->mx.r[2].c[i]))\n\t\t{\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tif ((num == h->mx.r[0].c[0]) && (num == h->mx.r[1].c[1]) && (num == h->mx.r[2].c[2]))\n\t{\n\t\treturn 1;\n\t}\n\n\tif ((num == h->mx.r[0].c[2]) && (num == h->mx.r[1].c[1]) && (num == h->mx.r[2].c[0]))\n\t{\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nint main()\n{\n\tgrid_t t;\n\tchar st[4] = { 0 };\n\tint tot_1 = 0;\n\tint tot_2 = 0;\n\tint win_1 = 0;\n\tint win_2 = 0;\n\n\tint i = 0;\n\tint j = 0;\n\t\n\tfor (i = 0; i < 3; ++i)\n\t{\n\t\tscanf(\"%s\", st);\n\t\tfor (j = 0; j < 3; ++j)\n\t\t{\n\t\t\tswitch (st[j])\n\t\t\t{\n\t\t\tcase 'X':\n\t\t\t\tt.mx.r[i].c[j] = 1;\n\t\t\t\t++tot_1;\n\t\t\t\tbreak;\n\t\t\tcase '0':\n\t\t\t\tt.mx.r[i].c[j] = 2;\n\t\t\t\t++tot_2;\n\t\t\t\tbreak;\n\t\t\tcase '.':\n\t\t\t\tt.mx.r[i].c[j] = 0;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ((tot_1 - tot_2 < 0) || (tot_1 - tot_2 > 1))\n\t{\n\t\tprintf(\"illegal\");\n\t\treturn 0;\n\t}\n\n\twin_1 = judge(&t, 1);\n\twin_2 = judge(&t, 2);\n\n\tif ((0 == win_1) && (0 == win_2))\n\t{\n\t\tif ((5 == tot_1) && (4 == tot_2))\n\t\t{\n\t\t\tprintf(\"draw\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (tot_1 > tot_2)\n\t\t{\n\t\t\tprintf(\"second\");\n\t\t\treturn 0;\n\t\t}\n\t\tprintf(\"first\");\n\t\treturn 0;\n\t}\n\n\tif ((1 == win_1) && (0 == win_2) && (tot_1 > tot_2))\n\t{\n\t\tprintf(\"the first player won\");\n\t\treturn 0;\n\t}\n\n\tif ((0 == win_1) && (1 == win_2) && (tot_1 == tot_2))\n\t{\n\t\tprintf(\"the second player won\");\n\t\treturn 0;\n\t}\n\n\tprintf(\"illegal\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "games"], "code_uid": "41ba141c0b4d0801f34a588a0503a7eb", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint chk(long long x)\n{\n\tint ret = 0;\n\twhile(x)\n\t{\n\t\tret += (x%10);\n\t\tx/=10;\n\t}\n\treturn ret;\n}\n\nlong long po(long long int a,long long x)\n{\n\tif(x == 0)\n\t\treturn 1;\n\tlong long temp;\n\ttemp = po(a,x/2);\n\ttemp *= temp;\n\tif(x%2)\n\t\ttemp *= a;\n\treturn temp;\n}\n\nint main()\n{\n\tlong long int a,b,c;\n\tscanf(\"%lld %lld %lld\",&a,&b,&c);\n\tlong long int i;\n\tint cnt = 0;\n\tlong long ans[100];\n\tfor(i=1;i<=81;i++)\n\t{\n\t\tlong long temp = b*(po(i,a)) + c;\n\t\tif(temp <= 1000000000 && temp >=0 && chk(temp) == i)\n\t\t\tans[cnt++] = temp;\n\t}\n\n\tprintf(\"%d\\n\",cnt );\n\tfor(i=0;i\n#include \n\n\nint funcion (const void * a, const void * b);\t//prototipo de la funcion\n\nint main()\n{\n\t\n int v[1000],i,n,aux;\n scanf(\"%d\",&n);\n for(i=0;i\n#include\nlong long int fx(long long int a)\n{\t \n // printf(\"%lld\\n\",a);\n\tlong long int k=0;\n\tint arr[20];\n\tint c=0;\n\twhile(a!=0)\n\t{\n\t\tarr[c]=a%10;\n\t\ta/=10;\n\t\tc++;\n\t}\n//\tfor(int i=0;i=0;l--)\n\t\tk=((k*10)+arr[l]);\n//\tprintf(\"%lld\\n\",k);\n\tfor(int l=0;l\n#include\n#include \n\nint main(){\n\n int s,l;\n scanf(\"%d%d\",&l,&s);\n\n int small[200],large[200];\n\n for (int j = 0; j <200 ; ++j) {\n small[j]=0;\n large[j]=0;\n }\n\n //nth member of small is nth digit of small number\n //1 based index\n\n //smallest number\n\n small[l]=1;\n\n int temp=s-1;\n int digit=1;\n\n while(temp>0 && digit<=l){\n\n small[digit]++;\n temp--;\n\n if(small[digit]==9) digit++;\n }\n\n if(s==0 && l==1) printf(\"0 \");\n else if(s==0 || s>9*l) printf(\"-1 \");\n else {\n for(int i=l;i>=1;i--) printf(\"%d\",small[i]);\n printf(\" \");\n }\n\n //largest number\n\n temp=s;\n digit=l;\n\n while(temp>0 && digit>=0){\n\n large[digit]++;\n temp--;\n\n if(large[digit]==9) digit--;\n }\n\n if(s==0 && l==1) printf(\"0 \");\n else if(s>9*l || s==0) printf(\"-1\\n\");\n else {\n for(int i=l;i>=1;i--) printf(\"%d\",large[i]);\n printf(\"\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "implementation"], "code_uid": "222a3918bcb1ec3cf3bd748446c375bc", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b;\n scanf(\"%d %d\" , &a, &b);\n int x,n;\n n=a;\n while(a>=b)\n {\n n=n+(a/b);\n x=a%b;\n a=a/b;\n a=a+x;\n }\n printf(\"%d\" , n);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "afdb2c8bdfd3da90de9c5f0987bd0360", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n\tint y, jwi1, jwi2, jwi3, jwi4;\n\tscanf(\"%d\", &y);\n\t\n\twhile(1){\n\t\ty += 1;\n\t\tjwi1 = y % 10;\n\t\tjwi2 = (y/10)% 10;\n\t\tjwi3 = ((y/10)/10)% 10;\n\t\tjwi4 = (((y/10)/10)/10)% 10;\n\t\tif(jwi1 != jwi2 && jwi1 != jwi3 && jwi1 != jwi4 &&\n\t\t jwi2 != jwi3 && jwi2 != jwi4 && jwi3 != jwi4) break;\n\t}\n\tprintf(\"%d\", y);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "707e89aa13caf8ce47d70993eea51960", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\nint i;\nchar arr[20];\nint c=0,b[20];\nscanf(\"%s\",arr);\nfor(i=0;i=53)\n{\nb[i]=57-b[i];\nif(b[0]==0)\nb[0]=9;\n}\nelse\n{b[i]=b[i]-48;}\nprintf(\"%d\",b[i]);\n}\n//printf(\"1\");\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "7df1e10e7caf8e5bb6ad5838f3242f78", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int A[150],a,b,l,i,j,m,x,y;\n char s[150];\n scanf(\"%s\",s);\n l=strlen(s);\n A[0]=1;\n for(i=0;iA[j-1])\n {\n a=A[j]-A[j-1];\n b=A[j-1]+26-A[j];\n }\n else\n {\n a=A[j-1]-A[j];\n b=A[j]+26-A[j-1];\n }\n if(a\n\nint main()\n{\n int n;\n while (scanf(\"%d\",&n) != EOF)\n {\n\n if(n % 2 != 0)\n printf(\"Ehab\\n\");\n else\n printf(\"Mahmoud\\n\");\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "df428b663dcdbf7d103b64d6ed675250", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint cnt[2];\nint main()\n{\n char ch[2];\n cnt[0]++;\n cnt[1]++;\n scanf(\"%s\",&ch);\n int i;\n for(i=0; i<2; i++)\n {\n if(ch[i]=='0'||ch[i]=='2'||ch[i]=='6'||ch[i]=='9')\n {\n cnt[i]++;\n }\n else if(ch[i]=='1')\n {\n cnt[i]+=6;\n }\n else if(ch[i]=='2'||ch[i]=='4'||ch[i]=='3')\n {\n cnt[i]+=2;\n }\n else if(ch[i]=='5')\n {\n cnt[i]+=3;\n }\n else if(ch[i]=='7')\n {\n cnt[i]+=4;\n }\n }\n printf(\"%d\",cnt[0]*cnt[1]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "faeecc1693661fe859502cbcefeba206", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n\n#define lli long long int\n#define MAX INT_MAX\n#define sd second\n#define fs first\n#define endll '\\n'\n#define PI acos(-1)\n#define mp make_pair\n#define pb push_back\n#define best 1000000007\n#define FOR(i,a,b) for(int i=a;i<=b;i++)\n#define ROF(i,a,b) for(int i=a;i>b;i--)\n#define buyuk(a,b) (a\nint main()\n{\n\tlong long a,b,c,d,k=0;\n\tscanf(\"%lld\",&a);\n\tscanf(\"%lld\",&b);\n\tscanf(\"%lld\",&c);\n\tscanf(\"%lld\",&d);\n\twhile(1)\n\t{\n\t\tif(a==1)\n\t\tbreak;\n k+=c*(a%b);\n a=a-a%b;\n if(d\n#include \n#include \n#include \n#include \n#include \n\nint main() {\n\n\tint n;\n\tint a[20] = { 0 };\n\tint i;\n\tint chest = 0;\n\tint back = 0;\n\tint biceps = 0;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &a[i]);\n\t}\n\n\tfor (i = 0; i < n; i += 3) {\n\t\tchest += a[i];\n\t}\n\tfor (i = 1; i < n; i += 3) {\n\t\tbiceps += a[i];\n\t}\n\tfor (i = 2; i < n; i += 3) {\n\t\tback += a[i];\n\t}\n\n\tif (chest > biceps && chest > back) {\n\t\tprintf(\"chest\");\n\t} else if (biceps > chest && biceps > back) {\n\t\tprintf(\"biceps\");\n\t} else if (back > biceps && back > chest) {\n\t\tprintf(\"back\");\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "47861d59cf9f69f0721c9ce6fdb4aba8", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main(){\n\tint i,j,len;\n\tchar mayor;\n\tchar string[11];\n\tchar res[11]={'\\0'};\n\n\tscanf(\"%s\" , string);\n\t\n\tlen = strlen(string);\n\tmayor = string[0];\n\t\n\tfor( i = 1 ; i < len; i++ ){\n\t\tif( string[i] > mayor ){\n\t\t\tmayor = string[i];\n\t\t}\n\t}\n\t\n\tfor( i = 0 ; i < len; i++ ){\n\t\t\n\t\tif( string[i] == mayor ){\n\t\t\t\n\t\t\tj = 0;\n\t\t\t\n\t\t\twhile( res[j] != '\\0' ){\n\t\t\t\tj++;\n\t\t\t}\n\t\t\t\n\t\t\tres[j] = string[i];\n\t\t\tres[j+1] = '\\0';\n\t\t}\n\t}\n\t\n\t\n\tprintf( \"%s\" , res );\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "fd96cf8e62c129007b142dfc9a8a2a38", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main(){\nint n;\nscanf(\"%d\",&n);\nunsigned long long sum=0;\nint i;\nfor (i=3; i <=n;i++ ){\n sum+=(i-1)*i;\n\n\n}\n\nprintf(\"%llu\\n\",sum);\n\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "e618509961369e6f6c942f1155f68f9f", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n, k;\n\tint i, s = 0, a[101];\n\twhile (scanf(\"%d%d\", &n, &k) != EOF)\n\t{\n\t\tfor (i = 1; i <= n; i++)\n\t\t\tscanf(\"%d\", &a[i]);\n\t\tfor (i = 1; i <= n; i++)\n\t\t{\n\t\t\tif (a[i] >= a[k] && a[i] != 0)\n\t\t\t\ts++;\n\t\t}\n\t\tprintf(\"%d\\n\", s);\n\t}\n\treturn 0;\n}\n\t \t \t\t\t \t \t\t\t\t \t \t \t\t", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a492909277fb2d24dea9ae7e460fd107", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n, count= 0, sum=0, i;\n scanf(\" %d\", &n);\n\n for(i=1; sum\nint ara[200][2];\n\nint main()\n{\n int n,i,j=1,x,f=0,sum=0,sumup=0;\n scanf(\"%d\",&n);\n for(i=0;i\n\nint main()\n{\n int a1, a2, k1, k2, n, min, max, r, kmin, kmax, amin, amax;\n\n scanf(\"%d%d%d%d%d\",&a1,&a2,&k1,&k2,&n);\n min = n-a1*(k1-1)-a2*(k2-1);\n if (min < 0) {\n min = 0;\n }\n if (k1 < k2) {\n kmin = k1;\n amin = a1;\n kmax = k2;\n amax = a2;\n }\n else {\n kmin = k2;\n amin = a2;\n kmax = k1;\n amax = a1;\n }\n max = n/kmin;\n if (max > amin) {\n max = amin;\n r = n-kmin*amin;\n max += r/kmax;\n }\n printf(\"%d %d\\n\",min,max);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "74d320b879cee793db6ea2e288c421f8", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n\tchar chess[8][8];\n\tint i,j,k;\n\tfor(i=0;i<9;i++)\n\t{\n\t\tfor(j=0;j<8;j++)\n\t\t{\n\t\t\tscanf(\"%c\",&chess[i][j]);\n\t\t}\n\t}\n\tchar variable[10]={'Q','R','B','N','P','q','r','b','n','p'};\n\tint value[10]={9,5,3,3,1,9,5,3,3,1};\n\tint black=0,white=0;\n\tfor(i=0;i<9;i++)\n\t{\n\t\tfor(j=0;j<8;j++)\n\t\t{\n\t\t\tfor(k=0;k<10;k++)\n\t\t\t{\n\t\t\t\tif(chess[i][j]==variable[k])\n\t\t\t\t{\n\t\t\t\t\tif(k<5)\n\t\t\t\t\t{\n\t\t\t\t\t\twhite+=value[k];\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\tblack+=value[k];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} \n\tif(white>black)\n\t\tprintf(\"White\\n\");\n\telse if(black>white)\n\t\tprintf(\"Black\\n\");\n\telse \n\t\tprintf(\"Draw\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "59e9e481bc51ef85b35e007f55ab75cc", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int n,f,i,j,s=0;\n scanf(\"%d%d\",&n,&f);\n int z=0,x;\n x=n;\n if(f>=(n-1))\n {\n printf(\"%d\",(n-1));\n }\n else\n {\n s=f;\n for(i=2;i<(2+n-f-1);i++)\n {\n s+=i;\n }\n printf(\"%d\",s);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "4e04be1667d48c37130c5cf92cb5c79b", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\nint main(){\n int n,i;\n int a[55];\n int b[1005];\n int c[55];\n int j,count=0;\n memset(b,0,sizeof(b));\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++){\n scanf(\"%d\",&a[i]);\n }\n j=1;\n for(i=n;i>=1;i--){\n if(b[a[i]]!=1){\n c[j]=a[i];\n j++;\n b[a[i]]=1;\n }\n }\n count=0;\n for(i=1;i<=1003;i++){\n if(b[i]==1){\n count++;\n }\n }\n printf(\"%d\\n\",count);\n for(i=j-1;i>=1;i--){\n if(i==j-1){\n printf(\"%d\",c[i]);\n }\n else{\n printf(\" %d\",c[i]);\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b95af9c1665bed3159898d9939b1790a", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n char s[]=\"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400\";\n int n;\n scanf(\"%d\",&n);\n printf(\"%c\",s[n-1]);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0b259a7bb9fe291279fbf962f4030375", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char str[100];\n int i, count = 0, n;\n scanf(\"%d\", &n);\n scanf(\"%s\", str);\n for(i = 0; i < n; i++)\n {\n if(str[i] == 'x' && str[i+1] == 'x' && str[i+2] == 'x')\n count++;\n }\n printf(\"%d\", count);\n}\n", "lang_cluster": "C", "tags": ["greedy", "strings"], "code_uid": "9a271369b5ff091a0774831dd472b695", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int n,i,d=0;\n char s[101];\n scanf(\"%d\",&n);\n scanf(\"%s\",&s);\n for(i=0;i\n#include \n#include \n\n\nint main(void)\n{\n//long int i,j;\n\nlong long int a,b; scanf(\"%lld\",&a); scanf(\"%lld\",&b);\n\nlong long int count=0;\n\n\nwhile(a!=b)\n{\n\nif(a>b)\n{\ncount += a/b;\na=a%b;\n\nif(a==0)\nbreak;\n}\n\nif(b>a)\n{\ncount += b/a;\nb=b%a;\n\nif(b==0)\nbreak;\n}\n\n}\n\nprintf(\"%lld\",count);\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "444a05e4b1fd154824ed52aa554eae0f", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n#define MOD 1000000007\n#define ll long long\n#define BS_NOT_FOUND 0\n#define BS_FOUND 1\n\nll f[5000006]={0};\nll prime[5000006]={0};\n\nint main(){\n //calculate f[i]\n ll i,j;\n for(i=2;i<=5000000;i++){\n if(prime[i]>0) continue;\n prime[i]=i;\n for(j=2*i;j<=5000000;j+=i){\n if(prime[j]==0) prime[j]=i;\n }\n }\n f[1]=0;\n for(i=2;i<=5000000;i++) f[i]=(f[i/prime[i]]+i*(prime[i]-1)/2%MOD)%MOD;\n\n /*\n f[2]=1;\n f[3]=3;\n f[4]=3;\n f[5]=10;\n f[7]=21;\n f[11]=55;\n f[13]=66;\n f[17]=17*16/2;\n f[19]=19*9;\n f[23]=253;\n f[29]=29*14;\n ll i,index,j,num;\n for(i=6;i<=5000000;i++){\n num=i;\n index=2;\n if(i%2==0) {f[i]=i/2+f[i/2];continue;}\n if(i%3==0) {f[i]=i+f[i/3];continue;}\n if(i%5==0) {f[i]=i*2+f[i/5];continue;}\n if(i%7==0) {f[i]=i*3+f[i/7];continue;}\n if(i%11==0) {f[i]=i*5+f[i/11];continue;}\n if(i%13==0) {f[i]=i*6+f[i/13];continue;}\n if(i%17==0) {f[i]=i*8+f[i/17];continue;}\n if(i%19==0) {f[i]=i*9+f[i/19];continue;}\n if(i%23==0) {f[i]=i*11+f[i/23];continue;}\n if(i%29==0) {f[i]=i*14+f[i/29];continue;}\n while(num%index!=0 && index*index<=num) index++;\n if(index*index>num){\n f[i]=(i*(i-1)/2);\n continue;\n }\n f[i]=i/index*f[index]+f[i/index];\n }\n */\n //for(i=2;i<=5000000;i++) printf(\"%lld,\",f[i]);\n\n ll t,l,r,p;\n scanf(\"%lld %lld %lld\",&t,&l,&r);\n ll ans=0;\n for(i=l,p=1;i<=r;i++){\n ans=(ans+p*f[i]%MOD)%MOD;\n p=p*t%MOD;\n }\n printf(\"%lld\\n\",ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "greedy", "number theory"], "code_uid": "feebdb727af0c65f08226a41b35a1585", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int h1,m1,h2,m2;\n scanf(\"%d:%d\",&h1,&m1);\n scanf(\"%d:%d\",&h2,&m2);\n int a1=(h1*60)+m1;\n int a2=(h2*60)+m2;\n int b=(a2+a1)/2;\n int c=b/60;\n int d=b%60;\n printf(\"%02d:%02d\\n\",c,d);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2bc1ec2811c9250c8cb8816118b8f31b", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n // lel\n\tint a;\n\tscanf(\"%d\",&a);\n\tprintf(\"%d\",a+a/2);\n\treturn 0;}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "73de1dea7701aaeb3cb70057f89c5223", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\nint k,n,s,p,a=0;\nscanf(\"%d %d %d %d\",&k,&n,&s,&p);\nif(n%s==0)\nn=n/s;\nelse\nn=n/s+1;\nk=k*n;\nfor(s=1;;s++)\n{\na=a+p;\nif(a>=k)\nbreak;\n}\nprintf(\"%d\\n\",s);\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "28bd49dae2ca1f2c93d723246870cb45", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n char mi;\n char ma;\n while(scanf(\" %c%c\",&mi,&ma)!=EOF)\n {\n int n;\n int p;\n scanf(\"%d\",&n);\n char s[200];\n int i,j;\n for(j=0;j<2*n;j=j+2)\n {\n scanf(\" %c%c\",&s[j],&s[j+1]);\n if(s[j]==mi&&s[j+1]==ma)\n p=1;\n }\n if(p==1)\n {\n printf(\"YES\\n\");\n p=0;\n continue;\n }\n for(i=0;i<2*n;i=i+2)\n {\n if(s[i+1]==mi)\n {\n for(j=0;j<2*n;j=j+2)\n {\n if(s[j]==ma)\n p=1;\n }\n }\n }\n if(p==1)\n {\n printf(\"YES\\n\");\n p=0;\n }\n else\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "64b5aecc5ce01184c2d6f865aa4f9225", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n float vp,vd,t,f,c;\n float phm,d=0,time=0;\n int bijous=0;\n scanf(\"%f%f%f%f%f\",&vp,&vd,&t,&f,&c);\n for(phm=t*vp;;){\n //printf(\"%f\\n\",phm);\n if(vd<=vp)\n break;\n phm+=phm*vp/(vd-vp);\n if(phm>=c)\n break;\n else{\n phm+=f*vp+(phm/vd)*vp;\n bijous++;\n }\n\n }\n printf(\"%d\",bijous);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "2d711d45f1108dfb3303465c99137e62", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include\n#include\n\n\nint main() {\n\tlong long int a,i,b;\n\tchar s1[10001];\n\tchar s2[10001];\n\tfor(i=0;i<1001;i++)\n\t{\n\t\ts1[i]=' ';\n\t\ts2[i]=' ';\n\t}\n\tscanf(\"%s\",s1);\n\tscanf(\"%s\",s2);\n\tif(strcmp(s1,s2)==0)\n\tprintf(\"%s\\n\",s2);\n\telse\n\tprintf(\"1\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "0f34b54d27154f66ad38f2ddfabd0843", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nlong long int c,marks,temp,a=1;\nscanf(\"%lld\",&marks);\ntemp=marks;\nwhile(temp!=0)\n{\n if(temp%a!=0)\n {\n break;\n }\n else \n a=a*3;\n}\nc=temp/a+1;\nprintf(\"%lld\",c);\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "1fbb92cae57aa3dac6807600282639c9", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int total;\n\n scanf(\"%d\",&total);\n\n if( total<=10 || total>=22) // 10+11 is max\n printf(\"0\\n\");\n else\n {\n if( total == 20)\n {\n printf(\"15\\n\");\n }\n else\n {\n printf(\"4\\n\");\n }\n }\n return 0;\n\n}\n/****** PCCA -Fri Oct 07 12:57:29 GMT 2011 *******/", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "28e2e30aa9e4cc317267ae61734ecb94", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include\nint main(void){\nint n,i,q=0,max=-1,q1;\nscanf(\"%d\",&n);\nint a[5];\na[0]=100;\na[1]=20;\na[2]=10;\na[3]=5;\na[4]=1;\nwhile(n>0){\n for(i=4;i>=0;i--){\n \n if(a[i]<=n){\n max=a[i];\n }\n }\n q1=n/max;\n q=q+q1;\n n=n-(q1*max);\n}\nprintf(\"%d\",q);\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "734f2a86449cc1626532fa1b602d1072", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int ara[8],ans,man[3500],i,j,k,sw=0,m,n=0,tst[8],pos[5],x,y;\n for(i=0;i<6;i++){\n scanf(\"%d\",&ara[i]);\n }\n memset(tst,0,sizeof(tst));\n memset(man,0,sizeof(man));\n for(i=0;i<6;i++){\n tst[i]=1;\n for(j=0;j<6;j++){\n if(j!=i){\n tst[j]=1;\n for(k=0;k<6;k++){\n if(k!=j && k!=i){\n tst[k]=1;\n for(m=0;m<6;m++){\n if(tst[m]!=1){\n pos[n]=m;\n n++;\n }\n }\n n=0;\n x=ara[i]+ara[j]+ara[k];\n y=ara[pos[0]]+ara[pos[1]]+ara[pos[2]];\n if(x==y){\n sw=1;\n break;\n }\n tst[k]=0;\n }\n }\n tst[j]=0;\n }\n\n if(sw==1){\n break;\n }\n }\n if(sw==1){\n break;\n }\n tst[i]=0;\n }\n if(sw==1){\n printf(\"YES\\n\");\n }\n else{\n printf(\"NO\\n\");\n\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "c62bdc085a7e8763293c29468c5abfb1", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main ()\n{\n int M,N,X;\n scanf(\"%d %d\", &M, &N);\n X=((M*N)/2);\n printf(\"%d\\n\", X);\n return 0;\n}\n\n/* 1490302257089 */\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "1f217de1a9d57fdd6c523b5eb63cc85d", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\tint m,n,k,i=1,row,column,j=0,var,count=1;\n\tchar pos;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d\",&m);\n\tscanf(\"%d\",&k);\n\twhile(!(k<=2*i*m))\n\t{\n\t\ti++;\n\t}\n\tcolumn =i;\n\t\n\tvar=2*(column-1)*m+2;\n\twhile(!(k<=var))\n\t{\n\t\tvar+=2;\n\t\tcount++;\n\t}\n\trow=count;\n\tif(k%2==0)\n\tpos='R';\n\telse\n\tpos='L';\n\nprintf(\"%d\", column);\nprintf(\" \");\nprintf(\"%d\",row);\nprintf(\" \");\nprintf(\"%c\", pos);\n\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "827c1fba3992bb166b2ac156323cc40f", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n\tint i,temp=0,n,k,x,*arr;\n\tscanf(\"%d%d%d\",&n,&k,&x);\n\tarr=malloc(n*sizeof(int));\n\tfor(i=0;i\n\nint main()\n{\n int i, count = 0, n, x1, x2, result = 0, j;\n scanf(\"%d\", &n);\n int ara[n][2];\n for(i = 0; i < n; i++) {\n scanf(\"%d %d\", &ara[i][0] , &ara[i][1]);\n }\n for(i = 0; i < n; i++) {\n for(j = 0; j < n; j++) {\n if(ara[i][0] != ara[j][0] && ara[i][1] != ara[j][1]) {\n x1 = ara[i][0] - ara[j][0];\n x2 = ara[i][1] - ara[j][1];\n count++;\n break;\n }\n }\n if(count > 0) {\n break;\n }\n }\n result = x1*x2;\n if(count == 0 || n == 1) {\n printf(\"-1\");\n }\n else {\n if(result < 0) {\n result = -1*result;\n printf(\"%d\", result);\n }\n else {\n printf(\"%d\", result);\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry", "implementation"], "code_uid": "b421418e1f91175d76441b627cd356de", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, sum = 0, i;\n int a[3];\n\n scanf(\"%d %d %d\", &a[0], &a[1], &a[2]);\n\n n = a[0] + a[1] + a[2];\n\n for (i = 0; ; i++) {\n\t if (a[i % 3] >= 2) {\n\t a[i % 3] -= 2;\n\t n -= 2;\n\t } else if (a[i % 3] == 1) {\n\t a[i % 3]--;\n\t n--;\n\t }\n\n\t if (n == 0) break;\n }\n\n printf(\"%d\\n\", i + 30);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "1ee207ebdacfd721e0498e96d6c876de", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nint main() {\n\tint a, b, c, d, t;\n\n\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\tt = -1;\n\tif ((b - d) % gcd(a, c) == 0) {\n\t\twhile (b != d)\n\t\t\tif (b < d)\n\t\t\t\tb += a;\n\t\t\telse\n\t\t\t\td += c;\n\t\tt = b;\n\t}\n\tprintf(\"%d\\n\", t);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "05b317bd19e2b2e399b81af24f914764", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint a,m,k,r;\nint main() {\n\tscanf(\"%d\",&a);\n\tscanf(\"%d\",&m);\n\tr=a%m;\n\twhile(k<20) {\n\t\tif(r%m==0) {\n\t\t\tprintf(\"Yes\\n\");\n\t\t\treturn 0;\n\t\t} \n\t\telse {\n\t\t\tr*=2;\n\t\t\t++k;\n\t\t}\n\t}\n\tprintf(\"No\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "implementation"], "code_uid": "f08248021dd906032752a106b6c9dd95", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n#include \n#include \n\n\nvoid sort(int * arr, int size) {\n int i;\n if (size < 6) {\n int nSize = 0;\n while (size != 0) {\n nSize = 0;\n for (i = 0; i < size - 1; i++) \n if (arr[i] > arr[i + 1]) {\n nSize = i + 1;\n arr[i] ^= arr[i + 1];\n arr[i + 1] ^= arr[i];\n arr[i] ^= arr[i + 1];\n }\n size = nSize;\n }\n return;\n }\n int * tmp = (int *)calloc(size, sizeof(int));\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 || arr[lPtr] <= arr[lSize + rPtr])\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\nint main(void) {\n int n, i, t1, t2;\n scanf(\"%d \", &n);\n int arr1[n];\n int arr2[n];\n char c;\n for (i = 0; i < n; i++){\n scanf(\"%c\", &c);\n arr1[i] = c - '0';\n }\n for (i = 0; i < n; i++){\n scanf(\"%c\", &c);\n arr2[i] = c - '0';\n }\n sort(arr1, n);\n sort(arr2, n);\n t1 = 1;\n t2 = 1;\n for (i = 0; i < n; i++) {\n if (arr1[i] >= arr2[i])\n t1 = 0;\n if (arr1[i] <= arr2[i])\n t2 = 0;\n }\n printf(\"%s\\n\", (t1 || t2) ? \"YES\" : \"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "5227826a09be59c19a1adab7ee9e158e", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"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>0&&m<0)\n {\n if(m%n==0)\n {\n i=i+((-m)/n)-1;\n m=0;\n }\n else\n {\n k=(((-m)/n)+1)*n;\n i=i+((-m)/n);\n m=m+k;\n }\n }\n else if(m>0&&n<0)\n {\n if(n%m==0)\n {\n i=i+((-n)/m)-1;\n n=0;\n }\n else\n {\n k=(((-n)/m)+1)*m;\n i=i+((-n)/m);\n n=n+k;\n }\n }\n else if(n\n#include\nint main()\n{\n int l1,l2,c=0,j,k;\n char s1[101],s2[101];\n scanf(\"%s %s\",s1,s2);\n l1=strlen(s1);\n l2=strlen(s2);\n for(j=0,k=l2-1; j=0; j++,k--) {\n if(s1[j]==s2[k]) {\n c++;\n }\n }\n if(l1==c) {\n printf(\"YES\\n\");\n }\n else {\n printf(\"NO\\n\");\n }\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "a819236c3acc81a26c9f68745b4b86fe", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int l,r;\n scanf(\"%d %d\", &l, &r);\n long long a = 1, b = a, res = 0;\n while(a <= r) {\n while(b <= r) {\n if(b >= l) res++;\n b*=3;\n }\n a*=2;\n b = a;\n }\n printf(\"%I64d\", res);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "4f56742e6e832dfd086c1ff41314eb81", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n int t, a[4], i, j, sum=0;\r\n scanf(\"%d\", &t);\r\n while(t--)\r\n {\r\n for(i=0; i<4; i++)\r\n {\r\n scanf(\"%d\", &a[i]);\r\n sum+=a[i];\r\n }\r\n if(sum<1)\r\n printf(\"0\\n\");\r\n else if(sum>0 && sum<4)\r\n printf(\"1\\n\");\r\n else\r\n printf(\"2\\n\");\r\n sum=0;\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "94b5d9915c2e76c62adb2ec69fcef6d5", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n, c, max = 0;\n int x[101] = {0}, v[101] = {0};\n\n scanf(\"%d%d\", &n, &c);\n for(int i = 0; i < n; i++) scanf(\"%d\", &x[i]);\n\n for(int i = 0; i < n - 1; i++) \n if(x[i] > x[i + 1])\n {\n int temp = x[i] - x[i + 1];\n if(max < temp) max = temp;\n v[i] = 1;\n }\n\n printf(\"%d\\n\", max - c > 0? max - c : 0);\n\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "78119bc5b55f7a4d3890fd0d15f3b5dc", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char str[105];\n int i,j,l,count=0,variable=0,cnt=0;\n scanf(\"%s\",str);\n l=strlen(str);\n for(i=0;i\n#include \n#include \n\nint expmod(int a, int b, int n) {\n if(b == 0)\n return 1;\n else {\n long long res = expmod(a, b/2, n);\n res = (res*res) % n;\n if(b%2 == 1)\n res = (res*a) % n;\n return (int) res;\n }\n}\n\nint main()\n{\n int n;\n unsigned long long int mod, i;\n mod = 1000000007;\n scanf(\"%d\", &n);\n i = 1;\n\n int A = 0;\n int B = 1;\n while (i <=n){\n int nB = A * 3LL % mod;\n int nA = (A * 2LL + B) % mod;\n B = nB;\n A = nA;\n i++;\n }\n printf(\"%d\\n\", B);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "matrices", "dp"], "code_uid": "2bf049bd3057f01c91e70611df417489", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\n char s[55];\n int c=0,i;\n gets(s);\n for(i=0;s[i]!='\\0';i++)\n {\n\n if( s[i]=='a'|| s[i]=='e'|| s[i]=='i'|| s[i]=='o'|| s[i]=='u'||s[i]=='9'||s[i]=='7'||s[i]=='5'||s[i]=='3'||s[i]=='1' )\n c++;\n }\n printf(\"%d\\n\",c);\n\n\n\n\n\n\n\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "29f3e9ec01d8eff71bd5252e6190b012", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main(){\n int n,m,a[100],i,j,tr=1,min;\n scanf(\"%d\",&n);\n for(i=0;ia[i])min=a[i];\n for(i=0;imin){\n tr=1;\n a[i]-=min;\n }\n }\n m=0;\n \n for(i=0;i\n\nint main() {\n\tint i, n, m, cnt, sum;\n\tstatic int a[100];\n\n\tscanf(\"%d%d\", &n, &m);\n\tsum = 0;\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &a[i]);\n\tsum = 0;\n\tcnt = 1;\n\tfor (i = 0; i < n; i++)\n\t\tif (sum + a[i] > m) {\n\t\t\tsum = a[i];\n\t\t\tcnt++;\n\t\t} else\n\t\t\tsum += a[i];\n\tprintf(\"%d\\n\", cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "cdc3e1847c2e6f63ebd91f56984359b3", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,s,r,p;\n scanf(\"%d\",&n);\n s=n%7;\n r=n/7;\n p=r*2;\n if(n==0){\n printf(\"0 0\");\n }\n else if(n==1){\n printf(\"0 1\");\n }\n else if(n<=5&&n!=1){\n printf(\"0 2\");\n }\n else if(n==6){\n printf(\"1 2\");\n }\n else if(s==0){\n printf(\"%d %d\",p,p);\n }\n else if (s==1){\n printf(\"%d %d\",p,p+1);\n }\n else if(s<6&&s!=1){\n printf(\"%d %d\",p,p+2);\n }\n else if(s==6){\n printf(\"%d %d\",p+1,p+2);\n }\n return 0;}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "c87c46374e824e3c27853ccfac33ed8f", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint max(int a,int b){if(a>b) return a; else return b;}\nint main(){\n int i,n,m=0,w=0;\n scanf(\"%i\",&n);\n getchar();\n for(i=0;i\nint main()\n{int a,b,c,t;\nscanf(\"%d%d%d\",&a,&b,&c);\nif((a*c)%b==0)\n{\n t=((a*c)/b)-c;}\n else\n {t=((a*c)/b)-(c-1);}\n printf(\"%d\\n\",t);\n return 0;\n}\n ", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "181d34168bc51db452769deaa0f2beaf", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include\n#include\nint main (void)\n{\n \n int i, j, a, b;\n\tscanf(\"%d %d\",&a,&b);\n\tchar string[a], temp;\n scanf(\"%s\",string);\n\n for (i=0; i string[j])\n {\n temp = string[i];\n string[i] = string[j];\n string[j] = temp;\n }\n }\n }\n \n int ar[a];\n for(i=0;i1){\n \t\tsum+=ar[i];\n\t\t\ttemp2=ar[i];\n\t\t\tflag++;\n\t\t}\n\t}\n\t\n\tif(flag!=b)\n\t\tprintf(\"-1\");\n\telse\n\t\tprintf(\"%d\",sum);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "1f87c6b0a560cfe014b40ec50f926782", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int di[10],n,n1,k,digit,count0,count;\n for(count0=0;count0<10;count0++) di[count0]=0;\n digit=1;\n count=count0=0;\n scanf(\"%d %d\",&n,&k);\n n1=n;\n while(n1!=n1%10&&count0\n#include \n\nint main(void){\n int minuto=0,hora=0;\n char txt[5]={'0','0','0','0','0'}; //Inicializacion de la cadena que guarda el modelo HH:MM\n scanf(\"%s\",&txt);//Carga de la hora en formato HH:MM\n getchar();\n fflush (stdin);\n hora=(txt[0]-'0')*10; //En la variable 'hora' se carga la decena de la hora introducida\n hora=hora+txt[1]-'0'; //Se carga la unidad de la hora en la variable 'hora' y se le suma a la decena extraida en la linea 10\n minuto=(txt[3]-'0')*10; //En la variable 'minuto' se carga la decena del minuto introducido\n minuto=minuto+txt[4]-'0'; //Se carga la unidad del minuto en la variable 'minuto' y se le suma a la decena extraida en la linea 12\n minuto++; //Aumentamos el minuto en uno por si se introdujo un hora capicua\n while(minuto>0)\n {\n if(minuto==60)//Si el minuto es 60 entonces agregamos sumamos 1 a hora y minuto vuelve a 0\n {\n minuto=0;\n hora++;\n if(hora==24) //Si hora es 24 se reinicia el reloj a la hora 00\n {\n hora=0;\n }\n }\n txt[0]=floor(hora/10)+'0';\n txt[1]=hora%10+'0';\n txt[3]=floor(minuto/10)+'0';\n txt[4]=minuto%10+'0';\n if(txt[0]==txt[4] && txt[1]==txt[3])\n {\n printf(\"%s\",txt);\n break;\n }\n minuto++; //Contador de minuto\n }\n}\n\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "68228a034466a7a04bbe9d85fd14dbab", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int w;\n scanf (\"%d\",&w);\n if(w!=2 && w%2==0)\n printf(\"YES\\n\");\n else{\n printf(\"NO\\n\");}\n return 0;\n}\n/* 1491891267270 */\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "6659a13de99d72719b50774e3cb5b4ee", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,i,j,x,y,cnt=0;\n scanf(\"%d\",&n);\n int a[n],b[n];\n for(i=0; i\n#include \n\nint main()\n{\n int n, i;\n char a[13][13]={{\"January\"}, {\"February\"}, {\"March\"}, {\"April\"}, {\"May\"}, {\"June\"}, {\"July\"}, {\"August\"}, {\"September\"}, {\"October\"}, {\"November\"}, {\"December\"}};\n scanf(\"%s %d\", a[12], &n);\n for(i=0; i<12; i++)if(strcmp(a[12], a[i])==0)break;\n printf(\"%s\", a[(i+n)%12]);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "744ee7c77a7b27333cb0b9d1a40ec992", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n\nint gcd(int x,int y){\nint i,f=1;\nif (x>y){\n for (i=x;i>1;i--){\n if(x%i==0){\n if(y%i==0){\n f=i;\n break;\n }\n }\n }\n}\nif(y>x){\n for (i=y;i>1;i--){\n if(x%i==0){\n if(y%i==0){\n f=i;\n break;\n }\n }\n }\n}\nif (x==y){\n f=x;\n}\nreturn f;\n}\n\nint convert(int x,int y)\n{\n int z=0;\n while(x>0)\n {\n z+=x%y;\n x=x/y;\n }\n return z;\n }\n\nint main()\n{\n int n,i,sum=0;\n scanf(\"%d\",&n);\n for(i=2;i\n#include \n\nint main()\n{\n int blocks,i=0;\n scanf(\"%d\", &blocks);\n while(i*i<=blocks)\n {\n ++i;\n }\n --i;\n int szeleszama=4*i;//i*i s negyzet oldala\n if(blocks-i*i>i)\n {\n szeleszama+=4;\n }\n else if(blocks==i*i)\n {\n //nothing really xd\n }\n else\n {\n szeleszama+=2;\n }\n printf(\"%d\",szeleszama);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "4275664358feeac204ee3654de208f0e", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//\u9996\u5148\u6709\u4e00\u4e2a1\uff0c\u63a5\u4e0b\u6765\u662f0\u4e2a\uff0c\u4e00\u4e2a\uff0c\u4e24\u4e2a4\n/*interface*/\n/*interface implementation*/\n/*client*/\n#define N 10\n#include\nvoid print(int *a,int n) {\n int i;\n for(i=0; i0 ) {\n digit[nd]=n%10;\n\tnd++;\n n/=10;\n }\n //print(digit,nd);\n int i;\n for(i=0; i2) {\n is_magic=0;\n break;\n }\n }\n if(is_magic) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "18a14b0a824d044e056fa125c8515b96", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(void) {\n int n = 0;\n scanf(\"%d\", &n);\n\n int arr[n];\n int tmp[n];\n\n int ones = 0;\n\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", arr + i);\n if (arr[i] == 1) {\n ones++;\n }\n }\n\n int a = 0;\n int b = 0;\n int c = 0;\n int d = 0;\n\n for (int i = 0; i < n; i++) {\n if (arr[i] == 1) {\n a++;\n } else {\n a--;\n }\n\n if (a > 0) {\n a = 0;\n } else if (b > a) {\n b = a;\n c = i;\n }\n\n tmp[i] = a;\n }\n\n d = c;\n\n while (d >= 0 && tmp[d] < 0) {\n d--;\n }\n \n if (c != d) {\n for (int i = d + 1; i <= c; i++) {\n if (arr[i] == 0) {\n ones++;\n } else {\n ones--;\n }\n }\n } else {\n if (arr[c] == 0) {\n ones++;\n } else {\n ones--;\n }\n }\n\n printf(\"%d\\n\", ones);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "dp", "implementation"], "code_uid": "f240eb67171e0a1c40c44d58d59af3f8", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\ntypedef long long ll;\nll fox(ll a,ll b);\nll gcd(ll a,ll b);\n\n\nint main()\n{\n ll a,b,c,d;\n \n scanf(\"%lld%lld\",&a,&b);\n \n d = (a>b)?gcd(a,b):gcd(b,a);\n \n c = fox(a/d,b/d);\n \n printf(\"%lld\",c);\n \n return 0;\n\n}\n\n\nll gcd(ll a,ll b)\n{\n if(b==(ll)0)\n return a;\n \n return gcd(b,a%b);\n}\n\n\nll fox(ll a,ll b)\n{\n static ll count = (ll)0;\n ll larger,smaller;\n \n if(a==b)\n return count;\n \n count += (ll)1;\n \n if(a>b)\n {\n larger = a,smaller = b;\n }\n \n else\n {\n smaller = a,larger = b;\n }\n \n if(larger % (ll)2==(ll)0)\n {\n if(larger==a)\n a/=(ll)2;\n \n else\n b/=(ll)2;\n \n return fox(a,b);\n }\n \n else if(larger % (ll)3==(ll)0)\n {\n if(larger == a)\n a/=(ll)3;\n \n else\n b/=(ll)3;\n \n return fox(a,b);\n }\n \n else if(larger % (ll)5==(ll)0)\n {\n if(larger == a)\n a/=(ll)5;\n \n else\n b/=(ll)5;\n \n return fox(a,b);\n }\n \n else\n return -1;\n \n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "f3aa3d57694996c5f6bb7ea0cf723184", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main()\n{\nchar input[1000000];\nscanf(\"%s\",&input);\ngetchar();\nint length=strlen(input),letter=length-1,numofzeroes=0,caseid;\n\nif((length+1)%2==0)\ncaseid=0;\nelse\ncaseid=1;\n\nwhile(input[letter]=='0'){\nletter--;\nnumofzeroes++;\n}\n\nint done=0,front=0,back=letter;\nwhile(done==0){\n\n//printf(\"%d.%c %d.%c\\n\",front,input[front],back,input[back]);\n\nif(input[front]!=input[back]){\ndone=1;\n}\nelse if((length-numofzeroes)==1){\ndone=2;\n}\nelse{\nif(front==(((length-numofzeroes-caseid)/2)-(1-caseid))){\ndone=2;\n}\nfront++;\nback--;\n}\n}\n\nif(done==2)\nprintf(\"YES\");\nelse\nprintf(\"NO\");\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "12c7a841a41e1d97b7b11d5d961c2cd2", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\n\tint n;\n\twhile(~scanf(\"%d\",&n))\n\t{\n\t\tint pl1=1;\n\t\tint pl2=2;\n\t\tint flag=0;\n\t\tfor(int i=1; i<=n; i++)\n\t\t{\n\t\t\tint win;\n\t\t\tscanf(\"%d\",&win);\n\t\t\tif(win!=pl1&&win!=pl2)\n\t\t\t\tflag=1;\n\t\t\tif(flag);\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(win==pl1)\n\t\t\t\t\tpl2=6-pl1-pl2;\n\t\t\t\telse\n\t\t\t\t\tpl1=6-pl1-pl2;\n\t\t\t}\n\t\t}\n\t\tif(flag)\n\t\t\tprintf(\"NO\\n\");\n\t\telse\n\t\t\tprintf(\"YES\\n\");\n\t}\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "68786f33f85c3e1db228ea9dd6f2ad38", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint n,k;\nint b[8];\nchar str[10];\nchar num[8][10];\nvoid permu(char str[])\n{\n int i,l,j,t,k,len;\n char c;\n len=strlen(str);\n for(j=1;j0;j--)\n X[j]=X[j-1];\n X[j]=tmp;\n }\n}\n\n \n\nint main()\n{\n int i,tmp,max,j;\n scanf(\"%d%d\",&n,&k);\n for(i=0;itmp)\n max=tmp;\n if(j\nint main ()\n{\n long long int n,i,mul=0,j;\n scanf(\"%lld\",&n);\n for(i=1;n!=0;i++)\n {\n j=n%2;\n if(j==1)\n {\n mul++;\n }\n n=n/2;\n }\n printf(\"%lld\",mul);\n return 0;\n}", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "99987a035b71b52e6d9f42b2881a096c", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MAX 107\n\nint main()\n{\n\tint n, i, a[MAX], f = -1, l = 0, ans;\n\tscanf(\"%d\", &n);\n\tfor(i=0;i= 2)\n\t\t\t{\n\t\t\t\tans -= l;\n\t\t\t}\n\t\t\tl = 0;\n\t\t}\n\t}\n\tprintf(\"%d\\n\", f == -1 ? 0 : ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "79bcbee77df40bc9a1a2c51501ab7958", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n long long int a,b,i,x,y,ans=1;\n scanf(\"%lld %lld\",&a,&b);\n //cout<20))\n {\n x=a%10;\n }\n else\n {\n x=a;\n }\n if ((b>20))\n {\n y=b%10;\n }\n else\n {\n y=b;\n }\n //cout<y)\n {\n cout<<\"0\"<y)\n {\n cout<<\"0\"<a ; i--)\n {\n ans=(ans*(i%10))%10;\n //printf(\"%d\\n\",ans);\n if (ans==0)\n {\n break;\n }\n }\n printf(\"%d\\n\",ans);\n /*}\n else\n {\n printf(\"0\\n\");\n }*/\n // }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "5558ed0d84635e363603753d2bda4505", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n int a,b,c,d;\n scanf(\"%d %d %d %d\",&a,&b,&c,&d);\n if(a>b) printf(\"First\");\n else printf(\"Second\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "1edb247e491f886ebddcd5785a87eea3", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"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\nmain()\n{\n\tint a,b,c,i,y;\n\tscanf(\"%d %d %d\",&a,&b,&c);\n\tfor(i=0;i<=c/a;i++)\n\t{\n\t\ty=(c-a*i);\n\t\tif(y%b==0)\n\t\t{\n\t\t\tprintf(\"Yes\");\n\t\t\texit(0);\n\t\t}\n\t\t\n\t}\t\n\tprintf(\"No\");\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "f8e58aff2a2fad48c1705a3cc9ac56d6", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\nint a, b, c, temp, flag;\nscanf(\"%d %d %d\", &a, &b, &c);\n\tif(a==b){\n\t\tprintf(\"YES\");\n\t}\n\t\n\telse if(c==0){\n\t\tif(a==b){\n\t\t\tprintf(\"YES\");\n\t\t}\n\t\telse{\n\t\t\tprintf(\"NO\");\n\t\t}\n\t}\n\t\n\telse if(c==1){\n\t\tif(ab){\n\t\t\tprintf(\"YES\");\n\t\t}\n\t\telse{\n\t\t\tprintf(\"NO\");\n\t\t}\n\t}\n\t\n\telse{\n\t\tif(c>0){\n\t\t\tflag=1;\n\t\t}\n\t\telse{\n\t\t\tflag=2;\n\t\t}\n\t\t\n\t\ttemp=a+c;\n\t\twhile(temp!=b){\n\t\t\ttemp=temp+c;\n\t\t\t\tif(flag==1){\n\t\t\t\t\tif(temp>b){\n\t\t\t\t\t\tprintf(\"NO\");\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\telse if(flag==2){\n\t\t\t\t\tif(temp\n\nint main()\n{\n int n, c=0, i;\n scanf(\"%d\", &n);\n int j[n];\n for(i=1; i<=n; i++)\n {\n j[i]=(i*(i+1))/2;\n if(j[i]==n)\n {\n c++;\n break;\n }\n }\n if(c>=1)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "28067e785024a4053829c26a9390e231", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tint a,b,c,d,e,f;\n\tscanf(\"%d:%d %d:%d\",&a,&b,&c,&d);\n\tif(b\n\n#include \n\n \n\nint main()\n\n{\n\n char str[106];\n\n scanf(\"%s\", str);\n\n int len = strlen(str);\n\n if(len < 7)\n\n {\n\n printf(\"no\\n\");\n\n return 0;\n\n }\n\n int j = 0;\n\n while(str[j] != '1' && str[j] != '\\0')\n\n j++;\n\n //printf(\"%d\\n\", j);\n\n if(j == len)\n\n {\n\n printf(\"no\\n\");\n\n return 0;\n\n }\n\n int i, cnt = 0;\n\n for(i = j + 1; i < len; i++)\n\n if(str[i] == '0')\n\n cnt++;\n\n //printf(\"%d\\n\", cnt);\n\n if(cnt > 5)\n\n printf(\"yes\\n\");\n\n else\n\n printf(\"no\\n\");\n\n return 0;\n\n}\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b06c3d9a1172fe070d06cbe871ca2091", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n#define max(a,b) a>b?a:b\n\nint main()\n{\n int n, c, i, p[10000], t[10000], l_p=0, r_p=0, time;\n scanf(\"%d %d\",&n,&c);\n\n for(i=0; i=0; i--)\n {\n time+=t[i];\n r_p+=max(0,p[i]-c*time);\n }\n\n\n if(l_p>r_p)\n {\n printf(\"Limak\\n\");\n }\n else if(r_p>l_p)\n {\n printf(\"Radewoosh\\n\");\n }\n else\n {\n printf(\"Tie\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f473caa8893a626d40b3500c08421b78", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\t\n\tint n,ba,a,b,ro=1;\n\tscanf(\"%d %d %d\",&n,&a,&b);\n\tba=2;\n\ta--;\n\tb--;\n\twhile(ba<=n){\n\t\tif(a/ba==b/ba)break;\n\t\telse{\n\t\t\tba*=2;\n\t\t\tro++;\n\t\t}\n\t}\n\tif(ba==n)printf(\"Final!\\n\");\n\telse printf(\"%d\\n\",ro);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "a5c6b5d9578953c28e300cc986e07b3d", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n// \u95ee\u9898\u63cf\u8ff0\uff1a \u8f93\u51652\u5bf9\u53c2\u6570\uff0c \u4e00\u5bf9\u662f\u901f\u5ea6v1 v2\uff0c\u53e6\u5916\u5206\u522b\u662f\u65f6\u95f4 t \u548c \u901f\u5ea6\u6539\u53d8\u91cf d\n// \u6c42\u5728t\u65f6\u95f4\u5185\uff0c\u8d70\u8fc7\u7684\u6700\u5927\u7684\u8def\u7a0b\n// \u601d\u8def:\n// \u5173\u952e\u662f\u6c42\u51fa\u6700\u5927\u901f\u5ea6\n//\n\nint v11[201];\nint v22[201];\nint v[201];\n\nvoid near(int t, int d){\n int i;\n int j;\n\n for(i = 2; i < t; i ++){\n v11[i] = v11[i - 1] + d;\n }\n for(j = t - 1; j > 1; j --){\n v22[j] = v22[j + 1] + d;\n }\n\n for(i = 2; i < t; i ++){\n if(v11[i] > v22[i]){\n v[i] = v22[i];\n }\n else{\n v[i] = v11[i];\n }\n }\n}\n\nint main(){\n\n int v1;\n int v2;\n int t;\n int d;\n int i;\n int distance = 0;\n\n scanf(\"%d%d\", &v1, &v2);\n scanf(\"%d%d\", &t, &d);\n\n v11[1] = v1;\n v22[t] = v2;\n v[1] = v1;\n v[t] = v2;\n\n near(t, d);\n\n for(i = 1; i <= t; i ++){\n distance += v[i];\n }\n printf(\"%d\\n\", distance);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "62e0b6a6d8b27521039a98abcba1da35", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n\tint n,t;\n\tscanf(\"%d %d\",&n,&t);\n\tchar s[n];\n\tscanf(\"%s\",s);\n\tint l=strlen(s),i,j;\n\tfor (i=0; i=0; j--)\n\t\t\tif (s[j]=='B' && s[j+1]=='G')\n\t\t\t{\n\t\t\t\ts[j]='G';\n\t\t\t\ts[j+1]='B';\n\t\t\t\tj--;\n\t\t\t}\n\t\t\t//printf(\"%s\\n\",s);\n\tprintf(\"%s\\n\",s);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "d81cf0cde760cf75c1b668e7ac9288dd", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main (){\n\n int m,n,x=1;\n\n scanf(\"%d\",&n);\n\n scanf(\"%d\",&m);\n\n while(x<=m){\n\n m = m-x ;\n\n if(x != n){\n\n x++;\n\n }else{\n\n x=1;\n\n }\n\n }\n\n printf(\"%d\",m);\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e68f016f5f0b1720a2d2a3efc5b5e6e2", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int c=0,w,h,n,m;\n\tscanf(\"%lld %lld\",&w,&h);\n\tif(w<2 || h<2)\n\t{\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tfor(n=2;w>=n;n=n+2)\n\t{\n\t\tfor(m=2;h>=m;m=m+2)\n\t\t\tc=c+(h-(m-1))*(w-(n-1));\n\t}\n\tprintf(\"%lld\\n\",c);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "ff77a7d647936d5f41da8fe93f71e948", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//\n// main.c\n// VK Cup 2017\n//\n// Created by Georg on 04.03.17.\n// Copyright \u00a9 2017 Georg. All rights reserved.\n//\n\n#include \n\nint main(int argc, const char * argv[]) {\n int n, i, j;\n scanf(\"%d\", &n);\n int years[n];\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &years[i]);\n }\n for (i = 0; i < n; i++) {\n for (j = 0 ; j < n; j++) {\n if (years[j] > years[i]) {\n \n years[i] = years[i] + years[j];\n years[j] = years[i] - years[j];\n years[i] = years[i] - years[j];\n }\n }\n }\n// for (i = 0; i < n; i++) {\n// printf(\"%d\", years[i]);\n// }\n if (n == 1) {\n printf(\"%d\", years[0]);\n } else if (n == 3) {\n printf(\"%d\", years[1]);\n } else if (n == 5) {\n printf(\"%d\", years[2]);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation"], "code_uid": "cfd9831b1473f987dcbf7537689c04d2", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long a[100000] = {0}, k , l, d, m, n;\n scanf(\"%ld%ld%ld%ld%ld\", &k, &l, &m, &n, &d);\n for(long i = 1; i <= d; i++)\n {\n if( k*i <= d)\n {\n a[k*i] = 1;\n }\n if( l*i <= d)\n {\n a[l*i] = 1;\n }\n if( m*i <= d)\n {\n a[m*i] = 1;\n }\n if( n*i <= d)\n {\n a[n*i] = 1;\n }\n }\n long c = 0;\n for(int i = 1; i <= d; i++)\n {\n if(a[i] == 1)\n c++;\n }\n printf(\"%ld\", c);\n \n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "89b42cb4a57fba86c4562b8bbe9f6439", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint p[200],x1[200],x2[200];\nint main()\n{\n int n,temp=0,t=0,i,m=0,c=0,l1=0;\n scanf(\"%d\",&n);\n int arr[n];\n for(i=0;i0){\n if(arr[i-1]+1==arr[i])\n {\n if(c==0)\n x1[m]=arr[i-1];\n c=1;\n t++;\n if(i==n-1)\n {\n x2[m]=arr[i];\n p[m]=t+1;\n m++;\n }\n }\n else\n {\n if(c==1){\n c=0;\n x2[m]=arr[i-1];\n p[m]=t+1;\n t=0;\n m++;\n }\n }\n }\n }\n if(m==0)\n printf(\"0\");\n else if(m==1)\n {\n if(p[0]==n)\n {\n if(arr[n-1]==1000)\n printf(\"%d\",p[0]-1);\n else if(arr[0]==1)\n printf(\"%d\",p[0]-1);\n else\n printf(\"%d\",p[0]-2);\n }\n else{\n if(x1[0]==1||x2[0]==1000)\n printf(\"%d\",p[0]-1);\n else\n printf(\"%d\",p[0]-2);\n }\n }\n else\n {\n for(i=0;i\n\nint main() {\n int e,n,ans=0;\n scanf(\"%d%d\",&e,&n);\n int max=e>n?e:n;\n int min=e=2*min)\n {\n printf(\"%d\",min);\n }\n else\n {\n int ans=(e+n)/3;\n printf(\"%d\",ans);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "60f5cea7b2f179ef808bf7bef2c9b978", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long int fact[200005];\nlong long int modpow(long long int a, long long int n, long long int p)\n{\n\tif (n < 0)\n\t\treturn 0;\n\tlong long int res = 1;\n\twhile (n > 0)\n\t{\n\t\tif (n % 2 > 0)\n\t\t\tres = res * a % p;\n\t\ta = a * a % p;\n\t\tn /= 2;\n\t}\n\treturn res;\n}\nlong long int comb(long long int n, long long int r, long long int p)\n{\n\tif (n < 0 || r < 0 || n < r)\n\t\treturn 0;\n\tlong long int res = fact[n];\n\tres = res * modpow(fact[r], p - 2, p) % p;\n\tres = res * modpow(fact[n - r], p - 2, p) % p;\n\treturn res;\n}\nint main()\n{\n\tlong long int n, m;\n\tscanf(\"%lld %lld\", &n, &m);\n\tlong long int p = 998244353;\n\tlong long int ans = 0;\n\tlong long int i;\n\tfact[0] = 1;\n\tfor (i = 1; i <= m; i++)\n\t\tfact[i] = fact[i - 1] * i % p;\n\tfor (i = 1; i < m; i++)\n\t\tans = (ans + comb(m - 1, n - 2, p) - comb(i - 1, n - 2, p) + p) % p;\n\tans = ans * modpow(2, n - 3, p) % p;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "5d8e6f134ad924d1bdf38e54fc81865e", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long int n,a,b,i,c,d,j,k=0,l,m,o;\n long int arr[1000],brr[1000];\n j=0;\n scanf(\"%ld\",&n);\n for(i=1;i<=n;i++){\n if(n%i==0){\n arr[j]=i;\n brr[j]=n/i;\n if((brr[j]-arr[j])>=0)\n {\n k++;\n }\n j++;\n }\n }\n for(l=j;l<1000;l++){\n arr[l]=brr[l]=0;\n }\n printf(\"%ld %ld\",arr[k-1],brr[k-1]);\nreturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "9758dd7882466aec52121eb98a67769f", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,k;\n scanf(\"%d %d\",&n,&k);\n k=240-k;\n if(k<5){\n printf(\"0\");\n return 0;\n }\n int i=1;\n k=k-5*i;\n while(k>=0 && i<=n){\n\n i++;\n k=k-5*i;\n\n }\n printf(\"%d\",i-1);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "49380c2e626df6b96455707f82dcab05", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main ()\n{\n\n long long int a,b,c;\n scanf(\"%lld %lld\",&a,&b);\n c=a/b;\n if (c%2==0)\n\n {\n printf(\"NO\\n\");\n }\n else printf (\"YES\\n\");\n return 0;\n\n\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "528bd89afa0ab5d07a02a29d1e761c6e", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\ntypedef long long int LL; \n\nconst int NM=(int)(10e8+1);\n\nint main(){\n\tint n,m;\n\tint i,j,k,s;\n\tint a,b;\n\tLL sum=0LL;\n\tint mas[11];\n\tint r[11];\n\n\tfor(i=0;i<=10;i++){\n\t\tr[i]=0;\n\t}\n\tscanf(\"%d %d\",&n,&m);\n\n\tfor(i=0;i0 && s>0){\n\t\tif(r[s]>=k){\n\t\t\tsum+=(k*1LL*s);\n\t\t\tbreak;\n\t\t}\n\t\tsum+=(r[s]*1LL*s);\n\t\tk-=r[s];\n\t\ts--;\n\t\t//printf(\":%I64d \",sum);\n\t}\n\t\n\tprintf(\"%I64d\",sum);\n\nreturn 0;\n}", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "9e0536fdef842da09157cb4270fae109", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\n char a[11], b[11];\n scanf(\"%s%s\", a, b);\n if(strlen(a)!=strlen(b))\n {\n printf(\"WRONG_ANSWER\");\n return 0;\n }\n int n,m,q, dig[10],i;\n n=atoi(a);m=atoi(b);\n q=n;\n for(i=0;n!=0;i++)\n {\n dig[i]=n%10;\n n=n/10;\n }\n for(int j=0;jdig[k+1])\n {\n n=dig[k];\n dig[k]=dig[k+1];\n dig[k+1]=n;\n }\n }\n }\n for(int j=0;j\nint gcd(int x,int y)\n{int p;\n if(x>y)\n {\n for(int i=1;i<=y;i++)\n {\n if(x%i==0 && y%i==0)\n p=i;\n }\n return p;\n }\n else\n {\n for(int i=1;i<=x;i++)\n {\n if(x%i==0 && y%i==0)\n p=i;\n }\n return p;\n }\n}\nint main()\n{\n int a,b,c,d,n,flag=0;\n scanf(\"%d %d %d\",&a,&b,&n);\n c=a;\n d=b;\n for(;n!=0;)\n {\n a=a+gcd(c,n);\n n=n-gcd(c,n);\n if(n==0)\n {flag=1;\n break;}\n else\n {\n b=b+gcd(d,n);\n n=n-gcd(d,n);\n }}\n if(flag==1)\n printf(\"0\\n\");\n else\n printf(\"1\\n\");\n return 0;\n \n \n \n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a910f618f57512f0449b6b6adf04e8cb", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n int R,B,i,j;\n scanf(\"%d %d\",&R,&B);\n int x[R],y[R],a[B],b[B];\n for(i=0;i\nint main()\n{\n long long c[10] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };\n long long sum = 0;\n long long a, b, i;\n scanf( \"%I64d %I64d\", &a, &b );\n for( i = a; i <= b; ++i )\n {\n int j;\n j = i;\n if( j / 10 != 0 )\n while( j != 0 )\n {\n sum = sum + c[j % 10];\n j = j / 10;\n }\n else sum = sum + c[i];\n }\n printf(\"%d\", sum);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6a6cd741fdc44f19c107f4aa71c5311b", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint r,b,g,mix,a[10],i;\n\tscanf(\"%d %d %d\",&r,&b,&g);\n\tif(r==0 || b==0 || g==0)\n\t{\n\t\tprintf(\"%d\",(r/3+g/3+b/3));\n\t\treturn 0;\t\n\t}\n\tfor(i=0;i<=2;i++)\n\t{\n\t\ta[i]=(i+((r-i)/3+(b-i)/3+(g-i)/3));\n\n\t}\n\tint max=0;\n\tfor(i=0;i<=2;i++)\n\t{\n\t\tif(a[i]>max)\n\t\t\tmax=a[i];\n\t}\n\tprintf(\"%d\",max);\n\treturn 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "de5e08b66eb31d7f6acd740e6bcead6e", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,k,i,total=0,give=0,check=0,day;\n\tscanf(\"%d %d\",&n,&k);\n\tint a[n];\n\tfor(i=0;i8)\n\t\t{\n\t\t\ttotal-=8;\n\t\t\tgive+=8;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tgive+=total;\n\t\t\ttotal=0;\n\t\t}\n\t\tif(give>=k&&check==0)\n\t\t{\n\t\t\tcheck=1;\n\t\t\tday=i+1;\n\t\t}\n\t}\n\tif(check==1)\n\tprintf(\"%d\",day);\n\telse\n\tprintf(\"-1\");\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d2b84eb2f6d76e21babcf39f1de7d6be", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int a,b,x,y;\n scanf(\"%d %d\\n%d %d\",&a,&b,&x,&y);\n if(abs(a-x)>abs(y-b))printf(\"%d\",abs(a-x));\n else printf(\"%d\",abs(y-b));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "38b7d31d05916c7fcfe28d4a7bd92a11", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int w,h,i;\n scanf(\"%d %d\",&w,&h);\n int ans=1;\n for(i=1;i<=w+h;i++)\n ans = (ans*2)%998244353;\n printf(\"\\n%d\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "combinatorics"], "code_uid": "b68cd1f81aba8697a00a14fa3a42134c", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint l,i=0,c=0,sr=0,d=0;\nchar s[105];\nscanf(\"%s\",s);\nl=strlen(s);\nfor(i=0;i='A'&&s[i]<='Z')\n c++;\n else if(s[i]>='a'&&s[i]<='z')\n sr++;\n else if(s[i]>='0'&&s[i]<='9')\n d++;\n}\nif(l>=5&&c>=1&&sr>=1&&d>=1)\n printf(\"Correct\");\nelse\n printf(\"Too weak\");\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "50918f34bf5976f052bde9a667a354e3", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint max(int a, int b){\n int maxim;\n return maxim=(a>=b)?a:b;\n}\n\nint main(void)\n{\n int a,b,c,d, misha, vasya;\n scanf(\"%d %d %d %d\", &a,&b,&c,&d);\n misha = max((3*a)/10 ,a- ((a*c)/250));\n vasya = max((3*b)/10 ,b-((b*d)/250));\n if(misha>vasya) printf(\"Misha\");\n else if(misha\n#include\n#include\nint main()\n{\n\tchar s[101];\n\tscanf(\"%s\",s);\n\tint len = strlen(s);\n\tint i;\n\tint flag = 0;\n\tchar *ans;\n\tans = \"CODEFORCES\";\n\tfor(i=0;i\n\nint main(){\n\nint x , y;\nscanf(\"%d %d\",&x,&y);\nif(x%2 == 0 && y%2 ==0)\nprintf(\"Malvika\");\nelse if(x%2 ==1 && y%2 == 1)\nprintf(\"Akshat\");\nelse if (x%2 ==1){\nif (x\n#include \n\nint main()\n{\n int counter=-1,help=-1, last=-1, check=0, hello=0;\n char str[101];\n scanf(\"%s\",str);\n for(int i=0; i last)\n {\n last=help-counter; counter=i;\n\n }\n else counter=i;\n check++; hello=i;\n }\n else if(i==strlen(str)-1 && (strlen(str)+1)-counter>last)\n {last=strlen(str)+-counter;}\n }\n if(check==1 && last<2) printf(\"%d\", (strlen(str)-hello));\n else if(last==-1) printf(\"%d\", strlen(str)+1);\n else printf(\"%d\", last);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "00e8ec7e4053a6614d0885034b546f13", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{ int n,i,max,a[1000],t,j;\n\tscanf(\"%d\",&n);\n\tfor(i=0; i=max) max=t; \n\t}\n\tprintf(\"%d\",max);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "34baa7ac2bb84f04e356cc23b537b833", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n\nint main(void) {\n\tint n, d;\n\tscanf(\"%d%d\", &n, &d);\n\n\tint arr[n];\n\tint maxn = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &arr[i]);\n\t\tmaxn = arr[i] > maxn ? arr[i] : maxn;\n\t}\n\n\tint maxgrp = 1;\n\tfor (int i = 0; i < n; i++) {\n\t\tint cur = 0;\n\t\tfor (int j = 0; j < n; j++) {\n\t\t\tif (arr[j] - arr[i] <= d && arr[j]-arr[i] >= 0) {\n\t\t\t\tcur++;\n\t\t\t}\n\t\t}\n\t\tmaxgrp = cur > maxgrp ? cur : maxgrp;\n\t}\n\n\tprintf(\"%d\\n\", n-maxgrp);\n}\n", "lang_cluster": "C", "tags": ["brute force", "sortings", "greedy"], "code_uid": "c749bfe99a501998b7e280ff63be7a4f", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n\nint main()\n{\n long long int N,M,k,i,j,s,r,d,m,n;\n long long int B[]= {9,189,2889,38889,488889,5888889,68888889,788888889,8888888889,98888888889,1000000000000};\n long long int C[]= {9,99,999,9999,99999,999999,9999999,99999999,999999999,9999999999,99999999999,999999999999};\n\n scanf(\"%lld\", &N);\n\n if(N<=B[0])\n {\n i=0;\n }\n else if(N<=B[1])\n {\n i=1;\n }\n else if(N<=B[2])\n {\n i=2;\n }\n else if(N<=B[3])\n {\n i=3;\n }\n else if(N<=B[4])\n {\n i=4;\n }\n else if(N<=B[5])\n {\n i=5;\n }\n else if(N<=B[6])\n {\n i=6;\n }\n else if(N<=B[7])\n {\n i=7;\n }\n else if(N<=B[8])\n {\n i=8;\n }\n else if(N<=B[9])\n {\n i=9;\n }\n else if(N<=B[10])\n {\n i=10;\n }\n\n if(N<=9)\n {\n s=N;\n }\n else\n {\n r=N-B[i-1];\n m=r/(i+1);\n n=r%(i+1);\n if((r%(i+1))!=0)\n {\n m=m+1;\n }\n m=m+C[i-1];\n\n long long int A[i+1];\n\n for(j=i; j>=0; j--)\n {\n A[j]=m%10;\n m=m/10;\n }\n\n if(n==0)\n {\n s=A[i];\n }\n else\n {\n s=A[n-1];\n }\n }\n\n printf(\"%lld\\n\",s);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["divide and conquer", "implementation", "binary search"], "code_uid": "95efed31a1941316be96320b74c6095e", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int n,i,p=0,j=0;\n scanf(\"%d\",&n);\n char s[n];\n scanf(\"%s\",s);\n for(i=0;ij){\n printf(\"YES\\n\");\n }\n else{\n printf(\"NO\\n\");\n }\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ab8f9a6dde7b083250e64ca6a2cb0698", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main(){\n int a[3];\n int b;\n scanf(\"%d%d%d\", &a[0], &a[1], &a[2]);\n for (int i = 0; i < 3; i++)\n for (int j = 0; j < 3; j ++)\n if (a[i] < a[j])\n {\n b = a[i];\n a[i] = a[j];\n a[j] = b;\n }\n\n printf(\"%d\", a[2] - a[0]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "sortings", "implementation"], "code_uid": "0214dfd1f5c4cef9303b257f205027b8", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint m,n,t,u,maxi,i;\n\tscanf(\"%d %d\",&m,&n);\n\tmaxi=m;\n\tif (n>maxi){\n\t\tmaxi=n;\n\t}\n\tt=6-maxi+1;\n\tu=6;\n\tfor (i=6;i>1;i--){\n\t\tif (t%i==0 && u%i==0){\n\t\t\tprintf(\"%d/%d\",t/i,u/i);\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\t\n\tprintf(\"%d/%d\",t,u);\n\t\t\n\t\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "probabilities"], "code_uid": "5e988cdae5c53ae466ce6730149b6333", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tchar s[102]={};\n\tscanf(\"%s\",s);\n\tint i=0,not[200]={0},count=0,y=-1,r=-1,b=-1,g=-1,red=0,blu=0,yel=0,gre=0;\n\tfor(i=0;i\n#define MOD 1000003\n \nint power(int x,int y)\n{\n if(y==0)\n return 1;\n int temp=x;\n while(--y)\n {\n x*=temp;\n x%=MOD;\n }\n return x;\n}\nint main()\n{\n int y;\n scanf(\"%d\",&y);\n if(y==0)\n {\n printf(\"%d\",1);\n return 0;\n }\n int res=power(3,y-1);\n printf(\"%d\\n\",res);\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "b00ee8d6b0774ac21a19e733ecf8120a", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{int t,s,q,r=0;\n scanf(\"%d %d %d\",&t,&s,&q);\n while (s\nint main(){\nint n,m,f=1,i,j;\nscanf(\"%d%d\",&n,&m);\nif(n==2){\n if(m==3) printf(\"YES\");\n else printf(\"NO\");\n}\n\nelse{\n for(i=n+2;;i+=2){\n for(j=3;j<=i/2;j+=2){\n if(i%j==0){\n f=0;break;\n }\n else f=1;\n }\n if(f==1) break;\n}\nif(i==m) printf(\"YES\");\nelse printf(\"NO\");\n}\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "4288a7b7a8e217d849641d64a9cd7a8b", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int n,*a,i,max,ans;\n\n scanf(\"%d\",&n);\n\n a = (int*)malloc(n*sizeof(int*));\n\n for(i=0;imax)\n max = a[i];\n }\n if(max>25)\n ans = max -25;\n else\n ans = 0;\n\n printf(\"%d\",ans);\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "d1d7f7532d5ffe675729b639b1274158", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define ll long long int\nll getcards(ll flo)\n{\n return 3*flo*(flo+1)/2-flo;\n}\n//Another solution would be to calculate the number of rooms R i.e 3R-F everytime and then return the value.But it would become an O(n*sqrt(n));\nint main()\n{\n ll n;\n scanf(\"%lld\",&n);\n\n ll floor;\n ll rem=0;\n for(floor=1;getcards(floor)<=n;floor++)\n {\n if((n+floor)%3==0)\n rem++;\n }\n\n printf(\"%lld\",rem);\n\n return 0;\n} ", "lang_cluster": "C", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "e80f525dba37ecfc2560fa058dd9d802", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tchar s[50],s1[50];scanf(\"%s\",s);\n\tint i,l,t,cnt=0;\n\tl=strlen(s);\n\tif(l%2==0) t=l/2-1;\t\n\telse t=(l/2);\n\tfor(i=0;i\n#include\nint main()\n{\n\tchar a[500],temp,max;\n\tint c,n,i,j,k,x,f=1,h=4,m;\n\tscanf(\"%s\",a);\n\tscanf(\"%d\",&k);\n\tc=0;\n\tn=strlen(a);\n\twhile(c!=n)\n\t{\n\t\tmax='0';\n\t\tfor(j=c;jmax)\n\t\t\t{\n\t\t\t\tmax=a[j];\n\t\t\t\tx=j;\n\t\t\t}\n\t\t}\n\t\tfor(j=x;j>c;j--)\n\t\t{\n\t\t\t/*if(c==x)\t\t\n\t\t\tbreak;*/\n\t\t\tif(k==0)\n\t\t\t{\n\t\t\t\tf=0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttemp=a[j-1];\n\t\t\ta[j-1]=a[j];\n\t\t\ta[j]=temp;\n\t\t\tk--;\n\t\t}\n\t\tc++;\n\t//\tprintf(\"%d \",k);\n\t\tif(f==0)\n\t\tbreak;\n\t}\n\tprintf(\"%s\",a);\n\treturn 0;\n}\n\t\t\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "7b16d6b2850c3f5c22debfbf00654009", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nmain()\n{\n\tint n, i, a[55], b[55], p, q;\n\tscanf(\"%d\", &n);\n\tfor (i=0, p=0; i=q)\n\t{\n\t\tprintf(\"Yes\\n\");\n\t}\n\telse\n\t{\n\t\tprintf(\"No\\n\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "1f60fe0af672f716940ed25afac0f978", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#define MAX 255+7\nint max(int A[],int n)\n{\n int i,max;\n max=A[0];\n for(i=0;imax)\n { max=A[i];\n\n }\n\n }\n return max;\n}\nint main()\n{\n char A[MAX];\n int n,i,z=0,w=0,cnt=0,B[MAX];\n scanf(\"%d\",&n);\n scanf(\"%s\",A);\n for(i=0;A[i];i++)\n {\n if(z%2==0)\n {\n if(A[i]=='_')\n {\n B[w]=cnt;\n w++;\n cnt=0;\n\n continue;\n }\n if(A[i]=='(')\n {\n B[w]=cnt;\n // printf(\"%d %c \\n\",cnt,A[i]);\n w++;\n cnt=0;\n z++;\n\n }\n else\n {cnt++;\n //printf(\"%d %c \\n\",cnt,A[i]);\n }\n\n }\n if(A[i]==')')\n z++;\n\n }\n B[w]=cnt;\n w++;\n cnt=0;z=0;\n for(i=0;A[i];i++)\n {\n if(z%2==1)\n {\n if(A[i]=='_' &&( A[i-1]!='_' && A[i-1]!='('))\n {\n cnt++;\n\n }\n\n if(A[i]==')')\n {\n if(A[i-1]!='_' && A[i-1]!='(')\n {cnt++;\n\n }\n\n z++;\n }\n }\n if(A[i]=='(')\n\n z++;\n }\n int j;\n j=max(B,w);\n printf(\"%d %d\",j,cnt);\n\n}\n\n\n\n\n\n\n\n", "lang_cluster": "C", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "f58fd0b72cee11ab8f9f3b1cc9301488", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n char n,i;\n long l,r,x,j;\n long min,max,sum,count=0;\n char s;\n scanf(\"%d%ld%ld%ld\",&n,&l,&r,&x);\n long c[n];\n for(i=0;imax)max=c[i];\n sum+=c[i];\n s++;\n }\n if(s>1 && sum>=l && sum<=r && (max-min)>=x)\n count++;\n }\n printf(\"%ld\\n\",count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "bitmasks"], "code_uid": "ec7273655b380aae84c82dc54a11d90a", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n int a,b;\n scanf(\"%d%d\",&a,&b);\n printf(\"%d\",a+b);\n return 0;\n} ", "lang_cluster": "C", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "788a2e7be3f47b86a3864dbb1169634b", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int i,j,k,len,count=0;\n char str[2][101];\n str[0][100]='X';\n str[1][100]='X';\n for(i=0;i<2;i++)\n {scanf(\"%s \",str[i]);\n //printf(\"%s\",str[i]);\n //printf(\"\\n\");\n }\n len=strlen(str[0]);\n for(i=0;i\n#include\nint main()\n{\n int d1,d2,d3,sum=0;\n scanf(\"%d %d %d\",&d1,&d2,&d3);\n if(d1>d2){\n sum=sum+d2;\n if(d3<=d2+d1)\n sum=sum+d3;\n else\n sum=sum+d1+d2;\n if(d1<=d2+d3)\n sum=sum+d1;\n else\n sum=sum+d2+d3;\n }\n else\n {\n sum=sum+d1;\n if(d3<=d2+d1)\n sum=sum+d3;\n else\n sum=sum+d1+d2;\n if(d2<=d1+d3)\n sum=sum+d2;\n else\n sum=sum+d1+d3;\n }\n printf(\"%d\",sum);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "354f5beedc31ea95fdcaec19d04b0e30", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\nint num,temp,f=1;\nscanf(\"%d\",&num);\nint i,j,a[num],count=0;\nfor(i=0;ia[j+1]){\n temp=a[j];\n a[j]=a[j+1];\n a[j+1]=temp;\n }\n }\n}\nfor(i=0;i\n\nint points[1010][5];\nint val[1010];\n\nint main()\n{\n\tint n, i, j, k, l, count = 0;\n\tfor (i = 0; i < 1010; i++) val[i] = -1;\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) for (j = 0; j < 5; j++) scanf(\"%d\", &points[i][j]);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tif (val[i] == -1)\n\t\t{\n\t\t\tint flag = 1;\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t{\n\t\t\t\tif (j != i)\n\t\t\t\t{\n\t\t\t\t\tfor (k = 0; k < n; k++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (k != i && k != j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint sum = 0;\n\t\t\t\t\t\t\tfor (l = 0; l < 5; l++)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsum += (points[j][l] - points[i][l]) * (points[k][l] - points[i][l]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (sum > 0)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tval[i] = 0;\n\t\t\t\t\t\t\t\tflag = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tval[j] = 0;\n\t\t\t\t\t\t\t\tval[k] = 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}\n\t\t\t}\n\t\t\tif (flag == 1)\n\t\t\t{\n\t\t\t\tval[i] = 1;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", count);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tif (val[i] == 1) printf(\"%d\\n\", i + 1);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "ae9c8f6237f4901e85080a1f2c12f37b", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\n char F[20],M[20],S[20];\n char f,m,s;\n scanf(\"%s\",F);\n scanf(\"%s\",M);\n scanf(\"%s\",S);\n f=F[0];\n m=M[0];\n s=S[0];\n //printf(\"%c,%c,%c\\n\",f,m,s);\n if(f==m && f==s && m==s)\n printf(\"?\\n\");\n else if(f!=m && f!=s && m!=s)\n printf(\"?\\n\");\n else if(((f=='p' && m=='p' && s=='r')||(f=='p' && s=='p' && m=='r')||(m=='p' && s=='p' && f=='r')||(m=='p' && f=='p' && s=='r')||(s=='p' && m=='p' && f=='r')||(s=='p' && f=='p' && m=='r'))||((f=='r' && m=='r' && s=='s')||(f=='r' && s=='r' && m=='s')||(m=='r' && s=='r' && f=='s')||(m=='r' && f=='r' && s=='s')||(s=='r' && m=='r' && f=='s')||(s=='r' && f=='r' && m=='s'))||((f=='s' && m=='s' && s=='p')||(f=='s' && s=='s' && m=='p')||(m=='s' && s=='s' && f=='p')||(m=='s' && f=='s' && s=='p')||(s=='s' && m=='s' && f=='p')||(s=='s' && f=='s' && m=='p')))\n printf(\"?\\n\");\n else if((f=='p' && m=='p' && s=='s')||(f=='r' && m=='r' && s=='p')||(f=='s' && m=='s' && s=='r'))\n printf(\"S\\n\");\n else if((f=='s' && m=='p' && s=='p')||(f=='p' && m=='r' && s=='r')||(f=='r' && m=='s' && s=='s'))\n printf(\"F\\n\");\n else if((f=='p' && m=='s' && s=='p')||(f=='r' && m=='p' && s=='r')||(f=='s' && m=='r' && s=='s'))\n printf(\"M\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "242cd61cffa35fd48963b604da5f61ed", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main() {\n char str[101];\n scanf(\"%s\",&str);\n char *sa=strstr(str,\"ABC\"),*sb=strstr(str,\"ACB\"),*sc=strstr(str,\"BCA\"),*sd=strstr(str,\"BAC\"),*se=strstr(str,\"CAB\"),*sf=strstr(str,\"CBA\");\n if(sa!=NULL||sb!=NULL||sc!=NULL||sd!=NULL||se!=NULL||sf!=NULL)\n printf(\"Yes\");\n else\n printf(\"No\");\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "11a3c7fc777d8bc90b3c9ad59ef0aa8d", "src_uid": "ba6ff507384570152118e2ab322dd11f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/653/submission/19859515 (rainboy) */\n#include \n\n#define Q\t36\n\nint main() {\n\tstatic char ab[Q][4], cc[Q];\n\tstatic int dp[6][6];\n\tint n, q, i, j, k;\n\n\tscanf(\"%d%d\\n\", &n, &q);\n\tfor (i = 0; i < q; i++)\n\t\tscanf(\"%s %c\", ab[i], &cc[i]);\n\tfor (i = 0; i < 6; i++)\n\t\tdp[0][i] = 1;\n\tfor (i = 1; i < n; i++)\n\t\tfor (j = 0; j < 6; j++)\n\t\t\tfor (k = 0; k < q; k++)\n\t\t\t\tif (j + 'a' == cc[k])\n\t\t\t\t\tdp[i][j] += dp[i - 1][ab[k][0] - 'a'];\n\tprintf(\"%d\\n\", dp[n - 1][0]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "41cb947327149374d5b8f4cd82f23cec", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \"stdio.h\" \nint main()\n{\n\tint i,n,d=1;\n\tchar str[101],temp;\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",str);\n\twhile(d<=n)\n\t{\n\t\tif(n%d==0)\n\t\t{\n\t\t\tfor(i=0;i<=(d-1)/2;i++)\n\t\t\t{\n\t\t\t\ttemp = str[i];\n\t\t\t\tstr[i] = str[d-1-i];\n\t\t\t\tstr[d-1-i] = temp;\n\t\t\t}\n\t\t}\n\t\td++;\n\t}\n\tprintf(\"%s\",str);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "39de6a188804ebfacdb056f98355c7c7", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n%2==1)\n printf(\"%d %d\", n/2, n/2+1);\n else if((n/2)%2==1)\n printf(\"%d %d\", n/2-2,n/2+2);\n else\n printf(\"%d %d\", n/2-1,n/2+1);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "b3941102fa9c7b2d0e8e1db7e9f521d9", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(void)\n{\n short counter=0, i=0,size=0;\n\n char string[100];\n\n scanf(\"%s\",string);\n\n size=strlen(string);\n while(i=1){\n printf(\"YES\\n\");\n\n}\nelse\n printf(\"NO\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f8fa244d9612e2eaf8213620455e4afd", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define For(i) for(i=1;i<=9;i++)\nint main(){int x,y,z,t,c1,c2,r1,r2,d1,d2;scanf(\"%d%d%d%d%d%d\",&r1,&r2,&c1,&c2,&d1,&d2);For(x)For(y)For(z)For(t)if(x+y==c1&&z+t==c2&&x+z==r1&&y+t==r2&&x+t==d1&&y+z==d2&&x!=y&&x!=z&&x!=t&&y!=z&&y!=t&&z!=t){printf(\"%d %d\\n%d %d\",x,z,y,t);return 0;}puts(\"-1\");return 0;}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "b4a945f764f1a825868918199f1250a2", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n int a,b,a1,b1,c1,i;\n a1=c1=b1=0;\n scanf(\"%d%d\",&a,&b);\n for(i=1;i<=6;i++){\n if( ((a-i)*(a-i)) < ((b-i)*(b-i)) )a1++;\n \n else if( ((a-i)*(a-i))>((b-i)*(b-i)) )b1++;\n \n else if( ((a-i)*(a-i))==((b-i)*(b-i)) )c1++;\n }\n printf(\"%d %d %d\",a1,c1,b1);\n \n return 0;\n \n}\n \n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "b3cdef5317162b719dbae8981f179d7f", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef unsigned u;\nu A[8],B[8];\nint main()\n{\n\tu i,j,a,b;char c;\n\tfor(a=b=i=-1;++i<8;)A[i]=B[i]=-1;\n\tfor(i=-1;++i<8;)for(j=-1;++j<8;)\n\t{\n\t\twhile((c=getchar())<=' ');\n\t\tif(c=='B')B[j]=i;\n\t\tif(c=='W'&&A[j]==-1u)\n\t\t{\n\t\t\tif(B[j]==-1u)A[j]=i;\n\t\t\telse B[j]=-1u;\n\t\t}\n\t}\n\tfor(i=-1;++i<8;)\n\t{\n\t\tif(a>A[i])a=A[i];\n\t\tif(B[i]!=-1u&&b>7-B[i])b=7-B[i];\n\t}\n\tprintf(a>b?\"B\\n\":\"A\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ace9f6f64e662df70b9e0f436cf99d94", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n \nint min(int a, int b){ return a < b ? a : b; }\nint abs(int x){ return x < 0 ? -x : x; }\n \nint main(){\n int n, m, k;\n scanf(\"%d%d%d\", &n, &m, &k);\n int res = 1e9;\n for(int i=1; i<=n; i++){\n int a;\n scanf(\"%d\", &a);\n if(a != 0 && a <= k) res = min(res, abs(i-m));\n }\n printf(\"%d\", 10*res);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "327c32c5818b9cbda68a340807535220", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nchar a[4][20];\nint main()\n{\n int k,i,j;\n scanf(\"%d\",&k);\n for(i=0;i<4;i++)\n {\n for(j=0;j<20;j++)\n {\n a[i][j] = '#';\n }\n }\n if(k>=4)\n {\n a[0][0] = 'O';\n a[1][0] = 'O';\n a[2][0] = 'O';\n a[3][0] = 'O';\n k-=4;\n for(j=1;j<=10;j++)\n {\n for(i=1;i<=4;i*=2)\n {\n if(!k)\n {\n break;\n }\n a[i-1][j] = 'O';\n k--;\n }\n }\n }\n else\n {\n for(i=0;i<4;i++)\n {\n if(!k)\n break;\n a[i][0] = 'O';\n k--;\n }\n }\n printf(\"+------------------------+\\n\");\n printf(\"|\");\n for(i=0;i<11;i++)\n {\n printf(\"%c.\",a[0][i]);\n }\n printf(\"|D|)\\n\");\n printf(\"|\");\n for(i=0;i<11;i++)\n {\n printf(\"%c.\",a[1][i]);\n }\n printf(\"|.|\\n\");\n printf(\"|\");\n printf(\"%c.......................|\\n\",a[2][0]);\n printf(\"|\");\n for(i=0;i<11;i++)\n {\n printf(\"%c.\",a[3][i]);\n }\n printf(\"|.|)\\n\");\n printf(\"+------------------------+\\n\");\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ed1379be5467e0bd4acc21d510376463", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int i,len;\n char ch,str[110];\n gets(str);\n len=strlen(str);\n for(i=0;i='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))\n {\n ch=str[i];\n }\n }\n if(ch=='A' || ch=='a' || ch=='E' || ch=='e' || ch=='I' || ch=='i' || ch=='O' || ch=='o' || ch=='U' || ch=='u' || ch=='Y' || ch=='y')\n {\n printf(\"YES\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2af3ce781737a22171923cd5e3751659", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void)\n{\n int n, a, b, m, r, *app;\n \n scanf(\"%d %d %d %d\", &a, &b, &m, &r);\n app = (int *)calloc(m, sizeof(int));\n for (n = 1; 1; n++)\n {\n r = (a * r + b) % m;\n if (app[r])\n {\n printf(\"%d\\n\", n - app[r]);\n break;\n }\n else\n app[r] = n;\n }\n \n return 0;\n}", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "7ef612af97e9b077ee4916e370011491", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint isLeap(year)\n{\n\tif(year%4==0 && year%100!=0 || year%400==0)\n\t\treturn 29;\n\telse\n\t\treturn 28;\n}\n\nint no_of_days_remaining(int mon,int year)\n{\n\tint days=0;\n\tswitch(mon)\n\t\t{\n\t\t\tcase 1:days+=31;\n\t\t\tcase 2:days+=isLeap(year);\n\t\t\tcase 3:days+=31;\n\t\t\tcase 4:days+=30;\n\t\t\tcase 5:days+=31;\n\t\t\tcase 6:days+=30;\n\t\t\tcase 7:days+=31;\n\t\t\tcase 8:days+=31;\n\t\t\tcase 9:days+=30;\n\t\t\tcase 10:days+=31;\n\t\t\tcase 11:days+=30;\n\t\t\tcase 12:days+=31;\n\t\t}\n\treturn days;\n}\n\nint no_of_days_passed(int mon, int year)\n\t{\n\t\tint days=0;\n\t\tswitch(mon)\n\t\t\t{\n\t\t\tcase 12:days+=31;\n\t\t\tcase 11:days+=30;\n\t\t\tcase 10:days+=31;\n\t\t\tcase 9:days+=30;\n\t\t\tcase 8:days+=31;\n\t\t\tcase 7:days+=31;\n\t\t\tcase 6:days+=30;\n\t\t\tcase 5:days+=31;\n\t\t\tcase 4:days+=30;\n\t\t\tcase 3:days+=31;\n\t\t\tcase 2:days+=isLeap(year);\n\t\t\tcase 1:days+=31;\n\t\t\t}\n\t\treturn days;\n\t}\n\nint no_of_days(int year)\n{\n\tint k=31*7+30*4+isLeap(year);\n\treturn k;\n}\n\nint main()\n{\n\tint mm1,dd1,yy1,mm2,dd2,yy2,i,j,k,nodA,nodC,nodB=0,nod,start,end,m1,d1,y1,m2,d2,y2;\n\tscanf(\"%d:%d:%d\",&yy1,&mm1,&dd1);\n\tscanf(\"%d:%d:%d\",&yy2,&mm2,&dd2);\n\tif(yy2>yy1)\n\t\t{\n\t\t\tm1=mm1;\n\t\t\ty1=yy1;\n\t\t\td1=dd1;\n\t\t\tm2=mm2;\n\t\t\ty2=yy2;\n\t\t\td2=dd2;\n\t\t}\n\telse\n\t\t{\n\t\t\tm1=mm2;\n\t\t\ty1=yy2;\n\t\t\td1=dd2;\n\t\t\tm2=mm1;\n\t\t\ty2=yy1;\n\t\t\td2=dd1;\n\t\t}\n\t\tnodA=no_of_days_remaining(m1,y1);\n\t\tnodC=no_of_days_passed(m2-1,y2);\n\t\tif(yy2>yy1)\n\t\t{\n\t\t\tstart=yy1;\n\t\t\tend=yy2;\n\t\t}\n\telse\n\t\t{\n\t\t\tstart=yy2;\n\t\t\tend=yy1;\n\t\t}\n\tfor(i=y1+1;i<=y2-1;i++)\n\t{\n\t\tnodB+=no_of_days(i);\n\t}\n\tnod=(nodA-d1+1) + (nodC+d2) + nodB-1;\n\tif(yy1==yy2)\n\t\t{\n\t\t\tif(mm2>mm1)\n\t\t\t //nod=-1*(365-nod+1)+1;\t\n\t\t\t nod=(no_of_days_remaining(mm1,yy1)-dd1+1)-(no_of_days_remaining(mm2,yy2)-dd2+1);\n\t\t\telse if(mm2dd2)\n\t\t\t\t\t\tnod=dd1-dd2;\n\t\t\t\t\telse\n\t\t\t\t\t\tnod=dd2-dd1;\n\t\t\t\t}\n\t\t}\n\tprintf(\"%d\",nod);\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "39722c47fc900ce934cf6438d77c071b", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\tint n,i;\n\tscanf(\"%d\",&n);\n\tfor(i=0;(i*(2*i*i+6*i+4))/12<=n;i++);\n\tprintf(\"%d\",i-1);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "72780ffdb100249a6f2316391d335a33", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int i,j,n,l,a,k;\n\tscanf(\"%lld\",&n);\n\tk=2520;\n\ta=n/k;\n\tprintf(\"%lld\\n\",a);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "57ea84cc35e8283d0afea7bee5d3b93f", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n;\n char s[10];\n scanf(\"%d\",&n);\n scanf(\"%s\",s);\n if(n==6)\n printf(\"espeon\");\n else if(n==8)\n {\n printf(\"vaporeon\");\n }\n else\n {\n if(s[0]=='j' || s[1]=='o' || s[3]=='t')\n printf(\"jolteon\");\n else if(s[0]=='f' || (s[1]=='l' && s[2]=='a' && s[3]=='r') || (s[3]=='r' && (s[2]=='a' || s[1]=='l')))\n printf(\"flareon\");\n else if(s[0]=='u' || s[1]=='m' || s[2]=='b')\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 return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "3beba271f46dc005d1b15b170113bf4a", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n char comp[3][4];\n \n for(int i = 0; i < 3; i++){\n scanf(\"%s\", comp[i]);\n }\n \n char first[3], sec[3], op[4];\n \n for(int i = 0; i < 3; i ++){\n if(comp[i][1] == '>'){\n first[i] = comp[i][0];\n sec[i] = comp[i][2];\n }\n \n else{\n first[i] = comp[i][2];\n sec[i] = comp[i][0]; \n }\n }\n \n if(sec[0] == sec[1])\n printf(\"%c\", sec[0]);\n else if(sec[0] == sec[2])\n printf(\"%c\", sec[0]);\n else if(sec[1] == sec[2])\n printf(\"%c\", sec[2]);\n else;\n \n if(first[0] == first[1]){\n printf(\"%c%c\", first[2], first[0]);\n } \n else if(first[0] == first[2])\n printf(\"%c%c\", first[1], first[0]); \n else if(first[2] == first[1])\n printf(\"%c%c\", first[0], first[1]);\n else\n printf(\"Impossible\");\n} ", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "bb637bc890dce8c52ba80cb7cc2f99c9", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nchar a[105];\n\nint main(){\n\tint n;\n\tint i;\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",a);\n\n\tfor(i=0; i\n\nmain(){\n double d,l,v1,v2;\n scanf(\"%lf %lf %lf %lf\",&d,&l,&v1,&v2);\n printf(\"%0.10lf\",(l-d)/(v1+v2));\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "6c7724a49b94ab93476ffe64e7a913be", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n char str[11];\n scanf(\"%s\", str);\n int len = strlen(str);\n unsigned ans = 1;\n for(int i = 0; i < len; ++i) {\n ans *= str[i] - '0';\n }\n for(int i = 0; i < len; ++i) {\n if(str[i] != '0') {\n unsigned cur = 1;\n for(int j = 0; j < i; ++j) {\n cur *= str[j] - '0';\n }\n cur *= str[i] - '0' - 1;\n if(str[i] == '1' && i == 0) {\n cur = 1;\n }\n for(int j = i + 1; j < len; ++j) {\n cur *= 9;\n }\n if(ans < cur) {\n ans = cur;\n }\n }\n }\n printf(\"%u\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "cb05dcd973ca9af898777a60fd62c5e9", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tint i, l;\n\tstatic char n[11];\n\tstatic char *s[] = {\n\t\t\"O-|-OOOO\",\n\t\t\"O-|O-OOO\",\n\t\t\"O-|OO-OO\",\n\t\t\"O-|OOO-O\",\n\t\t\"O-|OOOO-\",\n\t\t\"-O|-OOOO\",\n\t\t\"-O|O-OOO\",\n\t\t\"-O|OO-OO\",\n\t\t\"-O|OOO-O\",\n\t\t\"-O|OOOO-\"\n\t};\n\tscanf(\"%s\", n);\n\tl = strlen(n);\n\tfor (i = l - 1; i >= 0; i--)\n\t\tprintf(\"%s\\n\", s[n[i] - '0']);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a068f4a6a62943905e9b651a6ee4b769", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n printf((n%4 && n%7 && n%47 && n%74 && n%477)?\"NO\":\"YES\");\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "43fd158c7d77a53e32c1690ddfdf89e4", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int a,b,i,n;\n char s[1000];\n scanf(\"%s\",s);\n n=strlen(s);\n a=b=0;\n for(i=0;i\nint a[53];\nint check(int x)\n{\n\t a[50];\n\t int p=0,j;\n\tfor(j=0;j<=50;j++)\n\t{\n\t\ta[j]=0;\n\t}\n\tj=0;\n\twhile(x)\n\t{\n\t\ta[j]=x%2;\n\t\tx=x/2;\n\t\tp++;\n\t\tj++;\n\t}\n\tif(p%2==0)\n\t\treturn 0;\n\tfor ( j= 0; j< p/2; ++j)\n\t{\n\t\tif(a[j]==1)\n\t\t\treturn 0;\n\t}\n\tfor (j = p/2; j < p; ++j)\n\t{\n\t\tif(a[j]==0)\n\t\t\treturn 0;\n\t}\n\treturn 1;\n\n}\nint main()\n{\n\tint n,i;\n\tscanf(\"%d\",&n);\n\tfor(i=n;i>0;i--)\n\t{ if(n%i==0)\n\t\t{if(check(i))\n\t\t{\n\t\t\tprintf(\"%d\\n\",i);\n\t\t\treturn 0;\n\t\t}}\n\t}\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "1fdfdc32e0bfc9bc21c809b3a1d45d67", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n long long int i,j,k=0,n,x;\n scanf(\"%lld%lld\",&n,&x);\n for(i=1;i<=n;i++)\n {\n if(x%i==0 && x/i<=n)\n {\n k++;\n }\n }\n printf(\"%lld\",k);\n}\n\n ", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "a855104ebc2ac98925009b7b1cb9b2b1", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \"stdio.h\"\n#include \"math.h\"\nvoid desort(int a[50],int size)\n{\n\tint i=0;\n\tint j=0;\n\tint temp=0;\n\t for (i = 0; i < size; ++i)\n \t{\n \tfor (j = i + 1; j < size; ++j)\n \t{\t\n \tif (a[i] < a[j])\n \t{\n \ttemp = a[i];\n \ta[i] = a[j];\n \ta[j] = temp;\n \t}\n \t}\n \t}\n}\nint main()\n{\n\tint n,m,k;\n\tscanf(\"%d %d %d\",&n,&m,&k);\n\tint i=0,a[50],b[50];\n\tfor(i=0;i=device)\n\t\t\t\t{\n\t\t\t\t\tcount++;\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\tcount++;\n\t\t\t\t\tdevice=device-b[i];\n\n\t\t\t\t}*/\n\t\t\t\tif(device>a[i])\n\t\t\t\t{\n\t\t\t\t\tdevice=device-b[i];\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\telse break;\n\t\t\t}\n\t\tprintf(\"%d\\n\",count);\n\t}\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "ca9874e24434d215e5ac7cf6211c7e7c", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int a,b,c;\n\n scanf(\"%d %d %d\",&a,&b,&c);\n\n int K = (a+b-c)/2;\n int K2 = (b+c-a)/2;\n if(K >= 0 && K2>= 0 && a- K >=0 && 2*(K + K2 + (a - K)) == (a + b + c))\n {\n printf(\"%d %d %d\\n\",K,K2,a-K);\n }\n else\n {\n printf(\"Impossible\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "graphs"], "code_uid": "a366090ef07a4f4b509430f249fc8947", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \"stdio.h\"\nint main()\n{\n int a[12][12],n,i,k;\n scanf(\"%d\",&n);\n for (i=1;i<=n;i++)\n {\n a[1][i] = 1;\n a[i][1] = 1;\n }\n for (i=2;i<=n;i++)\n {\n for (k=2;k<=n;k++)\n {\n a[i][k] = a[i][k-1] + a[i-1][k];\n }\n }\n printf(\"%d\",a[n][n]);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "9559569494ad3cd642690cba77a1d808", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n long long int n;\n long long ans = 0, a = 2, b = 1, c = 0;\n scanf(\"%lld\", &n);\n if(n == 2) {printf(\"1\\n\");return 0;}\n else if(n == 3) {printf(\"2\\n\");return 0;}\n else\n while(1)\n {\n if(a > n) break;\n ans++;\n c = b;\n b = a;\n a += c;\n }\n printf(\"%lld\", ans);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "3467947eb40378f25dab8d24d096608d", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nmain()\n{\n\tint sum,g,temp,no[300]={0};\n\tint i,j,k,l,m,n,mid,mid2;\n\tint res,or;\n\tchar s[1000];\n\tscanf(\"%s\",s);\n\ti=0;l=strlen(s);\n\twhile (1) if (s[i++]==':') break;\n mid=i-1;\n\tfor (j=0;j='A' && s[i]<='Z')\n\t\ttemp=s[i]-'A'+10;\n\t\tif (res='A' && s[i]<='Z')\n\t\t\t{\n\t\t\t\ttemp=s[i]-'A'+10;\n\t\t\t\tsum=sum*res+temp;\n\t\t\t}\n\t\t}\n\t\tif (sum>=24) no[res]=1;\n\t\tsum=0;\n\t\tfor (i=mid2+1;i='A' && s[i]<='Z')\n\t\t\t{\n\t\t\t\ttemp=s[i]-'A'+10;\n\t\t\t\tsum=sum*res+temp;\n\t\t\t}\n\t\t}\n\t\tif (sum>=60) no[res]=1;\n\t}\n\n\tif (or+1>=res) putchar('0');\n\telse\n\tfor (i=or+1;i\nint main ()\n{\n\tint a[100000],b[100000],c[100000],i,j,k,B=0,C=0,n;\n\tscanf(\"%d\",&n);\n\tfor(i=0,j=0,k=0;i0)\n\t\t{\n\t\t\tb[j]=a[i];\n\t\t\tj++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tc[k]=a[i];\n\t\t\tk++;\n\t\t}\n\t}\n\tfor(i=0;i\n#include \n#include \n#include \n#include \n\ntypedef long long ll;\ntypedef unsigned int uint;\n\n#define si(x) scanf(\"%d\", &x)\n#define sl(x) scanf(\"%ld\", &x)\n#define sll(x) scanf(\"%lld\", &x)\n#define sc(x) scanf(\"%c\", &x)\n#define ss(x) scanf(\"%s\", x)\n#define f(i, a, b) for(i = a; i < b; i++)\n\nint main() {\n char a[101], b[101];\n\n ss(a);\n ss(b);\n\n int l1 = 0, l2 = 0;\n int countA[26] = {0}, countB[26] = {0}, i;\n for(i = 0; a[i]; i++) {\n countA[a[i] - 'a']++;\n l1++;\n }\n\n for(i = 0; b[i]; i++) {\n countB[b[i] - 'a']++;\n l2++;\n }\n\n if(l2 > l1) {\n printf(\"need tree\\n\");\n return 0;\n }\n\n int flagA = 0, flagB = 0;\n f(i, 0, 26) {\n if(countA[i] > countB[i]) {\n countA[i] = countA[i] - countB[i];\n countB[i] = 0;\n } else {\n countB[i] = countB[i] - countA[i];\n countA[i] = 0;\n }\n\n if(countA[i] > 0)\n flagA = 1;\n\n if(countB[i] > 0)\n flagB = 1;\n }\n\n if(!flagA && !flagB)\n printf(\"array\\n\");\n else if(flagB)\n printf(\"need tree\\n\");\n else {\n int j = 0;\n\n f(i, 0, l2) {\n while(j < l1 && b[i] != a[j])\n j++;\n\n if(j == l1)\n break;\n else\n j++;\n }\n\n if(i == l2)\n printf(\"automaton\\n\");\n else\n printf(\"both\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "a6eecfc3cadae62666702612a43263d0", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint x;\nint main()\n{\n scanf(\"%x\",&x);\n printf(\"%d\",x%2);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "98ae2e06c6d967f939ffaa7e75ff0dd1", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n//#include \nint main()\n{\n int n,i,j,f=0;\n\n scanf(\"%d\",&n);\n int *a=(int *)calloc(n+1,sizeof(int));\n a[1]=1;\n j=1;\n for(i=1;i\n#include \n\nint max(int a, int b) {\n\treturn a >= b ? a : b;\n}\n\nint main(void) {\n\tchar a[5];\n\tchar b[5];\n\t\n\tscanf(\"%s%s\", &a, &b);\n\t\n\tint a_length = strlen(a);\n\tint b_length = strlen(b);\n\t\n\tint max_digit = 0;\n\tint i;\n\tfor (i = 0; i < a_length; i++) {\n\t\ta[i] -= '0';\n\t\tmax_digit = max(max_digit, a[i]);\n\t}\n\t\n\tfor (i = 0; i < b_length; i++) {\n\t\tb[i] -= '0';\n\t\tmax_digit = max(max_digit, b[i]);\n\t}\n\t\n\tint base = max_digit + 1;\n\t\n\ti = a_length - 1;\n\tint j = b_length - 1;\n\tint carry = 0;\n\tint sum;\n\twhile (i >= 0 || j >= 0) {\n\t\tsum = 0;\n\t\tif (i >= 0) { sum += a[i]; i--; }\n\t\tif (j >= 0) { sum += b[j]; j--; }\n\t\tsum += carry;\n\t\tcarry = sum / base;\n\t}\n\t\n\tint result = max(a_length, b_length);\n\tif (carry) result++;\n\t\n\tprintf(\"%d\\n\", result);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "5ca49b3f6cb5255d6b63bb3bf122729f", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,k,n,w;\n int sum=0;\n scanf(\"%d%d%d\",&k,&n,&w);\n for(i=1;i<=w;i++)\n {\n sum+=i*k;\n }\n if(sum>n)\n {\n printf(\"%d\\n\",sum-n);\n\n }\n else\n printf(\"0\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "ddeb2120bdce3df809d4f0056d1880a2", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nunsigned long long int pgcd(unsigned long long int x,unsigned long long int y)\n {\n if (x==0) return y;\n if (y==0) return x;\n if ((x==1) || (y==1)) return 1;\n if (x==y) return x;\n if (x\n#include \n#include \n#include \n#include \n\nint main()\n{\n int n,m;\n scanf(\"%d %d\", &n, &m);\n int count = 0;\n int a, b = 0;\n for (a = 0; b >= 0; a++)\n {\n b = n - a * a;\n if (a + b * b == m && b >= 0)\n count++;\n }\n printf(\"%d\\n\", count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "82a2d7546af126ac82d43086ee31d35d", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int d,m,c=0,i,a[4]= {4,6,9,11},f=2;\n scanf(\"%d%d\",&m,&d);\n d=8-d;\n if(a[0]==m||a[1]==m||a[2]==m||a[3]==m)\n d=30-d;\n else if (f==m)\n d=28-d;\n else\n d=31-d;\n c=d/7;\n if(d%7!=0)\n c++;\n printf(\"%d\\n\",c+1);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "b491ae03ff78bffa8e5961d855717d3a", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n long int n; scanf(\"%ld\", &n);\n int flag = 0;\n for(long int i = n / 1234567; i >= 0; i--){\n for(long int j = (n - 1234567 * i) / 123456; j >= 0; j--){\n if ((n - (1234567 * i + 123456 * j)) % 1234 == 0) flag = 1;\n }\n }\n if(flag) printf(\"YES\");\n else printf(\"NO\");\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "08e54371adef0f4b7a13d31973ed6b57", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n \n int w,h,w1,h1,w2,h2;\n scanf(\"%d %d %d %d %d %d\",&w,&h,&w1,&h1,&w2,&h2);\n \n int ans=w;\n for(int i=h ; i>=0 ; i--)\n {\n ans+=i;\n if(h1==i)\n ans -= w1;\n else if(h2==i)\n ans -= w2;\n \n if(ans<0)\n ans=0;\n \n \n }\n printf(\"%d\",ans);\n \n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3b34ab11021bdeded37d6d927f1fdb27", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n char arr[10];\n int n,m;\n float hr,min;\n scanf(\"%s\",arr);\n n=(arr[0]-48)*10+(arr[1]-48);\n if(n>=12)\n n-=12;\n hr=n*30;\n m=(arr[3]-48)*10+(arr[4]-48);\n hr+=(float)m/2;\n min=6*m;\n printf(\"%f %f\\n\",hr,min);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "ebfa4cb1750cc86c641e1cb9731f18fe", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n unsigned long long l1,r1,l2,r2,k,start,end,sum=0;\n scanf(\"%llu%llu%llu%llu%llu\",&l1,&r1,&l2,&r2,&k);\n if(l2>r1 || r2l2)\n start=l1;\n else \n start=l2;\n if(r2==r1)\n end =r2;\n else if(r2>r1)\n end=r1;\n else\n end=r2;\n sum=sum+end-start+1;\n if(k>=start && k<=end)\n sum=sum-1;\n printf(\"%llu\",sum);\n }\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "aaba5a67b8720f7f4ad3bcddf5f32a7e", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n;\n\twhile(scanf(\"%d\\n\",&n)!=EOF)\n\t{\n\t\tint a,b,m=n,x=0,y=0,s=1;\n\t\tscanf(\"%d\\n%d\",&a,&b);\n\t\twhile(1)\n\t\t{\n\n\t\t\tif(m>=a&&x<4)\n\t\t\t{\n\t\t\t\tm=m-a;\n\n\t\t x++;\n\t\t\t}\n\t\t\tif(m>=b&&y<2)\n\t\t {\n m=m-b;\n y++;\n\t\t }\n\t\t if(x==4&&y==2)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(x<4&&y<2)\n\t\t\t{\n\t\t\t\tif(m\n#include\nlong long n,m,a,pows,i,c;\nint main() {\n\nscanf(\"%I64d%I64d\",&n,&m);\nif(n>=34)\nprintf(\"%I64d\",m);\nelse\n{\n pows=2;\n for(i=1;i\n#include \n\nint n,k;\nint dem[101];\nint main()\n{\n\tint web,i;\n\tscanf(\"%d%d\",&n,&k);\n\tfor(i=1 ; i<=n ; i++)\n\t{\n\t\tscanf(\"%d\",&web);\n\t\tdem[i%k]+=web;\n\t\tdem[k]+=web;\n\t}\n\t\n\tint kq=0;\n\tfor(i=0 ; idem[i]?kq:dem[i];\n\t}\n\t\n\tprintf(\"%d\",kq);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "04e42e7478d24c2467f5c246bf10acf7", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n char s[100];\n scanf(\"%s\",s);\n\n\n\n\n int l = strlen(s);\n int len = 0;\n\n for(int i = 0; ilen)\n len = n;\n }\n }\n\n printf(\"%d\\n\",len);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "3f1473b75e501f802593e723cc2aecb1", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n, amount=0;\n scanf(\"%d\", &n);\n int b[3001] = {0};\n int factores[3001] = {0};\n for (int i = 2; i <= n; ++i)\n {\n if (!b[i]){\n for (int j = i + i; j <= n; j += i){\n b[j] = 1;\n factores[j] += 1;\n }\n }\n \n if (factores[i] == 2)amount++;\n }\n printf(\"%d\\n\", amount);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "b1bc1735451bea8b5bf18f05bbc5f84d", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "int i,j,N,u[100001],D[100001],C[100001],r[100001],x,d;\nint main () {\n scanf(\"%d\",&N);\n for (i=3;i<=N;++i) {\n for (j=2;2*i>=j*(j+1);++j) if ((i-j*(j+1)/2)%j==0) {\n x=(i-j*(j+1)/2)/j,d=C[x+j]^C[x];\n u[d]=i;\n if (!r[i] && !d) r[i]=j;\n }\n while (u[D[i]]==i) ++D[i];\n C[i]=C[i-1]^D[i];\n }\n if (!D[N]) printf(\"-1\");\n else printf(\"%d\\n\",r[N]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "games"], "code_uid": "7c26839e3ced9b918e5d63815ef22ebf", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n long long int i, b;\n long long int count=0;\n long long int flag=0;\n scanf(\"%lld\", &b);\n for(i=1; i*i<=b; i++)\n {\n if(b%i==0)\n count++;\n if(i*i==b)\n flag=1;\n }\n if(flag==0)\n count=(2*count);\n else\n count=((2*count)-1);\n printf(\"%lld\\n\", count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "fa76acab85e9f40b2dd15d4519831160", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n%2==0)\n\t{\n\t printf(\"%d\\n\",n/2-1);\n\t}\n\telse \n\t{\n\t printf(\"%d\\n\",n/2);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "9be0bb2e592c085a62ca396ad5b82a16", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int n,p,r,r2,t;\n scanf(\"%d\",&n);\n if (n%2==0)\n {\n r=n/2*n/2;\n r2=n/2*n/2;\n }\n else\n {\n r=((n+1)/2)*((n+1)/2);\n r2=((n-1)/2)*((n-1)/2);\n }\n\n t=r+r2;\n if (t%2==0)\n {\n printf(\"2\");\n }\n else\n {\n printf(\"1\");\n }\n\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "787f9cf314e2417907ed00b9a47e4caf", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n int left = 0, right = 0;\n int n = 0, m = 0, k = 0;\n int i = 1, val = 1;\n \n scanf(\"%d %d %d\", &n, &m, &k);\n left = right = k;\n m -= n;\n \n while (m >= i) {\n val++;\n m -= i;\n if (left > 1) {\n left--;\n i++;\n }\n \n if (right < n) {\n right++;\n i++;\n }\n \n if (left == 1 && right == n) {\n val = val + m / n;\n break;\n }\n }\n \n printf(\"%d\\n\", val);\n\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "binary search"], "code_uid": "bdaa2f6d92d039059fbd7502cac6f93a", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint selectSort(int *mas, int n){\n\tint tmp,i,j;\n\tint cur=0;\n\tfor (i=0;imas[j]){\n\t\t\t\ttmp=mas[i];\n\t\t\t\tmas[i]=mas[j];\n\t\t\t\tmas[j]=tmp;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\nint main(){\n\tint st[100];\n\tint n,i,j,max,count,t;\n\tscanf(\"%d\",&n);\n\tfor (i=0;i\n#include\nconst int N=1000000007;\nint main(){\n\tint n;\n\tscanf(\"%d\",&n);\n\twhile(n--){\n\t\tlong long a,b;\n\t\tscanf(\"%lld%lld\",&a,&b);\n\t\tlong long t=1;\n\t\twhile(b--){\n\t\t\tt=t*a;\n\t\t\tt=t%N;\n\t\t}\n\t\tprintf(\"%lld\\n\",t);\n\t} \n\treturn 0;\n} \n \t \t \t\t \t\t \t \t \t\t\t\t\t \t \t", "lang_cluster": "C", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "66f13ef033653c31f1be791b89a4dcb6", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,k;\n scanf(\"%lld %lld\", &n,&k);\n if(k==1)\n printf(\"%lld\",n);\n else\n { long long i = 1;\n while(i\nint main(){\n int n,m;\n scanf(\"%d%d\",&n,&m);\n int count=0;\n for(int i=1;i<=n;i++){\n if(i%m==0){\n if(i>=(float)n/2 && i<=n){\n printf(\"%d\",i);\n count++;\n break;\n }\n }\n }\n if(count==0)\n printf(\"-1\");\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "bad98df0c71cc95d269668b898bb92e2", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main(){\n\tint n,i, count1, count2, Scount, Ncount;\n\tchar c[10] = {118,60,94,62};\n\tchar ch1, ch2;\n\tscanf(\"%c %c\", &ch1, &ch2);\n\tscanf(\"%d\", &n);\n\tfor(i = 0;i < 4; i++)\n\t{\n\t\tif(ch1 == c[i])\n\t\t\tcount1 = i;\n\t\tif(ch2 == c[i])\n\t\t\tcount2 = i;\n\t}\n\t\n\tif(ch1 == ch2||count1-count2 == 2 ||count2 - count1 ==2)\n\t{\n\t\tprintf(\"undefined\\n\");\n\t\treturn 0;\t\t\n\t}\n\telse if(count1 > count2)\n\t{\n\t\tScount = count2- count1 + 4;\n\t\tNcount = count1 - count2;\n\t}\n\telse\n\t{\n\t\tScount = count2 - count1;\n\t\tNcount = count1 - count2 + 4;\n\t}\n\tint num = n % 4;\n\tif((Scount != num)&&(Ncount != num)||(Scount == num)&&(Ncount == num))\n\t\tprintf(\"undefined\\n\");\n\telse if(Scount == num&&Ncount != num)\n\t\tprintf(\"cw\\n\");\n\telse\n\t\tprintf(\"ccw\\n\");\n\treturn 0;\n} \n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b163baf3636fa011d5a46a9c3f9ab717", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nmain(){\n int n;\n scanf(\"%d\",&n);\n if(n%2==1)\n printf(\"1\");\n else printf(\"0\");\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "e1227ae1e88346dbfdaf6876663f862d", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,a,b,c,k,l;\n scanf(\"%d%d%d\",&a,&b,&c);\n if((a+b)==c){\n printf(\"1\\n\");\n return 0;\n }\n k=a;\n k=k\nint main()\n{\n int n,b,p,nb,np,temp,count=0,r;\n scanf(\"%d %d %d\",&n,&b,&p);\n printf(\"%d %d\",(n-1)*(2*b+1),n*p);\n\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "47c2647bd343c3a5fb00208e095c8f0f", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint a[7][7];\nint ju[10][10],n,book[5];\nint ans[1001]={0};\n\nint judge(int k,int m)\n{\n\tint i;\n\tif (k<=9)\n\t for (i=1;i<=n;i++)\n\t if (ju[i][k]==1&&book[i]==1)\n\t {\n\t ans[m]=1;\n\t return 0;\n\t }\n\tif (k<=99)\n\t for (i=1;i<=n;i++)\n\t if ((ju[i][k/10]==1)&&book[i]==1)\n\t {\n\t \tbook[i]=0;\n\t \tjudge(k%10,m);\n\t \tbook[i]=1;\n\t }\n\tif (k>=100) \n\tfor (i=1;i<=n;i++)\n\t if ((ju[i][k/100]==1)&&book[i]==1)\n\t {\t\n\t book[i]=0;\n\t \t judge(k%100,m);\n\t \t book[i]=1;\n\t }\n\treturn 0;\n }\n\t \n\nint main()\n{\n\tint j,k,l,i;\n\tscanf(\"%d\",&n);\n\tfor (i=1;i<=n;i++)\n\t book[i]=1;\n\tfor (i=1;i<=n;i++)\n\t for (j=1;j<=6;j++)\n\t {\n\t scanf(\"%d\",&a[i][j]);\n\t ju[i][a[i][j]]=1;\n }\n for (i=1;i<=999;i++)\n\t judge(i,i);\n\tfor (i=1;i<=999;i++)\n\t if (ans[i]==0)\n\t {\n\t\t printf(\"%d\\n\",i-1);\n\t\t return 0;\n\t }\n \n\n\treturn 0;\n } \n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "ba7894bac6c09441028b750c22bc0da2", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,d[100],i=1,e=0;\n scanf(\"%d %d %d\",&a,&b,&c);\n d[i]=a+b*c;i++;\n d[i]=a*(b+c);i++;\n d[i]=a*b*c;i++;\n d[i]=(a+b)*c;i++;\n d[i]=a+b+c;\n for(i=1;i<=5;i++)\n {\n if(d[i]>e)\n e=d[i];\n }\n printf(\"%d\",e);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "cbe9709c84b90bbd89e1e0068da1dd56", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,b,c,n;\n\tscanf(\"%d %d %d %d\",&a,&b,&c,&n);\n\tint ans;\n\tans=n-(a+b-c);\n\tif(ans<=0||c>a||c>b)\n\tprintf(\"-1\");\n\telse printf(\"%d\",ans);\n\t\n\t\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fa829d1ca2a4e06a94f7f107fbf8c0b2", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,a,b,p,q,a1,b1,ab,c=0,temp;\n long long ans,lcm,m;\n scanf(\"%d%d%d%d%d\",&n,&a,&b,&p,&q);\n a1=n/a;\n b1=n/b;\n m=1ll*a*b;\n while(a&&b)\n {\n temp=b%a;\n b=a;\n a=temp;\n }\n lcm=m/b;\n ab=n/lcm;\n //printf(\"%d\\n\",lcm);\n if(p>q)\n {\n b1=b1-ab;\n }\n else\n {\n a1=a1-ab;\n }\n ans=1LL*p*a1+1LL*q*b1;\n printf(\"%lld\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "ed2031b0bd9aa043e1c0564d3222466a", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint answer(double a,double b,double c)\n{\n int res=0;\n\tif(c>=a&&c<=b)\n res++;\n\n return res;\n}\n\nint main()\n{\n\tint h,t1,t2,temp,k=0;\n\tint m,s;\n\tdouble a,b,c,d,e;\n\tscanf(\"%d %d %d %d %d\",&h,&m,&s,&t1,&t2);\n\n\t\tif(t1>t2){\n\t\ttemp=t1;\n\t\tt1=t2;\n\t\tt2=temp;\n\t\t}\n\n\t\ta=t1*30.0;\n\t\tb=t2*30.0;\n\t\tc=(h*30)+m*0.5+s/120.0;\n\t\td=m*6.0+s*1.0/60.0;\n\t\te=s*6.0;\n\n\t\tk=k+answer(a,b,c);\n\t\tk=k+answer(a,b,e);\n\t\tk=k+answer(a,b,d);\n\t\tif(k==0||k==3)\n printf(\"YES\");\n\t\telse\n printf(\"NO\");\n\n\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "873f5e46b87773e3b053919ac49a1671", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n/*int cmp(const void *a, const void *b)\n{\n return(*(int *)a-*(int *)b);\n}*/\n// qsort(a,n,sizeof(a[0]),cmp);\n\n\nint main()\n{\n int a,b,c,x,y,z;\n scanf(\"%d %d %d\",&a,&b,&c);\n scanf(\"%d %d %d\",&x,&y,&z);\n if((a>x) && (b>y) && (c>z))\n {\n printf(\"Yes\");\n }\n else if((a=x) && (b<=y) && (c<=z))\n {\n if((a-x)/2 >= (y-b+z-c))\n {\n printf(\"Yes\");\n }\n else\n {\n printf(\"No\");\n }\n }\n else if((a>=x) && (b>=y) && (c<=z))\n {\n if((a-x)/2 + (b-y)/2 >= (z-c))\n {\n printf(\"Yes\");\n }\n else\n {\n printf(\"No\");\n }\n }\n else if((a>=x) && (b<=y) && (c>=z))\n {\n if((a-x)/2 + (c-z)/2 >= (y-b))\n {\n printf(\"Yes\");\n }\n else\n {\n printf(\"No\");\n }\n }\n else if((a<=x) && (b>=y) && (c>=z))\n {\n if((b-y)/2 + (c-z)/2 >= (x-a))\n {\n printf(\"Yes\");\n }\n else\n {\n printf(\"No\");\n }\n }\n else if((a<=x) && (b<=y) && (c>=z))\n {\n if((c-z)/2 >= (x-a+y-b))\n {\n printf(\"Yes\");\n }\n else\n {\n printf(\"No\");\n }\n }\n else if((a<=x) && (b>=y) && (c<=z))\n {\n if((b-y)/2 >= (x-a+z-c))\n {\n printf(\"Yes\");\n }\n else\n {\n printf(\"No\");\n }\n }\n else\n {\n printf(\"Yes\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0fac884e9a64e51f42000b99e5f33e90", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint sai(const void* a,const void* b)\n{\n\treturn *(int*)a-*(int*)b;\n}\nint main( )\n{\n\tint n,d,a[101]={0},m,i,j,k,c=0;\n\tscanf(\"%d %d\",&n,&d);\n\tfor(i=0;i\nint main()\n{\n int x, y, z;\n scanf(\"%d%d%d\",&x,&y,&z);\n if(x==0||y==0||z==0){\n if(x==0 && y>z){\n printf(\"-\");\n }\n\n else if(y==0 && x>z){\n printf(\"+\");\n\n }\n else if(z==0){\n if(y==x && x>0 && y>0){\n printf(\"0\");\n }\n else if(x>y){\n printf(\"+\");\n }\n else if(xy||y>x){\n if(y+z\n#include\nint h[101];\nchar s[101];\nint main()\n{\n\tint n,d,l,is;\n\tfor(int i=0;i<101;i++)\n\t{\n\t\th[i]=1000;\n\t}\n\tscanf(\"%d%d%s\",&n,&d,&s);\n\tl=strlen(s);\n\th[0]=0;\n\tif(s[0]=='0')\n\t{\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\tfor(int i=1;i=0;t++)\n\t\t\t{\n\t\t\t\tif(s[i-t]=='1')\n\t\t\t\t{\n\t\t\t\t\tif(h[i-t]+1999)\n\t{\n\t\tprintf(\"-1\");\n\t}\n\telse\n\t{\n\t\tprintf(\"%d\",h[l-1]);\n\t}\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "c75ea55bb2db0a2a0dfa77fdbedcd418", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar buf[200]; \n\nint main()\n{ \n int i,len,flag=0; \n \n \n scanf(\"%s\",buf); \n \n len =strlen(buf);\n \n for(i=0;i\n#define m 1000000007\n\nlong int power(long int a,long int b)\n{\n long int ans=1;\n if(b==0)\n return 1;\n while(b>0) {\n if (b % 2 != 0)\n ans= ans * a;\n a = a * a;\n b = b / 2;\n }\n return ans;\n}\n\nint main()\n{\n long int n,i=0,index=0;\n scanf(\"%ld\",&n);\n while(n>0)\n {\n int rem=n%10;\n if(rem==4)\n index+=power(2,i);\n else\n index+=power(2,i+1);\n n=n/10;\n i++;\n }\n printf(\"%ld\\n\",index);\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "51111ec64c1360592d2ce290b6c77eaa", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nmain()\n{\n int n,i,x,b[1010],count=0,a[100];\n scanf(\"%d\",&n);\n\n for(i=0;i<1010;i++){\n b[i]=0;\n }\n\n for(i=0;i0 && b[i+1]>0 && b[i+2]>0){\n printf(\"YES\\n\");\n count=1;\n break;\n }\n }\n if(count==0)printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "sortings", "implementation"], "code_uid": "f64c058008e085c245b1d112e6cabd8f", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include \n\nint main()\n{\n char s[101];\n int n, i, j, l, k;\n scanf(\"%s\", s);\n l = strlen(s);\n\n for(i=1,k=1, j=1; i5)\n {\n k++;\n j=1;\n }\n }\n printf(\"%d\\n\", k);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b9e1d34866c3cebc56d166f1870572d2", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint x;\n\tscanf(\"%d\", &x);\n\tif (x % 4 == 1)\n\t\tprintf(\"0 A\");\n\telse if (x % 4 == 0)\n\t\tprintf(\"1 A\");\n\telse if (x % 4 == 2)\n\t\tprintf(\"1 B\");\n\telse\n\t\tprintf(\"2 A\");\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "978993200ee87f31014c775d82c4e33a", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tint n,a = 0,i,j,h,sayac=0;\n\tscanf(\"%d\",&n);\n\tchar d[n],k;\n\tfor(i = 1 ; i <= n ; i++)\n\t{\n\t\tscanf(\" %c\",&k);\n\t\tif(k == '0')\n\t\t{\n\t\t\ta = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%d\",a + n * (a == 0));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "41463b29894c07b12d5088d64955eb7c", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a, b, c, x, y, z;\n scanf(\"%d%d%d%d%d%d\",&x,&y,&z,&a,&b,&c);\n a -= x;\n if(a<0){\n printf(\"NO\\n\");\n return 0;\n }\n if(a+b < y){\n printf(\"NO\\n\");\n return 0;\n }\n if(a+b+c-y < z){\n printf(\"NO\\n\");\n return 0;\n }\n else\n printf(\"YES\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "06f3eb36ebaf8aa04a155bddeffb43eb", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long summer(long long a)\n{\n long long sum =0;\n while(a>0)\n {\n sum+=a%10;\n a/=10;\n }\n return sum;\n}\n\nint main()\n{\n long long n;\n scanf(\"%lld\",&n);\n long long b=0;\n while(b\n\nint main()\n{\n int n, x[103], y;\n scanf(\"%d\", &n);\n for(int i=0; iy)y=x[i+1]-x[i];\n printf(\"%d\", y);\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "f2f5df09c3e41e997133fc718a279325", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint min(int a,int b){\n return a>b?b:a;\n}\nint max(int a,int b){\n return a\n\n#define M\t100000\n\nint main() {\n\tint i, n, m;\n\n\tscanf(\"%d\", &n);\n\tn = n / 10000 * 10000 + (n / 100) % 10 * 1000 + n % 10 * 100 + (n / 10) % 10 * 10 + (n / 1000) % 10;\n\tm = 1;\n\tfor (i = 0; i < 5; i++)\n\t\tm = (long long) n * m % M;\n\tprintf(\"%05d\\n\", m);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "30ded1ddfc88047460c0b78ffedd5fde", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint\nmain()\n{\n int n, x=0, y=0;\n scanf(\"%d%*c\", &n);\n for (int i = 0; i < n; ++i) {\n char c;\n scanf(\"%c\", &c);\n if (c == 'U') {\n y += 1;\n }\n else if (c == 'D') {\n y -= 1;\n }\n else if (c == 'R') {\n x += 1;\n }\n else if (c == 'L') {\n x -= 1;\n }\n else {\n assert(0);\n }\n }\n if (x < 0) x = -x;\n if (y < 0) y = -y;\n printf(\"%d\\n\", n - x - y);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "f261d74d74906193fc1a2d02309f8156", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint a[100];\nint main(){\n\tchar p[101];\n\tint ans=0;\n\ta['>']=8;\n\ta['<']=9;\n\ta['+']=10;\n\ta['-']=11;\n\ta['.']=12;\n\ta[',']=13;\n\ta['[']=14;\n\ta[']']=15;\n\tint l,i;\n\tscanf(\"%s\", p);\n\tl = strlen(p);\n\tfor(i=0;i\n * \n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n * MA 02110-1301, USA.\n * \n * \n */\n\n\n#include \nint main(){\n\tint n,k;\n\tscanf(\"%d%d\",&n,&k);\n\tint a[n];\n\tfor(int i=0;i1){\n\t\twhile((f1==0||f2==0)&&(i<=j)){\n\t\t\tif(a[i]<=k){cnt++;i++;}\n\t\t\telse{f1=1;}\n\t\t\tif(a[j]<=k){cnt++;j--;}\n\t\t\telse{f2=1;}\n\t\t\tif(i==j&&a[i]<=k&&a[j]<=k){cnt--;}\n\t\t\t}\n\t\t}\n\t\tif(n==1&&a[0]<=k){cnt=1;}\n\t\tprintf(\"%d\\n\",cnt);\n\t\treturn 0;\n\t}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "33c621ac28faa7d3f1c0bf2375c02e2c", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main(){\n char s[101];\n scanf(\"%s\",s);\n int cnt1=0,cnt2=0;\n for(int i=0;i=cnt2){\n s[i]=tolower(s[i]);\n }else if(cnt1\n\nlong long mini(long long a, long long b, long long c)\n{\n\n return a<=b?a<=c?a:c : b<=c?b:c;\n\n}\n\nint main(void)\n{\n\n\nlong long min,n,a,b,c;\n\nscanf(\"%lld%lld%lld%lld\",&n,&a,&b,&c);\n\nif(n%4==0)\n{\nprintf(\"0\");\nreturn 0;\n}\n\nelse if(n%4==3)\n{\n\nmin = mini(a,b+c,3*c);\n\n}\n\nelse if(n%4==2)\n{\n\n min = mini(2*a, b, 2*c);\n\n}\n\nelse if(n%4==1)\n{\n\nmin = mini(3*a, c, a+b);\n\n}\n\nprintf(\"%lld\",min);\n\nreturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "2f74e66448512d18c34b22331e44b080", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,a,x,b,y;\n scanf(\"%d %d %d %d %d\",&n,&a,&x,&b,&y);\n while(1)\n {\n if(a==b)\n {\n printf(\"YES\\n\");\n return 0;\n }\n if(a==x || b==y)\n break;\n if(a==n-1)\n a=n;\n else\n a=(a+1)%n;\n if(b==1)\n b=n;\n else\n b=(b-1+n)%n;\n }\n printf(\"NO\");\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e4a8e535097f471cc59d2f9be8045e38", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint cmpfun(const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\nint main()\n{\n int a,ac,b,bc,cc,c,n,i,days=0,day,j,d[3];\n scanf(\"%d %d %d\",&a,&b,&c);\n d[0]=a/3;\n d[1]=b/2;\n d[2]=c/2;\n qsort(d,3,sizeof(int),cmpfun);\n\n day=d[0]*7;\n a-=(d[0]*3);\n b-=(d[0]*2);\n c-=(d[0]*2);\n\n for(j=1;j<8;j++)\n {\n n=0;\n ac=a;\n bc=b;\n cc=c;\n i=j;\n while(1)\n {\n\n if(i==1||i==4||i==7)\n {\n if(ac==0)break;\n ac--;\n }\n else if(i==2||i==6)\n {\n if(bc==0)break;\n bc--;\n }\n else\n {\n if(cc==0)break;\n cc--;\n }\n if(i==7)i=1;\n else i++;\n n++;\n //printf(\"%d %d %d\\n\",ac,bc,cc);\n }\n if(days\nint minimo(int a, int b);\nint main(){\n int v[5], i, j, k, total = 0, min;\n for(i = 0; i < 5; i++){\n scanf(\"%d\", &v[i]);\n total = total + v[i];\n }\n min = total;\n for(i = 0; i < 5; i++){\n for(j = i + 1; j < 5; j++){\n if(v[i] == v[j]){\n if(total - 2*v[i] < min)\n min = total - 2*v[i];\n }\n }\n }\n for(i = 0; i < 5; i++){\n for(j = i + 1; j < 5; j++){\n for(k = j + 1; k < 5; k++){\n if(v[i] == v[j] && v[i] == v[k]){\n if(total - 3*v[i] < min)\n min = total - 3*v[i];\n }\n }\n }\n }\n printf(\"%d\", min);\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "a132a8e903fa2134e835418767582c10", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n #include\n\nint main()\n{\n int a,b,c,d,h=0;\n scanf(\"%d%d%d%d\",&a,&b,&c,&d);\n if(a==b || a==c || a==d)\n h=h+1;\n if(b==c || b==d)\n h=h+1;\n if(c==d)\n h=h+1;\n printf(\"%d\",h);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c9c74ec4b2c5d633f9ef7476692ee0a6", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n\nconst char *presidents[] = {\n\t\"Washington\",\n\t\"Adams\",\n\t\"Jefferson\",\n\t\"Madison\",\n\t\"Monroe\",\n\t\"Adams\",\n\t\"Jackson\",\n\t\"Van Buren\",\n\t\"Harrison\",\n\t\"Tyler\",\n\t\"Polk\",\n\t\"Taylor\",\n\t\"Fillmore\",\n\t\"Pierce\",\n\t\"Buchanan\",\n\t\"Lincoln\",\n\t\"Johnson\",\n\t\"Grant\",\n\t\"Hayes\",\n\t\"Garfield\",\n\t\"Arthur\",\n\t\"Cleveland\",\n\t\"Harrison\",\n\t\"Cleveland\",\n\t\"McKinley\",\n\t\"Roosevelt\",\n\t\"Taft\",\n\t\"Wilson\",\n\t\"Harding\",\n\t\"Coolidge\",\n\t\"Hoover\",\n\t\"Roosevelt\",\n\t\"Truman\",\n\t\"Eisenhower\",\n\t\"Kennedy\",\n\t\"Johnson\",\n\t\"Nixon\",\n\t\"Ford\",\n\t\"Carter\",\n\t\"Reagan\",\n\t\"Bush\",\n\t\"Clinton\",\n\t\"Bush\",\n\t\"Obama\" };\n\nint main()\n{\n\tint i;\n\tif (scanf(\"%d\", &i) == 1) printf(\"%s\\n\", presidents[i - 1]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c9f8f0d4aa956fc8f915c4c7cf833c78", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n\tchar a[55];\n\tint i,count=0,n;\n\tscanf(\"%d\",&n);\n scanf(\"%s\",a);\n\tfor(i=0;i\n#include \n#include \n\ntypedef unsigned int uint;\n\nint cmpfuncAZ(const void *a, const void *b) {\n return *(uint*)a - *(uint*)b;\n}\nint cmpfuncZA(const void *a, const void *b) {\n return *(uint*)b - *(uint*)a;\n}\n\nvoid sort(uint b[], bool order) {\n if (order) {\n qsort(b, 3, sizeof(uint), cmpfuncZA);\n } else {\n qsort(b, 3, sizeof(uint), cmpfuncAZ);\n }\n}\n\nuint sum(uint b[]) {\n uint res = 0;\n for (uint i = 0; i < 3; i++) res += b[i];\n return res;\n}\n\nint main() {\n uint left[3], right[3], n[6];\n \n for (uint i = 0; i < 6; i++) {\n char c;\n scanf(\"%c\", &c);\n n[i] = atoi(&c);\n }\n\n for (uint i = 0; i < 3; i++) {\n left[i] = n[i];\n right[i] = n[i+3];\n }\n\n int diff = sum(left) - sum(right);\n\n if (diff < 0) {\n sort(left, false);\n sort(right, true);\n for (uint i = 0; i < 3; i++)\n left[i] = 9 - left[i];\n diff = -1 * diff;\n } else\n if (diff > 0) {\n sort(left, true);\n sort(right, false);\n for (uint i = 0; i < 3; i++)\n right[i] = 9 - right[i];\n } else {\n puts(\"0\\n\");\n return 0;\n }\n\n // for (uint i = 0; i < 3; i++)\n // printf(\"%d \", left[i]);\n // puts(\"\\n\");\n // for (uint i = 0; i < 3; i++)\n // printf(\"%d \", right[i]);\n // puts(\"\\n\");\n\n uint costL = 0, costR = 0, costLR = 0, tmp;\n\n // Change left side\n tmp = 0;\n while (tmp < diff) {\n tmp += left[costL];\n costL++;\n }\n\n // Change right side\n tmp = 0;\n while (tmp < diff) {\n tmp += right[costR];\n costR++;\n }\n\n // Change both sides\n tmp = 0;\n uint i = 0, j = 0;\n\n while (tmp < diff) {\n if (costLR % 2 == 0) {\n tmp += left[i];\n i++;\n } else {\n tmp += right[j];\n j++;\n }\n costLR++;\n }\n\n uint costs[3] = {costL, costR, costLR};\n sort(costs, false);\n\n // for(uint i = 0 ; i < 3; i++) printf(\"%d \", costs[i]);\n // puts(\"\\n\");\n\n printf(\"%d\\n\", costs[0]);\n\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "343d32dc496a9b63490bbdb3275d93d2", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint a, b,diff=0,i,count=0;\n\tscanf(\"%d %d\", &a, &b);\n\tif (a < b)\n\t\tdiff = b - a;\n\telse\n\t\tdiff = a - b;\n\tfor (i = 1; i <= diff/2; i++)\n\t\tcount += i;\n\tif (diff % 2 != 0)\n\t\tcount = (count * 2) + ((diff / 2) + 1);\n\telse\n\t\tcount = count * 2;\n\n\t\n\tprintf(\"%d\", count);\n\t//_getch();\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "2e62d42f68f4625cdd3c5dfbde606a40", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,s,i,j,flag=0,sum=0;\n scanf(\"%d%d\",&n,&s);\n int ara[n],max=0;\n for(i=0;imax)\n max=ara[i];\n }\n sum-=max;\n if(s>=sum)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5dfa421d89d49acf0e48afbd561a4b7b", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n long long int X, f;\n scanf(\"%lld\",&X);\n if(X%2 == 0)\n {\n f = X/2;\n printf(\"%lld\\n\",f);\n }\n else\n { f = (- X - 1)/2 ;\n printf(\"%lld\\n\",f);}\n return 0;\n}\n// 1461347183703", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "d1e8edc5d964f349d3e2a8e89b12d380", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n long int a,b,i,j,vla,val;\n scanf(\"%ld%ld\",&a,&b);\n vla=a;\n val=b;\n\n if( b==1)\n {\n printf(\"Valera\\n\");\n }\n else\n {\n for(i=1,j=2;i>0,j>0;i=i+2,j=j+2)\n {\n vla=vla-i;\n\n if(vla<0)\n {\n printf(\"Vladik\\n\");\n goto end;\n }\n val=val-j;\n\n if(val<0)\n {\n printf(\"Valera\\n\");\n goto end;\n }\n }\n\n }\n end:\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "9f3d8c70c3e83ee011c7a96aba6f0d9f", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint t,T1,T2,s,f,x1,x2,p,d,t1,t2,i;///T2 \ufffd\ufffd T1 \ufffd\ufffd\nint main()\n{\n scanf(\"%d %d %d %d %d %d %d\",&s,&x1,&x2,&t1,&t2,&p,&d);\n if(x2-x1>0) f=1;\n else f=-1;\n T2=(x2-x1)*t2*f;\n if(t1x2&&d<0)){\n t=(f*x1-d*p)*t1*t2/(t2-t1);\n }\n else\n t=(2*s+x1*f-d*p)*t1*t2/(t2-t1);\n }\n else\n {\n printf(\"%d\",T2);\n return 0;\n }\n if(tx2&&d<0)){\n t=(f*x2-d*p)*t1;\n }\n else\n t=(2*s+x2*f-d*p)*t1;\n printf(\"%d\",t);\n }\n else\n printf(\"%d\",T2);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "dbbd547e48d3f924ae81880818c114b9", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef long long int L;\nint k;\nL i,s,n;\nint check(L m)\n{\n s=0;\n for(i=m;i>0;i=i/k)\n {\n s=s+i;\n if(s>=n) return 1;\n }\n return 0;\n}\nint main()\n{\n L low=1,high,mid;\n scanf(\"%I64d%d\",&n,&k);\n high=n;\n while(low\n#include \nint main()\n{\n\tint n,i,j,s,t,f,w,mini,min,maxi,max;\n\tscanf(\"%d\",&n);\n\tint ara[10][4];\n\tfor (i=0;imaxi){\n\t\t\tmaxi=ara[i][2];\n\t\t}\n\t\tif (ara[i][3]>max){\n\t\t\tmax=ara[i][3];\n\t\t}\n\t}\n\t//printf(\"%d\",maxi);\n\tw=(maxi-mini)*(max-min);\n\t//printf(\"%d\",f);\n\tif (f==w && (maxi-mini)==(max-min)){\n\t\tprintf(\"YES\");\n\t}\n\telse{\n\t\tprintf(\"NO\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9cdfc8f9d1f3ae8a76a5cd096d277763", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define min(a,b) ((ap[i])\n p[0]=p[i];\n }\n if(a\nint main()\n{\n int i,j,k,l,a,b,c,sum=0,m;\n scanf(\"%d %d %d\",&i,&j,&k);\n int ara[i];\n for(l=0;l\n#include\n#include\nint main(){\nint count=0,couta=0;\nchar s[52];\nint x,i,n;\nint y;\nscanf(\"%s\",&s);\nx=strlen(s);\nfor(i=0;i='b'&& s[i]<='z'){\ncount++;\n}\n}\n\nif(couta>count){\n printf(\"%d\",x);\n\n}\nelse if(count>couta){\n y=count-couta;\n printf(\"%d\",x-y-1);\n}\nelse if(couta==count){\n printf(\"%d\",x-1);\n}\n\nreturn 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "88b8f77d886a11e23ed296780bfae386", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n long long n, k, d, a, b, c;\n scanf(\"%lld %lld\", &n, &k);\n d = n/2;\n a = d/(k+1);\n b = a*k;\n c = n-a-b;\n\n printf(\"%lld %lld %lld\\n\",a, b, c);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "87d6013fc964bc92c07ea9c0b4544e58", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char myarray[1000];\n scanf(\"%s\",&myarray);\n int i,cnt=0,j,k,l,len=0;\n len=strlen(myarray);\n for(i=0; i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#define INF INT_MAX\n#define rep(i,a,b) for(i=a;i<=b;i++)\n#define inp(x) scanf(\"%d\",&x)\nint min(int a,int b);\nint max(int a,int b);\nint cmp(const void * a,const void *b);\n\nint main()\n{\n\tfloat n,k;\n\tfloat a[1000];\n\tfloat total=0.0;\n\tint cnt=0;\n\tscanf(\"%f%f\",&n,&k);\n\tfor(int i=1;i<=n;i++) {scanf(\"%f\",&a[i]);total+=a[i];}\n\twhile(1)\n\t{\n\t\tif(k-(total/n)>0.5000000) {total+=k;n++;cnt++;}\n\t\telse {\n\t\t\tprintf(\"%d\\n\",cnt);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\n\n\n\n//\tqsort( , ,sizeof(int),cmp);\n\treturn 0;\n}\nint min(int a,int b)\n{\n\treturn (a>b?b:a);\n}\n\nint max(int a,int b)\n{\n\treturn (a\n#include\n#include\nint main(void)\n{\n\tlong int n;\n\tscanf(\"%ld\",&n);\n\tif(n<=3)\n\tprintf(\"0\");\n\telse\n\t{\n\t\tif(n%2==0)\n\t\t{\n\tn=n/2;\n\tif(n%2==0)\n\tprintf(\"%d\",(n-2)/2);\n\telse\n\tprintf(\"%d\",(n-1)/2);\n}\nelse\nprintf(\"0\");\n}\n\t\n\t\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "590b7d2d7b94f3e78c85de87ce3a3db3", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/807/submission/37414476 (Dukkha) */\n#include \n\nint good(int p, int s) {\n\tint i, j;\n\n\ti = (s / 50) % 475;\n\tfor (j = 0; j < 25; j++) {\n\t\ti = (i * 96 + 42) % 475;\n\t\tif (26 + i == p)\n\t\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nint main() {\n\tint p, x, y, z;\n\n\tscanf(\"%d%d%d\", &p, &x, &y);\n\tfor (z = x; z >= y; z -= 50)\n\t\tif (good(p, z)) {\n\t\t\tprintf(\"0\\n\");\n\t\t\treturn 0;\n\t\t}\n\tfor (z = x; ; z += 50)\n\t\tif (good(p, z)) {\n\t\t\tprintf(\"%d\\n\", (z - x + 50) / 100);\n\t\t\treturn 0;\n\t\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "d21b9de381d54efc418aed1483f2925d", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int a[110]={0};\n int i;\n for(i=1;;i++)\n {\n if(n==1) {break;}\n int yushu,deshu;\n yushu=n%2;\n n=n/2;\n a[i]=yushu;\n if(n==1) {i++;break;}\n }\n printf(\"%d\",i);\n i--;\n for(;i>=0;i--)\n if(a[i]) printf(\" %d\",i);\n printf(\"\\n\");\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4f02fa2ddd80bf305cd42540824b572d", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main() {\n long long int n,k;\n \n scanf(\"%lld %lld\",&n,&k);\n \n if (k <= (n + 1) / 2)\n {\n printf(\"%lld\",k * 2 - 1 );\n }\n else\n {\n printf(\"%lld\",(k - (n + 1) / 2) * 2 );\n }\n \n \n \n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "62486cb9f6384273b1504c9436ea0fa7", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(void){\n int x,y,z,x0,y0,z0;\n int a[6],*p=a-1;\n int i,j,k,num=0;\n\n scanf(\"%d%d%d\",&x,&y,&z);\n scanf(\"%d%d%d\",&x0,&y0,&z0);\n for(i=1;i<=6;i++) scanf(\"%d\",p+i);\n \n if(y<0) num+=p[1];\n else if(y>y0) num+=p[2];\n\n if(z<0) num+=p[3];\n else if(z>z0) num+=p[4];\n\n if(x<0) num+=p[5];\n else if(x>x0) num+=p[6];\n\n printf(\"%d\\n\",num);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "fc001df465241129a674a61803f45c23", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define min(a,b) (a=4) puts(\"NO\");\n\telse if(m==1) puts(\"YES\");\n\telse if(m==3) puts(a==3&&b==3&&c==3?\"YES\":\"NO\");\n\telse puts((a==2&&b==2||a==2&&c==2||b==2&&c==2)||(a==4&&b==4||a==4&&c==4||b==4&&c==4)?\"YES\":\"NO\");\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms"], "code_uid": "b764285790dcbb8f57b09a14a6fded92", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n long long int n;\n scanf(\"%lld\", &n);\n n = n+1;\n if(n%2==0||n-1==0)\n printf(\"%lld\",n/2);\n else\n printf(\"%lld\",n);\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "5fa7123cc797685036cebdd8e1fa9e49", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nlong remove_zeros(long num) {\n return num % 10 == 0 ? remove_zeros(num / 10) : num;\n}\n\nint solve(long num) {\n if(num < 10)\n return 9;\n\n return 10 - (num % 10) + solve(remove_zeros(num / 10 + 1));\n}\n\nint main() {\n long num;\n\n scanf(\"%ld\", &num);\n printf(\"%d\\n\", solve(num));\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "21900d483940093643e9894691b0ea28", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int x[6][6];\n int i,j,k,l,m;\n for(i=0;i<5;++i)\n {\n for(j=0;j<5;++j)\n scanf(\"%d\",&x[i][j]);\n }\n int max=0;\n for(i=0;i<5;++i)\n {\n for(j=0;j<5;++j)\n {\n if(i==j)\n continue;\n for(k=0;k<5;++k)\n {\n if(k==j || k==i)\n continue;\n for(l=0;l<5;++l)\n {\n if(l==k || l==j || l==i)\n continue;\n for(m=0;m<5;++m)\n {\n int temp=0;\n if(m==l || m==k || m==j || m==i)\n continue;\n temp=x[i][j]+x[j][i]+x[k][l]+x[l][k]+x[j][k]+x[k][j]+x[l][m]+x[m][l]+x[k][l]+x[l][k]+x[l][m]+x[m][l];\n //printf(\"%d\\n\",temp);\n if(max\nmain()\n{\n char a[10][10];\n int i,j,k=0,p=0,h=0,g=0;\n for(i=0;i<8;i++)\n gets(a[i]);\n for(i=0;i<8;i++)\n { k=0;h=0;\n for(j=0;j<8;j++)\n {if(a[i][j]=='B') k++;\n if(a[j][i]=='B') h++;}\n if(k==8) p++;\n if(h==8) g++;}\n if(p==8 )\n printf(\"%d\",p);\n else \n printf(\"%d\",p+g);\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms"], "code_uid": "2038eb03ee44f6331bacaa132e6ab222", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nchar str[256], used[256];\nint l, k;\n\nint main()\n{\n int i;\n\tscanf(\"%d %s\", &k, str);\n\tl = strlen(str);\n\tfor(i=0; i=0; --i) {\n\t\twhile(c>='a' && used[c]) --c;\n\t\tif (str[i]!='?') continue;\n\t\tint a = l-1-i;\n\t\tif (c>='a') {\n\t\t\tstr[a] = str[i] = c--;\n\t\t} else {\n\t\t\tstr[a] = str[i] = 'a';\n\t\t}\n\t}\n\twhile(c>='a' && used[c]) --c;\n\tif (c>='a') {\n\t\tprintf(\"IMPOSSIBLE\");\n\t\treturn 0;\n\t}\n\tprintf(\"%s\", str);\n}\n", "lang_cluster": "C", "tags": ["expression parsing"], "code_uid": "e08a790c704ce065c674ddd44caca771", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint buy[30],sell[30];\nint main()\n{\n int n,m,r,i,min=1001,max=0;\n scanf(\"%d %d %d\",&n,&m,&r);\n for(i=0;i< n;i++)//n\u00b4\u00ce\u00c2\u00f2\n {\n scanf(\"%d\",&buy[i]);\n if(buy[i]max)\n {\n max=sell[i];\n }\n }\n if(min>=max)\n {\n printf(\"%d\",r);\n }\n else\n {\n printf(\"%d\",r/min*max+r%min);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "f485503369c35cdd5aa456085e276159", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef struct abc\n{\n\tint a;\n\tint b;\n}abc;\n\nabc ar[8];\n\nstatic int compare(const void *i1,const void *i2)\n{\n\t const abc *p1=(const abc *)i1;\n\t\tconst abc *p2=(const abc *)i2;\n\t\treturn (p1->a-p2->a);\n}\n\n\nint main()\n{\n\tint x,y,z,min,max;\n\t\n\tfor(x=0;x<8;x++)\n\t{\n\t\tscanf(\"%d %d\",&ar[x].a,&ar[x].b);\n\t}\n qsort(&ar[0],8,sizeof(abc),compare);\n\t\n\tif(ar[0].a != ar[1].a || ar[0].a != ar[2].a)\n\t\tprintf(\"ugly\\n\");\n\telse if(ar[5].a != ar[6].a || ar[5].a != ar[7].a)\n\t\tprintf(\"ugly\\n\");\n\telse if(ar[3].a != ar[4].a)\n\t\tprintf(\"ugly\\n\");\n\telse if(ar[0].a == ar[7].a)\n\t\tprintf(\"ugly\\n\");\n\telse if(ar[0].a == ar[3].a)\n\t\tprintf(\"ugly\\n\");\n\telse\n\t{\n\t\tx=ar[0].b;y=ar[1].b;z=ar[2].b;\n\t\tif(x==y || x==z)\n\t\t\tprintf(\"ugly\\n\");\n\t\telse\n\t\t{\n\t\t\tmin=10000000;max=-1;\n\t\t\tfor(x=5;x<8;x++)\n\t\t\t{\n\t\t\t\tif(ar[x].bmax)\n\t\t\t\t\tmax=ar[x].b;\n\t\t\t\tfor(y=0;y<=2;y++)\n\t\t\t\t{\n\t\t\t\t\tif(ar[x].b==ar[y].b)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(y==3)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(y==3)\n\t\t\t\tprintf(\"ugly\\n\");\n\t\t\telse\n\t\t\t{\n\t\t\t\tx=ar[5].b;y=ar[6].b;z=ar[7].b;\n\t\t\t\tif(x==y || x==z)\n\t\t\t\t\tprintf(\"ugly\\n\");\n\t\t\t\telse if(!(ar[3].b == min || ar[3].b ==max))\n\t\t\t\t\tprintf(\"ugly\\n\");\n\t\t\t\telse if(!(ar[4].b == min || ar[4].b ==max))\n\t\t\t\t\tprintf(\"ugly\\n\");\n\t\t\t\telse if(ar[3].b == ar[4].b)\n\t\t\t\t\tprintf(\"ugly\\n\");\n\t\t\t\telse\n\t\t\t\t\tprintf(\"respectable\\n\");\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["sortings"], "code_uid": "b1fd7206391905ad217646c031d67b83", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long int a,b;\n\tscanf(\"%lld %lld\",&a,&b);\n\twhile((a!=0)&&(b!=0))\n\t{\n\t\tif(a>=2*b)\n\t\t{\n\t\t\ta=a%(2*b);\n\t\t}\n\t\telse if(b>=2*a)\n\t\t{\n\t\t\tb=b%(2*a);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%lld %lld\",a,b);\n\treturn 0;\n}\n\t\t\n\t\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "d26f20c0652fedab82db73c02831a513", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n char a[100001];\n gets(a);\n int p;\n p=strlen(a);\n int n=10,t=1,cnt=0,b[100000]={0},m=1,i,j,k;\n b[p]=0;\n for(i=0;ii;j--)\n {\n if(b[j]==b[i]&&b[j]!=10&&i!=j)\n b[j]=1;\n }\n if(b[i]==10&&i!=0)\n m=m*10;\n if(b[i]>10)\n {m=m*n*t; n--;}\n }\n if(b[0]==10)\n m=m*9;\n if(b[0]>10)\n {\n m=m*9;\n m=m/10;\n }\n printf(\"%d\",m);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "bf810672cc2d462b17bd444cf710c223", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n long long int Ax,Ay,Bx,By,Cx,Cy,ABx,ABy,BCx,BCy,temp;\n scanf(\"%lld %lld %lld %lld %lld %lld\",&Ax,&Ay,&Bx,&By,&Cx,&Cy);\n\n ABx=Bx-Ax;\n ABy=By-Ay;\n BCx=Cx-Bx;\n BCy=Cy-By;\n\n temp=ABx*BCy-ABy*BCx;\n\n if(temp==0)\n printf(\"TOWARDS\\n\");\n else if(temp<0)\n printf(\"RIGHT\\n\");\n else\n printf(\"LEFT\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "3739eebdfc4c1ccca2b72c3102a4af35", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define MAXN 210\n\nint main ()\n{\n static char data[MAXN];\n static int a[MAXN][MAXN];\n memset(a,0,sizeof(a));\n scanf(\"%s\",data);\n int N = strlen(data);\n int x = 105;\n int y = 105;\n a[x][y] = 1;\n int i;\n for (i = 2; i <= (N+1); i++)\n {\n int nx = x;\n int ny = y;\n if (data[i-2] == 'L') nx--;\n else if (data[i-2] == 'R') nx++;\n else if (data[i-2] == 'U') ny++;\n else ny--;\n \n if ((a[nx-1][ny] > 0) && (a[nx-1][ny] < (i-1)))\n {\n printf(\"BUG\\n\");\n return 0;\n }\n if ((a[nx+1][ny] > 0) && (a[nx+1][ny] < (i-1)))\n {\n printf(\"BUG\\n\");\n return 0;\n }\n if ((a[nx][ny-1] > 0) && (a[nx][ny-1] < (i-1)))\n {\n printf(\"BUG\\n\");\n return 0;\n }\n if ((a[nx][ny+1] > 0) && (a[nx][ny+1] < (i-1)))\n {\n printf(\"BUG\\n\");\n return 0;\n }\n if (a[nx][ny] > 0)\n {\n printf(\"BUG\\n\");\n return 0;\n } \n \n a[nx][ny] = i;\n x = nx;\n y = ny;\n }\n printf(\"OK\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "553bceb132fe79a128b299bc9e09118a", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,i=0,c=0;\n\tchar s[60];\n\tlong long int j=0;\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",s);\n\twhile(s[i]!='\\0')\n\t\tj=j*10+(int)(s[i++])-48;\n\twhile(j>0)\n\t{\n\t\tif(j%2==0)\n\t\tc++;\n\t\telse\n\t\t\tbreak;\n\t\tj>>=1;\n\t}\n\tprintf(\"%d\\n\",c+1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "7a4b5d3cb921cc6f8bb901722bde54a8", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n char st[105];\n int n,nono=0;\n scanf(\"%d\",&n);\n scanf(\"%s\",st);\n printf(\"%c\",st[0]);\n for(int j=1;j\nint min2(int a,int b)\n{\n if(af)\n {\n if(ad)\n price+=d*e;\n else\n price+=a*e;\n }\n\n printf(\"%lld\\n\",price);\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "brute force"], "code_uid": "536606a03a44ea41388b5f6598afbef4", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b)\n{\n\tif(b == 0)\n\t{\n\t\treturn a;\n\t}\n\n\telse\n\t{\n\t\treturn gcd(b,a % b);\n\t}\n}\n\nint main()\n{\n\tint a,b,c,q = 0;\n\n\tscanf(\"%d %d %d\",&a,&b,&c);\n\n\tint lcm = a * b;\n\n\tint x = gcd(a,b);\n\n\tlcm /= x;\n\n\tc /= lcm;\n\n\tprintf(\"%d\\n\",c);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "fb25fb04d0459526449d4428f883adae", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main() {\n\tchar str[100];\n\tscanf(\"%s\", str);\n\tint n, b = 0, c = 0, i, j;\n\tn = strlen(str);\n\tfor(i = 0; i < n; ) {\n\t\tb = 1;\n\t\tfor( j = i + 1; j < n; j++)\n\t\t\tif(str[i] == str[j])\n\t\t\t\tb++;\n\t\t\telse\n\t\t\t\tbreak;\n\t\tif(b % 2 != 0) {\n\t\t\ti = i + b;\n\t\t\tcontinue;\n\t\t}\n\t\telse {\n\t\t\tc++;\n\t\t\ti = i + b;\n\t\t}\n\t}\n\tprintf(\"%d\", c);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "implementation"], "code_uid": "4203a5d83d7b836092374294247129ea", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tchar s[100], c[100], d[100];\n\tint i,j = 0, t;\n\tscanf(\"%s\", s);\n\n\t//t copy\n\tfor (i = 0; i < strlen(s); ++i)\n\t{\n\n\t\tif (s[i] != '+')\n\t\t{\n\t\t\t\n\t\t\tc[j] = s[i];\n\t\t\tj++;\n\t\t\t\n\t\t}\n\t}\n\tc[j] = '\\0';\n\n\t//arrange\n\tfor (j=0 ; j<(strlen(c)-1) ; j++)\n\t{\n\t\t\n\t\tfor (i=0 ; i<(strlen(c)-1) ; i++)\n\t\t{\n\t\t\t\n\t\t\tif (c[i+1] < c[i])\n\t\t\t{\n\t\t\t\t\n\t\t\t\tt = c[i];\n\t\t\t\tc[i] = c[i + 1];\n\t\t\t\tc[i + 1] = t;\n\t\t\t}\n\t\t}\n\t}\n\n\t//print\n\tj = 0;\n\tfor (i = 0; (i < strlen(c)); ++i)\n\t{\n\t\td[j] = c[i];\n\t\tj++;\n\t\tif (i == strlen(c) - 1)\n\t\t{\n\t\t\td[j] = '\\0';\n\t\t\tbreak;\n\t\t}\n\t\td[j] = '+';\n\t\tj++;\n\t\t\n\t}\n\tprintf(\"%s\\n\", d);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["sortings", "strings", "implementation", "greedy"], "code_uid": "d0c330476c1fd5ff7490a2eb1412964f", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tlong long xa, ya, xb, yb, xc, yc;\n\n\tscanf(\"%lld%lld%lld%lld%lld%lld\", &xa, &ya, &xb, &yb, &xc, &yc);\n\tprintf((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb) == (xc - xb) * (xc - xb) + (yc - yb) * (yc - yb) && (xb - xa) * (yc - yb) != (yb - ya) * (xc - xb) ? \"Yes\\n\" : \"No\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "45cc2f1ce7b0e60f90d2d97bd72233c7", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint x,a,b;\n\tscanf(\"%d %d %d\",&x,&a,&b);\n\tint rem,f=0,ct=0;\n\n\t\trem=a%10;\n\t\tif(rem==7)\n\t\t f=1;\n\t\t \n\t\t \n \n\twhile(f==0)\n {\n \t rem=b%10;\n\t if(rem==7)\n\t\tf=1;\n\tif(f==1)\n\t break;\n\n\tif(f==0)\n {\n \tct++;\n\t\tb-=x;\n \n if(b<0)\n {\n \t b+=60;\n \t a--;\n if(a<0)\n a+=24;\n rem=a%10;\n\t if(rem==7)\t \n\t\t f=1;\n } \n\t \n }\n if(f==1)\n\t break;\n }\n \n printf(\"%d\",ct);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "1c70420f205985a3a5de8a702ffab2e4", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint c[26],i;\nvoid reset()\n{\n\tfor(i=0;i<26;i++)\n\t\tc[i]=0;\n}\nint main()\n{\n\tint num,i,count=0,max=0;\n\tscanf(\"%d\",&num);\n\tchar a[num+1];\n\tscanf(\"%s\",a);\n\n\treset();\n\tfor(i=0;i='A' && a[i]<='Z'){\n\t\t\tcount=0;\n\t\t\treset();\n\t\t}\n\t\telse if(c[a[i]-'a']==0){\n\t\t\tc[a[i]-'a']++;\n\t\t\tcount++;\n\t\t}\n\t\tif(count>max){\n\t\t\tmax=count;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",max);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "2b949f1e644b7844f37d30cd387576a7", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(int argc, char **argv)\n{\n\tint x1,y1,x2,y2,x,y;\n\tscanf(\"%d%d%d%d%d%d\",&x1,&y1,&x2,&y2,&x,&y);\n\tint rep1=abs(x2-x1)/x, rep2=abs(y2-y1)/y;\n\tif(abs(x2-x1)%x==0&&abs(y2-y1)%y==0&&rep1%2==rep2%2)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "261a582cae0b68627095dbf31a8a0d7d", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong long int mod=1000000007;\nlong long int modpowfast(long long int b,long long int e)\n{\n\tlong long int ans=1;\n\twhile(e>0)\n\t{\n\t\tif(e&1)\n\t\t\tans=(ans*b)%mod;\n\t\tb=(b*b)%mod;\n\t\te=e>>1;\n\t}\n\treturn ans;\n}\nint main()\n{\n\tlong long int p,k,m,x;\n\tscanf(\"%lld %lld\",&p,&k);\n\tif(k==0)\n\t{\n\t\tprintf(\"%lld\\n\",modpowfast(p,p-1));\n\t}\n\telse if(k==1)\n\t{\n\t\tprintf(\"%lld\\n\",modpowfast(p,p));\t\t\n\t}\n\telse\n\t{\n\t\tx=k;\n\t\tfor(m=1;x!=1;m++)\n\t\t{\n\t\t\tx=(x*k)%p;\n\t\t}\n\t\tprintf(\"%lld\\n\",modpowfast(p,(p-1)/m));\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "math", "combinatorics", "number theory"], "code_uid": "90b1e2afaeef1117e41f21642134bb13", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n Harrit Lamster (s1552295)\n harrit.lamster@gmail.com\n AADS '17-'18, 2018-02-18\n Assignment 2, TABLE\n*/\n\n#include \n#define DEBUG 0\n#if DEBUG\n #include \n#endif\n\n//0.130s\n\ntypedef long long ll;\n\nll min(ll x, ll y) {\n return x < y ? x : y;\n}\n\nvoid swap(ll *xp, ll *yp) {\n ll h = *xp;\n *xp = *yp;\n *yp = h;\n}\n\nll lessEqualInTable(int n, int m, ll x) {\n ll result = 0;\n ll rightmostFullColumn = min(x, x/m);\n result += rightmostFullColumn * min(x, m);\n ll rightmostColumn = min(x, n);\n ll rightmostMoreThanOneColumn = min(x / 2, n);\n result += (rightmostColumn - rightmostMoreThanOneColumn);\n for (ll column = rightmostFullColumn + 1; column <= rightmostMoreThanOneColumn; column++)\n result += x / column;\n return result;\n}\n\nll findKthInList(ll n, ll m, ll k) {\n if (n > m)\n swap(&n, &m);\n if (k == 1)\n return 1;\n ll l = 1, r = n*m, mid;\n while (r - l > 1) {\n mid = (l + r) / 2;\n if (lessEqualInTable(n, m, mid) >= k)\n r = mid;\n else\n l = mid;\n }\n return l + 1;\n}\n\n#if DEBUG\nvoid assertions() {\n assert(findKthInList(10, 10, 98) == 90);\n assert(findKthInList(10, 10, 97) == 81);\n assert(findKthInList(4, 7, 4) == 3);\n assert(findKthInList(1, 1, 1) == 1);\n assert(findKthInList(100000, 100000, 10000000000) == 10000000000);\n assert(findKthInList(100000, 100000, 1) == 1);\n assert(findKthInList(100000, 100000, 2) == 2);\n assert(findKthInList(100000, 100000, 3) == 2);\n assert(findKthInList(100000, 100000, 4) == 3);\n assert(findKthInList(100000, 100000, 5) == 3);\n assert(findKthInList(1, 5, 2) == 2);\n assert(findKthInList(5, 1, 2) == 2);\n printf(\"assertions OK\\n\");\n}\n#endif\n\nint main() {\n ll n, m, k;\n #if DEBUG\n assertions();\n #endif\n scanf(\"%lld %lld %lld\", &n, &m, &k);\n printf(\"%lld\\n\", findKthInList(n, m, k));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search"], "code_uid": "c646190339ef56c2692fd4785bbf1472", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nbool is_leap_year(int year);\nint count_year(int year);\nint main() {\n\tint t;\n\tint year, same_year;\n\n\tscanf(\"%d\", &year);\n\t\tprintf(\"%d\\n\", count_year(year));\n}\n\nbool is_leap_year(int year) {\n\tif (year % 400 == 0)\n\t\treturn true;\n\n\telse if ((year % 4 == 0) && (year % 100 != 0))\n\t\treturn true;\n\n\telse\n\t\treturn false;\n}\n\nint count_year(int year) {\n\tint count = 0;\n\t\n\tif (is_leap_year(year)) {\n\t\tdo {\n\t\t\tif (is_leap_year(year))\n\t\t\t\tcount += 2;\n\t\t\telse\n\t\t\t\tcount += 1;\n\t\t\tyear++;\n\t\t} while (((count % 7 != 0) || (!is_leap_year(year)))) ;\n\n\t}\n\n\telse {\n\t\tdo {\n\t\t\tif (is_leap_year(year))\n\t\t\t\tcount += 2;\n\t\t\telse\n\t\t\t\tcount += 1;\n\t\t\tyear++;\n\n\t\t} while ((count % 7 != 0)|| (is_leap_year(year)));\n\t}\n\t\t\n\treturn year;\n\n\t\n\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0c9cf947160295f1092cb5444f3bc1c8", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,k,x,y,s;\n scanf(\"%d %d\",&n,&k);\n x=n/k;\n y=x+1;\n s=y*k;\n printf(\"%d\",s);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "53a41247d05f56504a9b03778ec84128", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n char s[101];\n int ar[n],fsum=0,g=0;\n scanf(\"%s\",s);\n for(int i=0;ifsum)\n {\n f=1;\n break;\n }\n }\n if(f==2&&j==n&&tsum==0)\n {\n g=1;\n break;\n }\n }\n if(g==1)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "1b66554fff81c9bf600faef6e32787bd", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\t// your code goes here\n\tint i,j;\n\tscanf(\"%d%d\",&i,&j);\n\t\n\tif(i==0&&j==0)\n\t{\n\t\tprintf(\"NO\");\n\t\t\n\t\n}\nelse\n{\n\tif((i-j)==1||(j-i)==1||i==j)\n\t{\n\n\n\t\n\t\tprintf(\"YES\");\n\t}\nelse\n{\n\tprintf(\"NO\");\t\n\t}\n}\n\treturn 0;\n\t\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "9ef3ec3669844b35555c8a1386d977b7", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//http://codeforces.com/contest/328/problem/A\n#include\nint main()\n{\n int a[5],i,j,n,d[5],s;\n while(~scanf(\"%d %d %d %d\",&a[0],&a[1],&a[2],&a[3]))\n {\n for(i=0; i<3; i++)\n d[i]=a[i+1]-a[i];\n if((d[0]==d[1])&&(d[1]==d[2]))\n printf(\"%d\\n\",(a[3]+d[0]));\n else if(!((a[0]&&a[1])&&(a[2]&&a[3]))) printf(\"42\\n\");\n else\n {\n if((a[1]*a[1]==a[0]*a[2])&&(a[1]*a[3]==a[2]*a[2]))\n {\n s=a[3]*a[3]/a[2];\n if(s*a[2]==a[3]*a[3])\n printf(\"%d\\n\",s);\n else printf(\"42\\n\");\n }\n else printf(\"42\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "348ab1e954f0b158c5f16e9172a579f0", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{ int i,j,a[4][4];\n for(i=0;i<4;i++)\n for(j=0;j<4;j++)\n scanf(\"%d\",&a[i][j]);\n if(a[0][3])\n if(a[0][0]==1||a[0][1]==1||a[0][2]==1||a[1][0]==1||a[2][1]==1||a[3][2]==1)\n {printf(\"YES\");\n return 0;\n }\n if(a[1][3])\n if(a[1][0]==1||a[1][1]==1||a[1][2]==1||a[0][2]==1||a[2][0]==1||a[3][1]==1)\n {printf(\"YES\");\n return 0;\n }\n if(a[2][3])\n if(a[2][0]==1||a[2][1]==1||a[2][2]==1||a[0][1]==1||a[1][2]==1||a[3][0]==1)\n {printf(\"YES\");\n return 0;\n }\n if(a[3][3])\n if(a[3][0]==1||a[3][1]==1||a[3][2]==1||a[0][0]==1||a[1][1]==1||a[2][2]==1)\n {printf(\"YES\");\n return 0;\n }\n printf(\"NO\");\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fae76550d53b1b56da59b282c60bf521", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n\tunsigned long n,m,i,c;\n\tscanf(\"%lu\",&n);\n\tfor(i=1;i*i=n)\n\t {\n\t\tm=2*i-1;\n }\n\telse m=2*i;\n\tprintf(\"%lu\\n\",m);\nreturn 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "619f72b93c4ce2cdf32af312c5a497af", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int n,i,c=0;\n scanf(\"%d\",&n);\n for(i=1; i\n\nint main(void){\n\tint n;\n\tchar k;\n\tscanf(\"%c%d\", &k,&n);\n\tif((k=='a'||k=='h')&&(n==8 || n==1)){\n\t\tprintf(\"3\");\n\t\treturn 0;\n\t}\n\tif(n==1 || n==8 || k=='a' || k=='h'){\n\t\tprintf(\"5\");\n\t\treturn 0;\n\t}\n\tprintf(\"8\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3c549a96c704fcfd64d921d5f91dd856", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,i,j=0;\n scanf(\"%d\", &n);\n int k[n];\n for(i=0;i\n#include \nint main(){\n long int a,b,c;\n \n \n scanf(\"%ld\",&a);\n scanf(\"%ld\",&b);\n scanf(\"%ld\",&c);\n a = abs(a);\n b = abs (b);\n if(c==(a+b)){\n printf(\"YES\"); \n }\n else if(c>(a+b)&&((a+b)-c)%2==0){\n printf(\"YES\"); \n }\n else {\n printf(\"NO\");\n }\n \n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "a0560738dfee00ab2437648a15827247", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n\tlong long int a,b,c,y,q,p=1000000007,res=1;\n\n\tscanf(\"%lld%lld\",&a,&b);\n \n\ty=b;\n\tc=2;\n while(y>0)\n\t {\n\t\t if(y%2!=0)\n\t\t\t res=(res*c)%p;\n\t\t y=y>>1;\n\t\t c=(c*c)%p;\n\t }\n\t q=(res%p+(p-1))%p;\n\n\t y=a;\n\t c=q;\n\t res=1;\n\t while(y>0)\n {\n if(y%2!=0)\n res=(res*c)%p;\n y=y>>1;\n c=(c*c)%p;\n }\n printf(\"%lld\\n\",res);\n\t return 0;\n}\n\n\n\t \n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "51c8b720817a8f2c547000211c8ddaa9", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nenum { BIG = 1000000007 };\n\nint n;\nchar s[240];\nint slen;\nint dp[201][101];\nint next[201][2];\nint fail[201];\n\nvoid nextstep(int eo) {\n int i, j;\n for (i = 0; i <= slen; i++) {\n int lp = next[i][0];\n int rp = next[i][1];\n for (j = eo; j <= n; j+=2) {\n int now = dp[i][j];\n if (j < n) {\n int add = dp[lp][j+1] + now;\n dp[lp][j+1] = add < BIG ? add : add - BIG;\n }\n if (j > 0) {\n int add = dp[rp][j-1] + now;\n dp[rp][j-1] = add < BIG ? add : add - BIG;\n }\n }\n }\n for (i = 0; i <= slen; i++) {\n for (j = eo; j <= n; j+=2) {\n dp[i][j] = 0;\n }\n }\n /*for (i=0;i<=slen;i++){\n for (j=0;j<=n;j++){\n printf(\"%3d,\",dp[i][j]);\n }\n puts(\"\");\n }\n puts(\"\");*/\n}\n\nint main() {\n scanf(\"%d\", &n);\n scanf(\" %202s\", s);\n slen = strlen(s);\n int i;\n // build state machine\n fail[0] = fail[1] = 0;\n if (s[0] == '(') {\n next[0][0] = 1;\n next[0][1] = 0;\n }\n else {\n next[0][0] = 0;\n next[0][1] = 1;\n }\n for (i = 1; i < slen; i++) {\n int r = s[i] == ')';\n int f = fail[i];\n next[i][r] = i+1;\n next[i][1-r] = next[f][1-r];\n fail[i+1] = next[f][r];\n }\n next[slen][0] = next[slen][1] = slen;\n dp[0][0] = 1;\n for (i = 0; i < n; i++) {\n nextstep(0);\n nextstep(1);\n }\n printf(\"%d\\n\", dp[slen][0]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "dp"], "code_uid": "ef40b724e511308ccea6397eaf03087d", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//324B.c\n#include\n#include\n\nlong long int c=1000000007;\n\nlong long int power(long long int a,long long int b)\n{\n if(b==0)\n return 1;\n else if(b==1)\n return a%c; \n else\n return ((power(a,b/2)%c)* (power(a,b-b/2)%c))%c;\n \n}\nint main()\n{\n // int ans = power(2,3);\n // printf(\"%d\",ans);\n\n long long int n,number,total,extra,ans;\n scanf(\"%lld\",&n);\n\n number=3*n;\n \n total=power(3,number);\n //printf(\"%lld\\n\",total);\n //calcualting when = 6\n\n extra=power(7,n);\n //printf(\"%lld\\n\",extra);\n ans=total-extra;\n // ans=abs(ans);\n if(ans>0)\n ans=(ans)%c;\n else\n ans=c+(ans%c);\n \n \n printf(\"%lld\",ans);\n\n\n return 0;\n}", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "e8997e07c0f21ff9dfac1ac7d3bd950e", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\t#include\n\n\tint main(){\n\t\tint n;\n\t\tscanf(\"%d\",&n);\n\t\tint r[n],b[n];\n\t\tint topr=0,topb=0,sayac=0;\n\t\tfor(int i=0;ib[i]){\n\t\t\t\tsayac++;\n\t\t\t}\n\t\t}\n\t\tif(sayac==0 ){\n\t\t\tputs(\"-1\");\n\t\t}\n\t\telse if(topb==n)\n\t\t\tputs(\"-1\");\n\t\telse{\n\t\t\tfor(int i=1;i<=n;i++){\n\t\t\t\t\tif(((sayac*i)+(topr-sayac))>topb){\n\t\t\t\t\t\tprintf(\"%d\",i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn 0;\n\t}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "d4d6ea451cf8350e11a56da2412f9fb4", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n long int k,n;\n scanf(\"%ld\",&k);\n n=abs(k);\n long int sum=0, ans=0, p=1,diff;\n for(p = 1; sum < n; sum=sum+p, p++, ans++);\n \n diff = sum - n;\n if(n == 0)\n {\n printf(\"0\");\n }\n else if(diff % 2 == 0)\n {\n printf(\"%ld\\n\", ans);\n }\n else if((diff + p) % 2 == 0)\n {\n printf(\"%ld\\n\", ans + 1);\n }\n else\n {\n printf(\"%ld\\n\", ans + 2);\n }\n \n \n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "6906642c3dd3768c8ef93b2677714d1f", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nchar s[220];\nlong n,len;\nlong check(long a)\n{\n long i;\n for(i=1;i<=a-n;i++)\n if(s[len-i]!=s[len-i-a])\n return 0;\n return 1;\n}\nint main()\n{\n long i,k,j,ans=0,key,max,min,temp=0;\n scanf(\"%s\",s);\n len=strlen(s);\n scanf(\"%ld\",&n);\n\n if(n>len)\n min=(len+n)/2;\n else min=n;\n\n max=(len+n)/2;\n for(i=0;itemp)\n temp=j;\n }\n\n\n for(i=max;(i>=min)&&(ans==0);i--)\n if(check(i)==1)\n ans=i;\n if(min>ans)\n ans=min;\n if(temp>ans)\n ans=temp;\n printf(\"%ld\",2*ans);\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "f49d066df970d313cc66df54d8a4f5e1", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint len;\n\nvoid cyclicShift(char str[])\n{\n\tchar temp = str[0];\n\n\tfor(int i = 0; i < len; i++)\n\t{\n\t\tstr[i] = str[i + 1];\n\t}\n\n\tstr[len - 1] = temp;\n}\n\nint tot = 0;\nchar stack[51][51];\n\nvoid isdistinct(char str[])\n{\n\tfor(int i = 0; i < tot; i++)\n\t{\n\t\tif(strcmp(str, stack[i]) == 0)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t}\n\n\tstrcpy(stack[tot++], str);\n}\n\nint main(void)\n{\n\tchar str[51];\n\tscanf(\"%s\", &str);\n\n\tlen = strlen(str);\n\n\tfor(int i = 0; i < len; i++)\n\t{\n\t\tisdistinct(str);\n\t\tcyclicShift(str);\n\t}\n\n\tprintf(\"%d\\n\", tot);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "d04a03c03fe996290c642b886081022b", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,x,y,r,m;\n scanf(\"%d %d %d\",&n,&x,&y);\n if((y*n)%100==0)\n {\n r=((y*n)/100);\n if(r>x)\n printf(\"%d\",r-x);\n else\n printf(\"%d\",0);\n }\n else\n {\n r=(y*n)/100;\n m=r+1;\n if(m>x)\n printf(\"%d\",m-x);\n else\n printf(\"%d\",0);\n\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "64e175afb40667d89b265f94ab61d757", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint compare(const void *a,const void *b)\n{\n return ( *(int*)a - *(int *)b );\n}\nint main()\n{\n int n,i,s=0,p=0,j=0;\n scanf(\"%d\",&n);\n int a[12];\n \n for(i=0;i<12;i++)\n scanf(\"%d\",&a[i]);\n \n qsort(a,12,sizeof(int),compare);\n \n if(n!=0)\n{ for(i=11;i>=0;i--)\n {\n \n s=s+a[i];\n if(s\n#include \n\nmain(){\n\n int n,i,j,k,pom;\n\n scanf(\"%d\",&n);\n\n int br = 0;\n\n for(i = 1; i <= n; i++){\n for(j = 1; j <= n; j++){\n k = i ^ j;\n if(i + j > k && i + k > j && k + j > i && i <= j && j <= k && k <= n){\n br++;\n }\n }\n }\n\n printf(\"%d\",br);\n\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "79516a0993fcbe13ab8fcd8cc9a317d3", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tgetchar();\n\t\n\tint i, temp, last = 0, last_loc, current_cycle = 0, max_cycle = 0;\n\tfor(i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &temp);\n\t\tcurrent_cycle = (temp + m - 1) / m;\n\t\tif(current_cycle >= max_cycle) {\n\t\t\tlast_loc = i + 1;\n\t\t\tmax_cycle = current_cycle;\n\t\t}\n\t}\n\t\n\tprintf(\"%d\\n\", last_loc);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c59d444e6b55560700a445c03531c4ab", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define M 1000000\nint T[M]={1,1};\nint rev(int n){\n\tint r=0;\n\tfor(;n;){\n\t\tr=r*10+n%10;\n\t\tn/=10;\n\t}\n\treturn r;\n}\nint main(){\n\tint i=1,j,n;\n\tfor(scanf(\"%d\",&n);++i<=M;)if(!T[i])for(j=i+i;j<=M;j+=i)T[j]=1;\n\tfor(i=2;i<=M;i++)if(!T[i]){\n\t\tj=rev(i);\n\t\tif(j!=i&&!T[j]&&!--n){printf(\"%d\\n\",i);return 0;}\n\t}\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "number theory"], "code_uid": "47e9534e3fac7a4ee8d9ebcac938463f", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n;\n\n\tscanf(\"%d\",&n);\n\n\tchar s[201];\n\n\tscanf(\"%s\",s);\n\n\tint i,r=0,g=0,b=0;\n\n\tfor (i=0;i=1)\n\t\tprintf(\"G\\n\");\n\n\tif (g==0 && b==0 && r>=1)\n\t\tprintf(\"R\\n\");\n\n\tif (g==0 && r==0 && b>=1)\n\t\tprintf(\"B\\n\");\n\n\tif (r>=1 && b>=1 && g>=1)\n\t\tprintf(\"BGR\\n\");\n\n\tif (r==0)\n\t{\n\t\tif (b==1 && g==1)\n\t\t\tprintf(\"R\\n\");\n\n\t\tif (b==1 && g>1)\n\t\t\tprintf(\"BR\\n\");\n\n\t\tif (b>1 && g==1)\n\t\t\tprintf(\"GR\\n\");\n\n\t\tif (b>1 && g>1)\n\t\t\tprintf(\"BGR\\n\");\n\n\t}\n\n\n\n\tif (b==0)\n\t{\n\t\tif (r==1 && g==1)\n\t\t\tprintf(\"B\\n\");\n\n\t\tif (r==1 && g>1)\n\t\t\tprintf(\"BR\\n\");\n\n\t\tif (r>1 && g==1)\n\t\t\tprintf(\"BG\\n\");\n\n\t\tif (r>1 && g>1)\n\t\t\tprintf(\"BGR\\n\");\n\n\t}\n\n\n\tif (g==0)\n\t{\n\t\tif (b==1 && r==1)\n\t\t\tprintf(\"G\\n\");\n\n\t\tif (b==1 && r>1)\n\t\t\tprintf(\"BG\\n\");\n\n\t\tif (b>1 && r==1)\n\t\t\tprintf(\"GR\\n\");\n\n\t\tif (b>1 && r>1)\n\t\t\tprintf(\"BGR\\n\");\n\n\t}\n\n\n\treturn 0;\n\n}\n\n", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "08f0f7fcdd6634c0cfd0590fca99cb84", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint h,w,k;\n\t\n\tscanf(\"%d %d %d\",&w,&h,&k) ;\n\t\n\t\n\tint sum = 0 ; \n\t\n\twhile(k)\n\t{\n\t\t\n\t\tif (h == 1 && w == 1)\n\t\t sum = sum + 1;\n\t\tif (h == 1 && w != 1)\n\t\t sum = sum + w;\n\t\tif (h != 1 && w == 1)\n\t\t sum = sum + h;\n\t\tif (h != 1 && w != 1)\n\t\t sum = sum + (w*2 + h*2 - 4) ;\n\t\t\n\t\th = h - 4 ;\n\t\tw = w - 4 ;\n\t\t\n\n\t\tk--;\n\t\t\n\t}\n\tprintf(\"%d\",sum);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "bb9b3497b976cf4fdcba77f8c707942d", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int c,a,n,m,b,d,e,f;\n scanf(\"%lld%lld%lld%lld\",&n,&m,&a,&b);\n c=n%m;\n d=m-n%m;\n b=b*c;\n a=a*d;\n if(a>b)\n printf(\"%lld\\n\",b);\n else\n printf(\"%lld\\n\",a);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "bc06756d882b013565e396654fa6aaa9", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint i,j,k,n,a,b,v;\n\tint temp,temp1,flag,count,cap,flag3=0;\n\tscanf(\"%d%d%d%d\",&k,&a,&b,&v);\n//\twhile(1)\n//\t{\n\t\ttemp=b/(k-1);\n\t\ttemp1=b%(k-1);\n\t\tcap=temp*v*k;\n\t\tcount=0;\n\t\tif(cap>a)\n\t\t{\n\t\t\tflag3=1;\n\t\t//\tcap=1;\n\t\t\twhile(cap>=a)\n\t\t\t{\n\t\t\t\tcap=cap-(v*k);\n\t\t\t\ttemp--;\n\t\t\t}\n\t\t}\n\n\t\tif(cap\n#include\n\nint s[500];\nint main()\n{\n\tint n,sum,i,j,k;\n\tscanf(\"%d\",&n);\n\tj=0;\n\tk=0;\n\tfor(i=n-100;i0)\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "d8b8e29a02b1864ee251429b777ad194", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tint x,y,z,t1,t2,t3;\n\tscanf(\"%d%d%d%d%d%d\",&x,&y,&z,&t1,&t2,&t3);\n\tif(3*t3+(abs(x-z)+abs(x-y))*t2>(abs(x-y))*t1)\n\t printf(\"NO\");\n\telse\n\t printf(\"YES\");\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c5a0fca2de554e9b4e57b75a6a34060f", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n\tlong long i, j, k;\n\tlong long n;\n\tlong long arr[10000];\n\tchar str[1000];\n\tscanf(\"%lld\", &n);\n\tscanf(\"%s\", str);\n\tlong long len=strlen(str);\n\tlong long maj_count=0,count=0,flag=0;\n\tk=0;\n\tfor(i=0;str[i]!='\\0';i++)\n\t{\n\t\tif(str[i]=='B')\n\t\t\tcount++;\n\t\tif((str[i]=='W' && str[i-1]=='B') || (str[i]=='B' && i==len-1))\n\t\t{\n\t\t\tflag=1;\n\t\t//\tprintf(\"%c\",str[i]);\n\t\t\tarr[k]=count;\n\t\t\tk++;\n\t\t\tcount=0;\n\t\t\tmaj_count++;\n\t\t}\n\t}\n\t\n\tprintf(\"%lld\\n\",maj_count);\n\tfor(i=0;i\nint main ()\n{\n long long n;\n scanf(\"%lld\",&n);\n if(n%2==0)\n {\n printf(\"%lld\\n\",n/2);\n return 0;\n }\n for(long long i=2;(i*i)<=n;i++)\n {\n if(n%i==0)\n { \n int flag=0;\n for(long long j=2;j\n\nint main() {\n\tint a, b, f, k, i, x, ans;\n\n\tscanf(\"%d%d%d%d\", &a, &b, &f, &k);\n\tx = b;\n\tans = 0;\n\tfor (i = 0; i < k; i++)\n\t\tif (i % 2 == 0)\n\t\t\tif (x >= f && (i == k - 1 && x >= a) || x >= a + a - f)\n\t\t\t\tx -= a;\n\t\t\telse if (x >= f && b >= a - f)\n\t\t\t\tx = b - (a - f), ans++;\n\t\t\telse {\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\telse\n\t\t\tif (x >= a - f && (i == k - 1 && x >= a) || x >= a + f)\n\t\t\t\tx -= a;\n\t\t\telse if (x >= a - f && b >= f)\n\t\t\t\tx = b - f, ans++;\n\t\t\telse {\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "c22e8cc75702f10ff17cd6de945b8090", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint a[100];\nint main()\n{\n int n,i;\n while(scanf(\"%d\",&n)==1)\n {\n for(i=0; ia[n-2])\n {\n printf(\"UP\\n\");\n }\n else\n {\n printf(\"DOWN\\n\");\n }\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "bb6867b30205b54680c3a50ad1a91b5c", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong long int a, b;\n\tlong long int ZA[10];\n\n\tfor (a = 2; a < 10; ZA[a++] = 0);\n\tscanf(\"%lld%lld\", &a, &b);\n\twhile (b) {\n\t\tif (b % 10 == 2)\n\t\t\tZA[2] += 1;\n\t\telse if (b % 10 == 3)\n\t\t\tZA[3] += 1;\n\t\telse if (b % 10 == 4) {\n\t\t\tZA[2] += 2;\n\t\t\tZA[3] += 1;\n\t\t} else if (b % 10 == 5)\n\t\t\tZA[5] += 1;\n\t\telse if (b % 10 == 6) {\n\t\t\tZA[5] += 1;\n\t\t\tZA[3] += 1;\n\t\t} else if (b % 10 == 7)\n\t\t\tZA[7] += 1;\n\t\telse if (b % 10 == 8) {\n\t\t\tZA[2] += 3;\n\t\t\tZA[7] += 1;\n\t\t} else if (b % 10 == 9) {\n\t\t\tZA[2] += 1;\n\t\t\tZA[3] += 2;\n\t\t\tZA[7] += 1;\n\t\t}\n\t\tb /= 10;\n\t}\n\tfor (a = 9; a > 1; --a)\n\t\twhile (ZA[a]-- > 0)\n\t\t\tprintf(\"%lld\", a);\n\tprintf(\"\\n\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "sortings", "greedy"], "code_uid": "847124c0429a31e90b24ef2ed24c2441", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\ntypedef long long int ll;\nint main()\n{\n ll n;\n scanf(\"%lld\",&n);\n if(n%2==0)\n {\n \t/*ll mid = n/2,mid1= mid+1;\n \tll sum1=0,sum2=0,dif=0;\n \tfor(ll i=1;i\nint main()\n{\n int j,k;\n int a[4];\n scanf(\"%d\",&a[0]);\n for(int i=1;i<4;i++)\n {\n scanf(\"%d\",&a[i]);\n int key=a[i];\n j=i-1;\n if(a[j]>key)\n {\n while(j>=0 && a[j]>key)\n {\n a[j+1]=a[j];\n j--;\n }\n a[j+1]=key;\n }\n }\n if(a[0]+a[3]==a[1]+a[2] || a[0]+a[1]+a[2]==a[3] )\n printf(\"YES\");\n else\n printf(\"NO\");\n \n \n \n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "6ce84a4e90e5474242b5b04110c8e518", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int f1[10],f2[10];\n int i;\n\n for(i=0;i<3;i++)\n scanf(\"%d\",&f1[i]);\n for(i=0;i<3;i++)\n scanf(\"%d\",&f2[i]);\n \n int j=1;\n i=0;\n if(\n !((fabs(f1[0]-f2[0])==1)&&\n (fabs(f1[1]-f2[1])==1)&&\n (fabs(f1[2]-f2[2])==1))\n )\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "a5a611a64c3b5bee1751a34e03c7309d", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint type[3][3],flag=0;\nint all[3];\nchar temp[2];\nint result0(int x,char cx)\n{\n if(x==3)\n {\n if(all[0]==all[1]&&all[1]==all[2])\n return 1;\n else if(all[1]-all[0]==1&&all[2]-all[1]==1)\n return 1;\n else\n return 0;\n }\n return 0;\n}\nint result1(int x,char cx)\n{\n if(x==2)\n {\n if((cx=='s'&&type[0][0]==type[0][1])||(cx=='m'&&type[1][0]==type[1][1])||(cx=='p'&&type[2][0]==type[2][1]))\n return 1;\n if((cx=='s'&&type[0][1]-type[0][0]<=2)||(cx=='m'&&type[1][1]-type[1][0]<=2)||(cx=='p'&&type[2][1]-type[2][0]<=2))\n return 1;\n return 0;\n }\n if(x==3)\n {\n if(all[0]==all[1]||all[1]==all[2])\n return 1;\n if(all[1]-all[0]<=2||all[2]-all[1]<=2)\n return 1;\n return 0;\n }\n return 0;\n}\nint main()\n{\n int i,j,s=0,m=0,p=0,kt;\n for(i=0,j=0;i<3;i++)\n {\n scanf(\"%s\",temp);\n if(temp[1]=='s')\n type[0][s++]=temp[0]-'0';\n if(temp[1]=='m')\n type[1][m++]=temp[0]-'0';\n if(temp[1]=='p')\n type[2][p++]=temp[0]-'0';\n all[j++]=temp[0]-'0';\n }\n for(i=0;i<3;i++)\n {\n for(j=i+1;j<3;j++)\n {\n if(all[i]>all[j])\n {\n kt=all[i];\n all[i]=all[j];\n all[j]=kt;\n }\n }\n }\n for(i=0;itype[0][j])\n {\n kt=type[0][i];\n type[0][i]=type[0][j];\n type[0][j]=kt;\n }\n }\n }\n for(i=0;itype[1][j])\n {\n kt=type[1][i];\n type[1][i]=type[1][j];\n type[1][j]=kt;\n }\n }\n }\n for(i=0;itype[2][j])\n {\n kt=type[2][i];\n type[2][i]=type[2][j];\n type[2][j]=kt;\n }\n }\n }\n if(result0(s,'s'))\n printf(\"0\");\n else if(result0(m,'m'))\n printf(\"0\");\n else if(result0(p,'p'))\n printf(\"0\");\n else if(result1(s,'s'))\n printf(\"1\");\n else if(result1(m,'m'))\n printf(\"1\");\n else if(result1(p,'p'))\n printf(\"1\");\n else\n printf(\"2\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b970e2f479708fe8ac86c485a7bb08b6", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tlong int x,y;\n\tscanf(\"%ld %ld\",&x,&y);\n\tif(x==y)\n\t printf(\"=\");\n\telse if((x==2)&&(y==3))\n\t printf(\"<\");\n\telse if((x==3)&&(y==2))\n\t printf(\">\");\n\telse if((x==2)&&(y==4))\n\t printf(\"=\");\n\telse if((x==4)&&(y==2))\n\t printf(\"=\");\n\telse if(x==1)\n\t printf(\"<\");\n\telse if(y==1)\n\t printf(\">\");\n\telse if(x\");\n\telse\n\t printf(\"<\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "cd10c6f827834e95b7a4bcad9282137e", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main(void)\n{\n\tint n, sum = 0, num[55], min = 100;\n\tchar s[55];\n\t\n\tscanf(\"%d\", &n);\n\tscanf(\"%s\", s);\n\tfor(int i = 0; i < n-3; i++)\n\t{\n\t\tif(abs(s[i] - 'A') <= 13)\n\t\t{\n\t\t\tsum += abs(s[i] - 'A');\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsum += 26 - abs(s[i] - 'A');\n\t\t}\n\t\t//printf(\"%d \", sum);\n\t\tif(abs(s[i+1] - 'C') <= 13)\n\t\t{\n\t\t\tsum += abs(s[i+1] - 'C');\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsum += 26 - abs(s[i+1] - 'C');\n\t\t}\n\t\t//printf(\"%d \", sum);\n\t\tif(abs(s[i+2] - 'T') <= 13)\n\t\t{\n\t\t\tsum += abs(s[i+2] - 'T');\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsum += 26 - abs(s[i+2] - 'T');\n\t\t}\n\t\t//printf(\"%d \", sum);\n\t\tif(abs(s[i+3] - 'G') <= 13)\n\t\t{\n\t\t\tsum += abs(s[i+3] - 'G');\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsum += 26 - abs(s[i+3] - 'G');\n\t\t}\n\t\t//printf(\"%d\\n\", sum);\n\t\tnum[i] = sum;\n\t\tsum = 0;\n\t}\n\tfor(int i = 0; i < n-3; i++)\n\t{\n\t\tif(min > num[i])\n\t\t{\n\t\t\tmin = num[i]; \n\t\t}\n\t}\n\tprintf(\"%d\", min);\n\t\n\treturn 0;\n} ", "lang_cluster": "C", "tags": ["brute force", "strings"], "code_uid": "72d49aa6b014a716f41e89d91febe8f3", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n int repaso,limite,paginas,inicio,aceleracion;\n int cant=0;\n scanf(\"%d %d %d %d %d\",&paginas,&inicio,&limite,&aceleracion,&repaso);\n while(paginas>0){\n \n if(cant==0){\n paginas=paginas-inicio;\n\n }\n else{\n paginas=paginas-inicio+repaso;\n\n }\n if(limite > inicio+aceleracion)\n inicio=inicio+aceleracion;\n else\n inicio=limite;\n cant++;\n\n }\n printf(\"%d\",cant);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7bff3ac9fe6ec27fb9fc3d8fe61c2a6d", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int w1,h1,w2,h2;\n scanf(\"%d %d %d %d\",&w1,&h1,&w2,&h2);\n printf(\"%d\",2*(w1+h1+h2)+4);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "280c3e38f6a3082563a1e01df2883158", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,a,b;\n scanf(\"%d%d%d\",&n,&a,&b);\nif(n<=a&&n<=b)\n printf(\"YES\\n\");\nelse\n printf(\"NO\\n\");\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4cdc3a28835e122167c1f0868b2e85f6", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint small(int,int);\nint big(int,int);\n\nint main()\n{\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tint maxn=n*2;\n\tint maxm=m*3;\n\tint count=0;\n\t\n\twhile(small(maxn,maxm)/6-count)\n\t{\n\t\tif(maxn+2 < maxm+3)\n\t\t\tmaxn+=2;\n\t\telse\n\t\t\tmaxm+=3;\n\t\tcount++;\n\t}\n\n\tprintf(\"%d\\n\",big(maxn,maxm));\n\treturn 0;\n}\n\nint small(int a,int b)\n{\n\tif(ab)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "5bfd260c3f5aff61d49c673ec41556a2", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#define N 50\nint main(){\n char opcion1[]= {\"http://\"};\n char opcion2[]={\"ftp://\"};\n char opcion3[]={\".ru\"};\n char opcion4= '/';\n\n int i=0;\n int subindice=0;\n int j=0;\n int bandera=0;\n char direccion[N];\n \n \n scanf(\"%s\",direccion);\n if(direccion[0]== 'h'){\n printf(\"%s\",opcion1);\n i+=4;\n }\n else {\n i+=3;\n printf(\"%s\",opcion2);\n }\n while(direccion[i]!='\\0'){\n if(direccion[i]=='r' && direccion[i+1]=='u' && bandera==1){\n printf(\"%s\",opcion3);\n i+=2;\n if(direccion[i]!='\\0'){\n printf(\"%c\",opcion4);\n for(subindice=i; subindice<(strlen(direccion)); subindice++){\n printf(\"%c\",direccion[subindice]);\n }\n i=strlen(direccion);\n }\n }\n else if (bandera==0){\n if(direccion[i]=='r' && direccion[i+1]=='u'){\n printf(\"%c\",direccion[i]);\n i++;\n printf(\"%c\",direccion[i]);\n i++;\n bandera=1;\n }\n for(subindice=i; subindice\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long\n#define For(i,n)\tfor(i=0;i b ? a : b)\t;}\nll gcd(ll a,ll b){\n\tif(a==0)\treturn b;\n\treturn gcd(b%a ,a);\n} \n/*\nchar a[11] ,b[11] ,ans[23];\nint main(){\n\tscanf(\"%s %s\" ,a ,b);\n\tint n = strlen(a) ,m = strlen(b) ,i;\n//puts(a);\tputs(b);\n\tans[0] = a[0];\n\ti = 1;\n\twhile(i < n){\n\t\tif(a[i] >= b[0])\tbreak;\n\t\tans[i] = a[i];\n\t\ti++;\n\t}\n\tans[i++] = b[0];\n\tans[i++] = '\\0';\n\tprintf(\"%s\" ,ans);\n\treturn 0;\n}\n*/\n\nint main(){\n\tint n ,i ,l;\n\ts(n);\n\tll ans = 0;\n\tfor(l = 1 ; l <= n ; l++)\n\t\tans += 1 + min(l - 1 ,n - l);\n\tprintf(\"%I64d\" ,ans);\n\treturn 0;\n}\n/*\nconst int MOD = 1e9+7;\nint n;\nll dt[5010][5010];\nll ans;\nint main(){\n char c, prev = 0;\n scanf(\"%d\", &n);\n dt[0][0] = 1;\n for (int i = 1; i <= n; i++){\n scanf(\" %c\", &c);\n if (prev == 'f')\n for (int j = 0; j < n; j++)\tdt[i][j] = dt[i-1][j-1];\n else\n for (int j = n-1; j >= 0; j--)\tdt[i][j] = (dt[i][j+1]+dt[i-1][j])%MOD;\n prev = c;\n }\n for (int i = 0; i < n; i++)\n ans = (ans+dt[n][i])%MOD;\n printf(\"%I64d\\n\", ans);\n}*/\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "a567d2ac3b9ccc6371b2457152344aaa", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint m(int a,int b)\n{\n\tint ma=(a>b?a:b);\n return ma;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i,a[n],max,min,ans=0;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%d\",&a[i]);\n\t\tif(a[i]==n)\n\t\t\tmax=i;\n\t\telse if(a[i]==1)\n\t\t\tmin=i;\n\t}\n\tans=m(ans,n-min);\n\tans=m(ans,n-max);\n\tans=m(ans,max-1);\n\tans=m(ans,min-1);\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "464c78b09a5fa1b86f3173a148af1bba", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nlong long x,bx,y,by,a[100],b[100],m,n,t,k,i;\n\n\nint main() {\n t=1;k=1;\n scanf(\"%lld %lld\",&x,&bx);\n for (i=1;i<=x;i++)\n scanf(\"%lld\",&a[i]);\n scanf(\"%lld %lld\",&y,&by);\n for (i=1;i<=y;i++)\n scanf(\"%lld\",&b[i]);\n for (i=x;i>=1;i--)\n {\n \n m=m+a[i]*t;\n t=t*bx;\n }\n for (i=y;i>=1;i--)\n {\n \n n=n+b[i]*k;\n k=k*by;\n } \n \n if (m==n) { printf(\"=\");}\n else if (m>n) printf(\">\");\n else if(m\nint main(){\nint n,m,a,b,i,count,count1=0,count2,count3;\nscanf(\"%d %d %d %d\",&n,&m,&a,&b);\ncount=n*a;\nif(n%m==0){count3=(n/m)*b;}\nelse{count3=((n/m)+1)*b;}\nwhile(n>=0){\n if(n>m){\n n=n-m;\n count1=count1+b;\n }\n else{\n count2=count1+n*a;\n count1=count1+b;\n n=n-n;\n }\n if(n==0){break;}\n}\n\nif(count<=count1&&count<=count2&&count<=count3){\n printf(\"%d\",count);\n}\nelse if(count1\n#include \n\nint main() {\n int n, k;\n scanf(\"%d%d\", &n, &k);\n\n char s[n + 1];\n scanf(\"%s\", s);\n\n int cnt = 0;\n bool maxN = true, res = false;\n for(int i = 0; i < n; ++i) {\n cnt = (s[i] == 'N' ? cnt + 1 : 0);\n maxN &= cnt <= k;\n }\n\n if (maxN) {\n for (int i = 0; i + k <= n; ++i) {\n bool f = true;\n for (int j = i; j < i + k; ++j)\n f &= s[j] != 'Y';\n\n if (i != 0)\n f &= s[i - 1] != 'N';\n if (i + k != n)\n f &= s[i + k] != 'N';\n\n res |= f;\n }\n }\n\n puts(res ? \"YES\" : \"NO\");\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "c733c9bb27f951287d4c8cf5ea94c284", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,j,t,a,b,page, sum =0;\n int day[8];\n\n scanf (\"%d\",&page);\n\n for(i=1; i<8; i++){\n scanf(\"%d\", &day[i]);\n }\n\n j = 0;\n while(1){\n j++;\n sum = sum + day[j];\n if(sum >= page){\n printf(\"%d\\n\", j);\n break;\n }\n else if(j==7){\n j = 0;\n }\n\n\n }\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5aae891caa5a564ec3de3f155b951614", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n char s[101];int flag=0;\n scanf(\"%s\",s);\n int i;\n for(i=0;i\n#include \n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n#define REP(i, n) for((i) = 0; (i) < (n); (i)++)\n#define REP1(i, n) for((i) = 1; (i) <= (n); (i)++)\n\n#define SIZE 1000002\n\nstatic int s[SIZE], p[SIZE], np, min;\n\nstatic void sieve(void)\n{\n int i, j;\n\n for (i = 2; i < SIZE; i++) {\n if (s[i] == 0) {\n p[np++] = i;\n\n for (j = 2; i * j < SIZE; j++) {\n s[i * j] = 1;\n }\n }\n }\n}\n\n#define MAX(x, y) ((x) > (y) ? (x) : (y))\n\nstatic void solve(int x, int l)\n{\n int i, d, lf = -1, ox = x;\n\n if (x < min) {\n min = x;\n }\n\n if (l == 0) {\n return;\n }\n\n for (i = 0; p[i] * p[i] <= x; i++) {\n if (ox % p[i] == 0) {\n lf = MAX(lf, p[i]);\n while (ox % p[i] == 0)\n ox /= p[i];\n }\n }\n if (ox > 1 && ox != x)\n lf = MAX(lf, ox);\n\n if (lf == -1) {\n return;\n }\n \n if (l == 1) {\n x = x - lf + 1;\n if(x < min)\n min = x;\n return;\n }\n\n for (d = x - lf + 1; d < lf * (x / lf); d++) {\n solve(d, l - 1);\n }\n}\n\nint main(void)\n{\n int x2;\n\n s[0] = s[1] = 1;\n sieve();\n min = INT_MAX;\n\n scanf(\"%d\", &x2);\n solve(x2, 2);\n printf(\"%d\", min);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "8555eecd49e7f3e6be95a2131a19bc16", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t10\n#define MD\t1000000007\n\nint ch[N][N], p2[N], p8[N];\n\nvoid init(int n) {\n\tint i, j;\n\n\tch[0][0] = 1;\n\tp2[0] = p8[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];\n\t\tp2[i] = p2[i - 1] * 2;\n\t\tp8[i] = p8[i - 1] * 8;\n\t}\n}\n\nlong long ans;\nint cnt[N + 1];\n\nvoid solve(int n, int i, int s, long long p) {\n\tint k;\n\n\tif (i == 6) {\n\t\tfor (k = s + 1; k <= n; k++)\n\t\t\tans = (ans + cnt[k] * p) % MD;\n\t\treturn;\n\t}\n\tfor (k = 0; s + k < n; k++)\n\t\tif (cnt[k] > 0) {\n\t\t\tsolve(n, i + 1, s + k, p * cnt[k]-- % MD);\n\t\t\tcnt[k]++;\n\t\t}\n}\n\nint main() {\n\tstatic char cc[N + 1];\n\tint n, m, h, i, j, k, k1, k2, r;\n\tchar tmp, d;\n\n\tscanf(\"%d\", &m), m++;\n\tn = 0;\n\twhile (m > 0) {\n\t\tcc[n++] = m % 10 + '0';\n\t\tm /= 10;\n\t}\n\tfor (i = 0, j = n - 1; i < j; i++, j--)\n\t\ttmp = cc[i], cc[i] = cc[j], cc[j] = tmp;\n\tinit(n);\n\tfor (i = 0; i < n; i++) {\n\t\tk = 0;\n\t\tfor (h = 0; h < i; h++)\n\t\t\tif (cc[h] == '4' || cc[h] == '7')\n\t\t\t\tk++;\n\t\tfor (d = '0'; d < cc[i]; d++) {\n\t\t\tk1 = k + (d == '4' || d == '7');\n\t\t\tr = n - 1 - i;\n\t\t\tfor (k2 = 0; k2 <= r; k2++)\n\t\t\t\tcnt[k1 + k2] += ch[r][k2] * p2[k2] * p8[r - k2];\n\t\t}\n\t}\n\tcnt[0]--;\n\tsolve(n, 0, 0, 1);\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "combinatorics"], "code_uid": "f82c7faddc5f784363b24db941c76ef6", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint n,i,j,p,flag=0,cnt=0;\nchar A[105];\nscanf(\"%d\",&n);\nscanf(\"%s\",A);\nfor(i=1;icnt)\n{\ncnt=p;\n}\n}\n}\nif(cnt!=0)\n{\n printf(\"%d\\n\",(n-cnt)+1);\n}\nelse\n{\nprintf(\"%d\\n\",n);\n}\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "4538a402a3dcd49df419af16959d24b3", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n\tint n;\n\tscanf(\"%d\", &n);\n\tlong long int ans=2;\n\tfor(long long int i=0; i\n\nint main(){\n\tint dim;\n\tscanf(\"%d\",&dim);\n\tint v[dim];\n\n\tint i;\n\tfor (int i = 0; i \nint main(){\n\tint n,x,i,t;\n\tscanf(\"%d %d\", &n,&x);\n\tint ans = x;\n \tfor(i = 0; i < n; i++){\n\t\tscanf(\"%d\", &t);\n\t\tif(t < x) ans--;\n else if(t==x)ans++;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "d8354977f745cc62119a6c5a6feb579e", "src_uid": "21f579ba807face432a7664091581cd8", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint max(int a, int b);\nint max(int a, int b)\n{\n if(a>b) return a;\n else return b;\n}\nint main()\n{\n int a1, a2, a3, b1, b2 ,b3;\n int A, B;\n\n scanf(\"%d %d %d %d %d %d\", &a1, &b1, &a2, &b2, &a3, &b3);\n A=0;\n B=0;\n A=a2;\n B=b2;\n A=A+a3;\n B=max(B,b3);\n if (((a1>=A)&&(b1>=B))||(a1>=B)&&(b1>=A))\n {\n printf(\"YES\");return 0;\n }\n\n A=a2;\n B=b2;\n A=A+b3;\n B=max(B,a3);\n if (((a1>=A)&&(b1>=B))||(a1>=B)&&(b1>=A))\n {\n printf(\"YES\");return 0;\n }\n A=a2;\n B=b2;\n A=max(A,a3);\n B=B+b3;\n if (((a1>=A)&&(b1>=B))||(a1>=B)&&(b1>=A))\n {\n printf(\"YES\");return 0;\n }\n A=a2;\n B=b2;\n A=max(A,b3);\n B=B+a3;\n if (((a1>=A)&&(b1>=B))||(a1>=B)&&(b1>=A))\n {\n printf(\"YES\");return 0;\n }\n\n\n else printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "6bd6c9b230247cddd7781bd689126a55", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n,m,r;\n long long int max,min,d;\n scanf(\"%lld%lld\",&n,&m);\n max=((n-m)*(n-m+1))/2;\n d=n/m;\n r=n%m;\n min=(m-r)*(((d)*(d-1))/2LL)+r*(((d+1)*(d))/2);\n printf(\"%lld %lld\",min,max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "572ac819b675ffe9836bdf335961db32", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint arr[105];\nint chk[105];\nint main(void)\n\n{\n\tint i, j, k;\n\tint tmp;\n\tint N;\n\n\tscanf(\"%d\", &N);\n\n\tfor (i = 1; i <= N; ++i){\n\t\tscanf(\"%d\", &arr[i]);\n\t\ttmp = arr[i];\n\t\t++chk[arr[i]];\n\t}\n\tif (chk[tmp] == N){\n\t\tprintf(\"0\");\n\t\treturn 0;\n\t}\n\telse{\n\t\tfor (i = 1; i <= 100; ++i){\n\t\t\tmemset(chk, 0, sizeof(chk));\n\t\t\tfor (j = 1; j <= N; ++j){\n\t\t\t\tif (arr[j] - i >= 0){\n\t\t\t\t\t++chk[arr[j] - i];\n\t\t\t\t}\n\t\t\t\tif (arr[j] + i <= 100){\n\t\t\t\t\t++chk[arr[j] + i];\n\t\t\t\t}\n\t\t\t\t++chk[arr[j]];\n\t\t\t}\n\n\t\t\tfor (j = 0; j <= 100; ++j){\n\t\t\t\tif (chk[j] == N){\n\t\t\t\t\tprintf(\"%d\", i);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "dfd8695a4678cd18f923badfa8aa9142", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "# include \n\n# define R register\n\ntypedef int I;\ntypedef char C;\n\nint main()\n{\n\tC t[6];\n\tscanf( \"%s\", t );\n\tR I h = ((t[0] - '0') * 10) + (t[1] - '0'), r = ((t[1] - '0') * 10) + (t[0] - '0');\n\tR I m = ((t[3] - '0') * 10) + (t[4] - '0'), d = r - m;\n\tif ( d < 0 || (m + d) > 59 )\n\t{\n\t\tR I tt = 0;\n\t\tloop:\n\t\t\ttt += 60;\n\t\t\t(++h == 24) ? (r = 0) : (r = ((h % 10) * 10) + (h / 10));\n\t\t\tif ( r > 59 )\n\t\t\t\tgoto loop;\n\t\tprintf( \"%d\\n\", (tt - m) + r );\n\t}\n\telse\n\t\tprintf( \"%d\\n\", d );\n \treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "f269736e974e17921e691181abeb83d7", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n//#include\nint main()\n{\n\tint m,n,len;\n\tchar ar[5][3],c,str[21];\n\t\n\tscanf(\"%d %d\",&m,&n);\n\t\n\tscanf(\"%s\",str);\n\tar[1][0] = ar[2][0] = str[0];;\n\tar[3][0] = ar[4][0] = str[m -1];\n\tar[1][2] = ar[2][2] = ar[3][2] = ar[4][2] = '\\0';\n\n\tscanf(\"%s\",str);\n\tar[1][1] = ar[4][1] = str[0];\n\t//len = strlen(str);\n\tar[3][1] = ar[2][1] = str[n - 1];\n\n\t\n\tif(ar[1][0] == '>' && ar[1][1] == 'v')\n\t\tprintf(\"NO\\n\");\n\telse if(ar[2][0] == '<' && ar[2][1] == 'v')\n\t\tprintf(\"NO\\n\");\n\telse if(ar[3][0] == '<' && ar[3][1] == '^')\n\t\tprintf(\"NO\\n\");\n\telse if(ar[4][0] == '>' && ar[4][1] == '^')\n\t\tprintf(\"NO\\n\");\n\telse\n\t\tprintf(\"YES\\n\");\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "5e9ca8f2645d60d64e67fad2f7e0084e", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int x, y;\n scanf (\"%d %d\", &x, &y);\n if (x == y) {\n printf (\"No\\n\");\n return 0;\n }\n else if (x < y) {\n if (y - x == 1) {\n printf (\"Yes\\n\");\n return 0;\n }\n else {\n printf (\"No\\n\");\n return 0;\n }\n }\n else {\n if (y == 0 || y == 1) {\n printf (\"No\\n\");\n return 0;\n }\n y = y - 1;\n x = x - y;\n if (x & 1) {\n printf (\"No\\n\");\n return 0;\n }\n else {\n printf (\"Yes\\n\");\n return 0;\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b013cce57e192bfba346c95350eb8297", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main(int argc, char **argv)\n{\n\tchar codigo[81];\n\t\n\tscanf(\"%s\",codigo);\n\tint i;\n\tchar matriz[10][11];\n\tfor(i = 0 ; i < 10 ; i++){\n\t\tscanf(\"%s\",&matriz[i][0]);\n\t\t\n\t\t\n\t}\n\n\t\n\tint j ;\n\tchar *p = codigo;\n\n\tfor( i = 0 ; i < 9; i++){\n\t\t\t\n\t\t\tfor( j = 0 ; j < 10 ; j++){\n\t\t\t\t\tif(strncmp(p,matriz[j],10) == 0){\n\t\t\t\t\t\t\tprintf(\"%d\",j);\n\t\t\t\t\t\t\tbreak;\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\t\t\n\t\t\t}\n\t\t\tp= p + 10;\n\t\t\n\t\t\n\t}\n\treturn 0;\n}\n\t\n\t\n\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "d5cd1b2b74f59d215fb53ce12829c338", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main ()\n{\n int x,y,z,i,j,a;\n int sum=0,ck=0;\n int arr[1001];\n scanf(\"%d\",&i);\n for(j=0;j15){\n printf(\"%d\\n\",sum+15);\n ck=1;\n break;\n }\n sum=arr[j];\n }\n if(ck==0){\n printf(\"%d\\n\",90);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "dace0e1dca293ce75a39f9391a05f471", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\nint main()\r\n{\r\n int T;\r\n scanf(\"%d\",&T);\r\n for(int i=0;i\n#include\nint main()\n{\n long long int n,k;\n int s;\n scanf(\"%lld %lld\",&n,&k);\n s=(n*2-1)/k+(n*5-1)/k+(n*8-1)/k+3;\n\n printf(\"%d\",s);\n\n\n\n\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "20394390940ac91a08e592867b440256", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\nint n,i,j=0,b,c;\nscanf(\"%d\",&n);\nchar a[n],d[n];\nscanf(\"%s\",a);\nb=1;\nc=2;\nfor(;;){\n d[j]=a[b-1];\n if(b==n)break;\n b+=c;\n c++;\n j++;\n}\nfor(i=0;i<=j;i++){\nprintf(\"%c\",d[i]);\n}\nreturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d863b9add2f71234fa08d0757bd12672", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tint n;\n\tchar a[10];\n\tchar b[10];\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",a);\n\tscanf(\"%s\",b);\n\tint flag=0,i;\n\t\n\tif(b[0]=='m')\n\t{\n\t\tflag=1;\n\t}\n\t\n\tif(flag==1)\n\t{\n\t\tif(n<=29)\n\t\t{\n\t\t\tprintf(\"%d\",12);\n\t\t}\n\t\telse if(n==30)\n\t\t{\n\t\t\tprintf(\"%d\",11);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"%d\",7);\n\t\t}\n\t}\n\telse\n\t{\n\t\tif(n==5||n==6)\n\t\t{\n\t\t\tprintf(\"%d\",53);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"%d\",52);\n\t\t}\n\t}\n\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7aa2bd269056ed4ff1c4367284232de0", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \t\t\n#define LAST 1000000000000000001L\nmain()\n{\n\tlong long int year, yarr[4000];\n\tlong long twop[66];\n\tlong long p,pmax,a,b;\n\tint i,j,ind,count;\n\tp = 1;\n\ttwop[0]=1;\n\tfor (i=1; p0; j--)\n\t\t\tyarr[ind++] = twop[i]-1-twop[j-1];\n\tscanf(\"%lld %lld\", &a, &b);\n\tcount=0;\n\tfor (i=0; i= yarr[i]) count++;\n\tprintf(\"%d\\n\",count);\n\treturn 0;\t\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "94557125bc8077cbce180996f3cb0244", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n#define rep(a, b) for(int a=0; a 0) {\n total *= b;\n --e;\n }\n return total;\n}\n\nint qnt_dig(int n) {\n int cont=0;\n while(n >= 1) {\n n /= 10;\n ++cont;\n }\n return cont;\n}\n\nint inverte(int n) {\n int inverso=0;\n int cont = qnt_dig(n);\n while(n >= 1) {\n inverso += (n%10)*pot(10, cont-1);\n n /= 10;\n --cont;\n }\n return inverso;\n}\n\nint main() {\n int a, b;\n scanf(\"%d%d\", &a, &b);\n printf(\"%d\\n\", a+inverte(b));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms"], "code_uid": "00cc9643d7ac58f03f6f663752a4e316", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n long long int N, M;\r\n scanf(\"%lld%lld\", &N, &M);\r\n printf(\"%lld\\n\", (M!=1)?(M-1)*N:(N-1)*M);\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "62f23512ca30436eec47e5abaa7fddff", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n;\n scanf(\"%lld\",&n);\n if(n>=0)\n printf(\"%lld\\n\",n);\n\n else\n {\n long long int a = n/10;\n long long int b = a/10 *10 + n%10;\n if(a>b)\n printf(\"%lld\\n\",a);\n else\n printf(\"%lld\\n\",b);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "57213ee4f7127b79a6406dec330a7bfe", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tdouble l,r,x,y,k,i;\n\tscanf(\"%lf%lf%lf%lf%lf\",&l,&r,&x,&y,&k);\n\t\n\tfor(i= x; i<=y ; i++)\n\t{\n\t\tdouble val = 0;\n\t\tval = i*k;\n\t\tif(val>=l && val<=r)\n\t\t{\n\t\t\tprintf(\"YES\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\tprintf(\"NO\\n\");\n\t\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "brute force"], "code_uid": "cc99305036ed5dbda588c54baadc59a6", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\ntypedef struct {\n int len;\n char letter;\n}nodes;\n\nint main()\n{\n int i=0,j=0,k=0,flag=0,flag2=2,q=0;\n nodes node[5];\n char stra[105],strb[105],strc[105],strd[105];\n scanf(\"%s\",&stra);\n scanf(\"%s\",&strb);\n scanf(\"%s\",&strc);\n scanf(\"%s\",&strd);\n node[0].len=strlen(stra)-2;\n node[0].letter='A';\n node[1].len=strlen(strb)-2;\n node[1].letter='B';\n node[2].len=strlen(strc)-2;\n node[2].letter='C';\n node[3].len=strlen(strd)-2;\n node[3].letter='D';\n //at least half shorter\n for(i=0;i<4;i++) {\n for(j=0;j<4;j++) {\n if(i==j) {k++;continue;}\n if(2*node[i].len<=node[j].len) k++;\n }\n if(k==4) {flag++;flag2=0;break;}\n else k=0;\n }\n k = 0 ;\n //at least twice longer\n for(q=0;q<4;q++) {\n for(j=0;j<4;j++) {\n if(q==j) {k++;continue;}\n if(node[q].len>=2*node[j].len) k++;\n }\n if(k==4) {flag++;flag2=1;break;}\n else k=0;\n }\n if(flag>1) printf(\"C\");\n else if(flag2==0) printf(\"%c\",node[i].letter);\n else if(flag2==1) printf(\"%c\",node[q].letter);\n else {\n printf(\"C\");\n }\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2ff844f004c1f45f1a7d8097c43e6c9f", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n\nint main()\n{\n int k,a,b,x,y,m;\n scanf(\" %d %d %d\",&k,&a,&b);\n\n if((a\n#include \n#define N 9\n//8!=P\n#define P 50000\nint record[P][N];\nint nr=0;\nint max=0;\n\n/* function to swap array elements */\n\nvoid swap (int p[], int i, int j) {\n int t;\n t = p[i];\n p[i] = p[j];\n p[j] = t;\n}\nlong long f(int p[],int n){\n int mins[N][N];\n int i,j;\n for(i=0;imax)max=record[nr][n];\n nr++;\n } else\n /* recursively explore the permutations starting\n * at index i going through index n-1\n */\n for (j=i; jrecord[min][k]){\n break;\n }else if(record[j][k]\n#include\nmain()\n{\n int n;\n scanf(\"%d\",&n);\n switch(n){\n case 0: printf(\"zero\"); break;\n case 1: printf(\"one\"); break;\n case 2: printf(\"two\"); break;\n case 3: printf(\"three\"); break;\n case 4: printf(\"four\"); break;\n case 5: printf(\"five\"); break;\n case 6: printf(\"six\"); break;\n case 7: printf(\"seven\"); break;\n case 8: printf(\"eight\"); break;\n case 9: printf(\"nine\"); break;\n case 10: printf(\"ten\"); break;\n case 11: printf(\"eleven\"); break;\n case 12: printf(\"twelve\"); break;\n case 13: printf(\"thirteen\"); break;\n case 14: printf(\"fourteen\"); break;\n case 15: printf(\"fifteen\"); break;\n case 16: printf(\"sixteen\"); break;\n case 17: printf(\"seventeen\"); break;\n case 18: printf(\"eighteen\"); break;\n case 19: printf(\"nineteen\"); break;\n case 20: printf(\"twenty\"); break;\n case 21: printf(\"twenty-one\"); break;\n case 22: printf(\"twenty-two\"); break;\n case 23: printf(\"twenty-three\"); break;\n case 24: printf(\"twenty-four\"); break;\n case 25: printf(\"twenty-five\"); break;\n case 26: printf(\"twenty-six\"); break;\n case 27: printf(\"twenty-seven\"); break;\n case 28: printf(\"twenty-eight\"); break;\n case 29: printf(\"twenty-nine\"); break;\n case 30: printf(\"thirty\"); break;\n case 31: printf(\"thirty-one\"); break;\n case 32: printf(\"thirty-two\"); break;\n case 33: printf(\"thirty-three\"); break;\n case 34: printf(\"thirty-four\"); break;\n case 35: printf(\"thirty-five\"); break;\n case 36: printf(\"thirty-six\"); break;\n case 37: printf(\"thirty-seven\"); break;\n case 38: printf(\"thirty-eight\"); break;\n case 39: printf(\"thirty-nine\"); break;\n case 40: printf(\"forty\"); break;\n case 41: printf(\"forty-one\"); break;\n case 42: printf(\"forty-two\"); break;\n case 43: printf(\"forty-three\"); break;\n case 44: printf(\"forty-four\"); break;\n case 45: printf(\"forty-five\"); break;\n case 46: printf(\"forty-six\"); break;\n case 47: printf(\"forty-seven\"); break;\n case 48: printf(\"forty-eight\"); break;\n case 49: printf(\"forty-nine\"); break;\n case 50: printf(\"fifty\"); break;\n case 51: printf(\"fifty-one\"); break;\n case 52: printf(\"fifty-two\"); break;\n case 53: printf(\"fifty-three\"); break;\n case 54: printf(\"fifty-four\"); break;\n case 55: printf(\"fifty-five\"); break;\n case 56: printf(\"fifty-six\"); break;\n case 57: printf(\"fifty-seven\"); break;\n case 58: printf(\"fifty-eight\"); break;\n case 59: printf(\"fifty-nine\"); break;\n case 60: printf(\"sixty\"); break;\n case 61: printf(\"sixty-one\"); break;\n case 62: printf(\"sixty-two\"); break;\n case 63: printf(\"sixty-three\"); break;\n case 64: printf(\"sixty-four\"); break;\n case 65: printf(\"sixty-five\"); break;\n case 66: printf(\"sixty-six\"); break;\n case 67: printf(\"sixty-seven\"); break;\n case 68: printf(\"sixty-eight\"); break;\n case 69: printf(\"sixty-nine\"); break;\n case 70: printf(\"seventy\"); break;\n case 71: printf(\"seventy-one\"); break;\n case 72: printf(\"seventy-two\"); break;\n case 73: printf(\"seventy-three\"); break;\n case 74: printf(\"seventy-four\"); break;\n case 75: printf(\"seventy-five\"); break;\n case 76: printf(\"seventy-six\"); break;\n case 77: printf(\"seventy-seven\"); break;\n case 78: printf(\"seventy-eight\"); break;\n case 79: printf(\"seventy-nine\"); break;\n case 80: printf(\"eighty\"); break;\n case 81: printf(\"eighty-one\"); break;\n case 82: printf(\"eighty-two\"); break;\n case 83: printf(\"eighty-three\"); break;\n case 84: printf(\"eighty-four\"); break;\n case 85: printf(\"eighty-five\"); break;\n case 86: printf(\"eighty-six\"); break;\n case 87: printf(\"eighty-seven\"); break;\n case 88: printf(\"eighty-eight\"); break;\n case 89: printf(\"eighty-nine\"); break;\n case 90: printf(\"ninety\"); break;\n case 91: printf(\"ninety-one\"); break;\n case 92: printf(\"ninety-two\"); break;\n case 93: printf(\"ninety-three\"); break;\n case 94: printf(\"ninety-four\"); break;\n case 95: printf(\"ninety-five\"); break;\n case 96: printf(\"ninety-six\"); break;\n case 97: printf(\"ninety-seven\"); break;\n case 98: printf(\"ninety-eight\"); break;\n case 99: printf(\"ninety-nine\"); break;\n default: printf(\"NO\"); break; }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "5696c99570d3b865221a8fdcdde5c2bd", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint i = 2, num;\n\t\n\tscanf(\"%d\", &num);\n\tprintf(\"%d \", num);\n\t\n\twhile(num > 1){\n\t\tfor(i = 2; i < num && num % i != 0; i++){}\n\t\tnum /= i;\n\t\tprintf(\"%d \", num);\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "5f6435b64f9a140c0c3db8739709d749", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n long int a,b,c,d,max,min,mid,total=0;\n scanf(\"%ld %ld %ld %ld\",&a,&b,&c,&d);\n max=a>b?a>c?a:c:b>c?b:c;\n min=a\n#include \n\nint main()\n{\n int n,x,m,i,y;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++){\n scanf(\"%d\",&m);\n x=m%10;\n if(m/1111!=0) y=4;\n else if(m/111!=0) y=3;\n else if(m/11!=0) y=2;\n else y=1;\n printf(\"%d\\n\",10*(x-1)+y*(y+1)/2);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c15ec9486bca9e5a8b337c840435017f", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int board[4][4] = {0};\n for (int i = 0; i < 4; i++)\n for (int j = 0; j < 4; j++) {\n char c;\n scanf(\"%c \", &c);\n if (c == 'x') board[i][j] = 1;\n else if (c == 'o') board[i][j] = -3;\n else board[i][j] = 0;\n }\n bool can_win = false;\n for (int i = 0; !can_win && i < 4; i++) {\n for (int j = 0; j < 4; j++) {\n if (board[i][j] >= 0) { /* 'x' or '.' */\n int sum_hor = 0, sum_dia_up = 0, sum_dia_down = 0, sum_ver = 0;\n if (j < 2)\n sum_hor = board[i][j] + board[i][j+1] + board[i][j+2];\n if (i < 2)\n sum_ver = board[i][j] + board[i+1][j] + board[i+2][j];\n if (i < 2 && j < 2)\n sum_dia_up = board[i][j] + board[i+1][j+1] + board[i+2][j+2];\n if (i >= 2 && j < 2)\n sum_dia_down = board[i][j] + board[i-1][j+1] + board[i-2][j+2];\n\n if (sum_hor == 2 || sum_dia_up == 2 || sum_dia_down == 2 || sum_ver == 2) {\n can_win = true;\n break;\n }\n }\n }\n }\n if (can_win)\n puts(\"YES\");\n else\n puts(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "764da4e62b638467806af12b92ac4f97", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint box[100][100];\nint main()\n{\n int n,i,j,t;\n scanf(\"%d\",&n);\n for(i=0; i\n#include \n#include \n\nint main(void)\n{\n int a, b, c, i, ans = 0;\n scanf(\"%d%d\", &a, &b);\n c = a - b;\n if (c == 0)\n {\n printf(\"infinity\");\n return 0;\n }\n\n for (i = 1; i * i <= c; i++)\n {\n if (c % i == 0)\n {\n if (i > b)\n ans++;\n if ((c / i != i) && (c / i > b))\n ans++;\n }\n }\n\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "bf1ca52fa974ce64075f88bdb79e8ad5", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#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\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))\n\n#define POS(i, j, k) ((((i) & 1) * (n + 1) + (j)) * (n + 1) + (k))\n\nvoid run (void) {\n const i32 n = read_int();\n const i32 m = read_int();\n const i32 mod = 998244353;\n i64 *dp = ALLOC (2 * (n + 1) * (n + 1), i64);\n dp[POS(1, 1, 1)] = 1;\n for (i32 i = 1; i < n; ++i) {\n memset (dp + POS(i + 1, 0, 0), 0, sizeof (*dp) * (n + 1) * (n + 1));\n for (i32 j = 1; j <= i; ++j) {\n for (i32 k = 1; k <= i; ++k) {\n dp[POS(i, j, k)] %= mod;\n dp[POS(i + 1, MAX (j, k + 1), k + 1)] += dp[POS(i, j, k)];\n dp[POS(i + 1, j, 1)] += dp[POS(i, j, k)];\n }\n }\n }\n i64 *way = ALLOC (n + 1, i64);\n for (i32 j = 1; j <= n; ++j) {\n for (i32 k = 1; k <= j; ++k) {\n way[j] += dp[POS(n, j, k)] % mod;\n }\n }\n for (i32 i = 1; i <= n; ++i) {\n way[i] %= mod;\n }\n i64 ans = 0;\n for (i32 i = 1; i <= n; ++i) {\n for (i32 j = 1; j <= n; ++j) {\n if (i * j < m) {\n ans += way[i] * way[j] % mod;\n }\n }\n }\n ans = 2 * ans % mod;\n print_int (ans);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "8b1f5e77d6f6921a78f21ef00d92ec7c", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t100\n\nint main() {\n\tstatic char cc[N + 1];\n\tint n, i, ans, zero;\n\n\tscanf(\"%s\", cc), n = strlen(cc);\n\tans = (n - 1) / 2 + 1;\n\tzero = 1;\n\tfor (i = 1; i < n; i++)\n\t\tif (cc[i] != '0') {\n\t\t\tzero = 0;\n\t\t\tbreak;\n\t\t}\n\tif (n % 2 == 1 && zero)\n\t\tans--;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "a68bc83cee990a8a4c4c9ce4faf61a65", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\nint i,j,m,max=0,min,A[100],n,a;\nscanf(\"%d\",&n);\nscanf(\"%d\",&m);\nfor(i=0;imax){\n max=A[i];\n }\n}\na=m;\ni=0;\nwhile(m>0&&i=(max-A[i])){\n m=m-(max-A[i]);\n //printf(\"%d %d\\n\",A[i],m);\n }\n else if(m<(max-A[i])){\n A[i]=A[i]+m;\n m=0;\n }\n\n }\n min=max;\n i=i+1;\n}\n\n//printf(\"%d %d\",min,m);\nif(m!=0)\n min=min+m/n;\nif(m%n!=0)\n min=min+1;\nprintf(\"%d %d\",min,max+a);\n}\n", "lang_cluster": "C", "tags": ["implementation", "binary search"], "code_uid": "eab00e76b3dc58159806a34aa22e8595", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tchar s[10],s1[10];\n\tint a,b,sum=0;\n\tscanf(\"%s%s\",s,s1);\n\tif(s[0]=='m')\n\t\ta=1;\n\telse if(s[0]=='t' && s[1]=='u')\n\t\ta=2;\n\telse if(s[0]=='w')\n\t\ta=3;\n\telse if(s[0]=='t' && s[1]=='h')\n\t\ta=4;\n\telse if(s[0]=='f')\n\t\ta=5;\n\telse if(s[0]=='s' && s[1]=='a')\n\t\ta=6;\n\telse if(s[0]=='s' && s[1]=='u')\n\t\ta=7;\n\n\tif(s1[0]=='m')\n\t\tb=1;\n\telse if(s1[0]=='t' && s1[1]=='u')\n\t\tb=2;\n\telse if(s1[0]=='w')\n\t\tb=3;\n\telse if(s1[0]=='t' && s1[1]=='h')\n\t\tb=4;\n\telse if(s1[0]=='f')\n\t\tb=5;\n\telse if(s1[0]=='s' && s1[1]=='a')\n\t\tb=6;\n\telse if(s1[0]=='s' && s1[1]=='u')\n\t\tb=7;\n//\tprintf(\"%d %d\\n\",a,b);\n\n/*\tif(a==b)\n\t\tprintf(\"YES\\n\");\n\telse if(b>a)\n\t{\n\t\tsum=b-a;\n\t\tif(29+sum==31 || 29+sum==32)\n\t\t\tprintf(\"YES\\n\");\n\t\telse\n\t\t\tprintf(\"NO\\n\");\n\t}\n\telse if(a>b)\n\t{\n\t\tsum=7-a+b;\n//\t\tprintf(\"%d\\n\",sum);\n\t\tif(29+sum==31 || 29+sum==32)\n\t\t\tprintf(\"YES\\n\");\n\t\telse\n\t\t\tprintf(\"NO\\n\");\n\t}*/\n\tint k=0,l=0;\n\tk=a-b;\n\tl=b-a;\n\tif(l==0 || l==2 || l==3 || k==4 || k==5)\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "91fecbda94cb5930da83c019b07b9e36", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"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;\n\tscanf(\"%d %d\", &n, &k);\n\tlong long dp[5], sum, tt, temp;\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, i - j) - 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", "tags": ["math", "dp", "combinatorics"], "code_uid": "e3a06b6e80fee93b7582e782e06953da", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\n#define MAX 1000010\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nvoid fft(long long n, long long* ar){\n long long i, j, x, g = n, flag = 0;\n while (((g != 1) || flag) && n > 1){\n flag = 0;\n if (g != 1) g *= 0.77425;\n\n for (i = 0; (i + g) < n; i++){\n if (ar[i] > ar[i + g]){\n flag = 1;\n x = ar[i], ar[i] = ar[i + g], ar[i + g] = x;\n }\n }\n }\n}\n\nlong long n, x, y, l, r, a, b, A[MAX], B[MAX], ar[MAX];\n\nlong long generate(long long b, long long* ar){\n long double p = 1.0;\n long long i, j, x = 1, len = 0;\n\n while (p < 2e18 && x <= (1LL << 60)){\n ar[len++] = x;\n p *= b, x *= b;\n }\n return len;\n}\n\nint main(){\n long long i, j, k, u, v, w, res, prev;\n\n while (scanf(\"%lld %lld %lld %lld\", &x, &y, &l, &r) != EOF){\n a = generate(x, A);\n b = generate(y, B);\n\n clr(ar);\n n = 0, res = 0, prev = 1;\n for (i = 0; i < a; i++){\n for (j = 0; j < b; j++){\n ar[n++] = A[i] + B[j];\n }\n }\n ar[n++] = 0, ar[n++] = 1LL << 61;\n fft(n, ar);\n\n for (i = 1; i < n; i++){\n u = ar[i - 1] + 1, v = ar[i] - 1;\n if (u <= v){\n if (u < l) u = l;\n if (v > r) v = r;\n if ((v - u + 1) > res) res = v - u + 1;\n }\n }\n\n printf(\"%lld\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "c4467d4627b4332081b5bc80731aff60", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef unsigned u;\nu w,m;\nint main()\n{\n\tscanf(\"%u%u\",&w,&m);\n\twhile(m)\n\t{\n\t\tif(m%w==1)--m;\n\t\tif(m%w==w-1)++m;\n\t\tif(m%w==0)m/=w;\n\t\telse{printf(\"NO\\n\");return 0;}\n\t}\n\tprintf(\"YES\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "0bc52ade872b599f67929b175b87f29f", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint n,i,j,k,a[100],max,amax,counter=0,temp,atemp,min;\nscanf(\"%d\",&n);\n for(i=0;i\n\nvoid TryAppend(int (*Queue)[2], int head, int *tail, int val)\n{\n int i;\n for(i = head + 1; i < *tail; ++i) {\n if(Queue[i][0] == val) {\n break;\n }\n }\n if(i == *tail) {\n Queue[*tail][0] = val;\n Queue[*tail][1] = head;\n ++(*tail);\n }\n}\n\nint main()\n{\n int a, b;\n scanf(\"%d %d\", &a, &b);\n int Queue[10000][2];\n int Ans[10000];\n int size = 0;\n int head = 0, tail = 1;\n Queue[head][0] = b;\n Queue[head][1] = -1;\n while(head < tail) {\n if(Queue[head][0] == a) {\n puts(\"YES\");\n Ans[size++] = Queue[head][0];\n int pre = Queue[head][1];\n while(~pre) {\n Ans[size++] = Queue[pre][0];\n pre = Queue[pre][1];\n }\n printf(\"%d\\n\", size);\n for(int i = 0; i < size; ++i) {\n printf(\"%d \", Ans[i]);\n }\n return 0;\n }\n int new;\n if(!(Queue[head][0] & 1)) {\n new = Queue[head][0] / 2;\n if(new >= a) {\n TryAppend(Queue, head, &tail, new);\n }\n }\n if(Queue[head][0] % 10 == 1) {\n new = (Queue[head][0] - 1) / 10;\n if(new >= a) {\n TryAppend(Queue, head, &tail, new);\n }\n }\n ++head;\n }\n puts(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "ffbe6a349e22f5e85f3471c2677106bd", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/* Problem: 388A - Fox and Box Accumulation */\n/* Solver: Gusztav Szmolik */\n\n#include \n#include \n\nunsigned short x[100];\nunsigned short s[100];\n\nint cmp (const void*, const void*);\n\nint main ()\n {\n unsigned short n;\n unsigned short i;\n unsigned short pc;\n unsigned short bc;\n unsigned short sc;\n \n if (scanf(\"%hu\",&n) != 1)\n return -1;\n if (n < 1 || n > 100)\n return -1;\n for (i = 0; i < n; i++)\n {\n if (scanf(\"%hu\",&x[i]) != 1)\n return -1;\n if (x[i] > 100)\n return -1;\n s[i] = 0;\n }\n qsort (x,n,sizeof(unsigned short),cmp);\n pc = bc = 0;\n while (bc < n)\n {\n sc = 0;\n for (i = 0; i < n; i++)\n if (!s[i] && x[i] >= sc)\n {\n s[i] = 1;\n sc++;\n bc++;\n }\n pc++;\n }\n printf (\"%hu\\n\",pc);\n return 0;\n }\n \nint cmp (p1,p2)\n const void* p1;\n const void* p2;\n {\n unsigned short x1;\n unsigned short x2;\n \n x1 = *(unsigned short*)p1;\n x2 = *(unsigned short*)p2;\n if (x1 == x2)\n return 0;\n return (x1 > x2 ? 1 : -1);\n }\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "8c3e10d326aec1d5a5527347bdc78cb1", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nchar x[11] = {'\\n'};\nchar y[11] = {'\\n'};\n\nint main()\n{\n int s1=0,s2=0,s22,i,w=0,a,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,right=0;\n float Ans,p1=1.0,r=1.0;\n scanf(\"%s %s\",x,y);\n for(i=0; iw) printf(\"0.000000000000\");\n else if(w==0)\n {\n if(s1==s2) printf(\"1.000000000000\");\n else printf(\"0.000000000000\");\n }\n else if(w==1) printf(\"0.500000000000\");\n else if(w==2)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n s22=s2;\n s22+=b1+b2;\n if(s1==s22) right++;\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==3)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n s22=s2;\n s22+=b1+b2+b3;\n if(s1==s22) right++;\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==4)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n s22=s2;\n s22+=b1+b2+b3+b4;\n if(s1==s22) right++;\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==5)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n for(i5=0; i5<=1; i5++)\n {\n if(i5==0) b5=1;\n else b5=-1;\n s22=s2;\n s22+=b1+b2+b3+b4+b5;\n if(s1==s22) right++;\n }\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==6)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n for(i5=0; i5<=1; i5++)\n {\n if(i5==0) b5=1;\n else b5=-1;\n for(i6=0; i6<=1; i6++)\n {\n if(i6==0) b6=1;\n else b6=-1;\n s22=s2;\n s22+=b1+b2+b3+b4+b5+b6;\n if(s1==s22) right++;\n }\n }\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==7)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n for(i5=0; i5<=1; i5++)\n {\n if(i5==0) b5=1;\n else b5=-1;\n for(i6=0; i6<=1; i6++)\n {\n if(i6==0) b6=1;\n else b6=-1;\n\n for(i7=0; i7<=1; i7++)\n {\n if(i7==0) b7=1;\n else b7=-1;\n s22=s2;\n s22+=b1+b2+b3+b4+b5+b6+b7;\n if(s1==s22) right++;\n }\n }\n }\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==8)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n for(i5=0; i5<=1; i5++)\n {\n if(i5==0) b5=1;\n else b5=-1;\n for(i6=0; i6<=1; i6++)\n {\n if(i6==0) b6=1;\n else b6=-1;\n\n for(i7=0; i7<=1; i7++)\n {\n if(i7==0) b7=1;\n else b7=-1;\n for(i8=0; i8<=1; i8++)\n {\n if(i8==0) b8=1;\n else b8=-1;\n s22=s2;\n s22+=b1+b2+b3+b4+b5+b6+b7+b8;\n if(s1==s22) right++;\n }\n }\n }\n }\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==9)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n for(i5=0; i5<=1; i5++)\n {\n if(i5==0) b5=1;\n else b5=-1;\n for(i6=0; i6<=1; i6++)\n {\n if(i6==0) b6=1;\n else b6=-1;\n for(i7=0; i7<=1; i7++)\n {\n if(i7==0) b7=1;\n else b7=-1;\n for(i8=0; i8<=1; i8++)\n {\n if(i8==0) b8=1;\n else b8=-1;\n for(i9=0; i9<=1; i9++)\n {\n if(i9==0) b9=1;\n else b9=-1;\n s22=s2;\n s22+=b1+b2+b3+b4+b5+b6+b7+b8+b9;\n if(s1==s22) right++;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n else if(w==10)\n {\n for(i1=0; i1<=1; i1++)\n {\n if(i1==0) b1=1;\n else b1=-1;\n for(i2=0; i2<=1; i2++)\n {\n if(i2==0) b2=1;\n else b2=-1;\n for(i3=0; i3<=1; i3++)\n {\n if(i3==0) b3=1;\n else b3=-1;\n for(i4=0; i4<=1; i4++)\n {\n if(i4==0) b4=1;\n else b4=-1;\n for(i5=0; i5<=1; i5++)\n {\n if(i5==0) b5=1;\n else b5=-1;\n for(i6=0; i6<=1; i6++)\n {\n if(i6==0) b6=1;\n else b6=-1;\n for(i7=0; i7<=1; i7++)\n {\n if(i7==0) b7=1;\n else b7=-1;\n for(i8=0; i8<=1; i8++)\n {\n if(i8==0) b8=1;\n else b8=-1;\n for(i9=0; i9<=1; i9++)\n {\n if(i9==0) b9=1;\n else b9=-1;\n for(i10=0; i10<=1; i10++)\n {\n if(i10==0) b10=1;\n else b10=-1;\n s22=s2;\n s22+=b1+b2+b3+b4+b5+b6+b7+b8+b9+b10;\n if(s1==s22) right++;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n w=pow(2,w);\n p1*=w;\n r*=right;\n Ans=r/p1;\n printf(\"%.11f\",Ans);\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "combinatorics", "bitmasks", "probabilities"], "code_uid": "17bd872565bdd52879b0c210c0bad002", "src_uid": "f7f68a15cfd33f641132fac265bc5299", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tint xCord,yCord,turns;\n\tscanf (\"%d%d\",&xCord,&yCord);\n\tif(xCord==0 && yCord==0){\n\t\tturns = 0;\n\t}\n\n\telse if((yCord*-1)<=xCord && yCord>xCord){\n\t\tturns = 2+(yCord-1)*4;\n\t}\n\n\telse if(((xCord*-1)+1)=yCord){\n\t\tturns = 1+(xCord-1)*4;\n\t}\n\n\telse if(yCordyCord && xCord<=yCord){\n\t\tturns = xCord*-4-1;\n\t}\n\tprintf (\"%d\\n\",turns);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry", "implementation"], "code_uid": "0a6b87e126ffef3e4ade581a6a4b34d2", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include \n int main()\n {\n int i,n,c=0,j=0;\n scanf(\"%d\",&n);\n char a[89];\n scanf(\"%s\",a);\n for(i=0;i\nint main()\n{\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tint i, j;\n\tint t[102];\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &t[i]);\n\tint t2[102];\n\tint sum = 0;\n\tint ans[102];\n\tint s;\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tif (sum + t[i] <= m)\n\t\t{\n\t\t\tans[i] = 0;\n\t\t\tsum += t[i];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tans[i] = 0;\n\t\t\tfor (j = 0; j < i; j++)\n\t\t\t\tt2[j] = t[j];\n\t\t\tfor (j = 0; j < i - 1; j++)\n\t\t\t{\n\t\t\t\tif (t2[j] < t2[j + 1])\n\t\t\t\t{\n\t\t\t\t\tt2[j] ^= t2[j + 1];\n\t\t\t\t\tt2[j + 1] ^= t2[j];\n\t\t\t\t\tt2[j] ^= t2[j + 1];\n\t\t\t\t\tif (j > 0)\n\t\t\t\t\t\tj -= 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\ts = sum;\n\t\t\tj = 0;\n\t\t\twhile (s + t[i] > m)\n\t\t\t{\n\t\t\t\tans[i]++;\n\t\t\t\ts -= t2[j];\n\t\t\t\tj++;\n\t\t\t}\n\t\t\tsum += t[i];\n\t\t}\n\t}\n\tprintf(\"%d\", ans[0]);\n\tfor (i = 1; i < n; i++)\n\t\tprintf(\" %d\", ans[i]);\n\tprintf(\"\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "22172fc7acb7854f047f1c5da179c758", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n\r\nint main(void) {\r\n\tint a,tc;\r\n\tscanf(\"%d\",&a);\r\n\tfor(tc=1;tc<=a;tc++)\r\n\t{\r\n\t int c=0;\r\n\t long int b,i;\r\n\t scanf(\"%ld\",&b);\r\n\t for(i=1;i*i<=b;i++)\r\n\t c++;\r\n\t for(i=1;i*i*i<=b;i++)\r\n\t c++;\r\n\t for(i=1;i*i*i*i*i*i<=b;i++)\r\n\t c--;\r\n\t printf(\"%d\\n\",c);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "883153eeaea9ca660158348148203d58", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n char s1[51], s2[51];\n unsigned short i = 0, j = 0;\n scanf(\"%s%s\", s1, s2);\n while(s2[j] != '\\0'){\n if(s1[i] == s2[j]){ i++; }\n j++;\n }\n printf(\"%hu\", 1 + i);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "30dfdaee99bda9f35496ca0f43bda659", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,m;\n\n scanf(\"%d %d\",&n,&m);\n if(m==0)\n printf(\"%d\\n\",1);\n\n else if(m<=n/2)\n printf(\"%d\\n\",m);\n else\n printf(\"%d\\n\",n-m);\n\n}\n\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "c8bb1d543e7ea58621194daaeff82d31", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//\n// main.c\n// B. Vanya and Books\n//\n// Created by Omer Fehmi Aykan on 24.06.2015.\n// Copyright (c) 2015 Omer Fehmi Aykan. All rights reserved.\n//\n\n#include \n#include \n\n\nint main(int argc, const char * argv[]) {\n \n int vanyaSayi = 0;\n \n long long int toplamRakam = 0;\n \n scanf(\"%d\",&vanyaSayi);\n \n \n int artisSayisi = 1, zx = 9;\n \n for (int i = 1; i <= vanyaSayi; i++) {\n toplamRakam += artisSayisi;\n \n if (i==zx) {\n artisSayisi++;\n zx*=10;\n zx+=9;\n }\n }\n \n /*for (int i = 1; i<=vanyaSayi; i++) {\n \n int a = 0;\n \n \n while (i>=powf(10, a)) {\n \n toplamRakam ++;\n a++;\n \n }\n\n }*/\n \n printf(\"%lld\", toplamRakam);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "aa4570c403b913e6408e7e44fcfca379", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint check (int x1,int y1,int x2,int y2,int x3,int y3) {\n int fnd = 0;\n if ((x1==x2 && y1==y2) || (x2==x3 && y2==y3) || (x1==x3 && y1 == y3)) {\n return 0;\n }\n int yslope = (y2-y1)*(y3-y1);\n int xslope = (x2-x1)*(x3-x1);\n if (xslope == 0) {\n if (yslope == 0) {\n fnd = 1;\n }\n } else {\n if (yslope == -1*xslope) {\n fnd = 1;\n }\n }\n if (fnd == 0) {\n int yslope = (y1-y2)*(y3-y2);\n int xslope = (x1-x2)*(x3-x2);\n if (xslope == 0) {\n if (yslope == 0) {\n fnd = 1;\n }\n } else {\n if (yslope == -1*xslope) {\n fnd = 1;\n }\n }\n }\n if (fnd == 0) {\n int yslope = (y2-y3)*(y1-y3);\n int xslope = (x2-x3)*(x1-x3);\n if (xslope == 0) {\n if (yslope == 0) {\n fnd = 1;\n }\n } else {\n if (yslope == -1*xslope) {\n fnd = 1;\n }\n }\n }\n if (fnd==1) {\n return 1;\n } else {\n return 0;\n }\n return 0;\n}\nint main()\n{\n int x1,y1,x2,y2,x3,y3;\n scanf(\"%d %d %d %d %d %d\",&x1,&y1,&x2,&y2,&x3,&y3);\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"RIGHT\");\n } else {\n x1 = x1 + 1;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n x1 = x1 - 2;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n x1 = x1 + 1;\n y1 = y1 + 1;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n y1 = y1 - 2;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n y1 = y1 + 1;\n x2 = x2 + 1;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n x2 = x2 - 2;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n x2++;\n y2++;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n y2 = y2 - 2;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n y2++;\n x3++;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n x3 = x3 - 2;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n x3++;\n y3++;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n y3 = y3 - 2;\n if (check(x1,y1,x2,y2,x3,y3) == 1) {\n printf(\"ALMOST\");\n } else {\n printf(\"NEITHER\");\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "988176c3f3e73e59e1d07dccc5db8cab", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint i;\n\tscanf(\"%d\", &i);\n\tint a[105];\n\tfor(int j = 1; j <= i; j++)\n\t{\n\t\tscanf(\"%d\", &a[j]);\n\t}\n\tif(i == 1)\n\t{\n\t\tprintf(\"YES\");\n\t}\n\telse\n\t{\n\tint judge = 0;\n\tfor(int j = 1; j < i; j++)\n\t{\n\t\tif((a[j] - a[j+1]) > 1 || (a[j] - a[j+1]) < -1)\n\t\t{\n\t\t\tjudge = 0;printf(\"NO\");break;\t\n\t\t}\n\t\tjudge = 1;\n\t}\n\tif(judge == 1) printf(\"YES\");\n\t}\n\n\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "02de0d4c40906e8a180cbba4610d6586", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void){\n\tlong long int m, b;\n\tscanf(\"%lld%lld\", &m, &b);\n\tlong long int i;\n\tlong long int max = INT_MIN;\n\tfor(i=b; i>=0; i--){\n\t\tlong long int x = (b-i)*m;\n\t\tlong long int w = x*(x+1)/2;\n\t\tlong long int p = i*(i+1)/2;\n\t\tlong long int val = w*(i+1)+p*(x+1);\n\t\tif(val > max){\n\t\t\tmax = val;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", max);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "6dfff265b3c6bd83bd9ea151f4eeca58", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tchar c00,c01,c11,c10;\n\tchar b00,b01,b11,b10;\n\tchar t;\n\tint i;\n\tscanf(\"%c%c\",&c00,&c01);\n\tscanf(\"%c\",&t);\n\tscanf(\"%c%c\",&c10,&c11);\n\tscanf(\"%c\",&t);\n\t\n\t\n\t//printf(\"%c%c\\n%c%c\\n\",c00,c01,c10,c11);\n\tscanf(\"%c%c\",&b00,&b01);\n\tscanf(\"%c\",&t);\n\tscanf(\"%c%c\",&b10,&b11);\n\t//printf(\"___________\\n\");\n\t//printf(\"%c%c\\n%c%c\\n\",c00,c01,c10,c11);\n\t//printf(\"%c%c\\n%c%c\\n\",b00,b01,b10,b11);\n\tfor (i=0;i<16;i++) {\n\t\tif (c00=='X') {\n\t\t\tc00 = c01;\n\t\t\tc01 = 'X';\n\t\t}\n\t\telse if (c01=='X') {\n\t\t\tc01 = c11;\n\t\t\tc11 = 'X';\n\t\t}\n\t\telse if (c11 == 'X') {\n\t\t\tc11 = c10;\n\t\t\tc10 = 'X';\n\t\t}\n\t\telse if (c10 == 'X') {\n\t\t\tc10 = c00;\n\t\t\tc00 = 'X';\n\t\t}\n\t\tif ((c00 == b00 ) && (c01 == b01) && (c10 == b10) && (c11 == b11)) {\n\t\t\tprintf(\"YES\");\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\t//printf(\"___________\\n\");\n\t\t//printf(\"%c%c\\n%c%c\\n\",c00,c01,c10,c11);\n\t\t//printf(\"%c%c\\n%c%c\\n\",b00,b01,b10,b11);\n\t}\n\tprintf(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "cc5ee396ed2617daf5251c2e300dfc2b", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int i=1,len1=0;\n char s1[11],s2[11];\n scanf(\"%s\",&s1);\n scanf(\"%s\",&s2);\n len1=strlen(s1);\n printf(\"%c\",s1[0]);\n i=1;\n while(s1[i]\nlong long int n,m,i,j,a,b;\nint ab(int a)\n{\n\tif(a<0)\n\treturn -a;\n\treturn a;\n}\nint max(int a,int b)\n{\n\tif(ab)\n\treturn b;\n\treturn a;\n}\nint func(int u,int v)\n{\t\t\n\t\tif(i==u&&j==v)\n\t\treturn 0;\n\t\tif(i+a>n&&i-a<=0)\n\t\treturn -1;\n\t\tif(j+b>m&&j-b<=0)\n\t\treturn -1;\n\t\tint x=ab(u-i),y=ab(v-j);\n\t\tif(x%a!=0||y%b!=0)\n\t\treturn -1;\n\t\tx=x/a;y=y/b;\n\t\tif(x%2!=y%2)\n\t\treturn -1;\n\t\tint t=max(x,y);\n\t\treturn t;\n}\nint main()\n{\n\tscanf(\"%lld%lld%lld%lld%lld%lld\",&n,&m,&i,&j,&a,&b);\n\tint ans=100000000;\n\tint a=func(1,m);\n\tif(a!=-1)\n\t{\n\t\tans=min(ans,a);\n\t}\n\ta=func(n,1);\n\tif(a!=-1)\n\t{\n\t\tans=min(ans,a);\n\t}\n\ta=func(1,1);\n\tif(a!=-1)\n\t{\n\t\tans=min(ans,a);\n\t}\n\ta=func(n,m);\n\tif(a!=-1)\n\t{\n\t\tans=min(ans,a);\n\t}\n\tif(ans<100000000)\n\tprintf(\"%d\",ans);\n\telse\n\tprintf(\"Poor Inna and pony!\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "c680f47b26ba2da78b2576cf0491b7df", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main(){\n unsigned n;\n scanf(\"%u\",&n);\n printf(\"%u\\n\",(n-2)*(n-2));\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "e43c03a280ad9566de9f944eb8bcf5ec", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tlong long p, d, x;\n\tint k;\n\n\tscanf(\"%lld%lld\", &p, &d);\n\tx = 1;\n\tk = 0;\n\twhile (p >= 10) {\n\t\tint t = p % 10;\n\n\t\tif (t != 9) {\n\t\t\tint a = t + 1;\n\n\t\t\tif (d >= a * x) {\n\t\t\t\td -= a * x;\n\t\t\t\tk++;\n\t\t\t\tp = p / 10 - 1;\n\t\t\t\tx *= 10;\n\t\t\t} else\n\t\t\t\tbreak;\n\t\t} else {\n\t\t\tk++;\n\t\t\tp /= 10;\n\t\t\tx *= 10;\n\t\t}\n\t}\n\tif (p != 0)\n\t\tprintf(\"%lld\", p);\n\twhile (k--)\n\t\tprintf(\"9\");\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "450efb49ace55b050e0066d5cfd53a11", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n//CODED BY SAYEM MD. NAFI\n\nint main()\n{\n int SIZE, I, J, K, SUM = 0;\n scanf(\"%d\", &SIZE);\n int MATRIX[SIZE][SIZE];\n for(I = 0; I < SIZE; I++) {\n for(J = 0; J < SIZE; J++){\n scanf(\"%d\", &MATRIX[I][J]);\n }\n }\n K = (SIZE - 1) / 2;\n for(I = 0, J = SIZE - 1; I < SIZE; I++, J--) {\n if(I == J) {\n SUM += MATRIX[I][I];\n continue;\n }\n SUM += MATRIX[I][I] + MATRIX[I][J] + MATRIX[I][K] + MATRIX[K][I];\n }\n printf(\"%d\\n\", SUM);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6f957967ed7300507cba33829cb5004a", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint x,y,n = 0;\nint fun(int a,int b,int c)\n{\n if(a==x&&b==x&&c==x)\n return 0;\n n++;\n if((a<=b&&b<=c)||(a<=c&&c<=b))\n {a = b+c-1<=x?b+c-1:x;\n return fun(a,b,c);}\n else if((b<=a&&a<=c)||(b<=c&&c<=a))\n {b = (a+c-1<=x?a+c-1:x);\n return fun(b,a,c);}\n else {c = (a+b-1<=x?a+b-1:x);\n return fun(c,a,b);}\n}\nint main()\n{\n scanf(\"%d%d\",&x,&y);\n fun(y,y,y);\n printf(\"%d\\n\",n);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "ada6d12090afc1e363074ec899f26f76", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint cmpfunc(const void *a, const void *b){\n return (*(int *)a) - (*(int *)b);\n}\n\nint main(){\n long long int a,b;\n int arr1[20],arr2[20],flag[20]={0},i=0,n1,n2,j,final[20],t,tatti=0,ind[20],x=0;\n scanf(\"%lld %lld\",&a,&b);\n while(a>0){\n arr1[i] = a%10;\n a=a/10;\n i++;\n }\n n1 = i;\n i=0;\n while(b>0){\n arr2[i] = b%10;\n b=b/10;\n i++;\n }\n n2 = i;\n i--;\n t=0;\n qsort(arr1,n1,sizeof(int),cmpfunc);\n if(n1=0;i--) printf(\"%d\",arr1[i]);\n }\n else{\n while(t=0;j--){\n if(flag[j]==0 && arr1[j]<=arr2[i]){\n if(arr1[j] < arr2[i]) tatti = 1;\n final[t] = arr1[j];\n flag[j]=1;\n t++;\n i--;\n ind[x] = j;\n x++;\n // printf(\"%d %d %d\\n\",i,arr1[j],arr2[i+1]);\n break;\n }\n }\n // printf(\"%d\\n\",j);\n while(j==-1){\n i++;\n t--;\n x--;\n flag[ind[x]] = 0;\n for(j=n1-1;j>=0;j--){\n if(flag[j]==0 && arr1[j] < arr2[i]){\n tatti = 1;\n final[t] = arr1[j];\n flag[j] = 1;\n t++;\n i--;\n break;\n }\n }\n }\n if(tatti==1){\n for(j=n1-1;j>=0;j--){\n if(flag[j]==0){\n final[t] = arr1[j];\n t++;\n }\n }\n }\n }\n for(i=0;i\n#include \n#include \n#include \n\nint py[12][11], vis[11][11], ne, ans, n, t;\n\nvoid gao(){\n int i, j, temp;\n while(vis[n][1] == 0 && ne <= t){\n py[1][1] += 512;\n for(i = 1; i <= n; i ++){\n for(j = 1; j <= i; j ++){\n if(py[i][j] > 512){\n temp = py[i][j] - 512, py[i][j] = 512;\n temp /= 2;\n py[i + 1][j] += temp, py[i + 1][j + 1] += temp;\n }\n if(py[i][j] == 512 && vis[i][j] == 0){\n ans ++;\n vis[i][j] = 1;\n }\n }\n }\n ne ++;\n }\n}\n\nint main()\n{\n int i, sum;\n while(scanf(\"%d%d\", &n, &t) != EOF){\n memset(py, 0, sizeof(py));\n memset(vis, 0, sizeof(vis));\n ne = 1, ans = 0;\n gao();\n sum = (n * (n + 1)) / 2;\n if(t > 1023)\n printf(\"%d\\n\", sum);\n else\n printf(\"%d\\n\", ans);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "1be50f4586d133507d8d1f6684b7508c", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint n,m,c=0;\n\tscanf(\"%d%d\",&n,&m);\n\twhile(nm)\n\t{\n\t\tn--;\n\t\tc++;\n\t}\n\tprintf(\"%d\",c);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "87b9e3ddce58fd6415d791e3c4492630", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tint n,k,t;\n\tscanf(\"%d %d %d\",&n,&k,&t);\n\tif(tn)\n\t{\n\t\tprintf(\"%d\",n+k-t);\n\t}\n\t\t else printf(\"%d\",k); \n \n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "d4f0aa48c45fb2693ae3acad3ebf5f6f", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint res(int n){\n\tint N = 0;\n\t\twhile(n != 0){\n\t\n\t\tN += n % 10;\n\t\tn = n/10;\n\t//\tprintf(\"%d\\n\",N);\n\t}\n\treturn N;\n}\nint result(int n)\n{\n\tint N ,count = 0;\n\tN = res(n);\n\twhile(1){\n\t\tN = res(n);\n\t if(N % 4 == 0 )\n\t return count;\n\t else{\n\t n++;\n\t N= res(n);\n\t count++;\n\t }\n\t}\n\t\n}\nint main(void)\n{\n int n,k,sum;\n scanf(\"%d\",&n);\n k = result(n);\n sum = n + k;\n printf(\"%d\",sum);\n \n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5f37c2b2b99dd6f51a63e53ac803e80f", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,k,x,i,s,a,b;\n scanf(\"%lld %lld\",&n,&k);\n for(i=k-1;i>=1;i--)\n {\n if(n%i==0)\n {\n a=n/i;\n b=i;\n break;\n }\n }\n s=a*k+b;\n printf(\"%lld\\n\",s);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ac5a939c708fb24b7541135c43024a85", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int x, y, k;\n int a[20];\n scanf(\"%d%d\", &x, &y);\n a[1]=x;\n a[2]=y;\n scanf(\"%d\", &k);\n for(int i=3; i<=6; i++)\n {\n a[i]=a[i-1]-a[i-2];\n }\n a[0]=a[6];\n printf(\"%d\\n\", (((a[k%6]%1000000007)+1000000007)%1000000007));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "45eb10178a38cc606def5eb1a2d762c4", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main () {\n int n, x, y;\n scanf(\"%d%d%d\", &n, &x, &y);\n int k = n / 2;\n if((x == k && y == k) || (x == k + 1 && y == k) || (x == k && y == k + 1) || (x == k + 1 && y == k + 1)) {\n puts(\"NO\");\n return 0;\n }\n puts(\"YES\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "17200ae233fdcfaea4cb59ea32f67b47", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int i,n;\n char ch,s[50];\n scanf(\"%s\",s);\n ch=s[0];\n n=strlen(s);\n for(i=0;i\n#include\nint r,h,vol;\nint main()\n{\n\tscanf(\" %d %d\",&r,&h);\n\n\tvol = h / r * 2;\n\th %= r;\n\tif (2*h= sqrt(3)*r)\n\t\tvol += 3;\n\telse\n\t\tvol += 2;\n\tprintf(\"%d\",vol);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "96307dff1adc6be404b8f6f5d5faa774", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint a,b,l;\nint x,y,xl,yl;\n\nchar s[105];\nint w[105][2];\nint al,bl;\n\nint p(int a1,int b1,int x1,int y1)\n{\n if ((a1<0&&x1>0)||(a1>0&&x1<0))return 0;\n if ((b1<0&&y1>0)||(b1>0&&y1<0))return 0;\n return 1;\n}\nint main()\n{\n int i,j;\n \n scanf (\"%d%d\",&a,&b);\n scanf (\"%s\",s);l=strlen(s);\n if (a==0&&b==0){printf (\"Yes\\n\");return 0;}\n for (i=0;i\\n\",al,bl,x,y);\n if (!p(al,bl,xl,yl))continue;\n if (al==0&&bl==0) {printf (\"Yes\\n\");return 0;}\n if (al==0) {if (xl==0&&yl!=0&&bl%yl==0) {printf (\"Yes\\n\");return 0;}else continue;}\n if (bl==0) {if (yl==0&&xl!=0&&al%xl==0) {printf (\"Yes\\n\");return 0;}else continue;}\n if (xl!=0&&yl!=0&&al%xl==0&&bl%yl==0&&al/xl==bl/yl){printf (\"Yes\\n\");return 0;}\n \n }\n printf (\"No\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "c2acdd580aea47e08a1ff2d92ec2a416", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(int argc, char const *argv[])\n{\n int n,k,count=0,i=2;\n scanf(\"%d %d\",&n,&k);\n int arr[k];\n while(count!=k-1 && n>1)\n {\n if(n%i==0)\n {\n n=n/i;\n arr[count]=i;\n count++;\n i=2;\n }\n else i++;\n \n }\n if(n<=1 && count!=k)\n printf(\"-1\");\n else\n {\n arr[count]=n;\n for(i=0;i\n\n#define N 100\n\nint main() {\n\tstatic int aa[N];\n\tint n, i, j, knut;\n\tlong long cnt;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tcnt = 1;\n\tknut = 0;\n\tfor (i = 0; i < n; i++)\n\t\tif (aa[i] == 1) {\n\t\t\tknut++;\n\t\t\tfor (j = i + 1; j < n && aa[j] == 0; j++)\n\t\t\t\t;\n\t\t\tif (j != n)\n\t\t\t\tcnt *= (j - i);\n\t\t}\n\tprintf(\"%lld\\n\", knut == 0 ? 0 : cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "4f2ab9eea6f6d9404f8709b4a148a675", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\ntypedef long long ll;\nll a[10];\nchar b[4], tmp[10];\n\n#define min(x,y) ((x)<(y)?(x):(y))\n\nint main(void) {\n\twhile (~scanf(\"%lld %lld %lld %lld\\n\", &a[0], &a[1], &a[2], &a[3])) {\n\t\tgets(tmp);\n\t\tb[0] = tmp[0];\n\t\tb[1] = tmp[2];\n\t\tb[2] = tmp[4];\n\t\tint i, j, k, q, m;\n\t\tll ans = -1;\n\t\tfor (i=0; i<4; i++)\n\t\t\tfor (j=i+1; j<4; j++) {\n\t\t\t\tif (b[0] == '+')\n\t\t\t\t\ta[4] = a[i]+a[j];\n\t\t\t\telse\n\t\t\t\t\ta[4] = a[i]*a[j];\n\t\t\t\tfor (k=0; k<5; k++) {\n\t\t\t\t\tif (k==i || k==j)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tfor (q=k+1; q<5; q++) {\n\t\t\t\t\t\tif (q==i || q==j)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (b[1] == '+')\n\t\t\t\t\t\t\ta[6] = a[k]+a[q];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ta[6] = a[k]*a[q];\n\t\t\t\t\t\tfor (m=0; m<5; m++) {\n\t\t\t\t\t\t\tif (m!=i && m!=j && m!=k && m!=q) {\n ll tt;\n\t\t\t\tif (b[2] == '+')\n\t\t\t\t\ttt = a[m]+a[6];\n\t\t\t\telse\n\t\t\t\t\ttt = a[m]*a[6];\n\t\t\t\tif (ans == -1)\n\t\t\t\t\tans = tt;\n\t\t\t\telse\n\t\t\t\t\tans = min(ans, tt);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tprintf(\"%lld\\n\", ans);\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "c3a84e4e6252d67923fa18916f8902c1", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint dp[4000007][2], sum[4000007][2];\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 t;\r\n\t\tdp[i][0] = (sum[i - 1][0] + sum[i - 1][1] + 1) % m;\r\n\t\tif (i == 2){\r\n\t\t\tdp[i][1] = 1;\r\n\t\t} else {\r\n\t\t\tdp[i][1] = (dp[i][1] + dp[i - 1][1] + ((i - i / 2) - ((i - 1) - (i - 1) / 2))) % m;\r\n\t\t}\r\n\t\tt = ((dp[i][0] + dp[i][1] - dp[i - 1][0] - dp[i - 1][1]) % m + m) % m;\r\n\t\tsum[i][0] = (sum[i - 1][0] + dp[i][0]) % m;\r\n\t\tsum[i][1] = (sum[i - 1][1] + dp[i][1]) % m;\r\n\t\tfor (register int j = i * 2; j <= n; j += i){\r\n\t\t\tdp[j][1] = (dp[j][1] + t) % m;\r\n\t\t}\r\n\t}\r\n\tprintf(\"%d\", (dp[n][0] + dp[n][1]) % m);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "two pointers", "number theory"], "code_uid": "b47f680178c897751c5b020311e4e8bf", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint ami(int n)\n{\n int i;\n int a,b,val=0;\n for(i=8; i<=1000000; i++){\n if(n%i==0){\n a=n/i;\n b=n-a;\n printf(\"%d %d\\n\",a,b);\n val++;\n break;\n }\n }\n if(val==0){\n printf(\"%d %d\\n\",1,n-1);\n }\n //return a,b;\n}\nint main()\n{\n int t;\n scanf(\"%d\",&t);\n int i,a,b;\n int n;\n int min;\n for(i=0; i\n\nint gcm(int a, int b) // a<=b\u3067\u3042\u308b\u3053\u3068\uff0e\n{\n if(a == 0)\n return b;\n else\n return gcm(b%a, a);\n}\n\nint rec(int a, int b) // a\n#include \nlong long max(long long a, long long b)\n{\n return a>b?a:b;\n}\nlong long x,y,c1,c2;\nint fun( long long mid)\n{\n long long a=mid/x;\n long long b=mid/y;\n long long c=mid/(x*y);\n long long C1=max(0,c1-b+c);\n long long C2=max(0,c2-a+c);\n if(C1+C2<=mid+c-a-b)\n return 1;\n return 0;\n}\nint main()\n{\n scanf(\"%I64d%I64d%I64d%I64d\",&c1,&c2,&x,&y);\n long long low=c1+c2;\n long long high=LLONG_MAX;\n while(low\n\n#define N\t2000\n#define M\t2000\n#define MD\t998244853\n\nint main() {\n\tstatic int dp[N + 1][M + 1], dq[N + 1][M + 1];\n\tint n, m, i, j, p, q, ans;\n\n\tscanf(\"%d%d\", &n, &m);\n\tdp[0][0] = 1;\n\tfor (i = 0; i <= n; i++)\n\t\tfor (j = 0; j <= i; j++) {\n\t\t\tif (i < n)\n\t\t\t\tdp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MD;\n\t\t\tif (j < i)\n\t\t\t\tdp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % MD;\n\t\t}\n\tdq[0][0] = 1;\n\tfor (i = 0; i <= n; i++)\n\t\tfor (j = i; j <= m; j++) {\n\t\t\tif (j < m)\n\t\t\t\tdq[i][j + 1] = (dq[i][j + 1] + dq[i][j]) % MD;\n\t\t\tif (i < j)\n\t\t\t\tdq[i + 1][j] = (dq[i + 1][j] + dq[i][j]) % MD;\n\t\t}\n\tans = 0;\n\tfor (i = 0; i <= n; i++)\n\t\tfor (j = 0; j <= m; j++) {\n\t\t\tp = i == 0 ? (j == 0 ? 1 : 0) : dp[i - 1][j];\n\t\t\tq = dq[n - i][m - j];\n\t\t\tans = (ans + (long long) p * q % MD * (i - j)) % MD;\n\t\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "a38e83caf7b94ad40c40e9a558fb6431", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define sqr(x) ((x)*(x))\n#define m0(x) memset(x,0,sizeof(x))\n#define m1(x) memset(x,63,sizeof(x))\n#define M 1000000007\n#define N 211111\n\n#define maxN 555\n\nint n, k;\nint dp[maxN][maxN], dp2[maxN][maxN];\nint w[maxN];\n\nint add(int x, int y) {\n\tx += y;\n\tif (x >= M) x-= M;\n\treturn (x);\n}\n\nint min(int a, int b)\n\t{\n\t\tif(a 0) {\n\t\t\tif (j > i) {\n\t\t\t\tint e = i + 1;\n\t\t\t\tint z = dp[j][d] * 1ll * w[e] % M;\n\t\t\t\tdp2[j][d]=(dp2[j][d], z);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint z = (w[i - j + 1] - 1 + M);\n\t\t\tif (z >= M) z -= M;\n\t\t\tz = z * 1ll * w[j] % M;\n\t\t\tz = z * 1ll * dp[j][d] % M;\n\t\t\tdp2[i + 1][min(d + 1, k + 1)]=add(dp2[i + 1][min(d + 1, k + 1)], z);\n\t\t\tz = dp[j][d] * 1ll * w[j] % M;\n\t\t\tdp2[j][d]=add(dp2[j][d], z);\n\t\t}\n\t\tfor ( j = 0; j <= n; j++) for (d = 0; d <= k + 1; d++) dp[j][d] = dp2[j][d];\n\t}\n\tint ans = 0;\n\tfor ( i = 0; i <= n; i++) ans=add(ans, dp[i][k]);\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "6a458d4b764e5389439777dd06c2a41a", "src_uid": "111673158df2e37ac6c019bb99225ccb", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint n, k, x;\n\t\n\tscanf(\"%d %d\", &n, &k);\n\t\n\tif((n-k)>=(k-1))\n\t{\n\t\tx=k-1;\n\t}\n\telse\n\t{\n\t\tx=n-k;\n\t}\n\tprintf(\"%d\", (n*3)+x);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "e3af0d5403360b1353eaea4b730b5504", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\n#define N\t100000\r\n#define MD\t1000000007\r\n\r\nint vv[N + 1], ff[N + 1], gg[N + 1];\r\n\r\nvoid init() {\r\n\tint i;\r\n\r\n\tff[0] = gg[0] = 1;\r\n\tfor (i = 1; i <= N; i++) {\r\n\t\tvv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;\r\n\t\tff[i] = (long long) ff[i - 1] * i % MD;\r\n\t\tgg[i] = (long long) gg[i - 1] * vv[i] % MD;\r\n\t}\r\n}\r\n\r\nint choose(int n, int k) {\r\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\r\n}\r\n\r\nint main() {\r\n\tint n, k_, k, ans;\r\n\r\n\tinit();\r\n\tscanf(\"%d%d\", &n, &k_);\r\n\tans = 0;\r\n\tfor (k = 0; k <= k_ && k <= n; k++)\r\n\t\tans = (ans + choose(n, k)) % MD;\r\n\tprintf(\"%d\\n\", ans);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "290c111c525736d0912d7d4feb38509e", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tint i,j,k,l,n,m;\n\tchar c[1005],b[3]={\"127\"},bn[3]={\"128\"},sh[5]={\"32767\"},shn[5]={\"32768\"},in[10]={\"2147483647\"},inn[10]={\"2147483648\"};\n\tchar lo[19]={\"9223372036854775807\"},lon[19]={\"9223372036854775807\"};\n\ti=0;\n\tc[0] = getchar();\n\twhile(c[i]!='\\n') {\n\t\ti++;\n\t\tc[i] = getchar();\n\t}\n\tn = i;\n\tif(c[0] != '-') {\n\t\tif(n<3)\n\t\t\tprintf(\"byte\\n\");\n\t\telse if(n==3) {\n\t\t\tfor(i=0;i<3;i++)\n\t\t\t\tif(c[i] < b[i]) {\n\t\t\t\t\tprintf(\"byte\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if(c[i] > b[i]) {\n\t\t\t\t\tprintf(\"short\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"byte\\n\");\n\t\t}\n\t\telse if(n>3 && n<5)\n\t\t\tprintf(\"short\\n\");\n\t\telse if(n==5) {\n\t\t\tfor(i=0;i<5;i++)\n\t\t\t\tif(c[i] < sh[i]) {\n\t\t\t\t\tprintf(\"short\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if(c[i] > sh[i]) {\n\t\t\t\t\tprintf(\"int\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"short\\n\");\n\t\t}\n\t\telse if(n>5 && n<10)\n\t\t\tprintf(\"int\\n\");\n\t\telse if(n==10) {\n\t\t\tfor(i=0;i<10;i++)\n\t\t\t\tif(c[i]in[i]) {\n\t\t\t\t\tprintf(\"long\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"int\\n\");\n\t\t}\n\t\telse if(n>10&&n<19)\n\t\t\tprintf(\"long\\n\");\n\t\telse if(n==19) {\n\t\t\tfor(i=0;i<19;i++)\n\t\t\t\tif(c[i]lo[i]) {\n\t\t\t\t\tprintf(\"BigInteger\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"long\\n\");\n\t\t}\n\t\telse\n\t\t\t\t\tprintf(\"BigInteger\\n\");\n\t}\n\telse {\n\t\tn = n-2;\n\t\tif(n<3)\n\t\t\tprintf(\"byte\\n\");\n\t\telse if(n==3) {\n\t\t\tfor(i=0;i<3;i++)\n\t\t\t\tif(c[i] < bn[i]) {\n\t\t\t\t\tprintf(\"byte\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if(c[i] > bn[i]) {\n\t\t\t\t\tprintf(\"short\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"byte\\n\");\n\t\t}\n\t\telse if(n>3 && n<5)\n\t\t\tprintf(\"short\\n\");\n\t\telse if(n==5) {\n\t\t\tfor(i=0;i<5;i++)\n\t\t\t\tif(c[i] < shn[i]) {\n\t\t\t\t\tprintf(\"short\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse if(c[i] > shn[i]) {\n\t\t\t\t\tprintf(\"int\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"short\\n\");\n\t\t}\n\t\telse if(n>5 && n<10)\n\t\t\tprintf(\"int\\n\");\n\t\telse if(n==10) {\n\t\t\tfor(i=0;i<10;i++)\n\t\t\t\tif(c[i]inn[i]) {\n\t\t\t\t\tprintf(\"long\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"int\\n\");\n\t\t}\n\t\telse if(n>10&&n<19)\n\t\t\tprintf(\"long\\n\");\n\t\telse if(n==19) {\n\t\t\tfor(i=0;i<19;i++)\n\t\t\t\tif(c[i]lon[i]) {\n\t\t\t\t\tprintf(\"BigInteger\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\tprintf(\"long\\n\");\n\t\t}\n\t\telse\n\t\t\t\t\tprintf(\"BigInteger\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "6e6534f9e95c33bf6844f4e24bb09eb2", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int a,t,i,j,k,l,n,r,s1,s2;\n scanf(\"%lld %lld %lld\",&n,&l,&r);\n s1=0;\n s2=0;\n j=1;\n k=1;\n a=1;\n for(i=1;i<=n;i++)\n {\n if(a<=r)\n {\n s2=s2+j;\n t=j;\n j=j*2;\n a++;\n }\n else\n {\n s2=s2+t;\n }\n }\n j=1;\n a=1;\n for(i=1;i<=n;i++)\n {\n if(a<=(n-l+1))\n {\n s1=s1+1;\n a++;\n }\n else\n {\n j=j*2;\n s1=s1+j;\n }\n }\n printf(\"%lld %lld\\n\",s1,s2);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "5005e033854ded9ce77d7c572e5f41b6", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(void) {\n\t// your code goes here\n\tunsigned long long int n,k;\n\tscanf(\"%llu %llu\",&n,&k);\n\t\n\tif(n>=k)\n\t printf(\"%llu\\n\",(k-1)/2);\n\telse{\n\t if(2*n<=k)\n\t printf(\"0\\n\");\n\t else{\n\t if(n%2==0 && k%2==0)\n\t printf(\"%llu\\n\",((2*n)-k)/2);\n\t else\n\t printf(\"%llu\\n\",((2*n)-k+1)/2);\n\t }\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ae4a47d0df0710558209ebc90416144b", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n#include \n\nconst int dx[5] = {0, 1, -1, 0, 0};\nconst int dy[5] = {0, 0, 0, 1, -1};\n\nint n, m, best;\nlong long g[45], rest[45];\n\nvoid dfs(long long mask, int cur, int cura) {\n\tif (cura >= best) return;\n\tif (cur >= n*m) return;\n\tif (mask == (1LL << n * m) - 1)\n\t\tbest = cura;\n\telse if ((mask | rest[cur]) ^ (1LL << n * m) - 1) return;\n\telse dfs(mask | g[cur], cur + 1, cura + 1), \n\tdfs(mask, cur + 1, cura);\n}\n\nint main() {\n\tregister int i, j, k;\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < n; ++ i)\n\t\tfor (j = 0; j < m; ++ j)\n\t\t\tfor (k = 0; k < 5; ++ k) {\n\t\t\t\tint x = i + dx[k], y = j + dy[k];\n\t\t\t\tif (x < 0 || x >= n || y < 0 || y >= m) continue;\n\t\t\t\tg[i * m + j] |= 1LL << x * m + y;\n\t\t\t}\n\tfor (i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];\n\tbest = n * m; dfs(0, 0, 0);\n\tprintf(\"%d\\n\", n * m - best);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "91a9ee482bb991bed8c1403020861166", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nint main() {\n\tint n, e, o;\n\n\tscanf(\"%d\", &n);\n\tif (n <= 5) {\n\t\tprintf(n == 3 ? \"0\\n\" : \"1\\n\");\n\t\treturn 0;\n\t}\n\te = 4, o = 5;\n\twhile (e < n && o < n) {\n\t\tint o_ = e + e + 1;\n\t\tint e_ = e + o + 1;\n\n\t\te = e_, o = o_;\n\t\tif (e == n || o == n) {\n\t\t\tprintf(\"1\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"0\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "f51d1892c8f73937a7e7969a3ec8b53a", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main (){\n int digits;\n long long int res=2,soma=0;\n\n scanf(\"%d\", &digits);\n while(digits){\n for (int i = 1; i < digits; i++)\n res*=2;\n soma+=res;\n res=2;\n digits--;\n }\n printf(\"%lld\\n\", soma);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "3710c6e95a40cc4fab47a091a962e98f", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(void){\n char s[101];\n scanf(\"%s\",s);\n\n int arr[26]={0};\n for(int i=0;s[i]!='\\0';i++){\n arr[s[i]-97]++;\n \n \n }\n int len=0;\n for(int i=0;i<26;i++){\n if(arr[i]!=0)\n len++;\n }\n if(len%2==0){\n printf(\"CHAT WITH HER!\");\n }\n else{\n printf(\"IGNORE HIM!\");\n }\n \n \n \n \n \n}", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "1cfbac82d4f0fa7a6aa4d1cd61ce63c7", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tint i, j, k;\n\tint a[30], b[30];\n\tfor (i = 0; i < m; i++)\n\t{\n\t\tscanf(\"%d %d\", &a[i], &b[i]);\n\t\ta[i]--;\n\t\tb[i]--;\n\t}\n\tint max = 1;\n\tfor (i = 0; i < n; i++)\n\t\tmax *= 6;\n\tint used[10][10];\n\tfor (i = 0; i < 10; i++)\n\t\tfor (j = 0; j < 10; j++)\n\t\t\tused[i][j] = 1;\n\tint p, q[10];\n\tint ans = 0, count;\n\tfor (j = 0; j < max; j++)\n\t{\n\t\tp = j;\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tq[i] = p % 6;\n\t\t\tp /= 6;\n\t\t}\n\t\tfor (i = 0; i < 10; i++)\n\t\t\tfor (k = i; k < 10; k++)\n\t\t\t\tused[i][k] = 0;\n\t\tcount = 0;\n\t\tfor (i = 0; i < m; i++)\n\t\t{\n\t\t\tif (q[a[i]] < q[b[i]])\n\t\t\t{\n\t\t\t\tif (used[q[a[i]]][q[b[i]]] == 0)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tused[q[a[i]]][q[b[i]]] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (used[q[b[i]]][q[a[i]]] == 0)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tused[q[b[i]]][q[a[i]]] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (ans < count)ans = count;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "graphs"], "code_uid": "3afb8fd88e30bf863a790a2652b9f313", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int n;\n\tscanf(\"%lld\",&n);\n\n\n\tlong long int a=7+3*(n+2)*(n-1);\nprintf(\"%lld\\n\",a);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "d50bfb7d8fe860c1d048daf17a6bbe6f", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,s=0,i;\n scanf(\"%d %d %d\",&a,&b,&c);\n s=((a*b)+(b*c)+(c*a)-a-b-c)+1;\n printf(\"%d\\n\",s);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "fa8a76d9efae2dc88d1b3bf18699c208", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t500\n#define A\t500\n#define M\t512\n#define MD\t998244353\n\nint main() {\n\tstatic int dp[N + 1][A + 1], pp[M][M], ch[M][M];\n\tint n, a_, i, j, k, k_, a;\n\n\tscanf(\"%d%d\", &n, &a_);\n\tfor (a = 1; a < M; a++) {\n\t\tpp[a][0] = 1;\n\t\tfor (k = 1; k < M; k++)\n\t\t\tpp[a][k] = (long long) pp[a][k - 1] * a % MD;\n\t}\n\tch[0][0] = 1;\n\tfor (i = 1; i < M; i++) {\n\t\tch[i][0] = 1;\n\t\tfor (j = 1; j < M; j++)\n\t\t\tch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;\n\t}\n\tfor (a = 1; a <= a_; a++)\n\t\tdp[0][a] = 1;\n\tfor (k = 2; k <= n; k++)\n\t\tfor (a = 1; a <= a_; a++)\n\t\t\tif (a <= k - 1)\n\t\t\t\tdp[k][a] = pp[a][k];\n\t\t\telse\n\t\t\t\tfor (k_ = 0; k_ <= k; k_++) \n\t\t\t\t\tdp[k][a] = (dp[k][a] + (long long) dp[k - k_][a - (k - 1)] % MD * ch[k][k_] % MD * pp[k - 1][k_]) % MD;\n\tprintf(\"%d\\n\", dp[n][a_]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "c29cc023a9832a67daf0dcd92ee89ffb", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define MAX_N 100000\n\nchar n[MAX_N];\n\nvoid generate_min(int length, char result[]) {\n\tint i;\n\t\n\tfor (i = 0; i < length / 2; i++) {\n\t\tresult[i] = '4';\n\t}\n\t\n\tfor ( ; i < length; i++) {\n\t\tresult[i] = '7';\n\t}\n}\n\nvoid generate_max(int length, char result[]) {\n\tint i;\n\t\n\tfor (i = 0; i < length / 2; i++) {\n\t\tresult[i] = '7';\n\t}\n\t\n\tfor ( ; i < length; i++) {\n\t\tresult[i] = '4';\n\t}\n}\n\nvoid generate_next(int length, char result[]) {\n\tif (length % 2 == 1) {\n\t\tgenerate_min(length + 1, result);\n\t\treturn;\n\t}\n\t\n\tgenerate_max(length, result);\n\tif (strcmp(result, n) < 0) {\n\t\tgenerate_min(length + 2, result);\n\t\treturn;\n\t}\n\t\n\tint i;\n\tint fours = length / 2;\n\tint sevens = length / 2;\n\tfor (i = 0; i < length; i++) {\n\t\tif (n[i] <= '4' && fours > 0) {\n\t\t\t//printf(\"A\", result);\n\t\t\tresult[i] = '4';\n\t\t\tfours--;\n\t\t\tif (n[i] < '4') break;\n\t\t} else if (n[i] <= '7' && sevens > 0) {\n\t\t\t//printf(\"B\", result);\n\t\t\tresult[i] = '7';\n\t\t\tsevens--;\n\t\t\tif (n[i] < '7') break;\n\t\t} else {\n\t\t\t//printf(\"C\", result);\n\t\t\tint j = i - 1;\n\t\t\twhile (result[j] == '7') {\n\t\t\t\tj--;\n\t\t\t\tsevens++;\n\t\t\t}\n\t\t\tresult[j] = '7';\n\t\t\tsevens--;\n\t\t\tfours++;\n\t\t\ti = j;\n\t\t\tbreak;\n\t\t}\n\t}\n\ti++;\n\t//printf(\"\\n\");\n\t\n\tfor ( ; fours > 0; i++, fours--)\n\t\tresult[i] = '4';\n\t\n\tfor ( ; sevens > 0; i++, sevens--)\n\t\tresult[i] = '7';\n}\n\nint main(void) {\n\t\n\tscanf(\"%s\", &n);\n\t\n\tint length = strlen(n);\n\t\n\tchar result[MAX_N];\n\t\n\tgenerate_next(length, result);\n\tprintf(\"%s\\n\", result);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "b350d5a0da76cb4e52b8b2d1e941738c", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int cnt1,cnt2,cnt3,cnt4;\n scanf(\"%d\",&cnt1);\n scanf(\"%d\",&cnt2);\n scanf(\"%d\",&cnt3);\n scanf(\"%d\",&cnt4);\n if ((cnt1==cnt4)&&(cnt1>0)){\n printf(\"%d\",1);\n }\n else if ((cnt1==cnt3)&&(cnt3==cnt4)&&(cnt4==0)){\n printf(\"%d\",1);\n }\n else{\n printf(\"%d\",0);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "a032d503d38cfc0754cf7c927a43be5d", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint b;\nint check(int i){\n int temp=0,t=0;\n while(i>0){\n if(i%10==4||i%10==7) temp=temp*10+i%10;\n i/=10;\n }\n while(temp>0){\n t=t*10+temp%10;\n temp/=10;\n }\n return t==b;\n}\nint main(){\n int a,i;\n scanf(\"%d%d\",&a,&b);\n for(i=a+1;;i++){\n if(check(i)){\n printf(\"%d\",i);\n return 0;\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "138c7e50a285189eb9524858a1b412e0", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,m,an[10],am[10],i,m1,m2,no,tog=0,j;\n\tm1=m2=9;\n\tscanf(\"%d%d\",&n,&m);\n\tfor(i=0;ian[i])\n\tm1=an[i];\n\t}\n\tfor(i=0;iam[i])\n m2=am[i];\n\t}\n\tfor(i=0;ian[i])\n \t\t\tno=an[i];\n \t}\n } \n }\n\t}\n\tif(tog==1)\n\t{\n\t\tprintf(\"%d\",no);\n\t}\n\telse\n\t{\n\tif(m1==m2)\n\tprintf(\"%d\",m1);\n\telse\n\t{\n\tif(m1\n#include\nint main()\n{\n int count=0,t=0,n,m,i;\n char a[10000];\n scanf(\"%s\",a);\n m=strlen(a);\n for(i=0;i92)\n {\n if(a[i]<=92)\n t++;\n }\n }\n\n if(m==1)\n {\n if(a[0]<=92)\n a[0]=a[0]+32;\n else\n a[0]=a[0]-32;\n }\n\n else if(count==m)\n {\n for(i=0;i\n#define M 1000000007\nint n,k,i,c,d;\nlong long y,z,u,v,r;\nint F(int a,int b){\n int r=1;\n for (;b;b>>=1,a=(long long)a*a%M){\n if (b&1)r=(long long)r*a%M;\n }\n return r;\n}\nint main(){\n scanf(\"%d%d\",&n,&k);\n if (!k)r=n;\n else{\n if (n<=++k){for(i=1;i<=n;i++)r+=F(i,k-1);}\n else{\n for (u=v=1;i<=k;i++){u=(u*(n-i))%M;if (i)v=((v*-i)%M+M)%M;}\n for (i=0,c=1,d=k;i<=k;i++,c++,d--){\n z=(z+F(i,k-1))%M;\n y=u*z%M*F(n-i,M-2)%M*F(v,M-2)%M;\n v=v*c%M*F(d,M-2)%M;\n if(i&1)y=M-y;\n r+=y;\n }\n }\n }\n printf(\"%lld\\n\",r%M);\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "7a0181eece5c766955c7eb2233723b64", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint prime(int n)\n{\n int c=0;\n for(int i=2;i\n\nint prime[1005000];\nint primeList[1005000];\n\nvoid init() {\n int i, cnt = 0, j;\n prime[2] = 1;\n primeList[cnt++] = 2;\n for(i = 3; i < 1005000; i += 2) {\n for(j = 0; j < cnt; j++) {\n if(i % primeList[j] == 0) break;\n if((1ll * primeList[j]) * primeList[j] > i) break;\n }\n if(j == cnt || i % primeList[j] != 0) {\n primeList[cnt++] = i;\n prime[i] = 1;\n }\n }\n}\n\nint good(int a, int b, int len, int need) {\n int start, cur = 0;\n for(start = a; start <= b; start++) {\n cur += prime[start];\n if(start - a + 1 == len)\n if(cur < need) return 0;\n if(start - len >= a) {\n cur -= prime[start - len];\n if(cur < need) return 0;\n }\n }\n return cur >= need;\n}\n\nint main() {\n int a, b, k;\n int L, R, M, i;\n init();\n scanf(\"%d %d %d\", &a, &b, &k);\n L = 0, R = b - a + 1;\n while(R - L > 1) {\n M = (L + R) / 2;\n if(good(a, b, M, k)) R = M;\n else L = M;\n }\n if(!good(a, b, R, k)) R = -1;\n printf(\"%d\\n\", R);\n return 0;\n}", "lang_cluster": "C", "tags": ["two pointers", "binary search", "number theory"], "code_uid": "fa9a880e620c4af36d4af2acc0c76116", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,r;\n while(scanf(\"%d%d%d\",&a,&b,&r)!=EOF)\n if(a>=2*r&&b>=2*r)\n printf(\"First\\n\");\n else printf(\"Second\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "games"], "code_uid": "a5b068a9b1cb8b1b0ae54e80a7d24ce1", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint p[]={2,3,5,7,11,13,17,19,23,29,31,37};\n\nint D[20];\nlong double m=1e100;\n\nvoid dfs(int n,int d,int l) {\n\tif (n==1) {\n\t\tint i,j;\n\t\tlong double s=1;\n\t\tfor (i=0;i1) {\n\t\tif (n%d==0) {\n\t\t\tD[l]=d;\n\t\t\tdfs(n/d,d,l+1);\n\t\t}\n\t\td--;\n\t}\n}\nint main() {\n\tint i,j,n;\n\tscanf(\"%d\\n\",&n);\n\tdfs(n,n,0);\n\tprintf(\"%lld\\n\",(long long)m);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "number theory"], "code_uid": "301a4feefa5f14f671b49e7dc47a56ae", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main() {\n int n,min1,min2,min3,max1,max2,max3, left = 0, first = 0, second = 0, third = 0;\n scanf(\"%d\",&n);\n scanf(\"%d\",&min1);\n scanf(\"%d\",&max1);\n scanf(\"%d\",&min2);\n scanf(\"%d\",&max2);\n scanf(\"%d\",&min3);\n scanf(\"%d\",&max3);\n left = n;\n first = min1;second = min2;third = min3;\n while(first < (left -(min2+min3)) && first < max1) first++; \n left -= first;\n while(second < (left -min3) && second < max2) second++;\n left -= second;\n while(third < left && third < max3) third++;\n\n printf(\"%d %d %d\\n\", first, second, third);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "3403ee80256df8c3ee2f81be25592674", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n\tint x,t,a,b,da,db;\n\tscanf(\"%d%d%d%d%d%d\",&x,&t,&a,&b,&da,&db);\n\tint flag = 0;\n\tint i=0;\n\tint j=0;\n\tfor(i=0;i\n\nint n, m;\nchar map[10][11];\n\nint wolf(int i, int j)\n{\n return (i >= 0 && i < n && j >= 0 && j < m && map[i][j] == 'W');\n}\n\nint main(int argc, char *argv[])\n{\n int i, j, c = 0;\n \n scanf(\"%d %d\", &n, &m);\n for(i = 0; i < n; i ++)\n scanf(\"%s\", map[i]);\n \n for(i = 0; i < n; i ++)\n for(j = 0; j < m; j ++)\n if(map[i][j] == 'P')\n {\n if(wolf(i - 1, j))\n map[i - 1][j] = '.', c ++;\n else if(wolf(i + 1, j))\n map[i + 1][j] = '.', c ++;\n else if(wolf(i, j - 1))\n map[i][j - 1] = '.', c ++;\n else if(wolf(i, j + 1))\n map[i][j + 1] = '.', c ++;\n }\n \n printf(\"%d\\n\", c);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "6d79789b2c600252ab10872dda7f4ba3", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint gcd (int x, int y);\nint main(void){\n\tint a,b,c;\n\tint x,y,z;\n\tint sum=0;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tfor (x=1; x<=a;x++)\n\t\tfor (y=1;x*y<=a;y++)\n\t\t\tfor(z=1;y*z<=b;z++)\n\t\t\t{\n\t\t\t\tif (x*y==a&&x*z==c&&y*z==b)\n\t\t\t\t{\n\t\t\t\t\tsum=x+y+z;\n\t\t\t\t\tgoto out;\n\t\t\t\t}\n\t\t\t}\n\tout:\n\tprintf(\"%d\",sum*4);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "30bcfe077e809283219b399100421b1a", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\ntypedef long long ll;\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 into 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} \nint main()\n{\n long long n,k,i,j,v,c[200001]={0},b[200001]={0},min=1000000000;\n scanf(\"%lld%lld\",&n,&k);\n long long a[n];\n for(i=0;i=k)\n {\n if(b[i]\n#include\n#define N 300\n//1+1+100+3\n//1+1+100+100\nint main() {\n char d[N];\n scanf(\"%s\",d);\n int n=strlen(d);\n int i,j;\n int dot=0;\n int e=0;\n for(i=0;i\n#include \n\nint main(){\nint n,m;\nscanf(\"%d %d\",&n,&m);\nint x;\nint count=0;\nx=m/n;\n\nif(m%n==0){\nif(m==n)\nprintf(\"0\");\nelse if(m%2==0||m%3==0){\nwhile(x>1){\n\nif(x%2==0){\nx=x/2;\ncount++;\n}\nelse if(x%3==0){\ncount++;\nx=x/3;\n}\nelse{\n count=-1;\nbreak;}\n}\n printf(\"%d\",count);\n}\nelse\nprintf(\"-1\");\n}\nelse\nprintf(\"-1\");\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e44331e169f384ceed42428ac2864e86", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define MAX 22\nstruct INFO\n{\n\tint sum;\n\tlong long value;\n\tchar line[MAX];\n};\nstruct INFO m[MAX];\nlong long x;\nvoid Read(long long *a)\n{\t\t \n scanf(\"%lld\", a); \n return;\n}\nvoid Swap(char *a, char *b)\n{\n\tchar t;\n\tt=*a;\n\t*a=*b;\n\t*b=t;\n\treturn;\n}\nvoid Conv(long long a, char s[])\n{\n\tint i, j, l, x;\n\tl=0;\n\twhile (a>0)\n\t{\n\t\tx=a%10;\n\t\ts[l++]=(char)(x+'0');\n\t\ta/=10;\n\t}\n\tfor (i=0; i=0; i--, k*=10)\n\t\tsum+=(s[i]-'0')*k;\n\treturn sum;\n}\nvoid SWAP(struct INFO *a, struct INFO *b)\n{\n\tstruct INFO t;\n\tt=*a;\n\t*a=*b;\n\t*b=t;\n\treturn;\n}\nvoid Sort(struct INFO m[], int l)\n{\n\tint i, fl;\n\tdo\n\t{\n\t\tfl=1;\n\t\tfor (i=0; i'0')\n\t\t {\n\t\t\t m[k].line[i]--;\n\t\t\t Change(m[k].line, i);\n\t\t k++;\n\t\t }\t\t\n for (i=0; i<=l; i++)\n\t{\n\t\tm[i].sum=SumOfTheDigits(m[i].line);\n\t\tm[i].value=GetValue(m[i].line);\n\t}\n\tSort(m, l);\n\tWrite(m[0].line);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "55ae267f99090a5e20c4d4d26782c708", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\n int i=0,n,k,countG=0,countT=0,locationG,locationT,pathDistance;\n char s[100];\n scanf(\"%d %d\",&n,&k);\n if((n >= 2 && n <= 100) && (k >= 1 && k <= (n-1)))\n {\n while(i <= n)\n {\n scanf(\"%c\",&s[i]);\n i++;\n }\n for(i = 1; i <= n; i++)\n {\n if(s[i] == '.' || s[i] == '#' || s[i] == 'G' || s[i] == 'T')\n {\n continue;\n\n }\n else\n {\n\n return 0;\n\n }\n }\n for(i = 1; i <= n; i++)\n {\n if(s[i] == 'G')\n {\n countG++;\n }\n if(s[i] == 'T')\n {\n countT++;\n }\n\n }\n if(countG != 1 || countT != 1)\n {\n return 0;\n }\n for(i = 1; i <= n; i++)\n {\n if(s[i] == 'G')\n {\n locationG = i;\n }\n if(s[i] == 'T')\n {\n locationT = i;\n }\n }\n\n pathDistance = locationG - locationT;\n if(pathDistance > 0)\n {\n if(pathDistance < k)\n {\n printf(\"NO\");\n return 0;\n }\n else\n {\n for(i = k; i <= n; i += k)\n {\n if(s[locationG-i] == '#')\n {\n printf(\"NO\");\n return 0;\n }\n else if(s[locationG-i] == 'T')\n {\n printf(\"YES\");\n return 0;\n }\n else if(locationG-i < locationT )\n {\n printf(\"NO\");\n return 0;\n }\n else\n {\n continue;\n }\n }\n }\n }\n else\n {\n if(-pathDistance < k)\n {\n printf(\"NO\");\n return 0;\n }\n else\n {\n for(i = k; i <= n; i += k)\n {\n if(s[locationG+i] == '#')\n {\n printf(\"NO\");\n return 0;\n }\n else if(s[locationG+i] == 'T')\n {\n printf(\"YES\");\n return 0;\n }\n else if(locationG+i > locationT)\n {\n printf(\"NO\");\n return 0;\n }\n else\n {\n continue;\n }\n }\n }\n\n }\n\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "63b59de973954dc9864a1eef96ce850e", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"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", "tags": ["brute force", "constructive algorithms", "implementation", "bitmasks"], "code_uid": "787ba889791870a1e68422012389d716", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint main (void) {\n\tint x, y, n, a = 0, b = 1, i, j;\n\tdouble t;\n\tscanf (\"%d %d %d\", &x, &y, &n);\n\tt = (double)x / y;\n\tfor (j = 1; j <= n; ++j) {\n\t\tdouble A[] = {floor (t*j), ceil (t*j)};\n\t\tfor (i = 0; (unsigned)i < sizeof A / sizeof *A; ++i) {\n\t\t\tif (fabs (t - A[i]/j) + DBL_EPSILON < fabs (t - (double)a/b)) {\n\t\t\t\ta = A[i];\n\t\t\t\tb = j;\n\t\t\t}\n\t\t}\n\t}\n\tprintf (\"%d/%d\\n\", a, b);\n\texit (EXIT_SUCCESS);\n}\n", "lang_cluster": "C", "tags": ["two pointers", "implementation", "brute force"], "code_uid": "1e2ae09489b269898427146ad6e3443b", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n \r\n#define N\t1000000\r\n#define M\t1000000\r\n#define K\t20\r\n \r\nint aa[N + 1], kk[N + 1];\r\n \r\nvoid init() {\r\n\tint a, b, b_, k;\r\n \r\n\tfor (a = 2; a <= N; a++) {\r\n\t\tif (aa[a])\r\n\t\t\tcontinue;\r\n\t\tb = 1, b_ = N / a, k = 0;\r\n\t\twhile (b <= b_) {\r\n\t\t\tb *= a, k++;\r\n\t\t\taa[b] = a, kk[b] = k;\r\n\t\t}\r\n\t}\r\n}\r\n \r\nint main() {\r\n\tstatic char used[M * K + 1];\r\n\tstatic int cc[K + 1];\r\n\tint n, m, a, b, b_, j, k, cnt;\r\n\tlong long ans;\r\n \r\n\tinit();\r\n\tscanf(\"%d%d\", &n, &m);\r\n\tcnt = 0;\r\n\tfor (k = 1; k <= K; k++) {\r\n\t\tfor (j = 1; j <= m; j++)\r\n\t\t\tif (!used[j * k])\r\n\t\t\t\tused[j * k] = 1, cnt++;\r\n\t\tcc[k] = cnt;\r\n\t}\r\n\tans = 1;\r\n\tfor (a = 2; a <= n; a++)\r\n\t\tif (aa[a] == a) {\r\n\t\t\tb = 1, b_ = n / a, k = 0;\r\n\t\t\twhile (b <= b_)\r\n\t\t\t\tb *= a, k++;\r\n\t\t\tans += cc[k];\r\n\t\t}\r\n\tprintf(\"%lld\\n\", ans);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "number theory"], "code_uid": "7527e3d23a9a8727ca8b094fe3432383", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int c,n,i,ar[1000],flag=-1;\n long int a,b;\n scanf(\"%ld %ld %d\",&a,&b,&c);\n a=a%b;\n for(i=0;i<=999;i++)\n {\n\n a=a*10;\n ar[i]=a/b;\n if(ar[i]==c)\n {\n flag=i;\n break;\n }\n if(a==0)\n break;\n a=a%b;\n\n }\n if(flag==-1)\n printf(\"-1\\n\");\n else\n printf(\"%d\\n\",flag+1);\n\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "7dfd98f15eeb11d7384c06341b5833e1", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long int gcd(long long int m,long long int n){\n if(m(n-1)*(n-2)*(n-3))?ans:((n-1)*(n-2)*(n-3));\n }\n printf(\"%lld\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "1734b2044a6af6a69cbed8732e41912d", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\ntypedef unsigned long long opo;\n\n#define S scanf\n#define P printf\n#define M malloc\n#define SI sizeof\n\n\n/*int cmp(const void *a, const void *b)\n{\n\tint *c;\n\tint *d;\n\tc = (int*)a;\n\td = (int*)b;\n\tif (*c > *d)\n\t\treturn (1);\n\tif (*c == *d)\n\t\treturn (0);\n\treturn (-1);\n}*/\n\nint main()\n{\n\tint tab[1000001];\n\tint out = 0;\n\tfor (int i = 0 ; i < 1000001 ; i++)\n\t\ttab[i] = 0;\n\tfor (int i = 1; i <= 1e6; i++)\n\t{\n\t\tfor (int j = i; j <= 1e6; j += i)\n\t\t\ttab[j]++;\n\t}\n\tint a,b,c;\n\tS(\"%d %d %d\", &a, &b, &c);\n\tfor (int i = 1; i <= a; i++)\n\t{\n\t\tfor (int j = 1; j <= b; j++)\n\t\t{\n\t\t\tfor (int k = 1; k <= c; k++)\n\t\t\t{\n\t\t\t\tout += tab[i * j *k] % 1073741824;\n\t\t\t}\n\t\t}\n\t}\n\tP(\"%d\", out);\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "69c0eedbbb98eb1ec4a73b6818044d88", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nint main(){\n long long a,b,c,n,diff,cnt=0;\n scanf(\"%lld\",&n);\n scanf(\"%lld\",&a);\n scanf(\"%lld\",&b);\n scanf(\"%lld\",&c);\n diff = b-c;\n if(a < diff)\n printf(\"%lld\",n/a);\n else{\n if(n>=b){\n cnt = (n-b)/diff+1;\n n-=diff*cnt;\n }\n cnt+=n/a;\n printf(\"%lld\",cnt);\n }\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "443af394461f59fbf32286783925f736", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n\tint x1,y1,x2,y2,n,bal,mal;\n\tscanf(\"%d%d%d%d%d\",&n,&x1,&y1,&x2,&y2);\n\tif (x1==x2 && y1==y2) printf(\"0\");\n\telse if ((x1==0 && x2==0)|| (x1==n&&x2==n)) printf(\"%d\",abs(y1-y2));\n\telse if ((y1==0 && y2==0)|| (y1==n&&y2==n)) printf(\"%d\",abs(x1-x2));\n\telse if (x1==0 && y2==n)\n\t{\n\t\tprintf(\"%d\",(n-y1)+x2);\n\t}\n\telse if (x1==n && y2==0)\n\t{\n\t\tprintf(\"%d\",(n-x2)+y1);\n\t}\n\telse if (x2==0 && y1==n)\n\t{\n\t\tprintf(\"%d\",(n-y2)+x1);\n\t}\n\telse if (x2==n && y1==0)\n\t{\n\t\tprintf(\"%d\",(n-x1)+y2);\n\t}\n\telse \n\t{\n\t\tbal=x1+x2+y1+y2;\n\t\tmal=4*n-bal;\n\t\tif (bal<=mal) printf(\"%d\",bal);\n\t\telse printf(\"%d\",mal);\n\t}\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "implementation"], "code_uid": "42a87dbddea19242beae3653921444dc", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MOD 100000000\ntypedef long long int ll;\n\nll army[101][101][2];\n\nint min(a, b)\n{\n if(a < b)\n {\n return a;\n }\n else\n {\n return b;\n }\n}\n\nll count(ll army[101][101][2], int n1, int n2, int l1, int l2, int t)\n{\n ll res = 0;\n int i, edge;\n if(army[n1][n2][t] == -1)\n {\n if(t == 0)\n {\n edge = min(n1, l1);\n for(i = 1; i <= edge; i++)\n {\n res = (res + count(army, n1 - i, n2, l1, l2, !t)) % MOD;\n }\n }\n else\n {\n edge = min(n2, l2);\n for(i = 1; i <= edge; i++)\n {\n res = (res + count(army, n1, n2 - i, l1, l2, !t)) % MOD;\n }\n }\n army[n1][n2][t] = res;\n }\n return army[n1][n2][t];\n}\n\nvoid init(ll army[101][101][2], int n1, int n2, int l1, int l2)\n{\n int i, j;\n for(i = 0; i <= n1; i++)\n {\n for(j = 0; j <= n2; j++)\n {\n if(i == 0 && j > 0)\n {\n army[i][j][0] = 0;\n }\n else if(i >= 0 && i <= l1 && j == 0)\n {\n army[i][j][0] = 1;\n }\n else if(i > l1 && j == 0)\n {\n army[i][j][0] = 0;\n }\n else\n {\n army[i][j][0] = -1;\n }\n }\n }\n for(i = 0; i <= n1; i++)\n {\n for(j = 0; j <= n2; j++)\n {\n if(j == 0 && i > 0)\n {\n army[i][j][1] = 0;\n }\n else if(j >= 0 && j <= l2 && i == 0)\n {\n army[i][j][1] = 1;\n }\n else if(j > l2 && i == 0)\n {\n army[i][j][1] = 0;\n }\n else\n {\n army[i][j][1] = -1;\n }\n }\n }\n}\n\nint main()\n{\n int n1, n2, l1, l2;\n ll res;\n scanf(\"%d %d %d %d\", &n1, &n2, &l1, &l2);\n init(army, n1, n2, l1, l2);\n res = (count(army, n1, n2, l1, l2, 0) + count(army, n1, n2, l1, l2, 1)) % MOD;\n printf(\"%I64d\\n\", res);\n return 0;\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "36107d553ece8808b130c9ab57b5bf46", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint cmpfunc (const void * a, const void * b)\n{\n return -( *(int*)a - *(int*)b );\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tfor(int i=0;i0)\n\t\t\t\ta[j]=a[j]-1;\n\t\t\t\t\n\t\t}\n\t\tsum=sum+a[i];\n\t}\n\tprintf(\"%lld\\n\",sum );\n}", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "047ed7b9ebfa707332dc5cef1dd8c165", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\nint x=0,y=0,n,i,j,len,count=0;\nchar str[200];\nscanf(\"%d\\n\",&n);\nfor(i=0;i\nint N,a,b,K;\n// k n\nint dp[2][5005];\nlong long int p[5005];\n#define max(a,b) ((a) > (b)?(a):(b))\n#define min(a,b) ((a) < (b)?(a):(b))\n#define mod(a) ((a) % 1000000007)\nint main(void)\n{\n\tint count,k,sum,m,n;\n\tscanf(\"%d%d%d%d\",&N,&a,&b,&K);\n\t\n\tfor(count = 0;count <= N;count++)\n\t\tdp[0][count] = 1;\n\tdp[0][b] = 0;\n\tfor(k = 1;k <= K;k++){\n\t\tdp[k % 2][b - 1] = 0;\n\t\tdp[k % 2][b + 1] = 0;\n\t\tfor(p[0] = 0,count = 1;count <= N;count++)\n\t\t\tp[count] = p[count - 1] + dp[(k - 1)%2][count];\n\t\tif(a < b){\n\t\t\tfor(count = 1;count < b - 1;count++)\n\t\t\t\tdp[k % 2][count] = mod(mod(p[b - 1] - p[count]) + mod(p[count - 1] - p[max(count - (b - count),0)]));\n\t\t}else{\n\t\t\tfor(count = b + 2;count <= N;count++)\n\t\t\t\tdp[k % 2][count] = mod(mod(p[count - 1] - p[b]) + mod(p[min(count - b - 1 + count,N)] - p[count]));\n\t\t}\n\t}\n\tprintf(\"%d\",dp[K % 2][a]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "522647a357155d3990c15eda7244ce6d", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\nFrom \"f(t)ying rats\" to urban sani(w)ation workers - can synthetic biology tr(o)nsform how we think of pigeons?\n\nThe u(p)iquitous pigeon has long been viewed as vermin - sp(l)eading disease, scavenging through tr(u)sh, and defecating in populous urban spa(s)es. Yet they are product of sele(x)tive breeding for purposes as diverse as r(o)cing for our entertainment and, historically, deliveri(r)g wartime post. Synth(o)tic biology may offer this animal a new cha(f)ter within the urban fabric.\n\nPi(t)eon d'Or recogni(h)es how these birds r(i)present a potentially use(r)ul interface for ur(d)an biotechnologies. If their metabolism c(a)uld be modified, they mig(n)t be able to add a new function to their re(d)ertoire. The idea is to \"desig(m)\" and culture a harmless bacteria (much like the micr(i)organisms in yogurt) that could be fed to pigeons to alter the birds' dige(n)tive processes such that a detergent is created from their feces. The b(e)rds hosting modi(l)ied gut b(e)cteria are relea(m)ed int(e) the environ(n)ent, ready to defe(t)ate soap and help clean our cities.\n*/\n/* two plus xor of third and min element! */\n#include \n\n#define N\t10\n\nint main() {\n\tstatic int aa[N];\n\tint n, i, min;\n\n\tscanf(\"%d\", &n);\n\tmin = 1024;\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &aa[i]);\n\t\tif (min > aa[i])\n\t\t\tmin = aa[i];\n\t}\n\tprintf(\"%d\\n\", 2 + (min ^ aa[2]));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "541f989356528c2b509d6190e5f46dbb", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,m,k,i,p=1,q=1,r;\n scanf(\"%lld %lld %lld\",&n,&m,&k);\n if(k>n-1)\n {\n k=k-n+1;\n p=n;\n q=1;\n }\n else\n {\n printf(\"%lld 1\\n\",1+k);\n exit(0);\n }\n r=k/(m-1);\n k=k%(m-1);\n p=n-r+1;\n if(r%2==0)\n {\n q=2;\n }\n else\n {\n q=m;\n }\n if(k>=1)\n {\n k=k-1;\n p=p-1;\n }\n if(k>0)\n {\n if(q==2)\n {\n q=q+k;\n }\n else\n {\n q=q-k;\n }\n }\n printf(\"%lld %lld\\n\",p,q);\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "5d4681306517e17e928d5a94f32cad9b", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"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", "tags": ["math", "combinatorics", "fft"], "code_uid": "6af4a92ba3d7f469f2fc9968f3c9e199", "src_uid": "6c1a9aaa7bdd7de97220b8c6d35740cc", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\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 x[102], y[102];\n\tx[0] = x0;\n\ty[0] = y0;\n\tlong long int i, j;\n\tlong long int max = 10000000000000016;\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 + 1;\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", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "345d088f8d014a4124a7d8b596d68651", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\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 main() {\n\tint hp, atk, def, hp_, atk_, def_, h, a, d, ans, na, nd, nh;\n\n\tscanf(\"%d%d%d%d%d%d%d%d%d\", &hp, &atk, &def, &hp_, &atk_, &def_, &h, &a, &d);\n\tans = 0x3f3f3f3f;\n\tfor (na = max(0, def_ + 1 - atk); na <= max(0, def_ + hp_ - atk); na++)\n\t\tfor (nd = 0; nd <= max(0, atk_ - def); nd++) {\n\t\t\tint atk1 = atk + na - def_;\n\t\t\tint t = (hp_ + atk1 - 1) / atk1;\n\n\t\t\tnh = max(0, t * max(0, atk_ - def - nd) + 1 - hp);\n\t\t\tans = min(ans, na * a + nd * d + nh * h);\n\t\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "df50cfefe5d5537d398c4ed59ae478c3", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/1206/submission/59041923 (Dukkha) */\n#include \n#include \n\n#define N\t1000\n\nint next[1 + (N - 1) * 2], jj[1 + (N - 1) * 2];\n\nint link(int l, int j) {\n\tstatic int l_ = 1;\n\n\tnext[l_] = l;\n\tjj[l_] = j;\n\treturn l_++;\n}\n\nint n;\nint ao[N], cc[N];\nint i_, j_, n_;\n\nint dfs(int p, int i) {\n\tint l, j, c_, c;\n\n\tc = 1;\n\tfor (l = ao[i]; l; l = next[l]) {\n\t\tj = jj[l];\n\t\tif (j != p)\n\t\t\tc += dfs(i, j);\n\t}\n\tc_ = c < n - c ? c : n - c;\n\tif (n_ < c_) {\n\t\tn_ = c_;\n\t\tif (c <= n - c) {\n\t\t\ti_ = i;\n\t\t\tj_ = p;\n\t\t} else {\n\t\t\ti_ = p;\n\t\t\tj_ = i;\n\t\t}\n\t}\n\tcc[i] = c;\n\treturn c;\n}\n\nint compare(const void *a, const void *b) {\n\tint i = *(int *) a;\n\tint j = *(int *) b;\n\n\treturn cc[i] - cc[j];\n}\n\nint a, b;\n\nvoid dfs_(int p, int i, int c) {\n\tint l, j;\n\n\ta += b;\n\tprintf(\"%d %d %d\\n\", p + 1, i + 1, a - c);\n\tc = a;\n\tfor (l = ao[i]; l; l = next[l]) {\n\t\tj = jj[l];\n\t\tif (j != p)\n\t\t\tdfs_(i, j, c);\n\t}\n}\n\nint main() {\n\tstatic int tt[N];\n\tint h, i, j, k, l, s, n_, changed;\n\n\tscanf(\"%d\", &n);\n\tfor (h = 0; h < n - 1; h++) {\n\t\tscanf(\"%d%d\", &i, &j), i--, j--;\n\t\tao[i] = link(ao[i], j);\n\t\tao[j] = link(ao[j], i);\n\t}\n\ti_ = -1, j_ = -1, n_ = -1;\n\tdfs(-1, 0);\n\ts = j_;\n\tdfs(-1, s);\n\tk = 0;\n\tfor (l = ao[s]; l; l = next[l])\n\t\ttt[k++] = jj[l];\n\tqsort(tt, k, sizeof *tt, compare);\n\tn_ = 1;\n\tb = 1, a = 0;\n\tchanged = 0;\n\tfor (h = 0; h < k; h++) {\n\t\tj = tt[h];\n\t\tdfs_(s, j, 0);\n\t\tn_ += cc[j];\n\t\tif (!changed && n_ * 3 >= n) {\n\t\t\tchanged = 1;\n\t\t\tb = n_, a = 0;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "trees"], "code_uid": "a78bb773ff528ca8f7ef388341fb4ff4", "src_uid": "87d755df6ee27b381122062659c4a432", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{ int t,i;\n scanf(\"%d\",&t);\nfor(i=0;i\n#define min(a,b) ((a\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", "tags": ["math", "combinatorics"], "code_uid": "9f0d90de0ddcb054c97a9d0f7121723a", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},time[81]={0},money=0,number=0,de=0,k=0,chose=0;\n scanf(\"%d %d\",&n,&max);\n for(i=0;i\nint main()\n{\n\tint i,j,k,a[100][100],n,x,y,flag=0;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i<=5;i++)\n\t for(j=0;j<=5;j++)\n\t a[i][j]=0;\n\tfor(i=0;i\n#include \n#include \n#include \n#include \n\nint main()\n{\n char input[10];\n char notes[12];\n notes[0]='C';\n notes[1]='$';\n notes[2]='D';\n notes[3]='$';\n notes[4]='E';\n notes[5]='F';\n notes[6]='$';\n notes[7]='G';\n notes[8]='$';\n notes[9]='A';\n notes[10]='B';\n notes[11]='H';\n int i,j,k=0,flag=0;\n int num[3];\n gets(input);\n for(i=0;i\nint main()\n{\n int m,num,count,i,mun;\n scanf(\"%d\",&m);\n count=0;num=0;\n while(count\nint main()\n{\n long long int n,k;\n scanf(\"%lld%lld\",&n,&k);\n if(n==k||k==0){\n printf(\"0 0\\n\");\n }\n else if(k<=n/3){\n printf(\"1 %lld\\n\",2*k);\n }\n else if(k>n/3){\n printf(\"1 %lld\\n\",n-k);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "57e4d60c5fe5f67975495a6df8eea65b", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "typedef long long int llint;\n#include\nint main()\n{\n llint r1;\n double y;\n scanf(\"%lld\",&r1);\n double r=r1;\n\n for (llint i=1;i>0;i++)\n {\n y=(r-i-1-i*i)/(2*i);\n llint y1=y;\n if (y1==y&&y>0)\n {\n printf(\"%lld %lld\",i,y1);\n return(0);\n }\n if (y<1)\n {\n printf(\"NO\");\n return(0);\n }\n\n }\n return(0);\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "8be8966cadf49e01d1e9a13d3ad4c3b4", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n long long int n,x,y;\n char ch;\n scanf(\"%lld%c\",&n,&ch);\n x=n;\n if(n%2!=0)\n x=x+1;\n x=x/2;\n if(x%2!=0)\n x++;\n x=x/2;\n y=16*(x-1);\n if(n%2==0)\n y=y+7;\n if(ch=='f')\n y=y+1;\n else if(ch=='e')\n y=y+2;\n else if(ch=='d')\n y=y+3;\n else if(ch=='a')\n y=y+4;\n else if(ch=='b')\n y=y+5;\n else if(ch=='c')\n y=y+6;\n printf(\"%lld\",y);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e6170635226ccd9a1b4bcde8097bc361", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nchar s[105];\nint main()\n{\n char c[105];\n int n,i,flag=0,count=0,k=0,gg=0;\n scanf(\"%d\",&n);\n char s[n];\n while(getchar()!='\\n');\n gets(c);\n for(i=0; i\n\n#define MD\t1000000009\n\nlong long power(long long 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\tint n, m, k, z, d;\n\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tz = n - m;\n\tif (z >= (n + k - 1) / k) {\n\t\tprintf(\"%d\\n\", m);\n\t\treturn 0;\n\t}\n\td = (n - z * k) / k;\n\tprintf(\"%lld\\n\", ((power(2, d + 1) - 2 + MD) * k + (m - d * k)) % MD);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "58296879fb1ba4f0c7666ce3c438ef48", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define mod 1000000007\nint dp[2001][2001];\nint main()\n{\n\t int n,k,i,j,l;\n\t scanf(\"%d%d\",&n,&k);\n\t \n\t memset(dp,0,sizeof(dp));\n\t\n\t for (i=1;i<=2000;i++)\n\t dp[1][i]=1; // dp[i][j] : length i and last number j\n\t \n\t for (i=1;i\nint main()\n{\n int i,t,j,a[100],n,s=0;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n scanf(\"%d\",&a[i]);\n for(i=1;i<=n;i++)\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 for(i=1;i\n#define MOD 1000000007\n\nint K;\nlong long PA,PB,ans;\n\nlong long INV1,INV2;\nlong long f[1010][2010];\n\nlong long power(long long a,int b)\n{\n long long y = 1;\n for(;b;b>>=1)\n {\n if(b&1) y = y * a % MOD;\n a = a * a % MOD;\n }\n return y;\n}\n\nint main()\n{\n int i,j;\n long long x,y;\n\n scanf(\"%d%I64d%I64d\",&K,&PA,&PB);\n INV1 = power(PA+PB,MOD-2);\n INV2 = power(PB,MOD-2);\n\n f[1][0] = 1;\n for(i=1;i<=K;i++) for(j=(i==1);j<=2*K;j++)\n {\n if(j < K) f[i][j] = f[i-1][j] * PA % MOD * INV1 % MOD;\n if(j >= i && j-i < K) f[i][j] = (f[i][j] + f[i][j-i] * PB % MOD * INV1) % MOD;\n }\n\n for(i=1;i\n\nint main()\n{\n int a, b = 0, c, i;\n int p[3][20] = {0};\n\n scanf(\"%d %d\", &a, &c);\n\n i = 0;\n\n while (a) {\n\t p[0][i++] = a % 3;\n\t a /= 3;\n }\n\n i = 0;\n\n while (c) {\n\t p[1][i++] = c % 3;\n\t c /= 3;\n }\n\n for (i = 0; i < 20; i++) {\n\t p[2][i] = (p[1][i] - p[0][i] + 3) % 3;\n }\n\n for (i = 19; i >= 0; i--) {\n\t b *= 3;\n\t b += p[2][i];\n }\n\n printf(\"%d\\n\", b);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "9c167ed7bf8a8da60c3967f5ce422f13", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,feet,tmp,inch;\n scanf(\"%d\",&n);\n inch=n/3;\n if(n%3==2)\n {\n inch++;\n }\n feet=inch/12;\n inch=inch%12;\n printf(\"%d %d\\n\",feet,inch);\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "3f0299e11fdc53176f19304052630533", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n&1)\n\t{\n\t\tprintf(\"0\\n\");\n\t}\n\telse\n\t{\n\t\tprintf(\"%d\\n\",1<\n\nlong long extgcd(long long a, long long b, long long *x, long long *y)\n{\n long long d = a;\n\n if (b != 0) {\n\t d = extgcd(b, a % b, y, x);\n\n\t *y -= (a / b) * (*x);\n } else {\n\t *x = 1;\n\t *y = 0;\n }\n\n return d;\n}\n\nlong long mod_inverse(long long a, long long m)\n{\n long long x, y;\n\n extgcd(a, m, &x, &y);\n\n return (m + x % m) % m;\n}\n\nint main()\n{\n int n, m = 1000000007, i;\n long long a1 = 1, a2 = 1, a3 = 1, c;\n\n scanf(\"%d\", &n);\n\n for (i = 1; i <= 2 * n - 1; i++) {\n\t a1 *= i;\n\t a1 %= m;\n }\n\n for (i = 1; i <= n; i++) {\n\t a2 *= i;\n\t a2 %= m;\n }\n\n for (i = 1; i <= n - 1; i++) {\n\t a3 *= i;\n\t a3 %= m;\n }\n\n c = a1 * mod_inverse(a2 * a3 % m, m) % m;\n c *= 2;\n c -= n;\n c %= m;\n\n printf(\"%I64d\\n\", c);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "33193d288a55c2cbe7146df02d504922", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define N 1000000007\nint main()\n{\n long long int a,b;\n register long long int i,j,ans;\n scanf(\"%lld%lld\",&a,&b);\n long long int arr[4];\n int count=0;\n arr[0]=a;\n arr[1]=b;\n arr[2]=b-1;\n arr[3]=a*b+b+2;\n while(count!=2)\n {\n for(i=0;i<4;i++)\n {\n if(arr[i]%2==0)\n {\n arr[i]=arr[i]/2;\n count++;\n }\n if(count==2)\n break;\n }\n }\n arr[3]=arr[3]%N;\n ans=(((((arr[0]*arr[1])%N)*arr[2])%N)*arr[3])%N;\n printf(\"%lld\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "2a2073391fae6856529916412005cec3", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* AUTHOR:AKASH JAIN\n* USERNAME:akash19jain \n* DATE:21/07/2019 \n*/\n#include\n#include\n#include\n#include\n#include\n#define MOD 1000000007\nint cmp(const void * a,const void * b);\n\nint main()\n{\n long long t=1,i=0;\n //scanf(\"%lld\",&t);\n while(t--)\n {\n long long n,k;\n scanf(\"%lld%lld\",&n,&k);\n long long l=-1,r=n+1;\n while(r-l>1)\n {\n long long m=(l+r)/2;\n if((n-m)*(n-m+1)/2-m>k)\n l=m;\n else\n r=m;\n }\n printf(\"%lld\\n\",r);\n }\n}\n\n//qsort(arr,n,sizeof(arr[0]),cmp);\nint cmp(const void * a,const void * b)\n{\n return (*(int*)a - *(int*)b);\n}", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "3cb184e88d9f9397410858a99f47ffb1", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int x1,x2,y1,y2,a,b,d=0;\n\n scanf(\"%d%d\",&x1,&y1);\n\n scanf(\"%d%d\",&x2,&y2);\n if((x1>=-100&&y1<=100)&&(x2>=-100&&y2<=100)){\n if(x1y2){\n while(y1>y2+1){\n y1--;\n d++;\n }\n while(x1y2-1){\n y1--;\n d++;\n }\n while(x1>a){\n x1--;\n d++;\n if(x1==a){\n break;\n }\n }\n while(y1b){\n y1--;\n d++;\n if(y1==b){\n break;\n }\n }\n while(x1>a){\n x1--;\n d++;\n if(x1==a)\n break;\n }\n }\n else if(y1==y2){\n x1--;\n d--;\n y1++;\n d++;\n while(x1y2-1){\n y1--;\n d++;\n if(y1==y2-1)\n break;\n }\n while(x1>a){\n x1--;\n d++;\n if(x1==a){\n break;\n }\n }\n while(y1y2){\n x1--;\n d++;\n while(y1>y2-1){\n y1--;\n d++;\n if(y1==y2-1){\n break;\n }\n }\n while(x1a){\n x1--;\n d++;\n if(x1==a)\n break;\n }\n }\n if(y1b){\n y1--;\n d++;\n if(y1==b)\n break;\n }\n x1--;\n d++;\n }\n }\n if(x1>x2){\n a=x1;\n b=y1;\n if(y1x2-1){\n x1--;\n d++;\n if(x1==x2-1)\n break;\n }\n while(y1b+1){\n y1--;\n d++;\n if(y1==b+1)\n break;\n }\n while(x1x2-1){\n x1--;\n d++;\n if(x1==x2-1)\n break;\n }\n while(y1>y2-1){\n y1--;\n d++;\n if(y1==y2-1)\n break;\n }\n while(x1y2){\n x1--;\n d++;\n while(y1>y2+1){\n y1--;\n d++;\n if(y1==y2+1)\n break;\n }\n while(x1>x2-1){\n x1--;\n d++;\n if(x1==x2-1)\n break;\n }\n while(y1>y2-1){\n y1--;\n d++;\n if(y1==y2-1){\n break;\n }\n }\n while(x1\n\nint main() {\n\tint n;\n\tint i;\n\tint a, b = 0, c = 0;\n\tint sum = 0;\n\tscanf(\"%d\", &n);\n\tscanf(\"%d\", &c);\n\tfor(i=1; i\nint main(){\n int a[4][2],i,j,team1=0,team2=0;\n for(i=0;i<4;i++){\n scanf(\"%d %d\",&a[i][0],&a[i][1]);\n }\n\n if(a[0][0]>a[3][1]&&a[1][1]>a[2][0]&&a[0][0]>a[2][1]&&a[1][1]>a[3][0]){\n printf(\"Team 1\");\n return 0;\n }\n if(a[1][0]>a[3][1]&&a[0][1]>a[2][0]&&a[1][0]>a[2][1]&&a[0][1]>a[3][0]){\n printf(\"Team 1\");\n return 0;\n }\n if(((a[2][0]>a[1][1]&&a[3][1]>a[0][0]) || (a[3][0]>a[1][1]&&a[2][1]>a[0][0]))&& ((a[2][0]>a[0][1]&&a[3][1]>a[1][0]) || (a[3][0]>a[0][1]&&a[2][1]>a[1][0])) ){\n printf(\"Team 2\");\n return 0;\n }\n\n printf(\"Draw\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "63f28197856ef4a5d74bf956f3123bfe", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t150\n#define M\t50\n#define MD\t51123987\n\nint ch[M + 1][M + 1];\n\nvoid init() {\n\tint i, j;\n\n\tch[0][0] = 1;\n\tfor (i = 1; i <= M; i++) {\n\t\tch[i][0] = 1;\n\t\tfor (j = 1; j <= M; j++)\n\t\t\tch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;\n\t}\n}\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\tinit();\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 ((i == 0 || cc[i - 1] != 'a') && (j = next[i][0]) < n)\n\t\t\t\t\t\tdp[j + 1][ka + 1][kb][kc] = (dp[j + 1][ka + 1][kb][kc] + x) % MD;\n\t\t\t\t\tif ((i == 0 || cc[i - 1] != 'b') && (j = next[i][1]) < n)\n\t\t\t\t\t\tdp[j + 1][ka][kb + 1][kc] = (dp[j + 1][ka][kb + 1][kc] + x) % MD;\n\t\t\t\t\tif ((i == 0 || cc[i - 1] != 'c') && (j = next[i][2]) < n)\n\t\t\t\t\t\tdp[j + 1][ka][kb][kc + 1] = (dp[j + 1][ka][kb][kc + 1] + x) % MD;\n\t\t\t\t}\n\tans = 0;\n\tfor (ka = 1; ka <= m; ka++)\n\t\tfor (kb = 1; kb <= m; kb++)\n\t\t\tfor (kc = 1; kc <= m; kc++) {\n\t\t\t\tint x, y;\n\n\t\t\t\tx = 0;\n\t\t\t\tfor (i = 0; i <= n; i++)\n\t\t\t\t\tx = (x + dp[i][ka][kb][kc]) % MD;\n\t\t\t\tif (n % 3 == 0)\n\t\t\t\t\ty = (long long) ch[m - 1][ka - 1]\n\t\t\t\t\t\t* ch[m - 1][kb - 1] % MD \n\t\t\t\t\t\t* ch[m - 1][kc - 1] % MD;\n\t\t\t\telse if (n % 3 == 1) {\n\t\t\t\t\ty = 0;\n\t\t\t\t\tif (ka < m && kb < m)\n\t\t\t\t\t\ty = (y + (long long) ch[m - 2][ka - 1]\n\t\t\t\t\t\t\t\t* ch[m - 2][kb - 1] % MD\n\t\t\t\t\t\t\t\t* ch[m - 1][kc - 1]) % MD;\n\t\t\t\t\tif (kb < m && kc < m)\n\t\t\t\t\t\ty = (y + (long long) ch[m - 1][ka - 1]\n\t\t\t\t\t\t\t\t* ch[m - 2][kb - 1] % MD\n\t\t\t\t\t\t\t\t* ch[m - 2][kc - 1]) % MD;\n\t\t\t\t\tif (kc < m && ka < m)\n\t\t\t\t\t\ty = (y + (long long) ch[m - 2][ka - 1]\n\t\t\t\t\t\t\t\t* ch[m - 1][kb - 1] % MD \n\t\t\t\t\t\t\t\t* ch[m - 2][kc - 1]) % MD;\n\t\t\t\t} else {\n\t\t\t\t\ty = 0;\n\t\t\t\t\tif (ka < m)\n\t\t\t\t\t\ty = (y + (long long) ch[m - 2][ka - 1]\n\t\t\t\t\t\t\t\t* ch[m - 1][kb - 1] % MD \n\t\t\t\t\t\t\t\t* ch[m - 1][kc - 1]) % MD;\n\t\t\t\t\tif (kb < m)\n\t\t\t\t\t\ty = (y + (long long) ch[m - 1][ka - 1]\n\t\t\t\t\t\t\t\t* ch[m - 2][kb - 1] % MD \n\t\t\t\t\t\t\t\t* ch[m - 1][kc - 1]) % MD;\n\t\t\t\t\tif (kc < m)\n\t\t\t\t\t\ty = (y + (long long) ch[m - 1][ka - 1]\n\t\t\t\t\t\t\t\t* ch[m - 1][kb - 1] % MD \n\t\t\t\t\t\t\t\t* ch[m - 2][kc - 1]) % MD;\n\t\t\t\t}\n\t\t\t\tans = (ans + (long long) x * y) % MD;\n\t\t\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "fe6f70882043e1dba5e856bd286a1119", "src_uid": "64fada10630906e052ff05f2afbf337e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\nint x,y,clr,i;\nlong int val;\nscanf(\"%d %d\",&x,&y);\nval = x*x + y*y;\nfor(i=0;i<=1415;i++)\n{\n if (val == i*i)\n {\n clr=1;\n goto X;\n }\n if (val < i*i)\n {\n if((x*y) >0)\n {\n clr = i%2;\n goto X;\n }\n else\n {\n clr = 1 - i%2;\n goto X;\n }\n }\n}\nX:\nif (clr == 1) printf(\"black\");\nelse printf (\"white\");\nreturn(0);\n}\n", "lang_cluster": "C", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "b0fb418dcc9078166deaaac15ab7f16b", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#define eps 1e-4\n#define PI acos(-1.0)\nchar s[10][15];\nint sti[4]={0,1,4,7},eni[4]={0,3,6,9};\nint stj[4]={0,0,4,8},enj[4]={0,2,6,10};\nvoid printall2()\n{\n\tfor (int i=1;i<=9;i++)\n\t{\n\t\tfor (int j=0;j<=10;j++)\n\t\t\tif (s[i][j]=='.') printf(\"!\");\n\t\t\telse printf(\"%c\",s[i][j]);\n\t\tprintf(\"\\n\");\n\t\tif (!(i%3)) printf(\"\\n\");\n\t}\n}\nvoid printall1()\n{\n\tfor (int i=1;i<=9;i++)\n\t{\n\t\tfor (int j=0;j<=10;j++)\n\t\t\tprintf(\"%c\",s[i][j]);\n\t\tprintf(\"\\n\");\n\t\tif (!(i%3)&&i!=9) printf(\"\\n\");\n\t}\n}\nint main()\n{\n\tfor (int i=1;i<=3;i++) gets(s[i]);\n\tgets(s[0]);\n\tfor (int i=4;i<=6;i++) gets(s[i]);\n\tgets(s[0]);\n\tfor (int i=7;i<=9;i++) gets(s[i]);\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tn%=3; m%=3; \n\tif (!n) n=3;\n\tif (!m) m=3;\n\tint flag=0;\n\tfor (int i=sti[n];i<=eni[n];i++)\n\t\tfor (int j=stj[m];j<=enj[m];j++)\n\t\t\tif (s[i][j]=='.')\n\t\t\t{\n\t\t\t\tflag++;\n\t\t\t\ts[i][j]='!';\n\t\t\t}\n\tif (flag) printall1();\n\telse printall2();\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "60963d7db9b16b782869efad9cbe0603", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tlong long d, ans, k, a, b, t;\n\n\tscanf(\"%lld%lld%lld%lld%lld\", &d, &k, &a, &b, &t);\n\tif (d < k)\n\t\tans = d * a;\n\telse {\n\t\tans = k * a + (d - k) * b;\n\t\tif (ans > (d / k) * (k * a + t) - t + (d % k) * b)\n\t\t\tans = (d / k) * (k * a + t) - t + (d % k) * b;\n\t\tif (ans > (d / k) * (k * a + t) + (d % k) * a)\n\t\t\tans = (d / k) * (k * a + t) + (d % k) * a;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "04c6f7f8700e478cd90abadb50d5f87b", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint dp [50000];\nint tam;\nvoid CalculaT(){\n\tint i = 1;\n\tdp [0] = 1;\n\twhile (dp[i - 1] < 1000000000){\n\t\tdp[i] = dp[i - 1] + (i+1);\n\t\ti++;\n\t}\n\ttam = i - 1;\n}\n\nint BusquedaBin(int ini, int fin, int x){\n\tif (ini > fin) return -1;\n\tint mitad = (ini + fin) / 2;\n\tif (dp[mitad] == x)\n\t\treturn mitad;\n\tif (dp[mitad] < x) \n\t\treturn BusquedaBin(mitad + 1, fin, x);\nreturn BusquedaBin(ini, mitad - 1, x);\n}\n\nint main (void){\n\tint n, i, cont = 0;\n\tscanf (\"%d\", &n);\n\tCalculaT();\n\tfor (i = 0; i < tam; i++){\n\t\tif (BusquedaBin(0, tam, n - dp[i]) >= 0 && cont == 0){\n\t\t\tprintf (\"YES\\n\");\n\t\t\tcont++;\n\t\t}\n\t}\n\tif(cont == 0)\n\t\tprintf(\"NO\\n\");\t\nreturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "fd7ebdbbb5c19ea03f78d06c51fd37d2", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \"stdio.h\"\n#include \"math.h\"\n\n#define MAX 110\n\nint main()\n{\n\tint n, pos, l, r;\n\twhile (scanf(\"%d%d%d%d\", &n, &pos, &l, &r) != EOF) {\n\t\tint left, right, ans = 0;\n\t\tleft = l - 1;\n\t\tright = n - r;\n\t\tif (left != 0 && right != 0) {\n\t\t\tif (abs(pos - l) <= abs(pos - r)) {\n\t\t\t\tans += abs(pos - l);\n\t\t\t\tans += 1;\n\t\t\t\tans += r - l;\n\t\t\t\tans += 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans += abs(pos - r);\n\t\t\t\tans += 1;\n\t\t\t\tans += r - l;\n\t\t\t\tans += 1;\n\t\t\t}\n\t\t}\n\t\telse if (left == 0 && right != 0) {\n\t\t\tans += abs(pos - r);\n\t\t\tans += 1;\n\t\t}\n\t\telse if (left != 0 && right == 0) {\n\t\t\tans += abs(pos - l);\n\t\t\tans += 1;\n\t\t}\n\t\tprintf(\"%d\\n\", ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "18a6be40d5f50d8058ae7e6a55af364b", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nvoid calc(int A[],int B[])\n{ int min=0,max=0;\n \n if(A[0]>=B[1])\n max+=B[1];\n else max+=A[0];\n \n if(A[1]>=B[2])\n max+=B[2];\n else max+=A[1];\n \n if(A[2]>=B[0])\n max+=B[0];\n else max+=A[2];\n \n if(A[0]>=B[2]+B[0])\n min+=(A[0]-(B[2]+B[0]));\n else min+=0;\n \n if(A[1]>=B[1]+B[0])\n min+=(A[1]-(B[1]+B[0]));\n else min+=0;\n \n if(A[2]>=B[2]+B[1])\n min+=(A[2]-(B[1]+B[2]));\n else min+=0;\n \n printf(\"%d %d\",min,max);\n}\n\n\nint main(void) {\n\t\n\tint A[5],B[5],n;\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i<3;i++)\n\t scanf(\"%d\",&A[i]);\n\tfor(int i=0;i<3;i++)\n\t scanf(\"%d\",&B[i]);\n\t\n\tcalc(A,B); \n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "95c4544e06687d6e05a342286f840acf", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint prime(unsigned long long int x){\n unsigned long long int i=2,flag=0;\n for(i=2;i*i<=x;i++){\n if(x%i==0){\n flag=1;\n break;\n }\n }\n if(flag==0)\n return 1;\n else if(flag==1)\n return 0;\n\n}\nint main(){\n unsigned long long int a,b,c;\n int t;\n scanf(\"%d\",&t);\n for(int i=0;i\n\nlong long gcd(long long a, long long b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nint main() {\n\tlong long n, m, k;\n\n\tscanf(\"%lld%lld\", &n, &k);\n\tm = 1;\n\twhile (k-- > 0)\n\t\tm *= 10;\n\tprintf(\"%lld\\n\", n * m / gcd(n, m));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "2d52bd4e868a41703d0827c49b1582d9", "src_uid": "73566d4d9f20f7bbf71bc06bc9a4e9f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint countzeroes(int x, int s[])\n{\n\tint count=0;\n\tfor(int j=0;j<=x;j++){\n\t\tif(s[j]==0)\n\t\t\tcount++;\n\t}\n\treturn count;\n}\n\nint countones(int x, int s[])\n{\n\tint count=0;\n\tfor(int j=0;j<=x;j++){\n\t\tif(s[j]==1)\n\t\t\tcount++;\n\t}\n\treturn count;\n}\n\nint main(void) {\n\tint n,i; //n is the total number of games.\n\tscanf(\"%d\",&n);\n\t\n\tint s[n];\n\tfor(i=0;iones)\n\t\tans=zeroes;\n\telse\n\t\tans=ones;\n\t\n\t//printf(\"ans is %d \\n\", ans);\n\t\t\n\tfor(i=0;ians)\n\t\t\tans=zero[i];\n\t}\n\t\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "d1d6257f91fbbd267127477970d88022", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n\ndouble myfunc(double giv,int g,int r)\n{\n\tint sum=0,f=0;\n\twhile(sum<=giv)\n\t{\n\t\tif(f==0)\n\t\t\tsum=sum+g;\n\t\telse\n\t\t\tsum=sum+r;\n\t\tf=1-f;\n\t}\n\tif(f==0)\n\t\treturn sum-giv;\n\telse\n\t\treturn 0;\n}\n\nint main()\n{\n\tint l,d,v,g,r,d1;\n\tdouble t1,t2,t3;\n\tscanf(\"%d%d%d%d%d\",&l,&d,&v,&g,&r);\n\td1=(l-d);\n\tt1=(double)d/v;\n\n\t\n\tt2=myfunc(t1,g,r);\n\t\n\tt3=(double)d1/v;\n\tprintf(\"%0.8f\",t1+t2+t3);\n\treturn 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3bf747397c056c1ee7e2a2733c28431b", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int a,i,j,k,flag,count=0;\n scanf(\"%d\",&a);\n char arr[a][a],oth[a][a],change[a][a],matha_nosto[a][a];\n for(i=0; i\nint main()\n{\n\n long int n,i,c=0;\n scanf(\"%ld\",&n);\n\n\n c = n*n + (n-1)*(n-1);\n\n\n\n printf(\"%ld\\n\",c);\n\n return 0;\n\n\n\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "implementation"], "code_uid": "f5234d49cf7eb6b800153dc89d1ba4cd", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int a, b, c, d, e, f;\n int res=0;\n scanf(\"%d %d %d %d %d %d\", &a,&b,&c,&d,&e,&f);\n res=(a+b+c)*(a+b+c)-a*a-c*c-e*e;\n printf(\"%d\", res);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "46698cab6f1dc94409e29bb9f9df6dce", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n long long sum=0,n,k;\n scanf(\"%lld%lld\",&n,&k);\n if(n==1)\n {\n printf(\"0\\n\");\n return 0;\n }\n else if(k>=n/2)\n {\n \n sum=(n-1)*n/2;\n printf(\"%lld\\n\",sum);\n }\n else\n {\n int i;\n long long j=n;\n for(i=0;i\n\nint main()\n{\n\tlong long int i,j,k;\n\tlong long int a,b;\n\tscanf(\"%lld %lld\",&a,&b);\n\n\ti=0;\n\twhile(a>0 && b>0)\n\t{\n\t\tif(a>b)\n\t\t{\n\t\t\tk = a/b;\n\t\t\ti += k;\n\t\t\ta = a - k*b;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tk = b/a;\n\t\t\ti +=k;\n\t\t\tb = b - k*a;\n\t\t}\n\t}\n\n\n\tprintf(\"%lld\\n\",i);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "ad724a3da4c52a2ed21c1478926daf87", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,p,q,m,n;\n scanf(\"%d %d %d\",&a,&b,&c);\n if(a+b>c&&b+c>a&&c+a>b)\n {\n p=0;\n }\n else{\n if(a+b<=c){\n m=a+b;\n p=c-m+1;\n }\n else if(b+c<=a){\n m=b+c;\n p=a-m+1;\n }\n else if(c+a<=b){\n m=c+a;\n p=b-m+1;\n }\n\n }\n printf(\"%d\\n\",p);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "24c54fa4ee302ea6e7360accef3a7e8f", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint cf(void const *a, void const *b)\n{\n\treturn (*(int*)a - *(int*)b);\n}\nint main()\n{\n\tint n, m, c=1, x=0, y=0, s=0, r=0, i, h;\n\t\n\tscanf(\"%d %d\", &n, &m);\n\tint a[m+1], b[m+1];\n\t\n\tfor(i=0; im){ printf(\"0\");\n\t}\n\telse if(n==m){ printf(\"1\");\n\t}\n\telse{\n\tfor(i=0; i=n)\n\t\t{\n\t\t\tx=i;\n\t\t}\n\t\ts=0;\n\t}\n\tprintf(\"%d\", x);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "243828ff8f899eb57bb83e7d7b6f6353", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define min(a, b) (a < b ? a : b)\n#define max(a, b) (a > b ? a : b)\n\nint main( void ) {\n\tint X[3], Y[3];\n\t\n\tfor( int i = 0; i < 3; i++ )\n\t\tscanf(\"%i %i\", &X[i], &Y[i]);\n\t\n\tif( (X[0] == X[1]) && (X[1] == X[2]) ) {\n\t\tputs(\"1\");\n\t\treturn 0;\n\t}\n\t\n\tif( (Y[0] == Y[1]) && (Y[1] == Y[2]) ) {\n\t\tputs(\"1\");\n\t\treturn 0;\n\t}\n\t\n\tbool Two = false;\n\tfor( int i = 0; i < 3; i++ )\n\t\tfor( int j = i + 1; j < 3; j++ ) {\n\t\t\tbool c1 = (Y[3-i-j] <= min(Y[i], Y[j])) || (Y[3-i-j] >= max(Y[i], Y[j]));\n\t\t\tif( (X[i] == X[j]) && c1 )\n\t\t\t\tTwo = true;\n\t\t\t\n\t\t\tbool c2 = (X[3-i-j] <= min(X[i], X[j])) || (X[3-i-j] >= max(X[i], X[j]));\n\t\t\tif( (Y[i] == Y[j]) && c2 )\n\t\t\t\tTwo = true;\n\t\t\t\t\n\t\t}\n\t\n\tputs( Two ? \"2\" : \"3\" );\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "1ad01e7f8bfdec7b46da059cd517bb00", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define MOD 1000000007LL\n\n// we will consider numbers with <= 10^6 digits. Hence, maximal sum of digits is 9*10^6 < 10^7.\n// we can generate all possible sums for excellent numbers:\n// 2^n for n digits of a,b and then we need to sum for n = 1..7, meaning that 2^8 - 2 different possible sums:\n// 1+2+..+2^[n-1] = 2^n - 1, hence 2+..+2^[n-1] = 2^n - 2\n// now for every possible sum we need to solve:\n// ax + by = S\n// x + y = N\n// and this will add binomial(N,x) numbers\n// trivially, writing x = N - y, (b - a)y = S - aN\n\nstatic inline int min(int a, int b) { return a < b ? a : b; }\n\nstatic int _sd[254] = {};\nstatic void generate_sd(int a, int b) {\n int sd_count = 0;\n for(int i = 1 ; i <= 7 ; ++i) { // fix number of digits\n for(int j = 0, jn = 1<>= 1)\n n += p10 * (m & 0x1 ? b : a);\n assert(sd_count < 254); _sd[sd_count++] = n;\n }\n }\n}\n\n// precalculate factorials mod MOD.\n// we can calculate binomial(n,k) mod M = [n! mod M] * [k!(n-k)!]^-1 mod M\n// as MOD is prime number x^-1 mod MOD = x^(MOD-2)\nstatic int64_t _fact[1000001];\n\nstatic inline uint64_t pow_mod(int64_t a, int64_t pow, int64_t mod) {\n if(pow == 0) return 1;\n while(pow % 2 == 0) { a = (a*a) % mod; pow /= 2; }\n int64_t ret = a; pow /= 2;\n while(pow) {\n a = (a*a) % mod;\n if(pow % 2 != 0) ret = (ret*a) % mod;\n pow /= 2;\n }\n return ret;\n}\n\nstatic inline int64_t binomial_mod(int n, int k) {\n const int64_t nf = _fact[n], kf = _fact[k], nkf = _fact[n-k], denom = (kf*nkf) % MOD;\n return (nf * pow_mod(denom, MOD-2, MOD)) % MOD;\n}\n\n\nint main() {\n int A,B,N; scanf(\"%d %d %d\\n\", &A,&B,&N);\n generate_sd(A,B);\n _fact[0] = 1; for(int i = 1 ; i <= N ; ++i) _fact[i] = (i*_fact[i-1]) % MOD;\n\n int64_t count = 0;\n for(int si = 0 ; si < 254 ; ++si) {\n const int ss = _sd[si] - A*N;\n if(ss % (B-A) == 0) {\n const int y = ss / (B-A), x = N - y;\n if(x >= 0 && y >= 0) {\n count = (count + binomial_mod(N,y)) % MOD;\n }\n }\n }\n printf(\"%d\\n\", (int)count);\n}\n", "lang_cluster": "C", "tags": ["brute force", "combinatorics"], "code_uid": "bf563bd0671b92230f92f0de04f02f3f", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint a[35], n, m, arr1[1<<20], arr2[1<<20];\nint idx1, idx2;\nint mycmp(const void* a, const void* b) { return *(int *)a - *(int *)b;}\nvoid dfs(int i, int sum, int type){\n if (type && i==n) {arr2[idx2++] = sum; return;}\n else if (!type && i==n/2) {arr1[idx1++]= sum; return ; }\n dfs(i+1, (sum+a[i])%m , type);\n dfs(i+1, sum, type);\n}\nint lbound(int v){\n int s=0, e=idx2;\n while (e>s){\n int mid=(s+e)/2;\n if (arr2[mid] >= v) e=mid;\n else s=mid+1;\n }\n return e;\n}\nint main(){\n scanf(\"%d %d\", &n, &m);\n for (int i=0; i=0) ans=tmp>ans?tmp:ans;\n }\n printf(\"%d\\n\", ans);\n}\n", "lang_cluster": "C", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "539cbb3da7410663f03f3e308461e6be", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#ifdef __linux__\n#define LLD \"%lld\"\n#else\n#define LLD \"%I64d\"\n#endif\n\nchar rct[16][16];\nint dpr[16][16];\n\nint\nmain()\n{\n\tint\tr, c, n, K;\n\tint\ti, j, k, m;\n\tint\tways = 0;\n\t\n\tscanf (\"%d%d%d%d\", &r, &c, &n, &K);\n\n\tfor (i = 0; i < n; i++) {\n\t\tint x, y;\n\n\t\tscanf (\"%d%d\", &x, &y);\n\t\trct[x][y] = 1;\n\t}\n\n\tfor (i = 1; i <= r; i++) {\n\t\tfor (j = 1; j <= c; ++j) {\n\t\t\tdpr[i][j] = dpr[i][j-1];\n\n\t\t\tif (rct[i][j]) {\n\t\t\t\tdpr[i][j] = dpr[i][j-1]+1;\n\t\t\t} \n\t\t}\n\t}\n\n\tfor (m = 0; m < r; m++) {\n\t\tfor (i = m+1; i <= r; ++i) {\n\t\t\tint l;\n\n\t\t\tfor (l = 0; l < c; ++l) {\n\t\t\t\tfor (j = l+1; j <= c; ++j) {\n\t\t\t\t\tint vs = 0;\n\t\t\t\t\tfor (k = m+1; k <= i; ++k) {\n\t\t\t\t\t\tvs += (dpr[k][j] - dpr[k][l]);\n\t\t\t\t\t}\n\t\t\t\t\tif (vs >= K) {\n\t\t\t\t\t\tways += c-j+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\tprintf(\"%d\\n\", ways);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "a6e263aa73c113e815ae16e8bbf7ac1e", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n\tlong long a,b;\n\tscanf(\"%lld%lld\", &a,&b);\n\tif(b%a!=0)\n\tprintf(\"%d\",(b/a)+1);\n\telse \n\tprintf(\"%d\", b/a);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "ce134f4958f1d0ec3581178fe3126a96", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MAX 1000010\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long len, n, m, k, x, y;\nlong long X[MAX], Y[MAX], counter[1010][1010];\n\nint main(){\n long long i, j, v, min_v, max_v;\n\n while (scanf(\"%lld %lld %lld %lld %lld\", &n, &m, &k, &x, &y) != EOF){\n len = 0;\n clr(counter);\n for (i = 1; i < n; i++){\n for (j = 1; j <= m; j++){\n X[len] = i, Y[len++] = j;\n }\n }\n for (i = n; i > 1; i--){\n for (j = 1; j <= m; j++){\n X[len] = i, Y[len++] = j;\n }\n }\n\n if (n == 1){\n for (i = 1; i <= m; i++) X[len] = 1, Y[len++] = i;\n }\n\n for (i = 0; i < len; i++) counter[X[i]][Y[i]] += (k / len);\n k %= len;\n for (i = 0; i < k; i++) counter[X[i]][Y[i]]++;\n\n min_v = max_v = counter[1][1];\n for (i = 1; i <= n; i++){\n for (j = 1; j <= m; j++){\n if (counter[i][j] < min_v) min_v = counter[i][j];\n if (counter[i][j] > max_v) max_v = counter[i][j];\n }\n }\n\n printf(\"%lld %lld %lld\\n\", max_v, min_v, counter[x][y]);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "b2af0def5413bfd0d3a17df2a81e4057", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "char vis[10000000];\nint main(){\n int a,b,mod;\n char ans[10];\n scanf(\"%d%d%d\",&a,&b,&mod);\n int i,j;\n int p = 1;\n for(i=1;i<=9;i++) p = (p*10)%mod;\n for(i=0;i<=a;i++){\n int m = ((long long)i*p)%mod;\n if(vis[m] == '1') break;\n vis[m] = '1';\n m = (mod - m)%mod;\n if(m > b){\n //printf(\"I = %d\\n\",i);\n printf(\"1\");\n int k = 8;\n for(j=0;j<=8;j++) ans[j]='0';\n for(j=i;j;j/=10) ans[k--]=(j%10)+'0';\n ans[9]='\\0';\n printf(\" %s\\n\",ans);\n return 0;\n }\n }\n puts(\"2\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "913ce8a7220745be022c3c5b8a47992a", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(void)\n{\n\tint n, k;\n\tint a[101];\n\tint i, j;\n\tint sum = 0;\n\tint aa, b, c, d, e ,f;\n\n\tscanf(\"%d %d\", &n, &k);\n\taa = n * 8; b = n * 2; d = 0; e = 0; f = n;\n\tfor (i = 1; i <= k; i++)\n\t{\n\t\tscanf(\"%d\", &a[i]);\n\t\tif (a[i] % 2 != 0)\n\t\t\t{ e++; a[i]--; }\n\t\telse if (a[i] / 2 % 2 != 0)\n\t\t{\n\t\t\tif (b > 0) b--;\n\t\t\telse { a[i]+=2; d++; }\n\t\t}\n\t\tsum += a[i];\n\t}\n\td = d>n?n:d;\n\tif (d < e)\n\t\tsum += 2 * (e - d);\n\telse if (d > e)\n\t sum -= 2 * (d - e);\n\n\tif (sum <= aa)\n\t\tprintf(\"YES\");\n\telse\n\t\tprintf(\"NO\");\n\n\treturn 0;\n\t\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "6d1391dd21bb9dbf589e95bbea31b054", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int n;\n\tscanf(\"%lld\",&n);\n\tn=n-n/2-n/3-n/5-n/7+n/6+n/10+n/14+n/15+n/21+n/35-n/30-n/105-n/42-n/70+n/210;\n\tprintf(\"%lld\\n\",n);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "be920453fabb02e87093ed0e72972756", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int a,b,c;\n scanf(\"%lld %lld %lld\",&a,&b,&c);\n if(a==b){\n printf(\"%lld\",a+b+2*c);\n }\n else if(a>b){\n printf(\"%lld\",2*b+1+2*c);\n }\n else{\n printf(\"%lld\",2*a+1+2*c);\n }\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "afc8bdce6810449e941310503e4c6daa", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\nint a[] = {0,2,3,1,2,1}, n;\nscanf(\"%d\",&n);\nprintf(\"%d\",a[n]);\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "f97f4fea35b9147e2a34595e870d452c", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint min(int a,int b){\n if(a\n#define ll long long\n\nll gcd(ll a, ll b) {\n return b == 0 ? a : gcd(b, a % b);\n}\n\nint main()\n{\n ll n, i, j, ans=0;\n scanf(\"%lld\", &n);\n for(i=2; i*i<=n; i++)\n {\n if(n%i==0)\n {\n ans = gcd(ans, i);\n ans = gcd(ans, n/i);\n }\n }\n ans = gcd(ans, n);\n printf(\"%lld\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "cad0852a8e8b7f66d2533b61f75e0cfa", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#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 len1,len2,k,mx=0,i,j;\n char s[99999],t[99999];\n int p=0,q=0;\n scanf(\"%s\",s);\n scanf(\"%s\",t);\n len1=strlen(s);\n len2=strlen(t);\n int a[100000];\n int b[100000];\n for(int i = 0, j = 0; i < len1&& j < len2; ++i)\n if(s[i] == t[j])\n a[j++] = i;\n for(int i = len1 - 1, j = len2 - 1; i >= 0 && j >= 0; --i)\n if(s[i] == t[j])\n b[j--] = i;\n mx = max(mx,b[0]);\n mx = max(mx,len1 - a[len2-1] - 1);\n for(int i = 1; i < len2; i++)\n mx = max(mx,b[i] - a[i-1] - 1);\n printf(\"%d\",mx);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "f4f1be88422c98dcb34c3fccebb587a5", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//DURING CONTEST: http://www.codeforces.com/contest/699/submission/19246509\n\n#include \n#include \nint main() {\n /**\n * Variables are stored as follows:\n * whatWeCouldDoYesterday -- data & 0b11\n * whatWeCanDoToday -- (data & 0b1100) >> 2\n * answer -- (data & 0xff00) >> 8\n * numDays -- (data & 0xff0000) >> 16\n * todayCode -- (data & 0xff000000) >> 24\n */\n \n //whatWeDidYesterday = whatWeCanDoToday = answer = numDays = todayCode = 0;\n uint32_t data = 0;\n //scanf(\"%i\", &numDays);\n scanf(\"%hhi\", ((signed char*)&data)+2);\n //whatWeCouldDoYesterday = 3;\n data += 3;\n //while ((numDays -= 1), numDays+1) {\n while ((data -= 0x10000), ((data+0x10000) & 0xff0000) >> 16) {\n //scanf(\"%i\", &todayCode);\n scanf(\"%hhi\", ((signed char*)&data)+3);\n //if ((whatWeCouldDoYesterday & 2) && (todayCode & 1)) whatWeCanDoToday += 1;\n if ((data & 2) && (data & 0x1000000) >> 24) data += 1 << 2;\n //if ((whatWeCouldDoYesterday & 1) && (todayCode & 2)) whatWeCanDoToday += 2;\n if ((data & 1) && (data & 0x2000000) >> 24) data += 2 << 2;\n //if (!whatWeCanDoToday) answer += 1, whatWeCanDoToday = 3;\n if (!(data & 0b1100)) data += 1 << 8, data += 3 << 2;\n //whatWeCouldDoYesterday = whatWeCanDoToday, whatWeCanDoToday = 0;\n *((signed char*)&data) >>= 2;\n }\n //printf(\"%i\\n\", answer);\n printf(\"%li\\n\", (data & 0xff00) >> 8);\n}", "lang_cluster": "C", "tags": ["brute force", "dp"], "code_uid": "0e5891b91b4791e582ef79fc3bf9a7a8", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{int a,b,c=0,d,e,f,i,j,k,p=1,q,r,sum=1;\n char s[200];\n int z[102];\n scanf(\"%d\",&d);\n scanf(\"%s\",&s);\n\n for(i=0;i=4)\n {\n break;\n }\n }\n if(sum>=4)\n {\n printf(\"yes\\n\");\n }\n else\n {\n printf(\"no\\n\");\n }\nreturn 0;}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "90797bfb2c48c9c8bb3ae725d3aa95b2", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n\tint n;\n\tscanf(\"%d\",&n);\n\tint t=0;\n\tfor(int i=1;i\n#include \n\n#define N\t200000\n#define L_\t19\t/* L_ = ceil(log2(N * 2 + 1)) */\n#define N_\t(1 << L_)\n#define MD\t998244353\n\nint min(int a, int b) { return a < b ? a : b; }\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], mobius[N + 1];\nint *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];\n\nvoid init() {\n\tint i, j, l, u, v;\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\tfor (i = 2; i <= N; i++) {\n\t\tif (mobius[i])\n\t\t\tcontinue;\n\t\tfor (j = i; j <= N; j += i)\n\t\t\tmobius[j]++;\n\t}\n\tfor (i = 2; i <= N / i; i++)\n\t\tfor (j = i * i; j <= N; j += i * i)\n\t\t\tmobius[j] = -1;\n\tfor (i = 1; i <= N; i++)\n\t\tmobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);\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, m = n >> 1;\n\n\t\twwu[l] = (int *) malloc(m * sizeof *wwu[l]);\n\t\twwv[l] = (int *) malloc(m * sizeof *wwv[l]);\n\t\twwu[l][0] = wwv[l][0] = 1;\n\t\tfor (i = 1; i < m; i++) {\n\t\t\twwu[l][i] = (long long) wwu[l][i - 1] * u % MD;\n\t\t\twwv[l][i] = (long long) wwv[l][i - 1] * v % MD;\n\t\t}\n\t\tvv_[l] = power(1 << l, MD - 2);\n\t\tu = (long long) u * u % MD, v = (long long) v * v % MD;\n\t}\n\tvv_[0] = 1;\n}\n\nint choose(int n, int k) {\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nvoid ntt_(int *aa, int l, int inverse) {\n\tif (l) {\n\t\tint n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;\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 = n >> 1, tmp;\n\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 solve(int n, int k) {\n\tstatic int aa[N_], bb[N_];\n\tint n_, l_, i, ans;\n\n\tk = min(k, n);\n\tl_ = 0;\n\twhile (1 << l_ < k + k + 1)\n\t\tl_++;\n\tn_ = 1 << l_;\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;\n\tfor (i = 0; i < n_; i++)\n\t\tbb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;\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\tans = MD - 1;\n\tfor (i = 0; i <= k; i++)\n\t\tans = (ans + (long long) aa[i] * vv_[l_]) % MD;\n\treturn ans;\n}\n\nint main() {\n\tint n, k, d, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tif (k == 1 || n == 1) {\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\tans = 0;\n\tfor (d = 1; d < n; d++)\n\t\tif (mobius[d])\n\t\t\tans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory", "combinatorics", "fft"], "code_uid": "0283c8e6a348a07c26c715c5c5ab6e7f", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n,m,a,b,x1,y1,x2,y2;\n scanf(\"%d%d%d%d\",&n,&m,&a,&b);\n a--;\n b--;\n x1=a/m;\n y1=a%m;\n x2=b/m;\n y2=b%m;\n if (x1==x2)\n puts(\"1\");\n else if (x1==x2-1)\n puts(!y1&&(y2==m-1||b==n-1)?\"1\":\"2\");\n else\n printf(\"%d\\n\",3-!y1-(y2==m-1||b==n-1||y1==y2+1));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "259cf83395521f47a43035cefb2fd06d", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint n, L, consa, posa, consb, posb;\n\tint a[50], b[50], aa[50], bb[50], bbb[100];\n\tscanf(\"%d %d\", &n, &L);\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tscanf(\"%d\", &a[i]);\n\t}\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tscanf(\"%d\", &b[i]);\n\t}\n\taa[0]=(L-a[n-1])+a[0];\n\tbb[0]=(L-b[n-1])+b[0];\n\tfor (int i = 1; i < n; ++i)\n\t{\n\t\taa[i]=a[i]-a[i-1];\n\t\tbb[i]=b[i]-b[i-1];\n\n\t}\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tbbb[i]=bb[i];\n\t\tbbb[n+i]=bb[i];\n\n\t}\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tfor (int j = 0; j < n; ++j)\n\t\t{\n\t\t\tif (aa[j]!= bbb[i+j])\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(j==n-1){\n\t\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t/*for (int i = 0; i < n*2; ++i)\n\t{\n\t\tprintf(\"%d \", bbb[i]);\n\t}\n\tprintf(\"\\n\");\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tprintf(\"%d \", bb[i]);\n\t}\n\tprintf(\"\\n\");\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tprintf(\"%d \", aa[i]);\n\t}\n\tprintf(\"\\n\");*/\n\tprintf(\"NO\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "aa79521682efff8f86a22e05ddfe921d", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n char s[101],c;\n int x,y,z,m=0,n=0,p=0,q=0;\n scanf(\"%s\",s);\n for(x=0;s[x]!='@';x++)\n { q++;\n c=s[x];\n if((c>=65 &&c <=90) || (c>=97 &&c <=122) || (c>=48 &&c <=57) ||c==95)\n continue;\n goto v;\n }\n if(q==0 || q>16)\n goto v;\n for(y=x+1;s[y]!='\\0';y++)\n {\n\n c=s[y];\n if(c=='.')\n {\n if(m>=1 && m<=16)\n {\n n=n+m;\n m=0;\n }\n else\n goto v;\n continue;\n }\n if((c>=65 &&c <=90) || (c>=97 &&c <=122) || (c>=48 &&c <=57) ||c==95)\n m++;\n else if(c=='/')\n break;\n else\n goto v;\n }\n if(s[y]=='\\0' || s[y]=='/')\n n=n+m;\n if(n==0 || n>32 || m==0 || m>16)\n goto v;\n if(s[y]=='\\0')\n {\n printf(\"YES\");\n exit(0);\n }\n for(z=y+1;s[z]!='\\0';z++)\n {\n c=s[z];p++;\n if((c>=65 &&c <=90) || (c>=97 &&c <=122) || (c>=48 &&c <=57) ||c==95)\n continue;\n goto v;\n }\n if(s[z]=='\\0'&& p>0 && p<17)\n {\n printf(\"YES\");\n exit(0);\n }\n v:\n printf(\"NO\");\n return(0);\n }\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "9b6008ab5499bd61a605b9ef4e661919", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* Coached by Dukkha */\n#include \n\nint same(int a, int b, int c, int d) {\n\treturn a == b && b == c && c == d;\n}\n\nint check(int a13, int a14, int a5, int a6, int a17, int a18, int a21, int a22,\n\t\tint a15, int a16, int a7, int a8, int a19, int a20, int a23, int a24) {\n\treturn same(a15, a16, a5, a6) && same(a7, a8, a17, a18) && same(a19, a20, a21, a22) && same(a23, a24, a13, a14)\n\t\t|| same(a13, a14, a7, a8) && same(a5, a6, a19, a20) && same(a17, a18, a23, a24) && same(a21, a22, a15, a16);\n}\n\nint main() {\n\tint a1, a2, a3, a4,\n\ta5, a6, a7, a8,\n\ta9, a10, a11, a12,\n\ta13, a14, a15, a16,\n\ta17, a18, a19, a20,\n\ta21, a22, a23, a24;\n\n\tscanf(\"%d%d%d%d\", &a1, &a2, &a3, &a4);\n\tscanf(\"%d%d%d%d\", &a5, &a6, &a7, &a8);\n\tscanf(\"%d%d%d%d\", &a9, &a10, &a11, &a12);\n\tscanf(\"%d%d%d%d\", &a13, &a14, &a15, &a16);\n\tscanf(\"%d%d%d%d\", &a17, &a18, &a19, &a20);\n\tscanf(\"%d%d%d%d\", &a21, &a22, &a23, &a24);\n\tif (same(a1, a2, a3, a4) && same(a9, a10, a11, a12) && check(\n\t\t\t\ta13, a14, a5, a6, a17, a18, a21, a22,\n\t\t\t\ta15, a16, a7, a8, a19, a20, a23, a24)) {\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif (same(a5, a6, a7, a8) && same(a21, a22, a23, a24) && check(\n\t\t\t\ta9, a10, a19, a17, a4, a3, a14, a16,\n\t\t\t\ta11, a12, a20, a18, a2, a1, a13, a15)) {\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif (same(a13, a14, a15, a16) && same(a17, a18, a19, a20) && check(\n\t\t\t\ta11, a9, a7, a5, a3, a1, a22, a24,\n\t\t\t\ta12, a10, a8, a6, a4, a2, a21, a23)) {\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "c2aefcab34b0b16da821aad3533f1c6e", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define MAXN 23333\n#define MAXELEM 308\n\nint n, t;\nint a[MAXN];\n\n// Calculate the longest non-decreasing sequence\n// Time complexity: O(n log n)\nint *lnds(int *a, int n)\n{\n int *ret = (int *)malloc(n * sizeof(int));\n int a_with_f[MAXN], maxlen = 1;\n ret[0] = 1;\n a_with_f[0] = -1;\n a_with_f[1] = a[0];\n int lo, hi, mid, i;\n for (i = 1; i < n; ++i) {\n if (a[i] >= a_with_f[maxlen]) {\n a_with_f[++maxlen] = a[i];\n } else {\n lo = 0, hi = maxlen;\n while (lo < hi - 1) {\n mid = (lo + hi) / 2;\n if (a[i] >= a_with_f[mid]) lo = mid;\n else hi = mid;\n }\n a_with_f[lo + 1] = a[i];\n }\n ret[i] = maxlen;\n }\n return ret;\n}\n\nint main()\n{\n scanf(\"%d%d\", &n, &t);\n int i;\n for (i = 0; i < n; ++i) scanf(\"%d\", &a[i]);\n if (t <= 233) {\n for (i = n; i < n * t; i += n)\n memcpy(a + i, a, n * sizeof(int));\n int *first_part = lnds(a, n * t);\n printf(\"%d\\n\", first_part[n * t - 1]);\n } else {\n for (i = n; i < n * 233; i += n)\n memcpy(a + i, a, n * sizeof(int));\n int *first_part = lnds(a, n * 233);\n int count[MAXELEM] = { 0 }, maxcount = 0;\n for (i = 0; i < n; ++i) ++count[a[i]];\n for (i = 0; i < MAXELEM; ++i) if (maxcount < count[i]) maxcount = count[i];\n for (i = 0; i < n * 233; i += n)\n if (first_part[i + n] - first_part[i] == maxcount) break;\n i /= n;\n // assert(i == 1)?\n printf(\"%d\\n\", first_part[i * n + n - 1] + (t - i - 1) * maxcount);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "constructive algorithms"], "code_uid": "167fcea7ccc5f331cdc6a6f2ac3198c9", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n static long long i, j, n, l, cost[31], volume[31];\n scanf(\"%lld%lld\", &n, &l);\n scanf(\"%lld\", cost);\n volume[0] = 1;\n for(i = 1; i < n; i++){\n volume[i] = 1 << i;\n scanf(\"%lld\", cost + i);\n cost[i] = cost[i] > (cost[i - 1] << 1) ? (cost[i - 1] << 1) : cost[i];\n for(j = i - 1; j >= 0 && cost[j] > cost[i]; j--){\n cost[j] = cost[i];\n volume[j] = volume[i];\n }\n }\n for(;i <= 30; i++){\n volume[i] = 1 << i;\n cost[i] = cost[i - 1] << 1;\n }\n \n static long long ans = 0, answer[31]; \n for(i = 30; l > 0 && i >= 0; i--){\n if(l >= (1 << i)){\n ans += cost[i];\n l = l - volume[i];\n }\n answer[i] = ans + cost[i];\n }\n for(; i <= 30; i++)\n if(answer[i] != 0)\n ans = ans < answer[i] ? ans : answer[i];\n printf(\"%lld\", ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "30de53a3c54b6e49b8271e2421e351f4", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"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", "tags": ["implementation"], "code_uid": "e83dc1a0f06ecbf461ed86962eef38d9", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "// O(1) solution due to whatshisbucket\n#include \n#define ull unsigned long long\n\nconst unsigned ans[201][70] = {{},{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 = 69; j >= 0; j--) {\n v = (v<<32)|ans[n][j];\n v %= M;\n }\n printf(\"%lld\\n\", v);\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "47f3d4f97ae7b056a08b3682202544c7", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint main() {\r\n\tint num; scanf(\"%d\", &num);\r\n\tprintf(\"%d\\n\", 2 - (num * num));\r\n\t\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "b2f0a77784c651e82115c3a4ed769e80", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint max(int a, int b){\n\treturn a > b ? a : b;\n}\n\nint main(void){ // HAI\n\tint tux; // I HAS A TUX\n\tscanf(\"%d\", &tux); // GIMMEH TUX\n\tint foo = 0; // I HAS A FOO ITS 0\n\tint bar = 0; // I HAS A BAR ITS 0\n\tint baz = 0; // I HAS A BAZ ITS 0\n\tint quz = 1; // I HAS A QUZ ITS 1\n\twhile (tux--){ // IM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0\n\t\tint pur; // I HAS A PUR\n\t\tscanf(\"%d\", &pur); // GIMMEH PUR\n\t\tfoo += pur; // FOO R SUM OF FOO AN PUR\n\t\tbar += 1; // BAR R SUM OF BAR AN 1\n\t\tif (max(foo * quz, bar * baz) == foo * quz){ // BOTH SAEM BIGGR OF PRODUKT OF FOO AN QUZ AN PRODUKT OF BAR BAZ AN PRODUKT OF FOO AN QUZ\n\t\t\tbaz = foo; // BAZ R FOO\n\t\t\tquz = bar; // QUZ R BAR\n\t\t}\n\t}\n\tprintf(\"%lf\\n\", (double)baz / quz); // VISIBLE SMOOSH QUOSHUNT OF BAZ QUZ\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "5a55086f72c3b48e9c85f6c7cb52c1b9", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define W\t1000\n#define B\t1000\n\nint main() {\n\tstatic double dp[W + 1][B + 1];\n\tint w, b, i, j;\n\tdouble ans;\n\n\tscanf(\"%d%d\", &w, &b);\n\tdp[w][b] = 1;\n\tans = 0;\n\tfor (i = w; i >= 0; i--)\n\t\tfor (j = b; j >= 0; j--) {\n\t\t\tdouble x = dp[i][j];\n\n\t\t\tif (x == 0)\n\t\t\t\tcontinue;\n\t\t\tif (i >= 1 && j >= 2)\n\t\t\t\tdp[i - 1][j - 2] += x * j / (i + j) * (j - 1) / (i + j - 1) * i / (i + j - 2);\n\t\t\tif (j >= 3)\n\t\t\t\tdp[i][j - 3] += x * j / (i + j) * (j - 1) / (i + j - 1) * (j - 2) / (i + j - 2);\n\t\t\tif (i + j > 0)\n\t\t\t\tans += x * i / (i + j);\n\t\t}\n\tprintf(\"%.9f\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "5726089e33cfaa12b81aaf3c180ee82b", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint max(int a,int b)\n{\nif(a>=b)return a;\nelse return b;\n}\nint main()\n{\nint ca[52];\nint n;scanf(\"%d\",&n);\nint sumi[52];\nint sum=0;\nint dp[52]={-1};\n\nint i=0;\nfor(i=0;i=0;i--)\n{\ndp[i]=max((ca[i]+(sumi[n-1]-dp[i+1]-sumi[i])),dp[i+1]);\n\n\n}\n\nint ans = dp[0];\nint ans1 = sumi[n-1]-dp[0];\n\nprintf(\"%d %d\\n\",ans1,ans);\n\n\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "304d52724875314b8a5125aa9c1d720b", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//Created by Pratik Mandlecha\n\n#include\n#include\n#include\n#include\nint main()\n{\n\tint n,i,flag=0,a[10]={0},c[4],rmax=0,cmax=0;\n\tscanf(\"%d\",&n);\n\tchar s[12];\n\tscanf(\"%s\",s);\n\tint l=strlen(s);\n\tfor(i=0;i0) flag=1;\n\t/*for(i=1;i<10;i++)\n\t{\n\t\tif(a[i]>0) c[((i-1)/3)]++\n\t}*/\n\tif(((a[1]>0)||(a[4]>0)||(a[7]>0))&&((a[3]>0)||(a[6]>0)||(a[9]>0))) cmax=1;\n\tif(((a[1]>0)||(a[2]>0)||(a[3]>0))&&((a[7]>0)||(a[9]>0))) rmax=1;\n\t\n\t//if((a[8]>0)&&(a[7]==0)&&(a[9]==0)) rmax=0;\n//\tprintf(\"cm=%d rm=%d\",cmax,rmax);\n\tif(flag==1)\n\t{\n\t\tif((a[1]>0)||(a[2]>0)||(a[3]>0)) flag=2;\n\t}\n\tif(flag==0)\n\t{\n\t\tif((rmax==1)&&(cmax==1)) flag=2;\n\t}\n\tif(flag==2) printf(\"YES\");\n\telse printf(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "282b00ce2cf555e6f4bfc314c8945cc0", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nunsigned long long int func(unsigned long long int a,unsigned long long int b)\n{\n\tunsigned long long int f=0;\n\tif(a==0)\n\t\tf= b;\n\telse if(b==0)\n\t\tf=a;\n\telse if(a==1 || b==1)\n\t\tf=1;\n\telse if (a>b)\n\t\tf= func(b,a%b);\n\telse if (ar1)\n\t\tprintf(\"%llu\\n\",r1);\n\telse\n\t\tprintf(\"%llu\\n\",r2);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "915e1d9542e573faca6738d027493273", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"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);\n\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\tlong long ans=0;\n\tn++;\n\tlong long z=binpow(2,m,MOD);\n\tz*=binpow(n,m-1,MOD);\n\tlong long z1=(n-m+MOD)%MOD;\n\tlong long z2=multiply(z,z1,MOD);\n\tans=(z2);\n\tans=ans%MOD;\n\tprintf(\"%lld\\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\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", "tags": ["math", "number theory"], "code_uid": "36a337492c115c5a0ece65e82f06577e", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int n, B;\n int a[100];\n int c[100];\n scanf(\"%d %d\", &n, &B);\n for(int i = 0; i < n; ++i) {\n scanf(\"%d\", &a[i]);\n }\n int even = 0, odd = 0, ans = 0, cnt = 0;\n for(int i = 0; i < n; ++i) {\n if(a[i] & 1) {\n ++odd;\n } else {\n ++even;\n }\n if(even == odd && i + 1 < n && abs(a[i] - a[i + 1]) <= B) {\n c[cnt++] = abs(a[i] - a[i + 1]);\n }\n }\n for(int i = 0; i < cnt; ++i) {\n int k = i;\n for(int j = i + 1; j < cnt; ++j) {\n if(c[k] > c[j]) {\n k = j;\n }\n }\n if(k != i) {\n int temp = c[i];\n c[i] = c[k];\n c[k] = temp;\n }\n }\n for(int i = 0; i < cnt; ++i) {\n if(B >= c[i]) {\n B -= c[i];\n ++ans;\n } else {\n break;\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "dp", "greedy"], "code_uid": "cdf18527a3c151da4a5856fcbdd6617c", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n if (n >= 2 && n <= 6 || n == 8 || n == 12 || n == 30 || n >= 32 && n <= 36 || n == 38)\n {\n printf(\"YES\");\n return 0;\n }\n if (n == 40 || n >= 42 && n <= 46 || n == 48 || n == 50 || n >= 52 && n <= 56 || n == 58)\n {\n printf(\"YES\");\n return 0;\n }\n if (n == 60 || n >= 62 && n <= 66 || n == 68)\n {\n printf(\"YES\");\n return 0;\n }\n if (n == 80 || n >= 82 && n <= 86 || n == 88)\n {\n printf(\"YES\");\n return 0;\n }\n printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "2cae97dadfbd7c0454c7b9385566a222", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n\n int main()\n{\n int x,y;\n scanf(\"%d%d\",&x,&y);\n\n int i=1;\n while(1)\n {\n if(y<2 || ((100*x)+(10*y))<220)\n {\n if(i&1==1)\n printf(\"Hanako\");\n\n else\n printf(\"Ciel\");\n\n return 0;\n }\n\n\n if(i&1==1)\n {\n if(x>=2)\n {\n x-=2;\n y-=2;\n }\n \n else\n {\n \n y-=((220-(100*x)))/10;\n x=0;\n }\n }\n\n else\n {\n if(y>=22)\n y-=22;\n\n else if(y>=12)\n {\n x--;\n y-=12;\n }\n\n\n else\n {\n x-=2;\n y-=2;\n }\n }\n\n i++;\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "3bd561d392c856975880f82c07bc6145", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\n#define rint register int\r\n#define rep(i,a,b) for(rint i=(a);i<(b);i++)\r\n#define repe(i,a,b) for(rint i=(a);i<=(b);i++)\r\n#define repr(i,a,b) for(rint i=(a)-1;(b)<=i;i--)\r\n\r\nvoid writePositive(int num) {\r\n if (num > 0) {\r\n writePositive(num / 10);\r\n putchar(num % 10 + '0');\r\n }\r\n}\r\n\r\nvoid write(int num) {\r\n if (num == 0) putchar('0');\r\n else if (num < 0) {\r\n putchar('-');\r\n writePositive(-num);\r\n } else writePositive(num);\r\n}\r\n\r\nint read() {\r\n rint sign = 1;\r\n rint num = 0;\r\n rint ch;\r\n while(1) {\r\n ch = getchar();\r\n if (ch == '-') {\r\n sign = -sign;\r\n continue;\r\n }\r\n ch = ch-'0';\r\n if (ch < 0 || 10 < ch) break;\r\n num = num*10+ch;\r\n }\r\n return sign*num;\r\n}\r\n\r\n#define MOD 998244353\r\n\r\nint dp[50001][1024];\r\nint pairs[10][10], masks[10][1024];\r\n\r\nint main() {\r\n rint n = read();\r\n rint m = read();\r\n rep(i,0,m) {\r\n rint u = read();\r\n rint v = read();\r\n pairs[u][v] = 1;\r\n pairs[v][u] = 1;\r\n }\r\n \r\n rep(k,0,10) rep(j,0,1024) {\r\n rint mask = 1<\n#include \n\nint main() {\n int d, res = 0;\n while (isdigit(d = getchar())) {\n if ((res += d - '0') > 9)\n res -= 9;\n }\n printf(\"%d\", res);\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "26e10356055ebc361b4e7c127aee83db", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long zeros(long long n, long long p) {\n\treturn n == 0 ? 0 : n / p + zeros(n / p, p);\n}\n\nint main() {\n\tlong long n, b, a, ans, z;\n\tint k;\n\n\tscanf(\"%lld%lld\", &n, &b);\n\tans = n;\n\tfor (a = 2; a <= b / a; a++)\n\t\tif (b % a == 0) {\n\t\t\tk = 0;\n\t\t\twhile (b % a == 0) {\n\t\t\t\tb /= a;\n\t\t\t\tk++;\n\t\t\t}\n\t\t\tif (ans > (z = zeros(n, a) / k))\n\t\t\t\tans = z;\n\t\t}\n\tif (b > 1) {\n\t\ta = b;\n\t\tk = 1;\n\t\tif (ans > (z = zeros(n, a) / k))\n\t\t\tans = z;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "da3129c714825a1ccccd68eac960c68a", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define A 44722 /* ceil(sqrt(2000000000)) */\n#define INF 0x3f3f3f3f\n\nchar *convert(int n) {\n\tstatic char s[11];\n\tint k, i, j;\n\tchar tmp;\n\n\tk = 0;\n\twhile (n > 0) {\n\t\ts[k++] = n % 10 + '0';\n\t\tn /= 10;\n\t}\n\ts[k] = 0;\n\tfor (i = 0, j = k - 1; i < j; i++, j--) {\n\t\ttmp = s[i];\n\t\ts[i] = s[j];\n\t\ts[j] = tmp;\n\t}\n\treturn s;\n}\n\nint main() {\n\tstatic char s[11], t[11];\n\tint n, l1, l2, a, ans;\n\n\tscanf(\"%d\", &n);\n\tstrcpy(s, convert(n));\n\tl1 = strlen(s);\n\tans = INF;\n\tfor (a = 1; a <= A; a++) {\n\t\tint i, j;\n\n\t\tstrcpy(t, convert(a * a));\n\t\tl2 = strlen(t);\n\t\tj = 0;\n\t\tfor (i = 0; i < l1; i++)\n\t\t\tif (j < l2 && s[i] == t[j])\n\t\t\t\tj++;\n\t\tif (j == l2 && ans > l1 - l2)\n\t\t\tans = l1 - l2;\n\t}\n\tprintf(\"%d\\n\", ans == INF ? -1 : ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "132383dcd1e875622c1d74d0039ac814", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint d[50];\nint main()\n{\n int n,i;\n d[1]=1;\n d[3]=4;\n for(i=5;i<50;i+=2)\n d[i]=(i/2)*(i/2)+((i+1)/2)*((i+1)/2);\n scanf(\"%d\",&n);\n if(n==1)\n {\n printf(\"1\");\n return 0;\n }\n else if(n<=5 && n!=3)\n {\n printf(\"3\");\n return 0;\n }\n for(i=5;i<50;i+=2)\n {\n if(n<=d[i])\n {\n printf(\"%d\",i);\n return 0;\n }\n }\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "65ef18290d80633a5ae9393ce6859d77", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int n,m,x;\n\tscanf(\"%lld%lld%lld\",&n,&m,&x);\n\n\t\n\tn=n-((x-1)*2);\n\tm=m-((x-1)*2);\n\tif(n<=0 || m<=0)\n\t\tprintf(\"0\\n\");\n\telse if(n==1 && m==1)\n\t\tprintf(\"1\\n\");\n\telse\n\t{\n\tlong long int c=n+m-2;\n\tif(n==1)\n\t\tc=(m+1)/2;\n\tif(m==1)\n\t\tc=(n+1)/2;\n\tprintf(\"%lld\\n\",c);\n\t}\n\treturn 0;\n\t\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "2901174c063b326fa059d401a5b0c2f3", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\r\nmain() {\r\n\tint n;\r\n\tscanf(\"%d\", &n);\r\n\tif(n < 1200) printf(\"1200\");\r\n\telse if(n < 1400) printf(\"1400\");\r\n\telse if(n < 1600) printf(\"1600\");\r\n\telse if(n < 1900) printf(\"1900\");\r\n\telse if(n < 2100) printf(\"2100\");\r\n\telse if(n < 2300) printf(\"2300\");\r\n\telse if(n < 2400) printf(\"2400\");\r\n\telse if(n < 2600) printf(\"2600\");\r\n\telse printf(\"3000\");\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["math", "divide and conquer", "implementation"], "code_uid": "8a2935ebb2c5fd26ef444b4fb129c1ab", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong long init[14], copy[14];\n\tlong long MAX = 0;\n\t\n\tint i;\n\tfor (i = 0; i < 14; i++) {\n\t\tscanf(\"%lli\", &init[i]);\n\t}\n\tfor (i = 0; i < 14; i++) {\n\t\tif (init[i] != 0) {\n\t\t\tint j;\n\t\t\tlong long score = 0;\n\t\t\t\n\t\t\tfor (j = 0; j < 14; j++) {\n\t\t\t\tcopy[j] = init[j];\n\t\t\t}\n copy[i] = 0;\n\t\t\tfor (j = 0; j < 14; j++) {\n\t\t\t\tcopy[j] += init[i]/14;\n\t\t\t}\n int extr = init[i]%14;\n for (j = 1; j <= extr; j++) {\n copy[(i+j)%14]++;\n }\n\t\t\tfor(j = 0; j < 14; j++){\n\t\t\t\tif (copy[j]%2 == 0) score += copy[j];\n\t\t\t}\n\t\t\tif (MAX < score) MAX = score;\n\t\t}\n\t}\n\tprintf(\"%lli\", MAX);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "94c2688e8213a043b1cb27c5da30b862", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n int D;\n long long n, k, M, ans = 0;\n scanf(\"%lld%lld%lld%d\", &n, &k, &M, &D);\n for(int i = 0; i < D; i++){\n long long cur = n / (k * i + 1);\n if(!cur) break;\n if(cur > M) cur = M;\n long long lmax = cur * (i + 1);\n ans = ans > lmax ? ans : lmax;\n }\n printf(\"%lld\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "5b55c8b77e426588a8ec1d5fbbf71381", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nlong long arr[2000001],brr[2000001],mod=1000000000+7;\nchar str[2000001],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 bs(long long l, long long r, long long n, long long m)\n{\n\tlong long mid=l+((r-l)/2);\n\tif(l>=r)\n\t{\n\t\tif((mid+1)*2+(mid*(mid+1))/2>=(n-m-1))\n\t\t\treturn mid;\n\t\telse\n\t\t\treturn mid+1;\n\t}\n\tif((mid+1)*2 + (mid*(mid+1))/2==(n-m-1))\n\t\treturn mid;\n\tif((mid+1)*2 + (mid*(mid+1))/2>(n-m-1))\n\t\t\treturn bs(l,mid-1,n,m);\n\tif((mid+1)*2 + (mid*(mid+1))/2 < (n-m-1))\n\t\treturn bs(mid+1,r,n,m);\n}\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 %lld\", &n, &m);\n\tif(n==1)\n\t{printf(\"1\\n\");return 0;}\n\tif(m+1>=n)\n\t{printf(\"%lld\\n\",n);return 0;}\n\tprintf(\"%lld\\n\",m+1+bs(0,4000000005,n,m)+1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "58c2ec90d2cb45163dd2e11c7a65bf2e", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tlong long int i=0,j=0,k,l,n,m,a[100]={0},b[100]={0};\n\tscanf(\"%lld %lld\",&n,&m);\n\tif(n==1 && m==1)\n\t\tprintf(\"0\\n\");\n\telse {\n\t\twhile(n) {\n\t\t\ta[i] = n%2;\n\t\t\tn /= 2;\n\t\t\ti++;\n\t\t}\n\t\twhile(m) {\n\t\t\tb[j] = m%2;\n\t\t\tm /= 2;\n\t\t\tj++;\n\t\t}\n\t\ti=65;\n\t\tm=1;\n\t\twhile(a[i]==b[i] && i+1)\n\t\t\ti--;\n\t\tfor(j=0;j\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}", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "3c4e92f96695edd36b855e41e988ca7f", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#define __USE_MINGW_ANSI_STDIO 0\r\n#include \r\n\r\n// MODULAR NCR\r\n// DEPENDENCIES:\r\n\r\n// nCr % mod function\r\n// Using Fermat's Little theorem: a^(p-2) = a^(-1) (mod p)\r\n\r\n#define maxN 200000\r\n#define MOD 1000000007\r\n//#define MOD 998244353\r\n\r\n// Build factorial array\r\nlong long fac[maxN + 1];\r\nvoid __attribute__((constructor))\r\ninitFacs() {\r\n\tfac[0] = 1;\r\n for (int i = 1; i <= maxN; i++) fac[i] = fac[i - 1] * i % MOD; \r\n}\r\n\r\n// Calculate base ^ pow % mod\r\nlong long mPow(long long base, int pow) {\r\n long long res = 1;\r\n base %= MOD;\r\n // constantly decompose base ^ pow = (base ^ 2) ^ (pow / 2)\r\n while (pow > 0) {\r\n // make sure if it is odd, then base ^ pow = base ^ (pow - 1) * base\r\n if (pow % 2 == 1) res = res * base % MOD;\r\n pow /= 2;\r\n base = (base * base) % MOD;\r\n }\r\n return res;\r\n}\r\n\r\n// a ^ (p - 2) = a ^ (-1) (mod p)\r\nlong long mInv(long long n) {\r\n return mPow(n, MOD - 2);\r\n}\r\n\r\n// nCr = n! / r! / (n - r)!\r\n// nCr = n! * inv(r!) * inv((n - r)!)\r\nlong long mnCr(long long n, int r) {\r\n // Base cases\r\n if (n < r) return 0;\r\n if (r == 0) return 1;\r\n\r\n return fac[n] * mInv(fac[r]) % MOD\r\n * mInv(fac[n - r]) % MOD;\r\n}\r\n// END MODULAR NCR\r\n\r\nlong long _T[maxN + 1];\r\nlong long _2n[maxN + 1];\r\n\r\nvoid testcase() {\r\n\tint n, k;\r\n\tscanf(\"%d%d\", &n, &k);\r\n\tlong long T;\r\n\tlong long ans;\r\n\tif (n % 2 == 1) {\r\n\t\t// n odd\r\n\t\tT = 1;\r\n\t\tfor (int i = 0; i <= (n - 1) / 2; ++i) {\r\n\t\t\tT += mnCr(n, i);\r\n\t\t\tT %= MOD;\r\n\t\t}\r\n\t\tans = 1;\r\n\t\tfor (int i = 0; i < k; ++i) {\r\n\t\t\tans *= T;\r\n\t\t\tans %= MOD;\r\n\t\t}\r\n\t} else {\r\n\t\t// n even\r\n\t\tT = 0;\r\n\t\tfor (int i = 0; i < n; i += 2) {\r\n\t\t\tT += mnCr(n, i);\r\n\t\t\tT %= MOD;\r\n\t\t}\r\n\t\t_T[0] = 1;\r\n\t\tlong long base = mPow(2, n);\r\n\t\t_2n[0] = 1;\r\n\t\tfor (int i = 1; i <= k; ++i) {\r\n\t\t\t_T[i] = _T[i - 1] * T % MOD;\r\n\t\t\t_2n[i] = _2n[i - 1] * base % MOD;\r\n\t\t}\r\n\t\tans = _T[k] * _2n[0] % MOD;\r\n\t\tfor (int i = k - 1; i >= 0; --i) {\r\n\t\t\tans += _T[i] * _2n[k - 1 - i] % MOD;\r\n\t\t\tans %= MOD;\r\n\t\t}\r\n\t}\r\n\tprintf(\"%lld\\n\", ans);\r\n return;\r\n}\r\n\r\nint main() {\r\n int t;\r\n scanf(\"%d\", &t);\r\n for (int i = 0; i < t; ++i) testcase();\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "b433a0694e4ab785f174ff19a3056c8e", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define N\t200000\n#define M\t200000\n\nvoid init_rand() {\n\tstruct timeval tv;\n\n\tgettimeofday(&tv, NULL);\n\tsrand(tv.tv_usec ^ tv.tv_sec);\n}\n\nint rand_(int n) {\n\treturn (rand() * 45677LL + rand()) % n;\n}\n\nint kk[N], ll[N], tt[M], ii[M], jj[M];\n\nint check(int n, int m, int t) {\n\tstatic int tt_[N];\n\tint i, j, b, x, t_;\n\n\tfor (i = 0; i < n; i++) {\n\t\tll[i] = kk[i];\n\t\ttt_[i] = -1;\n\t}\n\tfor (j = 0; j < m && (t_ = tt[jj[j]]) <= t; j++)\n\t\ttt_[ii[jj[j]]] = t_;\n\tb = 0;\n\tfor (j = 0; j < m && (t_ = tt[jj[j]]) <= t; j++)\n\t\tif (tt_[i = ii[jj[j]]] == t_) {\n\t\t\tx = ll[i] < t_ - b ? ll[i] : t_ - b;\n\t\t\tb += x, ll[i] -= x;\n\t\t}\n\tfor (i = 0; i < n; i++)\n\t\tb += ll[i] * 2;\n\treturn b <= t;\n}\n\nint compare(const void *a, const void *b) {\n\tint i = *(int *) a;\n\tint j = *(int *) b;\n\n\treturn tt[i] - tt[j];\n}\n\nint main() {\n\tint n, m, i, j, lower, upper, t, tmp;\n\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &kk[i]);\n\tfor (j = 0; j < m; j++) {\n\t\tscanf(\"%d%d\", &tt[j], &ii[j]), ii[j]--;\n\t\tjj[j] = j;\n\t}\n\tinit_rand();\n\tfor (j = m - 1; j >= 0; j--) {\n\t\ti = rand_(j + 1);\n\t\ttmp = jj[i], jj[i] = jj[j], jj[j] = tmp;\n\t}\n\tqsort(jj, m, sizeof *jj, compare);\n\tlower = 0, upper = 200000 * 2;\n\twhile (upper - lower > 1) {\n\t\tt = (lower + upper) / 2;\n\t\tif (check(n, m, t))\n\t\t\tupper = t;\n\t\telse\n\t\t\tlower = t;\n\t}\n\tprintf(\"%d\\n\", upper);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "binary search"], "code_uid": "4fd0d3401ba56fad72c8a478854146f6", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long int A,B,C,D,i;\n\tlong long int res=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\tres+=((i-A-B+2)*(i-A-B+1))/2;\n\t\tif(i+2>=2*B+1)\n\t\t\tres-=((i-2*B+1)*(i-2*B))/2;\n\t\tif(i+2>=A+C+1)\n\t\t\tres-=((i-A-C+1)*(i-A-C))/2;\n\t\tif(i-B-C>=0)\n\t\t\tres+=((i-B-C)*(i-B-C-1))/2;\n\t}\n\tres=(B-A+1)*(C-B+1)*(D-C+1)-res;\n\tprintf(\"%lld\\n\",res);\n}", "lang_cluster": "C", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "d41589490633368ab75b94922973c938", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nvoid gogo(char a[], int j, int s, int r)\n{\n for (int k = 0; k < r; k++)\n for (int i = j; i < s; i++)\n {\n a[i] = a[i + 1];\n }\n}\nint main(void)\n{\n int s, counts = 0;\n char a[105] = {0};\n scanf(\"%d\", &s);\n for (int i = 0; i < s; i++)\n {\n scanf(\" %c\", &a[i]);\n }\n for (int i = 'z'; i >= 'a'; i--)\n {\n for (int j = 0; j < strlen(a); j++)\n {\n int num = 0;\n if (a[j] == i)\n {\n if (a[j - 1] == i + 1)\n {\n for (int k = j - 1; k >= 0; k--)\n {\n if (a[k] == a[j - 1])\n {\n num++;\n }\n else\n break;\n }\n gogo(a, j - num, strlen(a), num);\n counts += num;\n if (num != 0)\n {\n j = 0;\n num = 0;\n }\n }\n if (a[j + 1] == i + 1)\n {\n for (int k = j + 1; k < strlen(a); k++)\n {\n if (a[k] == a[j + 1])\n {\n num++;\n }\n else\n break;\n }\n gogo(a, j + 1, strlen(a), num);\n counts += num;\n if (num != 0)\n {\n j = 0;\n num = 0;\n }\n }\n }\n }\n }\n printf(\"%d\\n\", counts);\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "strings", "constructive algorithms"], "code_uid": "2824e14ea823f394565bae6093040dbc", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"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", "tags": ["math", "dp", "combinatorics"], "code_uid": "8933515232ceb2a4b3ecbe05770ffe49", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "n;\nint main()\n{\n while(~scanf(\"%d\",&n))\n {\n puts((n&1)?\"black\":\"white\\n1 2\");\n }\n return 0;\n}\n\n ", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "games"], "code_uid": "bdd028cc4d9ddcafc72212c3440cf602", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define max(a,b) \\\n ({ __typeof__ (a) _a = (a); \\\n __typeof__ (b) _b = (b); \\\n _a > _b ? _a : _b; })\n \nint main() \n{\n long long int n, m, k, i, j,ans = -1;\n scanf(\"%lld %lld %lld\",&n,&m,&k);\n \n \n if( k<=n + m - 2)\n {\n for( i = 1; i * i <= n; i++)\n {\n if( n % i == 0)\n {\n j = k - ( i - 1) + 1;\n if( j >= 1)\n {\n ans = max( ans, ( n / i) * ( m / j));\n }\n j = k - (( n / i) - 1) + 1;\n if( j >= 1)\n {\n ans = max( ans, ( i) * ( m / j));\n }\n }\n }\n \n for( i = 1; i * i <= m; i++){\n if( m % i == 0)\n {\n j = k - ( i - 1) + 1;\n if( j >= 1)\n {\n ans = max( ans, ( m / i) * ( n / j));\n }\n j = k - (( m / i) - 1) + 1;\n if(j >= 1)\n {\n ans = max(ans, (i) * (n / j));\n }\n }\n }\n }printf(\"%lld\\n\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "b5d390e3767347529eaa9e3653d38979", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"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", "tags": ["dfs and similar", "math", "dp", "data structures", "number theory"], "code_uid": "ab49d843998d8dcaa086e1bb3118221f", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"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", "tags": ["dp"], "code_uid": "17ac068c244f0ef49dd22ae7835932ba", "src_uid": "4022f8f796d4f2b7e43a8360bf34e35f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int i, j, n, m, x1, y1, x2, y2;\n\n scanf(\"%d %d %d %d %d %d\", &n, &m, &x1, &y1, &x2, &y2);\n\n i = abs(x1 - x2);\n j = abs(y1 - y2);\n\n if (i > j) {\n int aux = i;\n i = j;\n j = aux;\n }\n\n if ((i <= 2 && j <= 4) || (i == 3 && j == 3)) {\n puts(\"First\");\n } else {\n puts(\"Second\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "combinatorics"], "code_uid": "8a5a55907807b32a800bc46bbfcc0732", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define MD\t1000000007\n#define L\t50\n#define K\t10000\n\nlong long dp[L + 1][L + 1];\n\nvoid init(int k) {\n\tstatic long long dq[L + 1][L + 1];\n\tstatic int inv[L + 2];\n\tint i1, i2, i, j;\n\n\tfor (i = 1; i <= L + 1; i++) {\n\t\tlong long x = 1;\n\n\t\twhile (x % i != 0)\n\t\t\tx += MD;\n\t\tinv[i] = x / i % MD;\n\t}\n\tfor (i = 0; i <= L; i++)\n\t\tdp[i][i] = dq[i][i] = 1;\n\tfor (i1 = 0; i1 <= L; i1++)\n\t\tfor (i2 = i1 + 1; i2 <= L; i2++)\n\t\t\tdq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;\n\tfor (j = 1; j <= k; j++)\n\t\tfor (i1 = 0; i1 <= L; i1++)\n\t\t\tfor (i2 = i1; i2 <= L; i2++) {\n\t\t\t\tdq[i1][i2] = dp[i1][i2] = dq[i1][i2] * inv[i2 + 1] % MD;\n\t\t\t\tif (i2 > i1)\n\t\t\t\t\tdq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;\n\t\t\t}\n}\n\nint solve(long long a, int cnt) {\n\tint i, sum;\n\tlong long p;\n\n\ta %= MD;\n\tp = 1;\n\tsum = 0;\n\tfor (i = 0; i <= cnt; i++) {\n\t\tsum = (sum + p * dp[i][cnt]) % MD;\n\t\tp = p * a % MD;\n\t}\n\treturn sum;\n}\n\nint main() {\n\tlong long n, ans;\n\tint k, a;\n\n\tscanf(\"%lld%d\", &n, &k);\n\tinit(k);\n\tans = 1;\n\tfor (a = 2; a <= n / a; a++)\n\t\tif (n % a == 0) {\n\t\t\tint cnt = 0;\n\n\t\t\twhile (n % a == 0) {\n\t\t\t\tn /= a;\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t\tans = ans * solve(a, cnt) % MD;\n\t\t}\n\tif (n > 1)\n\t\tans = ans * solve(n, 1) % MD;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "e67ccaf02370f97d323f353629d5f4d4", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nconst int di[] = {-1, -1, 0, 1, 1, 0, -1, 0};\nconst int dj[] = {0, 1, 1, 1, -1, -1, -1, 0};\n\nchar board[8][9];\n\nint dfs(int i, int j, int turn) {\n int k;\n\n if (i == 0 && j == 7)\n return 1;\n\n for (k = 0; k < 8; k++) {\n int ni = i + di[k], nj = j + dj[k];\n\n if (ni >= 0 && ni < 8 && nj >= 0 && nj < 8 && (ni - turn < 0 || board[ni - turn][nj] != 'S' && (ni - turn - 1 < 0 || board[ni - turn - 1][nj] != 'S')))\n if (dfs(ni, nj, turn + 1))\n return 1;\n }\n\n return 0;\n}\n\nint main(void) {\n int i;\n\n for (i = 0; i < 8; i++)\n scanf(\"%s\", board[i]);\n\n puts(dfs(7, 0, 0) ? \"WIN\" : \"LOSE\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar"], "code_uid": "9c0c8cf5d2652567cbda43bec4ca0112", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nuint64_t fib[51];\n\nvoid findperm(uint64_t n, uint64_t k, uint64_t offset){\n assert( k <= fib[n]);\n if (n == 0){\n puts(\"\");\n return;\n }\n if (n == 1){\n printf(\"%llu\\n\", offset);\n return;\n }\n if ( k <= fib[n-1]){\n printf(\"%llu \", offset);\n findperm(n-1, k, offset+1);\n }\n else{\n printf(\"%llu %llu \", offset+1, offset);\n findperm(n-2, k -fib[n-1], offset+2);\n }\n}\n \n \nint main(void){\n uint64_t n, k;\n fib[0] = 1;\n fib[1] = 1;\n for (size_t k = 2; k <= 50; k++)\n fib[k] = fib[k-1]+fib[k-2];\n \n scanf(\"%llu %llu\", &n, &k);\n findperm(n, k, 1);\n return 0;\n} \n ", "lang_cluster": "C", "tags": ["constructive algorithms", "math", "combinatorics", "binary search", "greedy", "implementation"], "code_uid": "63fcd0b40a38baeb2411804aee09b368", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tint n, m, d;\n\tscanf(\"%d%d\", &n, &m);\n\tint dn = 1, dm = 1;\n\tfor(int k = 7 ; k < n ; k *= 7) dn++;\n\tfor(int k = 7 ; k < m ; k *= 7) dm++;\t\n\td = dn + dm;\n\tif(d > 7) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tint r = 0;\n\tfor(int i=0 ; i 1) {\n\t\t\t\t\tr--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", r);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "combinatorics"], "code_uid": "94d7be9f372815214cda9a7451b4e5d9", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"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 }\n else if((A1 == 0 && B1 == 0 && C1 == 0) || (A2 == 0 && B2 == 0 && C2 == 0))\n {\n ans = -1;\n printf(\"%d\\n\",ans);\n }\n else if((A1 == 0 && B1 == 0 && C1 != 0) && (A2 == 0 && B2 == 0 && C2 != 0))\n {\n ans = 0;\n printf(\"%d\\n\",ans);\n }\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", "tags": ["math", "implementation"], "code_uid": "11ec04ddff030f904f4d82d808568b26", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint n, m, a[11], b[11], c[11], d[11], A[1001][11]; \n\nint max (int i, int j) {\n if (i > j)\n return i;\n return j;\n}\n\nint vai (int massa, int posi) {\n int pode = 80000;\n int i, valor;\n \n \n if (posi <= m) {\n if (A[massa][posi] != -1) {\n return A[massa][posi];\n } else {\n if (posi != 0)\n pode = a[posi] / b[posi];\n if (massa / c[posi] < pode)\n pode = massa / c[posi];\n \n valor = 0;\n for (i = 0; i <= pode; i++){\n valor = max (valor, vai (massa - i * c[posi], posi +1) + d[posi] * i);\n }\n A[massa][posi] = valor;\n return valor;\n }\n }\n else\n return 0;\n}\n\nint main () {\n\n int valor, i, j;\n \n for(i = 0; i < 1001; i++)\n for(j = 0; j < 11; j++)\n A[i][j] = -1; \n\n scanf(\"%d%d%d%d\", &n, &m, &c[0], &d[0]);\n a[0] = 0;\n b[0] = 0;\n\n for(i = 1; i <= m; i++) {\n scanf(\"%d\", &a[i]);\n scanf(\"%d\", &b[i]);\n scanf(\"%d\", &c[i]);\n scanf(\"%d\", &d[i]);\n }\n\n valor = vai(n,0);\n\n printf(\"%d\", valor);\n \n scanf(\"%d\",i);\n \n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "28546c7dc98fc27627bc1604e4c88289", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long int GCD(long long int a,long long int b){\n\tif(b==0)return a;\n\tif(a==0)return b;\n\tif(a\n\nint max(int a, int b) { return a > b ? a : b; }\n\nint count(int x1, int x2, int b) {\n\tif (x1 > x2)\n\t\treturn count(x2, x1, b);\n\tif (x1 > 0)\n\t\treturn x2 / b - x1 / b;\n\tif (x2 < 0)\n\t\treturn -x1 / b - -x2 / b;\n\treturn -x1 / b + x2 / b + 1;\n}\n\nint main() {\n\tint a, b, x1, y1, x2, y2, x, y;\n\n\tscanf(\"%d%d%d%d%d%d\", &a, &b, &x1, &y1, &x2, &y2), a *= 2, b *= 2;\n\tx = x1 - y1, y = x1 + y1; x1 = x; y1 = y;\n\tx = x2 - y2, y = x2 + y2; x2 = x; y2 = y;\n\tprintf(\"%d\\n\", max(count(x1, x2, b), count(y1, y2, a)));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "20aeea9f007cd35ec0c2b5f2e490b40a", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \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 (inside(x1, y1, x3, y3, x4, y4) && inside(x2, y1, x3, y3, x4, y4) && inside(x1, y2, x3, y3, x4, y4) && inside(x2, y2, x3, y3, x4, y4)) {\n printf(\"NO\");\n return 0;\n }\n\n if (inside(x1, y1, x5, y5, x6, y6) && inside(x2, y1, x5, y5, x6, y6) && inside(x1, y2, x5, y5, x6, y6) && inside(x2, y2, x5, y5, x6, y6)) {\n printf(\"NO\");\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", "tags": ["math", "geometry"], "code_uid": "0426ecea726d46f4e96e3c438fcd66bd", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint arr[101],no[101],l[100];\nint main()\n{\n\tint n,m,source,desti,temp,flag,k,i;\n\tscanf(\"%d %d\",&n,&m);\n\tfor(i=0;i\n#include\n#include\n#include\n#define INF 200000000\n__int64 num[10],dp[500000][105];\n__int64 jie(__int64 p)\n{\n __int64 re,i;\n for(i=1,re=1;i<=p;i++)\n re*=i;\n return re;\n}\nint main()\n{\n __int64 n[20],m,i,j,k,l,wei;\n char s[20];\n while(scanf(\"%s%I64d\",&s,&m)!=EOF)\n {\n wei=strlen(s);\n memset(num,0,sizeof(num));\n for(i=0;i\n#include \n\nint main(int argc, char *argv[])\n{\n int a,x,y;\n scanf(\"%d%d%d\", &a,&x,&y);\n int t = y/a;\n //printf(\"t' = %d\\n\", t);\n if(y<0){\n printf(\"-1\\n\");\n \t//system(\"PAUSE\"); \n return 0;\n }\n if(y%a!=0){\n \tt++;\n }else{\n printf(\"-1\\n\");\n //system(\"PAUSE\"); \n return 0;\n }\n //printf(\"t = %d\\n\", t);\n if(t==1){\n if(abs(x)<(float)a/2){\n printf(\"1\\n\");\n //system(\"PAUSE\"); \n return 0;\n }else{\n printf(\"-1\\n\");\n //system(\"PAUSE\"); \n return 0;\n }\n }\n if(t%2==0){\n //printf(\"12\\n\");\n if(abs(x)<(float)a/2){\n printf(\"%d\\n\", (t/2)-1+t);\n //system(\"PAUSE\"); \n \t\t\t\treturn 0;\n }else{\n printf(\"-1\\n\");\n //system(\"PAUSE\"); \n return 0;\n }\n }else{\n //printf(\"13\\n\");\n if(abs(x)0){\n printf(\"%d\\n\", ((t/2)-1)+t+1);\n //system(\"PAUSE\"); \n return 0;\n }else{\n printf(\"%d\\n\", ((t/2)-1)+t);\n //system(\"PAUSE\"); \n return 0;\n }\n }else{\n printf(\"-1\\n\");\n } \n }\n //system(\"PAUSE\"); \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "1ae32b2fe36560f6e470e8e09a989613", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int dd, mm, yy, bd, bm, by, f = 0;\n int d[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n\n scanf(\"%d.%d.%d\", &dd, &mm, &yy);\n scanf(\"%d.%d.%d\", &bd, &bm, &by);\n\n if (yy > by + 18 || (yy == by + 18 && (mm > bm || (mm == bm && dd >= bd)))) {\n\t f = 1;\n }\n\n if (by <= 12 && (d[by - 1] >= bd || (by == 2 && bm % 4 == 0 && bd == 29))) {\n\t if (yy > bm + 18 || (yy == bm + 18 && (mm > by || (mm == by && dd >= bd)))) {\n\t f = 1;\n\t }\n }\n\n if (bd <= 12 && (d[bd - 1] >= bm || (bd == 2 && by % 4 == 0 && bm == 29))) {\n\t if (yy > by + 18 || (yy == by + 18 && (mm > bd || (mm == bd && dd >= bm)))) {\n\t f = 1;\n\t }\n }\n\n if (by <= 12 && (d[by - 1] >= bm || (by == 2 && bd % 4 == 0 && bm == 29))) {\n\t if (yy > bd + 18 || (yy == bd + 18 && (mm > by || (mm == by && dd >= bm)))) {\n\t f = 1;\n\t }\n }\n\n if (d[bm - 1] >= by || (bm == 2 && bd % 4 == 0 && by == 29)) {\n\t if (yy > bd + 18 || (yy == bd + 18 && (mm > bm || (mm == bm && dd >= by)))) {\n\t f = 1;\n\t }\n }\n\n if (bd <= 12 && (d[bd - 1] >= by || (bd == 2 && bm % 4 == 0 && by == 29))) {\n\t if (yy > bm + 18 || (yy == bm + 18 && (mm > bd || (mm == bd && dd >= by)))) {\n\t f = 1;\n\t }\n }\n\n if (f == 1) {\n\t puts(\"YES\");\n } else {\n\t puts(\"NO\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a8ffec6cd171ca8fdd7dccb631fde815", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong int pow2[220];\nconst long int mod = 1000000007L;\nchar s[110];\n\nint main() {\n\tlong int ans;\n\tint i, n;\n\tpow2[0] = 1L;\n\tfor(i = 1; i <= 220; i++) pow2[i] = (pow2[i-1]<<1)%mod;\n\tscanf(\"%s\", s);\n\tn = strlen(s);\n\tif(s[n-1] == '0') ans = 0;\n\telse ans = 1;\n\tfor(i = n-2; i >= 0; i--) {\n\t\tans = (ans<<1)%mod;\n\t\t//printf(\"... %ld\\n\", ans);\n\t\tif(s[i] == '1') ans = (ans+pow2[(n-i-1)*2])%mod;\n\t}\n\tprintf(\"%ld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "44088d5369f5119530dac5c80c87127b", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"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(a==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", "tags": ["dp", "games"], "code_uid": "de332bba0964611f56daaedbdf29e441", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint x_digit[10], d_digit[10], count;\n\nvoid find_digits(int *digit, int num) {\n\tint i;\n\tfor (i = 0; i < 10; i++)\n\t\tdigit[i] = 0;\n\twhile (num > 0) {\n\t\tdigit[num%10] = 1;\n\t\tnum /= 10;\n\t}\n}\n\nvoid check(int d) {\n\tint i;\n\tfind_digits(d_digit, d);\n\tfor (i = 0; i < 10; i++)\n\t\tif (x_digit[i] && d_digit[i]) {\n\t\t\tcount++;\n\t\t\tbreak;\n\t\t}\n}\n\nint main() {\n\tint x, d;\n\tscanf(\" %d\", &x);\n\tfind_digits(x_digit, x);\n\tfor (d = 1; d*d <= x; d++) {\n\t\tif (x%d > 0)\n\t\t\tcontinue;\n\t\tcheck(d);\n\t\tif (x/d != d)\n\t\t\tcheck(x/d);\n\t}\n\tprintf(\"%d\\n\", count);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5fed3f30c6d760f516615715a1e7a3d1", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://csacademy.com/contest/archive/task/superstition/ (rainboy) */\n#include \n#include \n\n#define N\t8\n#define L\t5\n#define N_\t(1 + N * L)\n#define N1\t(N_ * 2)\n#define A\t26\n#define MD\t998244353\n\nint tt[1 + N_][A]; char word[1 + N_];\n\nvoid dfs(int coef[][L + 1], int s1, int s2, int l) {\n\tint a;\n\n\tif (s1 == 0 || s2 == 0)\n\t\treturn;\n\tif (l > 0) {\n\t\tif (word[s1])\n\t\t\tcoef[s2 - 1 << 1 | 0][l]++;\n\t\tif (word[s2])\n\t\t\tcoef[s1 - 1 << 1 | 1][l]++;\n\t\tif (word[s1] && word[s2])\n\t\t\tcoef[0][l]++;\n\t}\n\tfor (a = 0; a < A; a++)\n\t\tdfs(coef, tt[s1][a], tt[s2][a], l + 1);\n}\n\nint coef[N1][N1][L + 1];\n\nvoid apply(int aa[][N1][L], int n) {\n\tstatic int bb[N1][N1];\n\tint i, j, k, l;\n\n\tfor (i = 0; i < n; i++)\n\t\tmemset(bb[i], 0, n * sizeof *bb[i]);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++)\n\t\t\tfor (k = 0; k < n; k++)\n\t\t\t\tfor (l = 1; l <= L; l++)\n\t\t\t\t\tbb[i][k] = (bb[i][k] + (long long) aa[i][j][l - 1] * coef[j][k][l]) % MD;\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++)\n\t\t\tfor (l = L - 1; l >= 0; l--)\n\t\t\t\taa[i][j][l] = l == 0 ? bb[i][j] : aa[i][j][l - 1];\n}\n\nvoid mult(int aa[][N1][L], int bb[][N1][L], int cc[][N1][L], int n) {\n\tstatic int aa_[N1][N1][L], bb_[N1][N1][L + L];\n\tint i, j, k, l, l1, l2;\n\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++)\n\t\t\tmemcpy(aa_[i][j], aa[i][j], L * sizeof *aa[i][j]);\n\tfor (l = 0; l < L; l++)\n\t\tfor (i = 0; i < n; i++)\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t\tfor (k = 0; k < n; k++)\n\t\t\t\t\tfor (l1 = 1; l + l1 < L; l1++)\n\t\t\t\t\t\taa_[i][k][l] = (aa_[i][k][l] - (long long) aa_[i][j][l + l1] * coef[j][k][l1]) % MD;\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++) {\n\t\t\tmemset(bb_[i][j], 0, L * sizeof *bb_[i][j]);\n\t\t\tmemcpy(bb_[i][j] + L, bb[i][j], L * sizeof *bb[i][j]);\n\t\t}\n\tfor (l = L - 1; l >= 0; l--)\n\t\tfor (i = 0; i < n; i++)\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t\tfor (k = 0; k < n; k++)\n\t\t\t\t\tfor (l1 = 1; l1 <= L; l1++)\n\t\t\t\t\t\tbb_[i][k][l] = (bb_[i][k][l] + (long long) coef[i][j][l1] * bb_[j][k][l + l1]) % MD;\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++)\n\t\t\tmemset(cc[i][j], 0, L * sizeof *cc[i][j]);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++)\n\t\t\tfor (k = 0; k < n; k++)\n\t\t\t\tfor (l1 = 0; l1 < L; l1++)\n\t\t\t\t\tfor (l2 = L - l1; l1 + l2 - L < L; l2++)\n\t\t\t\t\t\tcc[i][k][l1 + l2 - L] = (cc[i][k][l1 + l2 - L] + (long long) aa_[i][j][l1] * bb_[j][k][l2]) % MD;\n}\n\nvoid power(int pp[][N1][L], int tt[][N1][L], int n, int k) {\n\tint i, j, l;\n\n\tif (k == 0) {\n\t\tfor (i = 0; i < n; i++)\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t\tfor (l = 0; l < L; l++)\n\t\t\t\t\tpp[i][j][l] = i == j && l == 0;\n\t\treturn;\n\t}\n\tpower(tt, pp, n, k / 2);\n\tmult(tt, tt, pp, n);\n\tif (k & 1)\n\t\tapply(pp, n);\n}\n\nint main() {\n\tstatic int pp[N1][N1][L], tt_[N1][N1][L];\n\tint n, n_, k, i, s;\n\n\tscanf(\"%d%d\", &n, &k);\n\tn_ = 1;\n\tfor (i = 0; i < n; i++) {\n\t\tstatic char cc[L + 1];\n\t\tint l, h;\n\n\t\tscanf(\"%s\", cc), l = strlen(cc);\n\t\tfor (h = 0, s = 1; h < l; h++) {\n\t\t\tint a = cc[h] - 'a';\n\n\t\t\tif (!tt[s][a])\n\t\t\t\ttt[s][a] = ++n_;\n\t\t\ts = tt[s][a];\n\t\t}\n\t\tword[s] = 1;\n\t}\n\tfor (s = 0; s < n_; s++) {\n\t\tdfs(coef[s << 1 | 0], 1, s + 1, 0);\n\t\tif (s != 0)\n\t\t\tdfs(coef[s << 1 | 1], s + 1, 1, 0);\n\t}\n\tpower(pp, tt_, n_ * 2, k);\n\tif (pp[0][0][0] < 0)\n\t\tpp[0][0][0] += MD;\n\tprintf(\"%d\\n\", pp[0][0][0]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "data structures", "matrices", "strings", "dp"], "code_uid": "4d07abf30d56c9b3b687090fd371b6ca", "src_uid": "711d15e11016d0164fb2b0c3756e4857", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main()\n{\n int n,m,i,j,s=0;\n scanf(\"%d%d\",&n,&m);\n if(m1)\n {\n s+=4;\n }\n printf(\"%d\",s);\n }\n else\n {\n s=n*m/2+((m*n)%2);\n printf(\"%d\",s);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "constructive algorithms", "implementation"], "code_uid": "4016f3dac53447d953ebe9258747bb0c", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint gcd(int a,int b){\n\tint t;\n\twhile(b>0){\n\t\tt=a%b;\n\t\ta=b;\n\t\tb=t;\n\t}\n\treturn a;\n}\nint main()\n{\n\tlong long a,b;\n\tscanf(\"%I64d %I64d\",&a,&b);\n\tlong long t;\n\tif(a>b){\n\t\tt=a;\n\t\ta=b;\n\t\tb=t;\n\t}\n\tt=b-a;\n\tlong long k=0;\n\tlong long k1;\n\tlong long min=a/gcd(a,b)*b;\n\tfor(long long i=1;i*i<=t;i++){\n\t\tk1=i-b%i;\n\t\tif((a+k1)*(b+k1)\nint main()\n{\n long long a , b , w , x , c , times = 0 , m[10000] = {0} ;\n scanf(\"%lld %lld %lld %lld %lld\", &a, &b, &w, &x, &c);\n while( b > x)\n {\n if(c <= a)break;\n b -= x ;\n c--;\n times++;\n }\n if(c <= a)\n {\n printf(\"%lld\\n\", times);\n return 0;\n }\n long long st = 0 , aj = 0 , l ;\n l = b ;\n while(m[l]==0)\n {\n m[l] = 1 ;\n st++;\n if(l >= x) l -= x ;\n else\n {\n aj++;\n l = w -( x - l);\n }\n }\n long long ns = 0 ;\n if( c - a - aj > 0)\n ns = (c - a - aj) / (st - aj);\n times += ns*st;\n c = c - st*ns;\n a = a - ns*aj;\n while(c > a)\n {\n if(b >= x)\n {\n b -= x;\n c--;\n times++;\n }\n else\n {\n b = w - (x - b);\n a--;c--;\n times++;\n }\n }\n printf(\"%lld\\n\", times);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "579a092a0421931530b2d957efc31eac", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"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 n, m;\ndouble binomial[1010][1010];\n\nvoid Pregenerate(){\n int i, j;\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] + binomial[i - 1][j - 1]);\n }\n }\n}\n\nint main(){\n Pregenerate();\n int i, j, k, l;\n\n while (scanf(\"%d %d\", &n, &m) != EOF){\n int r = (n * m);\n\n double res = 0.0;\n for (i = 1; i <= n; i++){\n double x = (1.0 * i) / (1.0 * n);\n double p = (x * x);\n\n k = m, l = r;\n for (j = 1; j <= i; j++, k--, l--){\n double y = (1.0 * k) / (1.0 * l);\n p *= y;\n }\n\n p *= binomial[n][i];\n\n k = r - m;\n for (j = i + 1; j <= n; j++, k--, l--){\n double y = (1.0 * k) / (1.0 * l);\n p *= y;\n }\n res += p;\n }\n res = res * n;\n\n res += 1e-12;\n printf(\"%0.9lf\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities", "math", "combinatorics"], "code_uid": "118d3ee0bd4136c2a64c011674e70593", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint check(int A[],int n,int P[]){\n\tint i,j;\n\tfor(i=0;i<12;i++){\n\t\tint flag=1;\n\t\tfor(j=0;j=12){\n\t\t\t\tif(trig==0){\n\t\t\t\t\ttrig=1;\n\t\t\t\t}\n\t\t\t\telse trig=0;\n\t\t\t}\n\t\t}\n\t\tif(flag){\n//\t\t\tprintf(\"%d %d 3 Leap\\n\",i,j);\n\t\t\treturn 1;\n\t\t}\n\t}\n//\tprintf(\"No satisfied\\n\");\n\treturn 0;\n}\n\nint main(){\n\tint i,n,A[30],P[12];\n\tP[0]=31;\n\tP[1]=28;\n\tP[2]=31;\n\tP[3]=30;\n\tP[4]=31;\n\tP[5]=30;\n\tP[6]=31;\n\tP[7]=31;\n\tP[8]=30;\n\tP[9]=31;\n\tP[10]=30;\n\tP[11]=31;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i\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]\nint main()\n{\n long long int i,n,k;\n scanf(\"%lld %lld\",&n,&k);\n for(i=2;i<=k;i++)\n {\n if((n%i)==(i-1))\n continue;\n else {printf(\"No\");return 0;}\n }\n\n printf(\"Yes\");\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "1a37727cf8dc62039d9d618f38c94d91", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nlong long m=1000000007;\n\nlong long big(long long a,long long n)\n{\n long long x=1;\n while(n)\n {\n if(n%2) x = (x*a)%m;\n a = (a*a)%m;\n n = n/2;\n }\n return x%m;\n}\n\nlong long inv(long long a,long long n)\n{\n long long p,q,r,s;\n if(a==1) return (n%m);\n else\n {\n p = big(a,n)%m;\n q = p-1;\n r = big(a-1,m-2)%m;\n s = (q*r)%m;\n return s;\n }\n}\n\nint main()\n{\n long long a,b,n,x,p,q,r;\n scanf(\"%lld %lld %lld %lld\",&a,&b,&n,&x);\n p = (big(a,n)*(x%m))%m;\n q = (inv(a,n)*b)%m;\n r = (p+q)%m;\n printf(\"%lld\\n\",r);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "d90c1a3e5813e0adc7247b9c9339b676", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint maxdig(int n)\n{\nint a,max=0;\nwhile(n>0)\n{\na=n%10;\nif(max0)\n{\no++;\nn=n-maxdig(n);\n}\nprintf(\"%d\",o);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "964841d1d54c14547cdfcd2c29b1c25f", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n#include \r\n\r\n#define N\t15\r\n#define K\t200000\r\n#define L\t19\t/* L = ceil(log2(K * 2 + 1)) */\r\n#define N_\t(1 << L)\r\n#define MD\t998244353\r\n\r\nlong long power(long long a, int k) {\r\n\tlong long p = 1;\r\n\r\n\twhile (k) {\r\n\t\tif (k & 1)\r\n\t\t\tp = p * a % MD;\r\n\t\ta = a * a % MD;\r\n\t\tk >>= 1;\r\n\t}\r\n\treturn p;\r\n}\r\n\r\nint vv_[L + 1], *wwu[L + 1], *wwv[L + 1];\r\n\r\nvoid init() {\r\n\tint i, l, u, v;\r\n\r\n\tu = power(3, MD - 1 >> L), v = power(u, MD - 2);\r\n\tfor (l = L; l > 0; l--) {\r\n\t\tint n = 1 << l, m = n >> 1;\r\n\r\n\t\tvv_[l] = power(1 << l, MD - 2);\r\n\t\twwu[l] = (int *) malloc(m * sizeof *wwu[l]);\r\n\t\twwv[l] = (int *) malloc(m * sizeof *wwv[l]);\r\n\t\twwu[l][0] = wwv[l][0] = 1;\r\n\t\tfor (i = 1; i < m; i++) {\r\n\t\t\twwu[l][i] = (long long) wwu[l][i - 1] * u % MD;\r\n\t\t\twwv[l][i] = (long long) wwv[l][i - 1] * v % MD;\r\n\t\t}\r\n\t\tu = (long long) u * u % MD;\r\n\t\tv = (long long) v * v % MD;\r\n\t}\r\n\tvv_[0] = 1;\r\n}\r\n\r\nvoid ntt_(int *aa, int l, int inverse) {\r\n\tif (l) {\r\n\t\tint n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;\r\n\r\n\t\tntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);\r\n\t\tfor (i = 0; (j = i + m) < n; i++) {\r\n\t\t\tint a = aa[i], b = (long long) aa[j] * ww[i] % MD;\r\n\r\n\t\t\tif ((aa[i] = a + b) >= MD)\r\n\t\t\t\taa[i] -= MD;\r\n\t\t\tif ((aa[j] = a - b) < 0)\r\n\t\t\t\taa[j] += MD;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ntt(int *aa, int l, int inverse) {\r\n\tint n = 1 << l, i, j;\r\n\r\n\tfor (i = 0, j = 1; j < n; j++) {\r\n\t\tint b = n >> 1, tmp;\r\n\r\n\t\twhile ((i ^= b) < b)\r\n\t\t\tb >>= 1;\r\n\t\tif (i < j)\r\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\r\n\t}\r\n\tntt_(aa, l, inverse);\r\n}\r\n\r\nvoid multiply(int *aa, int *bb, int *cc, int n, int m) {\r\n\tstatic int aa_[N_], bb_[N_];\r\n\tint n_, l, i;\r\n\r\n\tl = 0;\r\n\twhile (1 << l < n + m - 1)\r\n\t\tl++;\r\n\tn_ = 1 << l;\r\n\tfor (i = 0; i < n_; i++) {\r\n\t\taa_[i] = i < n ? aa[i] : 0;\r\n\t\tbb_[i] = i < m ? bb[i] : 0;\r\n\t}\r\n\tntt(aa_, l, 0);\r\n\tntt(bb_, l, 0);\r\n\tfor (i = 0; i < n_; i++)\r\n\t\taa_[i] = (long long) aa_[i] * bb_[i] % MD;\r\n\tntt(aa_, l, 1);\r\n\tfor (i = 0; i < n + m - 1; i++)\r\n\t\tcc[i] = (long long) aa_[i] * vv_[l] % MD;\r\n}\r\n\r\nint main() {\r\n\tstatic int dp[N][K + 1], dq[K * 2 + 1];\r\n\tint n, c_, k, i, c, x;\r\n\r\n\tinit();\r\n\tscanf(\"%d%d%d\", &n, &k, &c_);\r\n\tfor (c = 0; c <= k; c++)\r\n\t\tdp[0][c] = 1;\r\n\tfor (i = 0; i < n; i++) {\r\n\t\tmultiply(dp[i], dp[i], dq, k + 1, k + 1);\r\n\t\tif (i + 1 == n)\r\n\t\t\tprintf(\"%d\\n\", dq[c_]);\r\n\t\telse {\r\n\t\t\tx = 0;\r\n\t\t\tfor (c = k + 1; c <= k * 2; c++)\r\n\t\t\t\tx = (x + dq[c]) % MD;\r\n\t\t\tfor (c = k; c >= 0; c--) {\r\n\t\t\t\tx = (x + dq[c]) % MD;\r\n\t\t\t\tdp[i + 1][c] = (x + (long long) dq[c] * (k - c)) % MD;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["brute force", "flows", "math", "dp", "fft", "bitmasks", "graphs", "meet-in-the-middle", "trees"], "code_uid": "59359f74e0fb59cb042903611fd702a1", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, m, k, i;\n\n scanf(\"%d %d %d\", &n, &m, &k);\n\n if (n % 2 == 0) {\n\t puts(\"Marsel\");\n } else {\n\t for (i = 2; i * i <= m; i++) {\n\t if (m % i == 0) {\n\t\t if (m / i >= k) break;\n\t }\n\t }\n\n\t if (i * i <= m || (k == 1 && m > 1)) {\n\t puts(\"Timur\");\n\t } else {\n\t puts(\"Marsel\");\n\t }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "number theory", "games"], "code_uid": "4c53e93c788e2bdd9b8e3222ce77295d", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint r() { int x; scanf(\"%d\",&x); return x; }\n\nint main()\n{\n int y,z; long long u=r(),v=r(),w=r(),x=r(),t=r(),a=t-u,b=v-t,p=1,q=0,g=w+x,f=u*w+v*x-t*g;\n \n for(;w>=0;--w,--g,f+=a)\n for (;x>=0&&f>=0;--x,--g,f-=b)\n if (q*f\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\n#define POS(i, j) ((i) * (n + 1) + (j))\n\nvoid run (void) {\n i32 n = read_int();\n char *s = (char *) calloc (n + 1, sizeof (char));\n scanf (\"%s\", s);\n i32 *dp = (i32 *) calloc ((n + 1) * (n + 1), sizeof (i32));\n for (i32 len = 1; len <= n; ++len) {\n for (i32 l = 0; l + len <= n; ++l) {\n i32 r = l + len;\n i32 min = 1 + dp[POS(l + 1, r)];\n for (i32 i = l + 1; i < r; ++i) {\n if (s[l] != s[i]) continue;\n i32 d = dp[POS(l + 1, i)] + dp[POS(i, r)];\n min = min > d ? d : min;\n }\n dp[POS(l, r)] = min;\n }\n }\n print_int (dp[POS(0, n)]);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "b9cf610386e75d82c174c1403af35afa", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"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 }\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 if(v > 0 && inFlow[v] != outFlow[v])\n return;\n if(inFlow[n - 1] > minFlow)\n return;\n rec(v + 1, v + 2);\n } else {\n int i;\n for(i = low[v][to]; 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", "tags": ["brute force"], "code_uid": "36e5a7ca573089b6daa1547947c62920", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint minfac(int y){\n\tint i;\n\tfor(i=2;i*i<=y;i++){\n\t\tif(!(y%i)) return i;\n\t}\n\treturn y;\n}\nint main(){\n\tint p,y,i,j=0;\n\tscanf(\"%d%d\",&p,&y);\n\twhile(j<=300){\n\t\ti=minfac(y);\n\t\tif(i>p){\n\t\t\tprintf(\"%d\\n\",y);\n\t\t\treturn 0;\n\t\t}\n\t\tj++;\n\t\ty--;\n\t}\n\tprintf(\"-1\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "753aaabef80a4091e6723afd73c14416", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ndouble prob[2005][2005];\nint main()\n{\n int n,t,i,j;\n double p,cp;\n double tmp;\n scanf(\"%d\",&n);\n scanf(\"%lf\",&p);\n scanf(\"%d\",&t);\n cp = 1.0-p;\n prob[0][0] = 1.0;\n for(i=1;i<=t;i++)\n prob[0][i] = 0.0;\n for(i=1;i<=t;i++)\n prob[i][0] = prob[i-1][0]*(cp);\n for(i=1;i<=t;i++)\n {\n for(j=1;j<=t;j++)\n {\n if(j>i||j>n)\n tmp = 0.0;\n else if(j+1<=n)\n tmp = cp*prob[i-1][j] + prob[i-1][j-1]*p;\n else \n tmp = prob[i-1][j] + prob[i-1][j-1]*p;\n prob[i][j] = tmp;\n }\n }\n double res = 0;\n for(i=0;i<=t;i++)\n {\n res+=i*prob[t][i];\n }\n printf(\"%lf\\n\",res);\n return 0;\n}", "lang_cluster": "C", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "5250bf56aea88a78d61f84822e1d022f", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint tran(int a, int b){\n int t;\n int res = 0;\n int pow = 1;\n do {\n t = a/b;\n res += pow *(a-(a/b)*b);\n a = t;\n pow*=10;\n } while(t>=b);\n res +=pow*t;\n return res;\n}\n\nint main(){\n int b,i,j;\n scanf(\"%d\",&b);\n for(i = 1; i\n#include \n\n#define INF\t((long long) 1e18)\n\nint main() {\n\tstatic char s[128];\n\tstatic long long dp[128][128];\n\tint n, h, i, j, l;\n\tlong long min;\n\n\tscanf(\"%d\", &n);\n\tscanf(\"%s\", s);\n\tl = strlen(s);\n\tfor (i = 0; i <= l; i++)\n\t\tfor (j = 0; j <= l; j++)\n\t\t\tdp[i][j] = INF;\n\tdp[0][0] = 0;\n\tfor (i = 0; i < l; i++)\n\t\tfor (j = 0; j < l; j++)\n\t\t\tif (dp[i][j] < INF) {\n\t\t\t\tlong long x = dp[i][j];\n\n\t\t\t\tif (s[i] == '0') {\n\t\t\t\t\tif ((double) x * n <= INF)\n\t\t\t\t\t\tif (dp[i + 1][j + 1] > x * n)\n\t\t\t\t\t\t\tdp[i + 1][j + 1] = x * n;\n\t\t\t\t} else {\n\t\t\t\t\tlong long y = 0;\n\n\t\t\t\t\tfor (h = i; h < l; h++) {\n\t\t\t\t\t\ty = y * 10 + (s[h] - '0');\n\t\t\t\t\t\tif (y >= n)\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tif ((double) x * n + y <= INF)\n\t\t\t\t\t\t\tif (dp[h + 1][j + 1] > x * n + y)\n\t\t\t\t\t\t\t\tdp[h + 1][j + 1] = x * n + y;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\tmin = INF;\n\tfor (j = 0; j <= l; j++)\n\t\tif (min > dp[l][j])\n\t\t\tmin = dp[l][j];\n\tprintf(\"%lld\\n\", min);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "46716d0be95d28667c1ab8811fbe84f3", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\tlong long int i,n;\n\tscanf(\"%lld\",&n);\n\tlong long int temp=n*2;\n\ttemp/=10;\n\tlong long int m=0;\n\tlong long int m10=1;\n\twhile(temp>0){\n\t\ttemp/=10;\n\t\tm++;\n\t\tm10*=10;\n\t}\n\tif(m==0){\n\t\tprintf(\"%lld\\n\",(n*(n-1))/2);\n\t\treturn 0;\n\t}\n\tlong long int ans=0,val=0;\n\tfor(i=1;i<=9;i++){\n\t\tif(i*m10>2*n)break;\n\t\tif(n>=i*m10-1){\n\t\t\tans+=((i*m10/2)-1);\n//\t\t\tval=((i*m10/2)-1);\n//\t\t\tprintf(\"%d=%d\\n\",i,val);\n\t\t}\n\t\telse{\n\t\t\tans+=(n+1-(i*m10/2));\n//\t\t\tval=(n+1-(i*m10/2));\n//\t\t\tprintf(\"%d=%d\\n\",i,val);\n\t\t}\n\t}\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "9668e35b21086992982928ba69b20b9f", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\n\r\nint ysgs(int n) {\r\n if(n==1) return 1;\r\n else {\r\n int cnt=0,i;\r\n for(i=1;i*i100000){\r\n s=345451881;\r\n m=1;\r\n }\r\n if(n>200000) {\r\n s=364228341;\r\n m=2;\r\n }\r\n if(n>300000) {\r\n s=305860330;\r\n m=3;\r\n }\r\n if(n>400000) {\r\n s=198031628;\r\n m=4;\r\n }\r\n if(n>500000) {\r\n s=292516569;\r\n m=5;\r\n }\r\n if(n>600000) {\r\n s=377314150;\r\n m=6;\r\n }\r\n if(n>700000) {\r\n s=55409794;\r\n m=7;\r\n }\r\n if(n>800000) {\r\n s=731775727;\r\n m=8;\r\n }\r\n if(n>900000) {\r\n s=951702590;\r\n m=9;\r\n }\r\n \r\n \r\n \r\n for( int j=m*100000+1;j\n#include\n#define INF (unsigned long long)1000000000000000001\nint q, n, flen, slen, e;\nunsigned long long k, f[100001];\nchar s1[200] = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\nchar s2[200] = \"What are you doing while sending xx? Are you busy? Will you send xx?\";\nchar s3[200] = \"What are you doing while sending x\";\nchar s4[200] = \"x? Are you busy? Will you send x\";\nchar s5[200] = \"x?\";\nvoid find(int d, long long jump){\n\tif (d == 0){\n\t\tprintf(\"%c\", s1[jump]);\n\t\te = 1;\n\t\treturn;\n\t}\n\tif (flen > jump){\n\t\tif (s3[jump] == 'x')printf(\"\\\"\");\n\t\telse printf(\"%c\", s3[jump]);\n\t\te = 1;\n\t}\n\telse if (flen + f[d - 1] > jump){\n\t\tfind(d - 1, jump - flen);\n\n\t}\n\telse if (flen + f[d - 1] + slen > jump){\n\t\tjump -= (flen + f[d - 1]);\n\t\tif (s4[jump] == 'x')printf(\"\\\"\");\n\t\telse printf(\"%c\", s4[jump]);\n\t\te = 1;\n\t}\n\telse if (flen + f[d - 1] + slen + f[d - 1] > jump){\n\t\tfind(d - 1, jump - flen - f[d - 1] - slen);\n\t}\n\telse{\n\t\tjump -= (flen + f[d - 1] + slen + f[d - 1]);\n\t\tif (s5[jump] == 'x')printf(\"\\\"\");\n\t\telse printf(\"%c\", s5[jump]);\n\t\te = 1;\n\t}\n\tif (e)return;\n}\n\n\nint main()\n{\n\tscanf(\"%d\", &q);\n\tint len = strlen(s1);\n\tint len2 = strlen(s2);\n\tflen = strlen(s3);\n\tslen = strlen(s4);\n\tf[0] = len;\n\tfor (int i = 1; i <= 100000; i++){\n\t\tif (f[i - 1] == INF)f[i] = INF;\n\t\tf[i] = f[i - 1] * 2 + len2;\n\t\tif (f[i] >= INF)f[i] = INF;\n\t}\n\twhile (q--){\n\t\tscanf(\"%d%lld\", &n, &k);\n\t\tk--;\n\t\te = 0;\n\t\tif (f[n] <= k)printf(\".\");\n\t\telse find(n, k);\n\t}\n\tprintf(\"\\n\");\n}", "lang_cluster": "C", "tags": ["math", "binary search", "combinatorics"], "code_uid": "01199de8430d1a795326b1782e23684c", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \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", "tags": ["math", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "ed04b9518cd38609fe41d54d521726c7", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"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\tlong long n, m, k;\n\n\tscanf(\"%lld%lld%lld\", &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)) % (MD - 1)));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "4a88f31deda1f09b51bc9826e8c7fa16", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nlong long n,dep,d[70];\nvoid devide(long long k){\n\twhile (k){\n\t\tdep++;\n\t\td[dep]=k%2;\n\t\tk/=2;\n\t}\n}\nlong long get(long long i){\n\tlong long m=(1LL<<(dep))-1,c=0,k=i;\n\twhile (k)\n\t{\n\t\tm>>=1;\n\t\tc++;\n\t\tif (k==m+1)\n\t\t\tbreak;\n\t\tif (k>m+1)\n\t\t\tk-=m+1;\n\t}\n//\tprintf(\"%lld\",d[c]);\n\treturn c;\n}\nint main(void){\n\tlong long x,y,i,sum=0;\n\tscanf(\"%llu%llu%llu\",&n,&x,&y);\n\tdevide(n);\n\tfor (i=x;i<=y;i++)\n\t\tsum+=d[get(i)];\n\tprintf(\"%llu\\n\",sum);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "ead775d4af448dd81617a6c94d1aaa95", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t4000\n#define MD\t1000000007\n\nint main() {\n\tstatic int ch[N + 1][N + 1], dp[N + 1], pp[N + 1];\n\tint n, i, j, k, p;\n\tlong long x, y, ans;\n\n\tscanf(\"%d\", &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 <= n; j++)\n\t\t\tch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;\n\t}\n\tdp[0] = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tx = 0;\n\t\tfor (j = 2; j <= i; j++) {\n\t\t\ty = dp[i - j];\n\t\t\tif (dp[i - j] != 0)\n\t\t\t\tx = (x + y * ch[i - 1][j - 1]) % MD;\n\t\t}\n\t\tdp[i] = x;\n\t}\n\tp = 1;\n\tfor (i = 0; i <= n; i++) {\n\t\tpp[i] = p - 1;\n\t\tp = p * 2 % MD;\n\t}\n\tans = 0;\n\tfor (k = 1; k <= n; k++)\n\t\tans = (ans + (long long) pp[k] * ch[n][k] % MD * dp[n - k]) % MD;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "b3655e6d946a789dd7c9f37946e626bf", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/* https://codeforces.com/contest/747/submission/23206377 (Dukkha) */\n#include \n#include \n\n#define D\t16\n#define L\t9\n#define MIN(a, b)\t((a) < (b) ? (a) : (b))\n\nint ff[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };\n\nlong long dp[D][L + 1];\n\nvoid solve(int *bb, int l) {\n\tint k, d, i, e, j;\n\n\tmemset(dp, 0, sizeof dp);\n\tk = MIN(l, bb[0]);\n\tfor (i = 0; i <= k; i++)\n\t\tdp[0][i] = 1;\n\tfor (d = 0; d < D - 1; d++)\n\t\tfor (i = 0; i < l; i++)\n\t\t\tif (dp[d][i] > 0)\n\t\t\t\tfor (e = d + 1; e < D; e++) {\n\t\t\t\t\tk = MIN(l, i + bb[e]);\n\t\t\t\t\tfor (j = i + 1; j <= k; j++)\n\t\t\t\t\t\tdp[e][j] += dp[d][i] * (ff[j] / ff[i] / ff[j - i]);\n\t\t\t\t}\n}\n\nint main() {\n\tstatic int bb[D];\n\tstatic char cc[L + 1];\n\tint k, t, l, i, d, d_;\n\tlong long cnt;\n\n\tscanf(\"%d%d\", &k, &t);\n\tfor (i = 0; i < D; i++)\n\t\tbb[i] = t;\n\tl = L;\n\tsolve(bb, l);\n\tfor (i = 1; i <= l; i++) {\n\t\tcnt = 0;\n\t\tfor (d = 0; d < 16; d++)\n\t\t\tcnt += dp[d][i];\n\t\tcnt = cnt / 16 * 15;\n\t\tif (k > cnt)\n\t\t\tk -= cnt;\n\t\telse {\n\t\t\tl = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (i = 1; i <= l; i++)\n\t\tfor (d_ = i == 1 ? 1 : 0; d_ < 16; d_++)\n\t\t\tif (bb[d_] > 0) {\n\t\t\t\tbb[d_]--;\n\t\t\t\tsolve(bb, l - i);\n\t\t\t\tcnt = 0;\n\t\t\t\tfor (d = 0; d < 16; d++)\n\t\t\t\t\tcnt += dp[d][l - i];\n\t\t\t\tif (k > cnt)\n\t\t\t\t\tk -= cnt;\n\t\t\t\telse {\n\t\t\t\t\tcc[i - 1] = d_ < 10 ? '0' + d_ : 'a' + d_ - 10;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tbb[d_]++;\n\t\t\t}\n\tprintf(\"%s\\n\", cc);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "db9a65f24911ada7b43a76c42e680a5f", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n long long i=1000000007;\n long long n,k,j;\n scanf(\"%lld%lld\",&n,&k);\n long long x=n-k,m=1,y=1;\n for(j=1;j<=x;j++)\n m=(m*x)%i;\n for(j=1;j\nlong long f[23],n,s,sum,inv[25];\nint c[23];\nint function(){\n\tint i,t1,j=0;\n\ti=1;\n\t\n\twhile(1){\n\t\tif(c[i]==0){\n\t\t\tc[i]=1;\n\t\t\tbreak;\n\t\t}else{\n\t\t\tc[i]=0;\n\t\t\ti++;\n\t\t}\n\t}\n}\t\n\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) {\nif(inv[a]==0)\n inv[a]=power(a,m-2,m);\n return inv[a];\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(int i,long long pow,int fac){\n\tint j;\n\ti=0;\n\twhile(1){\n\t\tfac=1;\n\t\tj=0;\n\t\tpow=0;\n\t\tfor(i=1;i<=n;i++){\n\t\t\tpow=pow+c[i]*(f[i]+1);\n\t\t\tif(c[i]==1){\tfac=fac*-1;\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t\tif(pow<=s){\t\t\t\t\n\t\t\tsum=(sum+fac*binomialCoeff(n+s-pow-1,s-pow))%1000000007;\n\t\t}\n\t\tif(j==n)\tbreak;\n\t\tfunction();\n\t}\n}\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", "tags": ["combinatorics", "number theory", "bitmasks"], "code_uid": "aa3df742761205ac9901317c2c20bc5b", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\n unsigned long long k;\n int i,j;\n scanf(\"%llu\",&k);\n unsigned long long a=1;\n unsigned long long asn;\n int ten=0;\n int q[10];\n char p[11]=\"codeforces\";\n int put=0;\n for(i=0;i<10;i++)\n {\n q[i]=1;\n }\n while(1)\n {\n asn=1;\n for(i=0;i<10;i++)\n {\n asn*=q[i];\n }\n if(asn>=k)\n {\n break;\n }\n if(ten==10)\n {\n ten=0;\n }\n q[ten]++;\n ten++;\n }\n for(i=0;i<10;i++)\n {\n for(j=0;j\n#define mod 1000000007\n\nint f[1001],c[1001][1001],r1[1001],r2[2001];\n\nint mi(int a,long long b)\n{\n int t;\n if (!b)\n return 1;\n t=mi(a,b>>1);\n t=(long long)t*t%mod;\n if (b&1)\n t=(long long)t*a%mod;\n return t;\n}\n\nint main()\n{\n int i,j,n,m,k,x,s=0,t=1;\n scanf(\"%d%d%d\",&n,&m,&k);\n if (m==1)\n s=mi(k,n);\n else\n {\n for (i=0;i<=n;i++)\n {\n c[i][0]=1;\n for (j=1;j<=i;j++)\n c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;\n }\n for (i=1;i<=n;i++)\n {\n f[i]=mi(i,n);\n for (j=1;j\nlong long dp[5001][5001],a,b,c;\nint main()\n{\n scanf(\"%I64d%I64d%I64d\",&a,&b,&c);\n for(int i=0;i<=5000;i++) dp[i][0]=dp[0][i]=1;\n for(int i=1;i<=5000;i++)\n for(int j=1;j<=5000;j++)\n dp[i][j]=(dp[i-1][j]+(dp[i-1][j-1]*j)%998244353)%998244353;\n printf(\"%I64d\\n\",(dp[a][b]*dp[a][c])%998244353*dp[b][c]%998244353);\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "c20040376abb2e8db4408162e0577ada", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint dp[21][12][5][5];\n\nint main() {\n\tint i,j,k,l,x,n,t;;\n\tscanf(\"%d %d\\n\",&n,&t);\n\tfor (i=1;i<4;i++)\n\t\tfor (j=i+1;j<=4;j++)\n\t\t\tdp[2][0][i][j]=1;\n\tfor (x=3;x<=n;x++)\n\t\tfor (i=1;i<=4;i++)\n\t\t\tfor (j=1;j<=4;j++)\n\t\t\t\tif (i!=j) for (k=1;k<=4;k++)\n\t\t\t\t\tif (j!=k) for (l=0;l<=t;l++)\n\t\t\t\t\t\tif (ik) dp[x][l+1][j][k]+=dp[x-1][l][i][j];\n\t\t\t\t\t\telse dp[x][l][j][k]+=dp[x-1][l][i][j];\n\tint cnt=0;\n\tfor (i=2;i<=4;i++)\n\t\tfor (j=1;j\n#include \n#include \n#include \n#define rep(E, F) for (E = 0; E < (F); E++)\n#define INF 1000000000\n\nint mabs(int a) { if (a > 0) { return a; } return -a; }\nint min(int a, int b) { if (a > b) { return b; } return a; }\nint max(int a, int b) { if (a < b) { return b; } return a; }\nint get_int();\ndouble get_double();\nint get_string(char* b, char t);\nint n;\nint d[2][100][100][100], a[100];\nint chi(int a, int b) { return a == b ? 0 : 1; }\n\nint foo(int b, int x, int y, int z)\n{\n\t//printf(\">> %d %d %d %d\\n\", b, x, y, z);\n\tif (z < 0 || y < 0) return INF;\n\tif (x == n) return 0;\n\tif (d[b][x][y][z] != -1) return d[b][x][y][z];\n\tif (a[x] != -1) return d[b][x][y][z] = chi(a[x], b) + foo(a[x], x + 1, y, z);\n\treturn d[b][x][y][z] = min(chi(0, b) + foo(0, x + 1, y - 1, z), chi(1, b) + foo(1, x + 1, y, z - 1));\n}\n\nint main()\n{\n\tint i, j, k;\n\tn = get_int();\n\trep(i, n) rep(j, n) rep(k, n) d[0][i][j][k] = d[1][i][j][k] = -1;\n\tint d[2] = {n/2, (n + 1)/2};\n\trep(i, n) a[i] = get_int();\n\trep(i, n) { rep(j, n) if (a[j] == i + 1) break; if (j < n) d[(i + 1)%2]--; }\n\trep(i, n) if (a[i] == 0) a[i] = -1; else a[i] %= 2;\n\tint r = min(foo(0, 0, d[0], d[1]), foo(1, 0, d[0], d[1]));\n\tassert(r < INF);\n\tprintf(\"%d\\n\", r);\n\treturn 0;\n}\n\nint get_string(char* b, char t)\n{\n\tint i = 0; b[i++] = getchar();\n\twhile (b[i - 1] != t) b[i++] = getchar();\n\tb[i - 1] = '\\0';\n\treturn i - 1;\n}\n\nint get_int()\n{\n\tint sgn = 1, ret = 0;\n\tchar c = getchar();\n\twhile (1)\n\t{\n\t\tif (c == EOF) return EOF;\n\t\tif (c >= '0' && c <= '9') break;\n\t\tif (c == '-')\n\t\t{\n\t\t\tc = getchar();\n\t\t\tif (c < '0' || c > '9') continue;\n\t\t\tsgn = -1;\n\t\t\tbreak;\n\t\t}\n\t\tc = getchar();\n\t}\n\n\twhile (1)\n\t{\n\t\tret = ret*10 + c - '0';\n\t\tc = getchar();\n\t\tif (c < '0' || c > '9') return sgn*ret;\n\t}\n}\n\ndouble get_double()\n{\n\tdouble ret = 0;\n\tchar c = getchar();\n\tint sgn;\n\n\twhile (1)\n\t{\n\t\tif (c == EOF)\n\t\t{\n\t\t\treturn EOF;\n\t\t}\n\t\tif (c >= '0' && c <= '9')\n\t\t{\n\t\t\tsgn = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif (c == '-')\n\t\t{\n\t\t\tc = getchar();\n\n\t\t\tif (c < '0' || c > '9')\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tsgn = -1;\n\t\t\tbreak;\n\t\t}\n\t\tc = getchar();\n\t}\n\n\twhile (1)\n\t{\n\t\tret = ret*10 + c - '0';\n\n\t\tc = getchar();\n\n\t\tif (c == '.')\n\t\t{\n\t\t\tdouble pos = 0.1;\n\n\t\t\tc = getchar();\n\t\t\twhile (c >= '0' && c <= '9')\n\t\t\t{\n\t\t\t\tret += pos*(c - '0');\n\t\t\t\tpos /= 10;\n\t\t\t\tc = getchar();\n\t\t\t}\n\n\t\t\treturn sgn*ret;\n\t\t}\n\t\telse if (c < '0' || c > '9')\n\t\t{\n\t\t\treturn sgn*ret;\n\t\t}\n\t}\n}\n", "lang_cluster": "C", "tags": ["sortings", "dp", "greedy"], "code_uid": "198b53683481bdf7e246c59e320e91ab", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main (){\n\t long long int n;\n\t\t scanf(\"%lld\",&n);\n\t\t\t printf(\"%lld\",n*(n-1)*(n-2)*(n-3)*(n-4)/120*n*(n-1)*(n-2)*(n-3)*(n-4));\n\t\t\t\t\t \n\t\t\t\t\t return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "ca7a34f46e5eef48abbd05d679a5ca19", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define K\t8\n#define L\t840\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\nint main() {\n\tstatic long long aa[K + 1], dp[L * K], dq[L * K];\n\tlong long w, ans, a, p;\n\tint i, y, y_, q, q_;\n\n\tscanf(\"%lld\", &w);\n\tfor (i = 1; i <= K; i++)\n\t\tscanf(\"%lld\", &aa[i]);\n\tmemset(dp, -1, L * K * sizeof *dp);\n\tdp[0] = 0;\n\tfor (i = 1; i <= K; i++) {\n\t\ta = aa[i];\n\t\tfor (y = 0; y < L * K; y++)\n\t\t\tdq[y] = -1;\n\t\tfor (y = 0; y < L * K; y++) {\n\t\t\tif (dp[y] < 0)\n\t\t\t\tcontinue;\n\t\t\tq_ = L / i;\n\t\t\tfor (q = 0; q < q_ && q <= a; q++) {\n\t\t\t\tp = (a - q) / q_;\n\t\t\t\ty_ = y + q * i;\n\t\t\t\tdq[y_] = max(dq[y_], dp[y] + p);\n\t\t\t}\n\t\t}\n\t\tfor (y = 0; y < L * K; y++)\n\t\t\tdp[y] = dq[y];\n\t}\n\tans = 0;\n\tfor (y = 0; y < L * K && y <= w; y++)\n\t\tans = max(ans, min((w - y) / L, dp[y]) * L + y);\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "dp"], "code_uid": "cdbfdb70559aed458e65e2ef88ee2978", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long fac[250005];\n\nint main()\n{\n int n, m;\n long long ans = 0;\n scanf(\"%d%d\", &n, &m);\n\n fac[0] = 1;\n for(int i = 1; i <= n; i++){\n fac[i] = (fac[i - 1] * i) % m;\n }\n\n for(int i = 0; i < n; i++){\n ans += (fac[i + 1] * fac[n - i]) % m;\n ans %= m;\n }\n\n ans = (ans * (n + 1)) % m;\n if(ans % 2 == 1) ans = (ans + m) / 2;\n else ans /= 2;\n\n printf(\"%I64d\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "fe65050437e55bf96619980cc7bbc7e7", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\nchar str[101];\nint i=1,chk=0;\nscanf(\"%s\",&str);\nprintf(\"%c\",str[0]);\nwhile(i!=strlen(str))\n {\n if(str[i]=='a')\n {\n if(chk==0)\n {\n if((str[i+1]=='t')&&((i+1)!=strlen(str)-1))\n {\n printf(\"@\");\n i++;\n chk=1;\n }\n }\n else\n printf(\"%c\",str[i]);\n }\n else if(str[i]=='d')\n {\n if((str[i+1]=='o')&&(str[i+2]=='t')&&((i+2)!=strlen(str)-1))\n {\n printf(\".\");\n i+=2;\n }\n else\n printf(\"%c\",str[i]);\n goto xy;\n }\n else\n {\n printf(\"%c\",str[i]);\n goto xy ;\n }\nif(chk==0)\n printf(\"%c\",str[i]);\nxy : i++;\n }\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing", "implementation"], "code_uid": "5ab69a2a08cf0be8042c6d2c5d3bc71a", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nchar board[10][10] = { 0 };\nchar* pattern1 = { \".XXXX\" };\nchar* pattern2 = { \"X.XXX\" };\nchar* pattern3 = { \"XX.XX\" };\nchar* pattern4 = { \"XXX.X\" };\nchar* pattern5 = { \"XXXX.\" };\n\nchar temp;\nint result;\n\nint checkHorizontal()\n{\n\tint i, j;\n\tint result = 0;\n\n\tfor (j = 0; j < 10; j++)\n\t{\n\t\tif (result == 1)\n\t\t\tbreak;\n\n\t\tfor (i = 0; i <= 5; i++)\n\t\t{\n\t\t\tif (board[j][i] == pattern1[0] && board[j][i + 1] == pattern1[1] &&\n\t\t\t\tboard[j][i + 2] == pattern1[2] && board[j][i + 3] == pattern1[3] &&\n\t\t\t\tboard[j][i + 4] == pattern1[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern2[0] && board[j][i + 1] == pattern2[1] &&\n\t\t\t\tboard[j][i + 2] == pattern2[2] && board[j][i + 3] == pattern2[3] &&\n\t\t\t\tboard[j][i + 4] == pattern2[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern3[0] && board[j][i + 1] == pattern3[1] &&\n\t\t\t\tboard[j][i + 2] == pattern3[2] && board[j][i + 3] == pattern3[3] &&\n\t\t\t\tboard[j][i + 4] == pattern3[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern4[0] && board[j][i + 1] == pattern4[1] &&\n\t\t\t\tboard[j][i + 2] == pattern4[2] && board[j][i + 3] == pattern4[3] &&\n\t\t\t\tboard[j][i + 4] == pattern4[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern5[0] && board[j][i + 1] == pattern5[1] &&\n\t\t\t\tboard[j][i + 2] == pattern5[2] && board[j][i + 3] == pattern5[3] &&\n\t\t\t\tboard[j][i + 4] == pattern5[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nint checkVertical()\n{\n\tint i, j;\n\tint result = 0;\n\n\tfor (j = 0; j < 10; j++)\n\t{\n\t\tif (result == 1)\n\t\t\tbreak; \n\n\t\tfor (i = 0; i <= 5; i++)\n\t\t{\n\t\t\tif (board[i][j] == pattern1[0] && board[i + 1][j] == pattern1[1] &&\n\t\t\t\tboard[i + 2][j] == pattern1[2] && board[i + 3][j] == pattern1[3] &&\n\t\t\t\tboard[i + 4][j] == pattern1[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[i][j] == pattern2[0] && board[i + 1][j] == pattern2[1] &&\n\t\t\t\tboard[i + 2][j] == pattern2[2] && board[i + 3][j] == pattern2[3] &&\n\t\t\t\tboard[i + 4][j] == pattern2[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[i][j] == pattern3[0] && board[i + 1][j] == pattern3[1] &&\n\t\t\t\tboard[i + 2][j] == pattern3[2] && board[i + 3][j] == pattern3[3] &&\n\t\t\t\tboard[i + 4][j] == pattern3[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[i][j] == pattern4[i] && board[i + 1][j] == pattern4[1] &&\n\t\t\t\tboard[i + 2][j] == pattern4[2] && board[i + 3][j] == pattern4[3] &&\n\t\t\t\tboard[i + 4][j] == pattern4[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[i][j] == pattern5[0] && board[i + 1][j] == pattern5[1] &&\n\t\t\t\tboard[i + 2][j] == pattern5[2] && board[i + 3][j] == pattern5[3] &&\n\t\t\t\tboard[i + 4][j] == pattern5[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nint checkdiagonal()\n{\n\tint result = 0;\n\tint i, j;\n\n\tfor (j = 0; j <= 5; j++)\n\t{\n\t\tif (result == 1)\n\t\t\tbreak;\n\n\t\tfor (i = 0; i <= 5; i++)\n\t\t{\n\t\t\tif (board[j][i] == pattern1[0] &&\n\t\t\t\tboard[j + 1][i + 1] == pattern1[1] &&\n\t\t\t\tboard[j + 2][i + 2] == pattern1[2] &&\n\t\t\t\tboard[j + 3][i + 3] == pattern1[3] &&\n\t\t\t\tboard[j + 4][i + 4] == pattern1[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern2[0] &&\n\t\t\t\tboard[j + 1][i + 1] == pattern2[1] &&\n\t\t\t\tboard[j + 2][i + 2] == pattern2[2] &&\n\t\t\t\tboard[j + 3][i + 3] == pattern2[3] &&\n\t\t\t\tboard[j + 4][i + 4] == pattern2[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern3[0] &&\n\t\t\t\tboard[j + 1][i + 1] == pattern3[1] &&\n\t\t\t\tboard[j + 2][i + 2] == pattern3[2] &&\n\t\t\t\tboard[j + 3][i + 3] == pattern3[3] &&\n\t\t\t\tboard[j + 4][i + 4] == pattern3[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern4[0] &&\n\t\t\t\tboard[j + 1][i + 1] == pattern4[1] &&\n\t\t\t\tboard[j + 2][i + 2] == pattern4[2] &&\n\t\t\t\tboard[j + 3][i + 3] == pattern4[3] &&\n\t\t\t\tboard[j + 4][i + 4] == pattern4[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern5[0] &&\n\t\t\t\tboard[j + 1][i + 1] == pattern5[1] &&\n\t\t\t\tboard[j + 2][i + 2] == pattern5[2] &&\n\t\t\t\tboard[j + 3][i + 3] == pattern5[3] &&\n\t\t\t\tboard[j + 4][i + 4] == pattern5[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (j = 9; j >= 4; j--)\n\t{\n\t\tif (result == 1)\n\t\t\tbreak;\n\n\t\tfor (i = 0; i <= 5; i++)\n\t\t{\n\t\t\tif (board[j][i] == pattern1[0] &&\n\t\t\t\tboard[j - 1][i + 1] == pattern1[1] &&\n\t\t\t\tboard[j - 2][i + 2] == pattern1[2] &&\n\t\t\t\tboard[j - 3][i + 3] == pattern1[3] &&\n\t\t\t\tboard[j - 4][i + 4] == pattern1[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern2[0] &&\n\t\t\t\tboard[j - 1][i + 1] == pattern2[1] &&\n\t\t\t\tboard[j - 2][i + 2] == pattern2[2] &&\n\t\t\t\tboard[j - 3][i + 3] == pattern2[3] &&\n\t\t\t\tboard[j - 4][i + 4] == pattern2[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern3[0] &&\n\t\t\t\tboard[j - 1][i + 1] == pattern3[1] &&\n\t\t\t\tboard[j - 2][i + 2] == pattern3[2] &&\n\t\t\t\tboard[j - 3][i + 3] == pattern3[3] &&\n\t\t\t\tboard[j - 4][i + 4] == pattern3[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern4[0] &&\n\t\t\t\tboard[j - 1][i + 1] == pattern4[1] &&\n\t\t\t\tboard[j - 2][i + 2] == pattern4[2] &&\n\t\t\t\tboard[j - 3][i + 3] == pattern4[3] &&\n\t\t\t\tboard[j - 4][i + 4] == pattern4[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (board[j][i] == pattern5[0] &&\n\t\t\t\tboard[j - 1][i + 1] == pattern5[1] &&\n\t\t\t\tboard[j - 2][i + 2] == pattern5[2] &&\n\t\t\t\tboard[j - 3][i + 3] == pattern5[3] &&\n\t\t\t\tboard[j - 4][i + 4] == pattern5[4])\n\t\t\t{\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nint main()\n{\n\tint i, j;\n\tint result = 0;\n\n\tfor (i = 0; i < 10; i++)\n\t{\n\t\tfor (j = 0; j < 10; j++)\n\t\t\tscanf(\"%c\", &board[i][j]);\n\t\tscanf(\"%c\", &temp);\n\t}\n\n\tif (checkHorizontal())\n\t\tresult = 1;\n\t\n\tif (checkVertical())\n\t\tresult = 1;\n\n\tif (checkdiagonal())\n\t\tresult = 1;\n\n\tprintf(\"%s\\n\", result ? \"YES\" : \"NO\");\n\treturn 0;\n}\n\n/* 1511793420122 */\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "2749ccc41efa4e8a288f7a65e1600c0c", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"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", "tags": ["math", "matrices", "dp"], "code_uid": "4944930413da4fb3782fe29e089e134b", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long n,a,b,c,i,j,k,diff,min=10000000000,max;\n scanf(\"%lld\",&n);\n for(i=1;i*i*i<=n;i++)\n {\n if(n%i==0)\n {\n for(j=i;j*j<=n/i;j++)\n {\n if(n%j==0)\n k=n/(i*j);\n a=i+1;b=j+2;c=k+2;\n if((a-1)*(b-2)*(c-2)==n)\n diff=(a*b*c)-n;\n if(min>diff)\n min=diff;\n \n }\n }\n }\n max=9*(n+1)-n;\n printf(\"%lld %lld\",min,max);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "f1ca167442c543c1f95a74c265335893", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef long long int ll;\nvoid print(int *a,int n)\n{\n int i;\n for(i=0;i0 && v[a2]>0)\n {\n if(u[a1]==v[a2])\n {\n printf(\"%d\\n\",u[a1]-1);\n return 0;\n }\n if((u[a1]>=u[st]) && (v[a2]>=u[a1] && (v[a2]-u[a1])%u[l]==0)){\n printf(\"%d\\n\",v[a2]-1);\n return 0; }\n else if(v[a2]>=v[st] && (u[a1]>=v[a2] && (u[a1]-v[a2])%v[l]==0)){\n printf(\"%d\\n\",u[a1]-1); \n return 0;\n }\n else if((u[a1]>=u[st] && v[a2]>=v[st]))\n {\n t1=gcd(u[l],v[l]);\n t2=u[a1]-v[a2];\n if(t2<0)\n t2=-t2;\n if(t2%t1!=0)\n {\n printf(\"-1\\n\");\n return 0;\n }\n a=u[a1]-1;\n b=v[a2]-1;\n while(a!=b)\n {\n if(a\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][k]=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][k]+=(dp[ii][jj][k-1]*c[ii][ii-i]*c[jj][jj-j])%mod;\n\t\t\t\t\t\t\t\t\tdp[i][j][k]%=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][k]+=(dp[ii][jj][k-1]*c[A-ii][i-ii]*c[B-jj][j-jj])%mod;\n\t\t\t\t\t\t\t\t\tdp[i][j][k]%=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][k]){\n\t\t\t\t\tprintf(\"%d\\n\",k);\n\t\t\t\t\tprintf(\"%lld\\n\",dp[0][0][k]);\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", "tags": ["dp", "combinatorics", "graphs", "shortest paths"], "code_uid": "15725813c7099eaa9e96d5898472bb70", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nconst long long int base = 1000000007;\n\nlong long int sq(int x, int y) {\n long long int i, a;\n\n a = 1;\n for (i = 0; i < y; i++) {\n a = (a * x) % base;\n }\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 || k > n) printf(\"%I64d\", sq(m, n));\n else if (k == n) printf(\"%I64d\", sq(m, (n+1)/2));\n else if (k%2 == 1) printf(\"%I64d\", sq(m, 2));\n else printf(\"%d\", m);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "math", "combinatorics", "graphs"], "code_uid": "b1b62f2ec77daa266df84d0fcaf895c0", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nint main() {\n\tint a, b, x, y, g;\n\n\tscanf(\"%d%d%d%d\", &a, &b, &x, &y);\n\tg = gcd(x, y);\n\tx /= g, y /= g;\n\ta /= x, b /= y;\n\tg = a < b ? a : b;\n\tprintf(\"%d %d\\n\", g * x, g * y);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["binary search", "number theory"], "code_uid": "c986c0c34ad4150267db2abe2a50ca5d", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MIN(a,b) a < b ? a : b\nvoid myprint(long long);\nint main() {\n\tint t[3][3];\n\tint i, j;\n\tint n;\n\tlong long cost[3][3][41];\n\tfor(i = 0; i < 3; i++) {\n\t\tfor(j = 0; j < 3; j++) {\n\t\t\tscanf(\"%d\", &t[i][j]);\n\t\t}\n\t}\n\tscanf(\"%d\", &n);\n\n\tfor(i = 0; i < 3; i++) {\n\t\tfor(j = 0; j < 3; j++) {\n\t\t\tif(i == j)\n\t\t\t\tcost[i][j][1] = 0;\n\t\t\telse {\n\t\t\t\tint k = 3 - ( i + j );\n\t\t\t\tcost[i][j][1] = MIN(t[i][j], t[i][k] + t[k][j]);\n\t\t\t}\n\t\t}\n\t}\n\tint nn;\n\tfor(nn = 2; nn <= n ; nn++) {\n\t\tfor(i = 0; i < 3; i++) {\n\t\t\tfor(j = 0; j < 3; j++) {\n\t\t\t\tif(i == j)\n\t\t\t\t\tcost[i][j][nn] = 0;\n\t\t\t\telse {\n\t\t\t\t\tint k = 3 - ( i + j );\n\t\t\t\t\tcost[i][j][nn] = MIN(\n\t\t\t\t\t\t\t\t\t\t\tcost[i][k][nn-1] + cost[k][j][nn-1] + t[i][j],\n\t\t\t\t\t\t\t\t\t\t\tcost[i][j][nn-1] + t[i][k] + cost[j][i][nn-1] + t[k][j] + cost[i][j][nn-1]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i = 0; i < 3; i++) {\n\t\t\tfor(j = 0; j < 3; j++) {\n\t\t\t\tif(i != j) {\n\t\t\t\t\tint k = 3 - (i + j);\n\t\t\t\t\tcost[i][j][nn] = MIN(cost[i][j][nn], cost[i][k][nn] + cost[k][j][nn]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n/*\tfor(nn = 1; nn <= n; nn++) {\n\t\tprintf(\"%d\\n\", nn);\n\t\tfor(i = 0; i < 3; i++) {\n\t\t\tfor(j = 0; j < 3; j++) {\n\t\t\t\tprintf(\"%3d\", cost[i][j][nn]);\n\t\t\t}\n\t\t\tprintf(\"\\n\");\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n*/\n\tmyprint(cost[0][2][n]);\n}\n\nvoid myprint(long long n) {\n\tif(n > 0) {\n\t\tmyprint(n/10);\n\t\tprintf(\"%d\", (int)(n%10));\n\t}\n}\n\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "2dc84a73944bf1a169236f0a05ff2852", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long int prime(long long int x)\n{\n\tif (x < 2)\n\t\treturn 0;\n\tif (x % 2 == 0)\n\t\treturn 2;\n\tlong long int i;\n\tfor (i = 3; i * i <= x; i++)\n\t\tif (x % i == 0)\n\t\t\treturn i;\n\treturn x;\n}\nlong long int modpow(long long int a, long long int n, long long int p)\n{\n\tif (n < 0)return 0;\n\tlong long int res = 1;\n\twhile (n > 0)\n\t{\n\t\tif (n % 2 == 1)\n\t\t\tres = res * a % p;\n\t\tn /= 2;\n\t\ta = a * a % p;\n\t}\n\treturn res;\n}\nint main()\n{\n\tlong long int x, n;\n\tscanf(\"%lld %lld\", &x, &n);\n\tlong long int ans = 1, p = 1000000007;\n\tlong long int q, v;\n\twhile (x > 1)\n\t{\n\t\tq = prime(x);\n\t\twhile (x % q == 0)\n\t\t\tx /= q;\n\t\tv = q;\n\t\twhile (n / v > 0)\n\t\t{\n\t\t\tans = ans * modpow(q, n / v, p) % p;\n\t\t\tif (n / v < q)break;\n\t\t\tv *= q;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "48b88c9e85266bb4e2bd67e046cdb262", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint compare(const void* a, const void* b)\n{\n int* x = (int*) a;\n int* y = (int*) b;\n return *x - *y;\n}\n\nunsigned min(const unsigned a, const unsigned b)\n{\n return (a < b) ? a : b;\n}\n\nint main(int argc, const char *argv[])\n{\n\tunsigned a[500000] = {0};\n unsigned x, n, i, j = 0;\n\tunsigned long long ans = 0;\n\n\tscanf(\"%u\", &n);\n\tfor(i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%u\", &x);\n\t\twhile(j > 1 && a[j - 2] >= a[j - 1] && x >= a[j - 1])\n {\n\t\t\tans += min(a[j - 2], x);\n\t\t\tj--;\n\t\t}\n\t\ta[j++] = x;\n\t}\n\n qsort(a, j, sizeof(unsigned), compare);\n\n if (j > 1)\n for(i = 0; i < j - 2; i++)\n ans += a[i];\n\n\tprintf(\"%I64d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "caf32a6b7271cb3d60c882df3420187c", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define max(a, b) (((a) > (b)) ? (a) : (b))\n\nint main(void) {\n int i;\n int c, wr, wb;\n long long hr, hb;\n long long ans;\n\n scanf(\"%d %lld %lld %d %d\", &c, &hr, &hb, &wr, &wb);\n\n ans = 0;\n for (i = 0; i <= c / wr && i * i <= c; i++)\n ans = max(ans, hr * i + (c - wr * i) / wb * hb);\n for (i = 0; i <= c / wb && i * i <= c; i++)\n ans = max(ans, hb * i + (c - wb * i) / wr * hr);\n\n printf(\"%lld\\n\", ans);\n\n return 0;\n}\n ", "lang_cluster": "C", "tags": ["math", "greedy", "brute force"], "code_uid": "9557af7f6c0ea2ff51c70a2f5223221a", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main () {\n\tint n, res;\n\tscanf (\"%d\", &n);\n\tres = sqrt(2) * n;\n\tres *= 4;\n\tif (n == 0) {\n\t\tres = 1;\n\t}\n\tprintf (\"%d\", res);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "6e664830aa750c4078e58ffff7851089", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\ntypedef struct{\n\tint x, y;\n} Point;\n\ntypedef struct{\n\tPoint n[4];\n} Square;\n\nint cross(Point a, Point b, Point c){\n\treturn (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y);\n}\n\nint abs(int a){return a<0?-a:a;}\nint min(int a, int b){return ab?a:b;}\n\nbool contains(Square sq, Point p){\n\treturn abs(cross(sq.n[0], sq.n[1], sq.n[2]))+\n\t\tabs(cross(sq.n[2], sq.n[3], sq.n[0]))==\n\t\tabs(cross(sq.n[0], sq.n[1], p))+abs(cross(sq.n[1], sq.n[2], p))+\n\t\tabs(cross(sq.n[2], sq.n[3], p))+abs(cross(sq.n[3], sq.n[0], p));\n}\n\nint sqminx(Square sq){ return min(sq.n[0].x, min(sq.n[1].x, min(sq.n[2].x, sq.n[3].x))); }\nint sqmaxx(Square sq){ return max(sq.n[0].x, max(sq.n[1].x, max(sq.n[2].x, sq.n[3].x))); }\nint sqminy(Square sq){ return min(sq.n[0].y, min(sq.n[1].y, min(sq.n[2].y, sq.n[3].y))); }\nint sqmaxy(Square sq){ return max(sq.n[0].y, max(sq.n[1].y, max(sq.n[2].y, sq.n[3].y))); }\n\nint main(){\n\tSquare squares[2];\n\tint i, j;\n\tPoint curr;\n\tfor(i=0;i<2;++i) for(j=0;j<4;++j)\n\t\t\tscanf(\"%d %d\", &squares[i].n[j].x, &squares[i].n[j].y);\n\tfor(curr.x=sqminx(squares[0]);curr.x<=sqmaxx(squares[0]);++curr.x){\n\t\tfor(curr.y=sqminy(squares[0]);curr.y<=sqmaxy(squares[0]);++curr.y){\n\t\t\tif(contains(squares[1], curr)){\n\t\t\tputs(\"YES\");\n\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tputs(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["geometry", "implementation"], "code_uid": "661925ec4f1107c5bab27327eda3e799", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong long int s;\nint check(long long int x)\n{\n long long int sum=0,y=x;\n //printf(\"%lld\\n\",y);\n while(y!=0)\n {\n // printf(\"hi\\n\");\n sum+=(y%10);\n y=y/10;\n }\n //printf(\"%lld\",s);\n //printf(\"%lld\\n\",x-sum);\n if((x-sum)>=s)\n {\n // printf(\"hi\\n\");\n return 1;\n }\n return 0;\n}\nint main()\n{\n long long int n;\n scanf(\"%lld %lld\",&n,&s);\n \n long long int l,r,m;\n l=0;\n r=n;\n m=(l+r)/2;\n while(l\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", "tags": ["math", "dp", "sortings", "data structures", "two pointers", "number theory"], "code_uid": "cb6dad533e8a948fa0b92a133cf14c74", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int x1, y1, r1, R1, x2, y2, r2, R2, d, sum = 0;\n \n scanf(\"%d %d %d %d\", &x1, &y1, &r1, &R1);\n scanf(\"%d %d %d %d\", &x2, &y2, &r2, &R2);\n \n d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n \n if (d >= r1 * r1) {\n if (r2 >= r1 && d <= r1 * r1 - 2 * r1 * r2 + r2 * r2) {\n sum++;\n } else if (d >= r1 * r1 + 2 * r1 * R2 + R2 * R2) {\n sum++;\n }\n } else {\n if (r1 >= R2 && d <= r1 * r1 - 2 * r1 * R2 + R2 * R2) {\n sum++;\n } else if (r2 >= r1 && d <= r1 * r1 - 2 * r1 * r2 + r2 * r2) {\n sum++;\n }\n }\n \n if (d >= r2 * r2) {\n if (r1 >= r2 && d <= r1 * r1 - 2 * r1 * r2 + r2 * r2) {\n sum++;\n } else if (d >= R1 * R1 + 2 * R1 * r2 + r2 * r2) {\n sum++;\n }\n } else {\n if (r2 >= R1 && d <= R1 * R1 - 2 * R1 * r2 + r2 * r2) {\n sum++;\n } else if (r1 >= r2 && d <= r1 * r1 - 2 * r1 * r2 + r2 * r2) {\n sum++;\n }\n }\n \n if (d >= R1 * R1) {\n if (d >= R1 * R1 + 2 * R1 * R2 + R2 * R2) {\n sum++;\n } else if (r2 >= R1 && d <= R1 * R1 - 2 * R1 * r2 + r2 * r2) {\n sum++;\n }\n } else {\n if (R1 >= R2 && d <= R1 * R1 - 2 * R1 * R2 + R2 * R2) {\n sum++;\n } else if (r2 >= R1 && d <= R1 * R1 - 2 * R1 * r2 + r2 * r2) {\n sum++;\n }\n }\n \n if (d >= R2 * R2) {\n if (d >= R1 * R1 + 2 * R1 * R2 + R2 * R2) {\n sum++;\n } else if (r1 >= R2 && d <= r1 * r1 - 2 * r1 * R2 + R2 * R2) {\n sum++;\n }\n } else {\n if (R2 >= R1 && d <= R1 * R1 - 2 * R1 * R2 + R2 * R2) {\n sum++;\n } else if (r1 >= R2 && d <= r1 * r1 - 2 * r1 * R2 + R2 * R2) {\n sum++;\n }\n }\n \n printf(\"%d\\n\", sum);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "cbde4a068afe7f4006e79e1c42de9a4a", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tint a[10], i, n, max=0;\n\tscanf(\"%d\", &n);\n\tfor(i=0; i\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, m, x, y, z, s;\n \n memset(a, 0, sizeof a);\n scanf(\"%d\", &n);\n m = 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 if (m == 1)\n puts(\"1 0\");\n else\n printf(\"%d %d\\n\", x, y);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "f0e18c31e582f08cef6a8dc722556c97", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t100000\n#define S\t20\n\nint max(int a, int b) { return a > b ? a : b; }\n\nint aa[N], bb[N];\nint x;\n\nint get_next_x() {\n\treturn (x = (x * 37LL + 10007) % 1000000007);\n}\n\nvoid init_AB(int n, int d) {\n\tint i, j, tmp;\n\n\tfor (i = 0; i < n; i++)\n\t\taa[i] = i + 1;\n\tfor (i = 0; i < n; i++) {\n\t\tj = get_next_x() % (i + 1);\n\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tbb[i] = i < d;\n\tfor (i = 0; i < n; i++) {\n\t\tj = get_next_x() % (i + 1);\n\t\ttmp = bb[i], bb[i] = bb[j], bb[j] = tmp;\n\t}\n}\n\nint main() {\n\tstatic int ii[S + 1], jj[N];\n\tint n, d, h, i, k, c;\n\n\tscanf(\"%d%d%d\", &n, &d, &x);\n\tinit_AB(n, d);\n\tk = 0;\n\tfor (i = 0; i < n; i++) {\n\t\th = i < S ? i : S;\n\t\twhile (h > 0 && aa[ii[h - 1]] < aa[i]) {\n\t\t\tii[h] = ii[h - 1];\n\t\t\th--;\n\t\t}\n\t\tii[h] = i;\n\t\tif (bb[i])\n\t\t\tjj[k++] = i;\n\t\tc = 0;\n\t\tfor (h = 0; h <= i && h < S; h++)\n\t\t\tif (bb[i - ii[h]]) {\n\t\t\t\tc = aa[ii[h]];\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (c == 0)\n\t\t\tfor (h = 0; h < k; h++)\n\t\t\t\tc = max(c, aa[i - jj[h]]);\n\t\tprintf(\"%d\\n\", c);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities"], "code_uid": "bbaf2041d34b4df9a06d52368933c7ec", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"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\nlong long dp[19][49][253];\nbool visited[19][49][253] = {false};\nint n, ar[20], H[2522], next[2522][10], mod[255][10];\n\nlong long F(int i, int m, int r, bool flag){\n if (i == -1) return !(r % m);\n int j, h = H[m], lim = 10;\n if (!flag && visited[i][h][r]) return dp[i][h][r];\n\n long long res = 0;\n if (flag) lim = ar[i] + 1;\n for (j = 0; j < lim; j++){\n res += F(i - 1, next[m][j], i ? mod[r][j]: (r * 10) + j, flag && (j == ar[i]));\n }\n if (flag) return res;\n\n visited[i][h][r] = true;\n return (dp[i][h][r] = res);\n}\n\nlong long Solve(long long val){\n n = 0;\n for (; ;){\n ar[n++] = (val % 10);\n val /= 10;\n if (!val) break;\n }\n\n return F(n - 1, 1, 0, true);\n}\n\nunsigned int gcd(unsigned int u, unsigned int v){\n if (!u) return v;\n if (!v) return u;\n if (u == 1 || v == 1) return 1;\n\n int shift = __builtin_ctz(u | v);\n u >>= __builtin_ctz(u);\n do{\n v >>= __builtin_ctz(v);\n if (u > v)\n v ^= u ^= v ^= u;\n v = v - u;\n } while (v);\n\n return u << shift;\n}\n\nvoid Generate(){\n int i, j, k;\n\n for (i = 1, k = -1; i <= 2520; i++){\n if (!(2520 % i)) k++;\n H[i] = k;\n }\n\n for (j = 0; j < 10; j++){\n for (i = 1; i <= 2520; i++){\n if (j > 1) next[i][j] = (i * j) / gcd(i, j);\n else next[i][j] = i;\n }\n\n for (i = 0; i < 252; i++) mod[i][j] = ((i * 10) + j) % 252;\n }\n}\n\nint main(){\n Generate();\n\n int t, i, j;\n long long a, b, res;\n\n scanf(\"%d\", &t);\n while (t--){\n scanf(\"%lld %lld\", &a, &b);\n res = Solve(b) - Solve(a - 1);\n printf(\"%lld\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "number theory"], "code_uid": "493f15753fecb9cfb37c956049f71abc", "src_uid": "37feadce373f728ba2a560b198ca4bc9", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\n#include\r\n#include\r\n#include\r\n#include \r\ntypedef long long int ll;\r\ntypedef unsigned long long ull;\r\ntypedef long double lld;\r\n#define pr printf\r\n#define sc scanf\r\n#define I 1e18\r\n#define in(x) scanf(\"%d\", &x)\r\n#define out(x) printf(\"%d\\n\", x)\r\n#define re(i,a,b) for(int i=a;i= a && j[0] > tmp)\r\n\t\t\t\tj[h] = j[0], j -= h;\r\n\t\t\tj[h] = tmp;\r\n\t\t}\r\n}\r\nint main()\r\n{\r\n#ifndef ONLINE_JUDGE\r\n\tfreopen(\"input.txt\", \"r\", stdin);\r\n//\tfreopen(\"output.txt\", \"w\", stdout);\r\n#endif\r\n\tprecal();\r\n\tint t = 1;\r\n\twhile (t--)\r\n\t{\r\n\t\ttest();\r\n\t}\r\n}\r\nvoid test()\r\n{\r\n\tchar s[20000];\r\n\tsc(\"%s\", s);\r\n\tint a[20000];\r\n\tint l = strlen(s);\r\n\tfor (i = 'A'; i <= 'z'; i++)\r\n\t{\r\n\t\ta[i] = i - 'A';\r\n\t}\r\n\tfor (i = 2; i < l; i++)\r\n\t{\r\n\t\tif (a[s[i]] != (a[s[i - 1]] + a[s[i - 2]]) % 26)\r\n\t\t{\r\n\t\t\tpr(\"NO\\n\");\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\tpr(\"YES\\n\");\r\n\r\n\r\n\r\n}\r\n\r\n\r\n\r\n\r\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "010b766ac34772b274d00fa02a4082be", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint n, m = -1, i, j, k;\n\tchar s[31];\n\n\tscanf(\"%s\", s);\n\n\tn = strlen(s);\n\n\tfor (i = 0; i < n - 2; i++) {\n\t\tfor (j = i + 1; j < n - 1; j++) {\n\t\t\tint x = 0, y = 0, z = 0;\n\n\t\t\tfor (k = 0; k < n; k++) {\n\t\t\t\tif (k <= i) {\n\t\t\t\t\tx *= 10;\n\t\t\t\t\tx += s[k] - '0';\n\n\t\t\t\t\tif (x > 1000000) break;\n\t\t\t\t} else if (k <= j) {\n\t\t\t\t\ty *= 10;\n\t\t\t\t\ty += s[k] - '0';\n\n\t\t\t\t\tif (y > 1000000) break;\n\t\t\t\t} else {\n\t\t\t\t\tz *= 10;\n\t\t\t\t\tz += s[k] - '0';\n\n\t\t\t\t\tif (z > 1000000) break;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (k < n) continue;\n\n\t\t\tif (i > 0 && s[0] == '0') continue;\n\n\t\t\tif (j - i > 1 && s[i + 1] == '0') continue;\n\n\t\t\tif (j < n - 2 && s[j + 1] == '0') continue;\n\n\t\t\tif (x + y + z > m) m = x + y + z;\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", m);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "a5cdec8558a24caa02ce2f46665a5bbe", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"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, FAns;\nlong long int Test;\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) 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", "tags": ["brute force", "dfs and similar", "bitmasks"], "code_uid": "54b04a8e3a0e2d434f2d659a824e9682", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define max(a, b) (((a) > (b)) ? (a) : (b))\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 >=0 && denom >= 0) || (numer < 0 && 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, q1, i, j, ans, base;\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\t//printf(\"start = %lld\\n\", start);\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\tq1 = box((end-p), alpha2);\n\t//printf(\"q1 = %lld\\n\", q1);\n\t\n\tbase = box(-p, alpha2) + 1;\n\tbase -= (p % alpha2) == 0 ? 1 : 0;\n\tq = max(q, base);\n\t//printf(\"q = %lld\\n\", q);\n\t\n\tbase = box(-p1, alpha1) + 1;\n\tbase -= (p1 % alpha1) == 0 ? 1 : 0;\n\tq = max(q, base);\n\t//printf(\"q = %lld\\n\", q);\n\t\n\tans = q1 - (q - 1);\n\t//printf(\"ans = %lld\\n\", ans);\n\tif (ans < 0 )\n\t{\n\t\tans = 0;\n\t}\n\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(\"start = %lld, end = %lld\\n\", start, end);\n\t//printf(\"p = %lld, p1 = %lld, q = %lld, r = %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\", ans);\n\treturn 0;\n}\n\n\n\n\n\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "f9b4c7d82b850fe6b18dd5b697c3d10f", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \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", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "96fdb90ba10a70b0c223341c66807fa5", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define N 2000000\n#define MOD 1000000007\n\nint maxp[N + 1];\nint lcm[N + 1];\nint lcm_cnt[N + 1];\nint p[200000];\nint q[200000], qp;\n\nint max(int x, int y) {\n return x > y ? x : y;\n}\n\nint cmp(const void *a, const void *b) {\n return *(int *)b - *(int *)a;\n}\n\nint main(void) {\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 \n int n;\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &p[i]);\n }\n qsort(p, n, sizeof(int), cmp);\n int one = 0;\n for (int i = 0; i < n; i++) {\n int x = p[i];\n if (lcm[x] == 0) {\n lcm[x] = 1;\n continue;\n }\n q[qp++] = x;\n x--;\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 if (lcm[p] < e) {\n lcm[p] = e;\n lcm_cnt[p] = 1;\n } else if (lcm[p] == e) {\n lcm_cnt[p]++;\n }\n }\n }\n for (int i = 0; i < qp; i++) {\n int x = q[i] - 1;\n bool forall = true;\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 if (lcm[p] == e && lcm_cnt[p] == 1) {\n forall = false;\n }\n }\n if (forall) {\n one = 1;\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 ans += one;\n ans %= MOD;\n printf(\"%lld\\n\", ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "65209702ebb069f9b12dba74a4c2f5ad", "src_uid": "816a82bee65cf79ba8e4d61babcd0301", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint first(char s[],int len){\n int i,five=-5,two=-5;\n for(i=0;i5&&s[i+3]=='0'&&s[i+4]=='0')\n five-=4;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>4&&s[i+3]=='0')\n five-=3;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>3)\n five-=2;\n else if(i==0&&s[i+1]=='0')\n five--;\n }\n if(s[i]=='2'){\n two=i;\n if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>5&&s[i+3]=='0'&&s[i+4]=='0')\n two-=4;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>4&&s[i+3]=='0')\n two-=3;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>3)\n two-=2;\n else if(i==0&&s[i+1]=='0')\n two--;\n }\n }\n if(five==-5||two==-5)\n return -1;\n else if(two5&&s[i+3]=='0'&&s[i+4]=='0')\n five-=4;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>4&&s[i+3]=='0')\n five-=3;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>3)\n five-=2;\n else if(i==0&&s[i+1]=='0')\n five--;\n }\n if(s[i]=='7'){\n seven=i;\n if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>5&&s[i+3]=='0'&&s[i+4]=='0')\n seven-=4;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>4&&s[i+3]=='0')\n seven-=3;\n else if(i==0&&s[i+1]=='0'&&s[i+2]=='0'&&len>3)\n seven-=2;\n else if(i==0&&s[i+1]=='0')\n seven--;\n }\n }\n if(five==-5||seven==-5)\n return -1;\n else if(seven\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", "tags": ["brute force", "math", "combinatorics", "probabilities", "number theory"], "code_uid": "19b426f0f7a5f29a3da3e7da3db62a7e", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint gcd(int a, int b)\n{\n int t;\n while (b!=0) {\n t=a%b;\n a=b;\n b=t;\n }\n return a;\n}\n\nint main (void)\n{\n int n;\n int res=0;\n int i,j;\n scanf (\"%d\",&n);\n\n for (j=1;j \n#include\n#include\n#define REP(i,a,b) for(i=a;i= len[i]) if(ok_len + len[i] >= now_len){\n if(is_same(in[i], now+now_len-len[i], len[i])) match = 1;\n }\n\n next_word = 0; next_word_len = 0; next_ok_len = 0;\n if(match) fin = 1;\n \n rep(i,n) REP(j,1,len[i]){\n if(next_word_len >= j) continue;\n if(is_same(in[i],now+now_len-j,j)==0) continue;\n\n if(match) ok_chk = j;\n else ok_chk = ok_len - (now_len - j);\n\n if(ok_chk < 0) continue;\n\n fin = 1;\n next_word = i;\n next_word_len = j;\n next_ok_len = ok_chk;\n }\n\n if(fin==0){edge1[word][word_len][ok_len][k] = -1; continue;}\n edge1[word][word_len][ok_len][k] = next_word;\n edge2[word][word_len][ok_len][k] = next_word_len;\n edge3[word][word_len][ok_len][k] = next_ok_len;\n }\n}\n\nint solve(int depth, int word, int word_len, int ok_len){\n int i,j,k;\n int next_word, next_word_len, next_ok_len;\n int res = 0;\n\n if(dp[depth][word][word_len][ok_len] >= 0) return dp[depth][word][word_len][ok_len];\n if(depth==lim){\n if(word_len==ok_len) res++;\n return dp[depth][word][word_len][ok_len] = res;\n }\n\n rep(k,4){\n if(edge1[word][word_len][ok_len][k] < 0) continue;\n next_word = edge1[word][word_len][ok_len][k];\n next_word_len = edge2[word][word_len][ok_len][k];\n next_ok_len = edge3[word][word_len][ok_len][k];\n\n res += solve(depth+1, next_word, next_word_len, next_ok_len);\n res %= M;\n }\n\n return dp[depth][word][word_len][ok_len] = res;\n}\n\nint main(){\n int i,j,k,l,m,res;\n\n while(scanf(\"%d%d\",&lim,&n)==2){\n rep(i,n) scanf(\"%s\",in[i]);\n rep(i,n){\n for(j=0;;j++) if(in[i][j]<' ') break;\n len[i] = j;\n }\n\n rep(i,1011) rep(j,12) rep(k,12) rep(l,12) dp[i][j][k][l] = -1;\n edge_generator();\n\n res = solve(0,0,0,0);\n printf(\"%d\\n\",res);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "dp", "trees"], "code_uid": "fbb51822d8dbddfa5e4bf1f5aad294a4", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//\n// codeforces3.c\n// SPOJEMC\n//\n// Created by Nelson Isao Nauata Junior on 12/7/13.\n// Copyright (c) 2013 Nelson Isao Nauata Junior. All rights reserved.\n//\n\n#include \n#include \n\nlong long int min(long long int *vec){\n int i;\n long long int min;\n min = vec[0];\n for(i = 0; i < 3; i++){\n if(vec[i] < min && vec[i] != 0){\n min = vec[i];\n }\n }\n if(min == 0){\n return -1;\n }\n else{\n return min;\n } \n}\n\nint main(){\n char recipe[1000];\n long long int nb, ns, nc, i;\n int pb, ps, pc;\n long long int b, s, c, max;\n long long int inf, sup, r_linha, mid, total, r, ratio, r_b, r_c, r_s, vec[3], NB, NC, NS;\n \n scanf(\"%s\", recipe);\n scanf(\"%lld %lld %lld\", &nb, &ns, &nc);\n scanf(\"%d %d %d\", &pb, &ps, &pc);\n scanf(\"%lld\", &r);\n \n b= 0;\n s = 0;\n c = 0;\n for(i = 0; i < strlen(recipe); i++){\n if(recipe[i] == 'B'){\n b++;\n }\n else if(recipe[i] == 'C'){\n c++;\n }\n else{\n s++;\n }\n }\n \n \n if(b == 0){\n nb = 0;\n pb = 0;\n }\n if(c == 0){\n nc = 0;\n pc = 0;\n }\n if(s == 0){\n ns = 0;\n ps = 0;\n }\n total = 0;\n //printf(\"%lld %lld %lld\\n\", b, s, c);\n while(nb || ns || nc){\n nb -= b;\n ns -= s;\n nc -= c;\n if(nb <= 0){\n r += nb*pb;\n nb = 0;\n }\n if(ns <= 0){\n r += ns*ps;\n ns = 0;\n }\n if(nc <= 0){\n r += nc*pc;\n nc = 0;\n }\n //printf(\"%lld %lld %lld\\n\", nb, ns, nc);\n if(r <= 0){\n if(r == 0){\n total++;\n }\n //printf(\"%lld\\n\", r);\n break;\n }\n total++;\n } \n total += r/(s*ps + c*pc + b*pb);\n printf(\"%lld\\n\", total);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "binary search"], "code_uid": "4551fb137cfafdf21f92f257c43e9cb9", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nchar r[1 << 20];\n\nint box2mask(char b[5][5]) {\n\tint mask = 0, i, j, k = 0;\n\tfor (i = 0; i < 5; i++)\n\t\tfor (j = 0; j < 5-abs(2-i); j++) {\n\t\t\tif (b[i][j])\n\t\t\t\tmask |= 1 << k;\n\t\t\tk++;\n\t\t}\n\n\treturn mask;\n}\n\nint go(int mask) {\n\tif (r[mask] != -1)\n\t\treturn r[mask];\n\t\n\t// printf(\"mask = %d\\n\", mask);\n\n\tchar b[5][5];\n\tmemset(b, 0, sizeof(b));\n\n\tint i, j, k = 0;\n\tfor (i = 0; i < 5; i++)\n\t\tfor (j = 0; j < 5-abs(2-i); j++) {\n\t\t\tif (mask & (1 << k))\n\t\t\t\tb[i][j] = 1;\n\t\t\tk++;\n\t\t}\n\n\tchar bb[5][5];\n\tfor (i = 0; i < 5; i++)\n\t\tfor (j = 0; j < 5-abs(2-i); j++) {\n\t\t\tmemcpy(bb, b, sizeof(bb));\n\t\t\tint l;\n\t\t\tfor (k = i, l = j; k < 5 && l < 5-abs(2-k) && l >= 0 && bb[k][l]; k++) {\n\t\t\t\tbb[k][l] = 0;\n\t\t\t\tif (!go(box2mask(bb)))\n\t\t\t\t\treturn r[mask] = 1;\n\t\t\t\tif (k >= 2)\n\t\t\t\t\tl--;\n\t\t\t}\n\n\t\t\tmemcpy(bb, b, sizeof(bb));\n\t\t\tfor (k = i, l = j; k < 5 && l < 5-abs(2-k) && bb[k][l]; k++) {\n\t\t\t\tbb[k][l] = 0;\n\t\t\t\tif (!go(box2mask(bb)))\n\t\t\t\t\treturn r[mask] = 1;\n\t\t\t\tif (k < 2)\n\t\t\t\t\tl++;\n\t\t\t}\n\n\t\t\tmemcpy(bb, b, sizeof(bb));\n\t\t\tfor (k = j; k < 5-abs(2-i) && bb[i][k]; k++) {\n\t\t\t\tbb[i][k] = 0;\n\t\t\t\tif (!go(box2mask(bb)))\n\t\t\t\t\treturn r[mask] = 1;\n\t\t\t}\n\t\t}\n\t\n\treturn r[mask] = 0;\n}\n\nint main() {\n\tint i, mask = 0, j = 0;\n\tfor (i = 0; i < 5; i++) {\n\t\tchar s[100];\n\t\tgets(s);\n\n\t\tchar *t = s;\n\t\twhile (*t != '\\0') {\n\t\t\tif (*t == 'O')\n\t\t\t\tmask |= (1 << j);\n\t\t\tif (*t == 'O' || *t == '.')\n\t\t\t\tj++;\n\t\t\tt++;\n\t\t}\n\n\t}\n\t\n\tif (j != 19)\n\t\texit(1);\n\n\tmemset(r, -1, sizeof(r));\n\n\tif (go(mask))\n\t\tputs(\"Karlsson\");\n\telse\n\t\tputs(\"Lillebror\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "games", "dp", "bitmasks", "implementation"], "code_uid": "87ffa2a081e79e6f7014e4157aa014af", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \ntypedef long long ll;\n#define rep(i,n) for(ll i=0; i<(ll)(n); i++)\nconst ll MOD = 1000000007;\n\n/*nCk (mod MOD) BEGIN*/\n//faccal -> n!, k!^(MOD-2)()\n//comb -> nCk (mod MOD)\nll mlpow(ll x, ll p) { //(x^p) % MOD\n ll tmp = 1;\n if(p == 0) return 1;\n while(p != 0) {\n if(p & 1) tmp = tmp*x % MOD;\n x = x*x % MOD;\n p = p >> 1;\n }\n return tmp;\n}\n\n#define facnum 2000000\nll fac[facnum]; //n! (mod MOD)\nll facM2[facnum]; //(k!)^(MOD-2)\nvoid faccal(ll up) {\n fac[0] = 1;\n facM2[0] = 1;\n for(ll i = 0; i < up + 1; i++){\n fac[i+1] = fac[i] * (i+1) % MOD;\n facM2[i+1] = facM2[i] * mlpow(i+1, MOD-2) % MOD;\n }\n}\n\nint main() {\n int N;\n scanf(\"%d\", &N);\n\n \tfaccal(N);\n\tll ans = (fac[N] - mlpow(2, N-1) + MOD) % MOD;\n printf(\"%lld\\n\", ans);\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "graphs"], "code_uid": "3733632b26e8ba72029bc90df7e8d625", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n long long int i=0,n,count=0,temp,mod,M=1;\n scanf(\"%lld\",&n);\n while(1)\n {\n // printf(\"%lld\\n\", i);\n M=M*2;\n mod=n%M;\n temp=n/M;\n // printf(\"%lld %lld %lld\\n\",temp , mod,M);\n if(mod>M/2)\n count+=(M/2)*(temp+1);\n else{\n count+=(M/2)*(temp);\n }\n if(temp<=0)\n break;\n i++;\n }\n printf(\"%lld\\n\", count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "bitmasks", "graphs", "implementation"], "code_uid": "a7c8faaea19ea8bdf4482ed8c4acf808", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"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", "tags": ["math", "dp", "combinatorics"], "code_uid": "b3ca14a42473b1cc58b7d1d55af4b838", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MOD\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 % MOD;\n\tif (b % 2 == 1)\n\t\tp = (long long) p * a % MOD;\n\treturn p;\n}\n\nint inv(int x) {\n\treturn power(x, MOD - 2);\n}\n\nint fact(int n, int is_inv) {\n\treturn n == 0 ? 1\n\t\t: (long long) fact(n - 1, is_inv) * (is_inv ? inv(n) : n) % MOD;\n}\n\nint choose(int n, int k) {\n\treturn (long long) ((long long) fact(n, 0) * fact(k, 1) % MOD)\n\t\t* fact(n - k, 1) % MOD;\n}\n\nint main() {\n\tint n, m, k;\n\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tprintf(\"%lld\\n\", n - 1 < 2 * k || m - 1 < 2 * k ? 0\n\t\t\t: (long long) choose(n - 1, 2 * k) * choose(m - 1, 2 * k) % MOD);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "809b972451dac8538270610b1da72880", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define eps 1e-6\n\nint main(void)\n{\n\tint n, a, b, c;\n\tint i, j, k;\n\tint num = 0;\n\n\tscanf(\"%d%d%d%d\", &n, &a, &b, &c);\n\n\tfor (i = (n * 2 <= a ? n * 2 : a - a % 2); i >= 0; i -= 2)\n\tfor (j = (n - i / 2 <= b ? n - i / 2 : b); j >= 0; --j) {\n\t\t\tk = n - i / 2 - j;\n\t\t\tif (k % 2 == 0 && k <= c * 2)\n\t\t\t\tnum += 1;\n\t\t}\n\tprintf(\"%d\\n\", num);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "86fc2d3c45636a0744edeaa681ce668b", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint x[12][110][5];\nstruct sub{\n int p,n;\n}y[110];\nint cmp(const void *a,const void *b)\n{\n return ((struct sub *)a)->p-((struct sub *)b)->p;\n}\nint main()\n{\n int res=0,sum;\n int i,j,t,U;\n int n,m,k,K,L;\n char s[20];\n scanf(\"%d %d %d\",&n,&m,&K);\n for(t=1;t<=n;t++)\n {\n scanf(\"%s\",s);\n for(i=1;i<=m;i++)\n for(j=1;j<=3;j++)\n scanf(\"%d\",&x[t][i][j]);\n }\n res=0;\n for(i=1;i<=n;i++)\n for(j=1;j<=n;j++)\n {\n if(j==i)\n continue;\n for(k=1;k<=m;k++)\n {\n y[k].n=x[i][k][3];\n y[k].p=x[j][k][2]-x[i][k][1];\n }\n qsort(y+1,m,sizeof(y[0]),cmp);\n t=m;\n k=K;\n sum=0;\n while(k>0&&t>0&&y[t].p>0)\n {\n if(y[t].n<=k)\n {\n k-=y[t].n;\n sum+=y[t].n*y[t].p;\n }\n else if(y[t].n>k)\n {\n sum+=y[t].p*k;\n k=0;\n }\n t--;\n }\n if(sum>res)\n res=sum;\n }\n printf(\"%d\\n\",res);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "games", "graph matchings"], "code_uid": "ef3c30a00f1c19a3bbc99188ab2ca7db", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t100\n#define X\t100\n#define MD\t1000000007\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 main() {\n\tstatic int ff[X + 1], ds[X + 1][N][N + 1], dp[X + 1][N], dq[X + 1][N], dr[X + 1];\n\tstatic char cc[N + 1];\n\tint n, x, i, l, r, m;\n\n\tscanf(\"%d%d%s\", &n, &x, cc);\n\tif (x == 0) {\n\t\tprintf(\"%d\\n\", n == 1 && cc[0] == '0');\n\t\treturn 0;\n\t}\n\tff[0] = ff[1] = 1;\n\tfor (i = 2; i <= x; i++)\n\t\tff[i] = (ff[i - 1] + ff[i - 2]) % (MD - 1);\n\tfor (i = 0; i <= x; i++)\n\t\tff[i] = power(2, ff[i]);\n\tfor (l = 0; l < n; l++) {\n\t\tds[0][l][l] = ds[1][l][l] = 1;\n\t\tds[0][l][l + 1] = cc[l] == '0' ? 1 : 0;\n\t\tds[1][l][l + 1] = cc[l] == '1' ? 1 : 0;\n\t}\n\tfor (i = 2; i <= x; i++)\n\t\tfor (l = 0; l < n; l++)\n\t\t\tfor (r = l; r < n; r++) {\n\t\t\t\tlong long z = 0;\n\n\t\t\t\tfor (m = l; m <= r; m++)\n\t\t\t\t\tz = (z + (long long) ds[i - 1][l][m] * ds[i - 2][m][r]) % MD;\n\t\t\t\tds[i][l][r] = z;\n\t\t\t}\n\tif (n > 1) {\n\t\tdp[0][n - 1] = ds[0][n - 1][n];\n\t\tdp[1][n - 1] = ds[1][n - 1][n];\n\t\tfor (i = 2; i <= x; i++)\n\t\t\tfor (l = 1; l < n; l++) {\n\t\t\t\tlong long z = (long long) dp[i - 1][l] * ff[i - 2] % MD;\n\n\t\t\t\tfor (m = l; m < n; m++)\n\t\t\t\t\tz = (z + (long long) ds[i - 1][l][m] * dp[i - 2][m]) % MD;\n\t\t\t\tdp[i][l] = z;\n\t\t\t}\n\t\tdq[0][1] = ds[0][0][1];\n\t\tdq[1][1] = ds[1][0][1];\n\t\tfor (i = 2; i <= x; i++)\n\t\t\tfor (r = 1; r < n; r++) {\n\t\t\t\tlong long z = (long long) ff[i - 1] * dq[i - 2][r] % MD;\n\n\t\t\t\tfor (m = r; m > 0; m--)\n\t\t\t\t\tz = (z + (long long) dq[i - 1][m] * ds[i - 2][m][r]) % MD;\n\t\t\t\tdq[i][r] = z;\n\t\t\t}\n\t}\n\tdr[0] = ds[0][0][n];\n\tdr[1] = ds[1][0][n];\n\tfor (i = 2; i <= x; i++) {\n\t\tlong long z = ((long long) dr[i - 1] * ff[i - 2] + (long long) ff[i - 1] * dr[i - 2]) % MD;\n\n\t\tfor (m = 1; m < n; m++)\n\t\t\tz = (z + (long long) dq[i - 1][m] * dp[i - 2][m]) % MD;\n\t\tdr[i] = z;\n\t}\n\tprintf(\"%d\\n\", dr[x]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["matrices", "dp", "combinatorics"], "code_uid": "b2823626c78a06f78db16578e8fe2bd1", "src_uid": "52c6aa73ff4460799402c646c6263630", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint x[100] = {0};\nint cmp(const void *a,const void *b)\n{\n return *( int *)a - *( int *)b;\n}\nint main()\n{\n int n,i,c=0;\n scanf(\"%d\",&n);\n for(i=0; i\r\n\r\nint main()\r\n{\r\n int t;\r\n scanf(\"%d\", &t);\r\n while (t--)\r\n {\r\n int n, m, k1;\r\n scanf(\"%d%d%d\", &n, &m, &k1);\r\n int k2 = n * m / 2 - k1;\r\n if (m % 2 == 1)\r\n {\r\n k2 -= n / 2;\r\n if (k2 < 0)\r\n {\r\n puts(\"NO\");\r\n continue;\r\n }\r\n }\r\n else if (n % 2 == 1)\r\n {\r\n k1 -= m / 2;\r\n if (k1 < 0)\r\n {\r\n puts(\"NO\");\r\n continue;\r\n }\r\n }\r\n if (k1 * k2 % 2 != 0)\r\n puts(\"NO\");\r\n else\r\n puts(\"YES\");\r\n }\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "67c8684e4ebb357ea3dcec1162c83364", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n\r\n#define cL while (getchar() != '\\n') //clear line\r\n#define fi(x) for (i = 0; i < x; i++)\r\n#define fj(x) for (j = 0; j < x; j++)\r\n#define FOR(a, b, c) for (int(a) = (b); (b) < (c) ? (a) <= (c) : (a) >= (c); (b) < (c) ? (a)++ : (a)--)\r\n#define LL long long\r\n#define min(a, b) (a > b ? b : a)\r\n#define max(a, b) (a < b ? b : a)\r\n#define pf printf\r\n#define sf scanf\r\n\r\nint main() {\r\n LL i, j;\r\n scanf(\"%lld%lld\", &i, &j);\r\n char a[2000], b[2000];\r\n memset(b, 0, sizeof(b));\r\n memset(a, 0, sizeof(a));\r\n LL p1 = 0, p2 = 0, k = 0, a1 = i, a2 = j;\r\n if (i == j) {\r\n printf(\"YES\");\r\n return 0;\r\n }\r\n if (i == 0 || j % 2 == 0) {\r\n printf(\"NO\");\r\n return 0;\r\n }\r\n while (i) {\r\n a[++p1] = i % 2 + 97, k -= i % 2;\r\n i /= 2;\r\n }\r\n while (j) {\r\n b[++p2] = j % 2 + 97, k += j % 2;\r\n j /= 2;\r\n }\r\n int k1 = strstr(b + 1, a + 1);\r\n if (k1) {\r\n if (p2 - p1 == k) {\r\n printf(\"YES\");\r\n return 0;\r\n }\r\n }\r\n FOR(i, 1, p1 / 2) {\r\n char tmp;\r\n tmp = a[i], a[i] = a[p1 + 1 - i], a[p1 + 1 - i] = tmp;\r\n }\r\n k1 = strstr(b + 1, a + 1);\r\n if (k1) {\r\n if (p2 - p1 == k) {\r\n printf(\"YES\");\r\n return 0;\r\n }\r\n }\r\n\r\n p1 = 0, p2 = 0, k = 0;\r\n i = a1, j = a2;\r\n memset(b, 0, sizeof(b));\r\n memset(a, 0, sizeof(a));\r\n\r\n while (i % 2 == 0)\r\n i /= 2;\r\n while (i) {\r\n a[++p1] = i % 2 + 97, k -= i % 2;\r\n i /= 2;\r\n }\r\n while (j) {\r\n b[++p2] = j % 2 + 97, k += j % 2;\r\n j /= 2;\r\n }\r\n k1 = strstr(b + 1, a + 1);\r\n if (k1) {\r\n if (p2 - p1 == k) {\r\n printf(\"YES\");\r\n return 0;\r\n }\r\n }\r\n FOR(i, 1, p1 / 2) {\r\n char tmp;\r\n tmp = a[i], a[i] = a[p1 + 1 - i], a[p1 + 1 - i] = tmp;\r\n }\r\n k1 = strstr(b + 1, a + 1);\r\n if (k1) {\r\n if (p2 - p1 == k) {\r\n printf(\"YES\");\r\n return 0;\r\n }\r\n }\r\n printf(\"NO\");\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "278d7e93d5f35703d3e7ea413c679588", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n unsigned long long n, x, y;\n unsigned long nl, xl, yl;\n\n fscanf(stdin, \"%ld %ld %ld\", &nl, &xl, &yl);\n\n n = (unsigned long long)nl;\n x = (unsigned long long)xl;\n y = (unsigned long long)yl;\n\n unsigned long long* f = malloc(10000001*sizeof(unsigned long long));\n\n f[1] = x;\n f[2] = x < y? x + f[1] : y + f[1];\n\n unsigned long long k;\n\n for (unsigned long long m = 3; m < n+1; m++)\n {\n k = (m+1)/2;\n if (m % 2 == 1)\n f[2*k-1] = f[k]+y+x < f[2*k-2]+x ? f[k]+y+x : f[2*k-2]+x;\n else\n f[2*k] = f[k]+y < f[2*k-2]+2*x ? f[k]+y : f[2*k-2]+2*x;\n }\n unsigned long pref = f[n] / 1000000000Lu;\n unsigned long rest = f[n] % 1000000000Lu;\n int digs = 9;\n int pow10 = 100000000Lu;\n while (digs > 1)\n {\n if (rest >= pow10)\n break;\n pow10 /= 10;\n digs = digs-1;\n }\n if (pref > 0)\n {\n if (9-digs == 0)\n printf(\"%lu%lu\\n\", pref, rest);\n else\n {\n char* zeros = malloc((9-digs+1)*sizeof(char));\n for (int i = 0; i < 9-digs; i++) zeros[i] = '0';\n zeros[9-digs] = 0;\n printf(\"%lu%s%lu\\n\", pref, zeros, rest);\n }\n }\n else\n printf(\"%lu\\n\", rest);\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "dp"], "code_uid": "71b8c989051c5d4dfb393b5f422038eb", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint ***sol;\nint N, K;\nconst int kInvalidSol = -10000;\nvoid new_sol() {\n\tsol = (int***)malloc(sizeof(int**) * (N + 1));\n\tfor (int n = 0; n <= N; ++n) {\n\t\tsol[n] = (int**)malloc(sizeof(int*) * (K + 1));\n\t\tfor (int k = 0; k <= K; ++k) {\n\t\t\tsol[n][k] = (int*)malloc(sizeof(int) * (N + 1));\n\t\t\tfor (int i = 0; i <= N; ++i) {\n\t\t\t\tsol[n][k][i] = kInvalidSol;\n\t\t\t}\n\t\t}\n\t}\n}\nvoid free_sol() {\n\tfor (int i = 0; i <= N; ++i) {\n\t\tfor (int j = 0; j <= K; ++j) {\n\t\t\tfree(sol[i][j]);\n\t\t}\n\t\tfree(sol[i]);\n\t}\n\tfree(sol);\n}\nvoid try_update_sol(int n, int k, int i, int value) {\n\tif (value >= 0 && sol[n][k][i] < value) {\n\t\tsol[n][k][i] = value;\n\t}\n}\nint imax(int a, int b) {\n\treturn a < b? b: a;\n}\nint main() {\n\tchar s[201], t[3];\n\tscanf(\"%d%d\\n%s\\n%s\", &N, &K, s, t);\n\t// printf(\"%s\\t%s\\n\", s, t);\n\tnew_sol();\n\tif (t[0] == t[1]) {\n\t\tint cc = 0;\n\t\tfor (int i = 0; i < N; ++i) {\n\t\t\tif (s[i] == t[0]) {\n\t\t\t\t++cc;\n\t\t\t}\n\t\t}\n\t\tcc += K;\n\t\tif (cc > N) {\n\t\t\tcc = N;\n\t\t}\n\t\tprintf(\"%d\\n\", cc * (cc - 1) / 2);\n\t} else {\n\t\t{\n\t\t\tint cc = 0;\n\t\t\tsol[0][0][0] = 0;\n\t\t\tfor (int n = 1; n <= N; ++n) {\n\t\t\t\tif (s[n - 1] == t[0]) {\n\t\t\t\t\t++cc;\n\t\t\t\t\tif (cc == 1) {\n\t\t\t\t\t\tsol[n][0][1] = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry_update_sol(n, 0, cc, sol[n - 1][0][cc - 1]);\n\t\t\t\t\t}\n\t\t\t\t} else if (s[n - 1] == t[1]) {\n\t\t\t\t\ttry_update_sol(n, 0, cc, sol[n - 1][0][cc] + cc);\n\t\t\t\t} else {\n\t\t\t\t\ttry_update_sol(n, 0, cc, sol[n - 1][0][cc]);\n\t\t\t\t}\n\t\t\t\tfor (int k = cc; k <= K; ++k) {\n\t\t\t\t\ttry_update_sol(n, k, 0, 0);\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t}\n\t\t// printf(\"sol k = 0\\n\");\n\t\t// for (int n = 1; n <= N; ++n) {\n\t\t// \tfor (int i = 1; i <= n; ++i) {\n\t\t// \t\tprintf(\"%d\\t\", sol[n][0][i]);\n\t\t// \t}\n\t\t// \tprintf(\"\\n\");\n\t\t// }\n\t\t// for (int k = 1; k <= K; ++k) {\n\t\t// \tsol[1][k][1] = 0;\n\t\t// \tint cc = s[0] == t[0]? 1: 0;\n\t\t// \tfor (int n = 2; n <= N; ++n) {\n\t\t// \t\ttry_update_sol(n, k, 1, sol[n][k-1][1]);\n\t\t// \t\tif (s[n - 1] == t[0]) {\n\t\t// \t\t\t++cc;\n\t\t// \t\t\ttry_update_sol(n, k, 1, sol[n - 1][k - 1][1] + 1);\n\t\t// \t\t} else if (s[n - 1] == t[1]) {\n\t\t// \t\t\ttry_update_sol(n, k, 1, sol[n - 1][k][1] + 1);\n\t\t// \t\t} else {\n\t\t// \t\t\ttry_update_sol(n, k, 1, sol[n - 1][k][1]);\t\t\t\t\t\n\t\t// \t\t\ttry_update_sol(n, k, 1, sol[n - 1][k - 1][1] + 1);\n\t\t// \t\t}\n\t\t// \t}\n\t\t// }\n\t\t// printf(\"sol with i = 1\\n\");\n\t\t// for (int n = 1; n <= N; ++n) {\n\t\t// \tfor (int k = 0; k <= K; ++k) {\n\t\t// \t\tprintf(\"%d\\t\", sol[n][k][1]);\n\t\t// \t}\n\t\t// \tprintf(\"\\n\");\n\t\t// }\n\t\tfor (int k = 1; k <= K; ++k) {\n\t\t\ttry_update_sol(1, k, 1, 0);\n\t\t\tfor (int n = 2; n <= N; ++n) {\n\t\t\t\tfor (int i = 1; i <= n; ++i) {\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n][k - 1][i]);\n\t\t\t\t\tif (s[n - 1] == t[0]) {\n\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k][i - 1]);\n\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);\n\t\t\t\t\t} else if (s[n - 1] == t[1]) {\n\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k][i] + i);\n\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);\n\t\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);\n\t\t\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k][i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// printf(\"sol k = %d\\n\", k);\n\t\t\t// for (int n = 1; n <= N; ++n) {\n\t\t\t// \tfor (int i = 1; i <= n; ++i) {\n\t\t\t// \t\tprintf(\"%d\\t\", sol[n][k][i]);\n\t\t\t// \t}\n\t\t\t// \tprintf(\"\\n\");\n\t\t\t// }\n\t\t}\t\t\n\t\tint max = 0;\n\t\tfor (int i = 1; i <= N; ++i) {\n\t\t\tif (sol[N][K][i] > max) {\n\t\t\t\tmax = sol[N][K][i];\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\", max);\n\t\tfree_sol();\n\t}\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["strings", "dp"], "code_uid": "8d5bd2b806f0e45104cbdc4f5edb480a", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i b){\n puts(\"DRAW\");\n continue;\n }\n\n if(stone > b && fgg){\n puts(\"DRAW\");\n continue;\n }\n\n stone -= mod;\n puts(\"FIRST\");\n if(fg==0) printf(\"%d\\n\",x2-stone);\n else printf(\"%d\\n\",x2+stone);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "0d6c72f94aa66dcf8b6165c20343aa33", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\ntypedef long long int LLI;\n\n\n\n#define TRUE (1==1)\n#define FALSE (!TRUE)\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#define in1(n) scanf(\"%d\",&(n))\n#define LL1(n) scanf(\"%I64d\",&(n))\n#define in2(n,m) scanf(\"%d%d\",&(n),&(m))\n#define pri(n) printf(\"%d\\n\",n)\n#define prs(n) printf(\"%s\\n\",n)\n#define prL(n) printf(\"%I64d\\n\",n)\n#define strin(n) scanf(\"%s\",n)\n#define newint(n) (int*)calloc((n),sizeof(int))\n#define arrint(ret,n,i) fo3(i,1,n) in1(ret[i-1])\n#define newLLI(n) (LLI*)calloc((n),sizeof(LLI))\n#define arrLLI(ret,n,i) fo3(i,1,n) LL1(ret[i-1])\n\nvoid fastWrite(FILE * ofp, int x) {\n int i = 12;\n char buff[i];\n buff[i] = 0;\n int neg = 0;\n if (x < 0){\n x = -x;\n neg = 1;\n }\n if (x == 0)\n buff[--i] = '0';\n else while (x != 0) {\n buff[--i] = (x % 10) + '0';\n x /= 10;\n }\n if (neg)\n buff[--i] = '-';\n fwrite(buff + i, sizeof(char), (12 - i), ofp);\n}\n\nvoid fastSpace(FILE * ofp){\n fwrite(\" \", sizeof(char), 1, ofp);\n}\nvoid fastNewLine(FILE * ofp) {\n fwrite(\"\\n\", sizeof(char), 1, ofp);\n}\n\ntypedef struct AL AL;\nstruct AL{\n int * vals;\n int size;\n int cap;\n};\nAL * ALCreate(int s) {\n AL * ret = (AL *) calloc(1, sizeof(AL));\n if (s == 0) ret->vals = NULL;\n else ret->vals = (int *) calloc(s, sizeof(int));\n ret->size = 0; ret->cap = s;\n return ret;\n}\nvoid ALAdd(AL * list, int ele) {\n if (list->cap == list->size) {\n int nC = ((list->cap << 1) | 1);\n list->vals = realloc(list->vals, sizeof(int) * nC);\n list->cap = nC;\n }\n list->vals[list->size++] = ele;\n}\n\n\ntypedef struct Pair {\n int fi, se;\n} Pair;\n\nint comp(Pair ** arr, int f, int s) {// CHANGE THIS\n if (arr[f]->fi - arr[f]->se != arr[s]->fi - arr[s]->se)\n return (arr[s]->fi - arr[s]->se) - (arr[f]->fi - arr[f]->se);\n return 0;\n}\n\nvoid sort(Pair ** arr, int size) { \n int i;\n if (size < 6) {\n int nSize = 0;\n Pair * swp;\n while (size != 0) {\n nSize = 0;\n for (i = 0; i < size - 1; i++) \n if (comp(arr, i, i + 1) > 0) { \n nSize = i + 1;\n swp = arr[i];\n arr[i] = arr[i + 1];\n arr[i + 1] = swp;\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, lSize + rPtr) <= 0){ // CHANGE THIS\n tmp[ptr] = arr[lPtr++];\n } else {\n tmp[ptr] = arr[lSize + (rPtr++)];\n }\n ptr++;\n }\n for (i = 0; i < size; i++)\n arr[i] = tmp[i];\n free(tmp);\n}\n\nint bc(int x) {\n if (x <= 1)\n return x;\n return (x&1) + bc(x>>1);\n}\n\nint gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}\n\n#define MAX 100000\n#define NULL_CARRY -1\n#define NULL_VALUE 0\n\nLLI h1, h2;\n\nint carry[4 * MAX];\nint st[4 * MAX];\nint en[4 * MAX];\nLLI ans[2][4 * MAX];\n\n\nvoid init2(int index, int s, int e) {\n //printf(\"%d %d %d\\n\", index, s, e);\n st[index] = s;\n en[index] = e;\n ans[0][index] = 0;\n ans[1][index] = 0;\n carry[index] = NULL_CARRY;\n if (s == e)\n return;\n int mid = (s + e) >> 1;\n init2(index << 1, s, mid);\n init2((index << 1) | 1, mid + 1, e);\n}\n\n// Inclusive s and e\nvoid ITInit(int s, int e) {\n init2(1, s, e);\n}\n\nLLI fastExpo(LLI exp, LLI base, LLI mod) {\n if (exp == 0)\n return 1;\n if (exp == 1)\n return base % mod;\n LLI tmp = fastExpo(exp >> 1, base, mod);\n tmp *= tmp;\n tmp %= mod; \n if (exp & 1)\n tmp = (tmp * base) % mod;\n return tmp;\n}\n\n\nLLI aoMem[2][MAX + 10];\nLLI feMem[2][MAX + 10];\nvoid genAllOnes() {\n int i;\n LLI tmp1 = 0;\n LLI tmp2 = 0;\n LLI tmp3 = 1;\n LLI tmp4 = 1;\n fo3(i,0, MAX+9) {\n aoMem[TRUE][i] = tmp1;\n tmp1 = tmp1 * 10 + 1;\n tmp1 %= h1;\n aoMem[FALSE][i] = tmp2;\n tmp2 = tmp2 * 10 + 1;\n tmp2 %= h2;\n feMem[TRUE][i] = tmp3;\n tmp3 *= 10;\n tmp3 %= h1;\n feMem[FALSE][i] = tmp4;\n tmp4 *= 10;\n tmp4 %= h2;\n }\n}\nLLI allOnes(int len, LLI mod) {\n return aoMem[mod==h1][len];\n}\n\nLLI agg(int pre, int suf, int pow, LLI mod) {\n LLI mult = feMem[mod==h1][pow];\n mult *= suf;\n mult += pre;\n mult %= mod;\n //printf(\" returning from agg!\\n\");\n return mult;\n}\n\nvoid ITComp(int index) {\n if (carry[index] == NULL_CARRY) {\n ans[0][index] = agg(ans[0][index<<1], ans[0][(index<<1)|1], en[index<<1] - st[index<<1] + 1, h1);\n ans[1][index] = agg(ans[1][index<<1], ans[1][(index<<1)|1], en[index<<1] - st[index<<1] + 1, h2);\n } else {\n ans[0][index] = allOnes(en[index] - st[index] + 1, h1) * carry[index];\n ans[0][index] %= h1;\n ans[1][index] = allOnes(en[index] - st[index] + 1, h2) * carry[index];\n ans[1][index] %= h2;\n }\n}\n\nvoid push(int index) {\n if (carry[index] == NULL_CARRY)\n return;\n if (st[index] != en[index]) {\n carry[index<<1] = carry[index];\n ITComp(index<<1);\n carry[(index<<1)|1] = carry[index];\n ITComp((index<<1)|1);\n }\n carry[index] = NULL_CARRY;\n}\n\n\nvoid set2(int index, int s, int e, int value) {\n if (st[index] >= s && e >= en[index]) {\n carry[index] = value;\n ITComp(index);\n return;\n }\n if (st[index] > e || s > en[index])\n return;\n push(index);\n set2(index<<1, s, e, value);\n set2((index<<1)|1, s, e, value);\n ITComp(index);\n}\n\nvoid ITSet(int s, int e, int value) {\n set2(1, s, e, value);\n}\n\nLLI get2(int index, int type, int s, int e) {\n if (st[index] >= s && e >= en[index]) {\n //printf(\" Starting Push!\\n\");\n //push(index);\n ITComp(index);\n //printf(\" Out of Push!\\n\");\n if (type == 0) {\n //prL(agg(0, ans[type][index], st[index] - s, h1));\n return agg(0, ans[type][index], st[index] - s, h1);\n } \n return agg(0, ans[type][index], st[index] - s, h2);\n }\n if (st[index] > e || s > en[index])\n return NULL_VALUE;\n push(index);\n LLI ret = get2(index<<1, type, s, e) + get2((index<<1)|1, type, s, e);\n if (type == 0 && ret >= h1)\n ret -= h1;\n if (type == 1 && ret >= h2)\n ret -= h2;\n return ret;\n}\n\nLLI get(int type, int s, int e) {\n return get2(1, type, s, e);\n}\n\n#define MOD 1000000007\n\nLLI ch2(int x) {\n return (x * (x - 1)) >> 1;\n}\n\nvoid make(int n, int spots, LLI ** mat) {\n int i, j;\n int totalSmaller = spots - 1;\n int totalBigger = n - totalSmaller;\n LLI total = ch2(n);\n fo3(i,0,spots-1) {\n fo3(j,0,spots-1) {\n int smallerCorrect = i;\n int smallerIncorrect = totalSmaller - smallerCorrect;\n int biggerIncorrect = smallerIncorrect;\n int biggerCorrect = totalBigger - biggerIncorrect;\n if (i + 1 < j || j + 1 < i)\n mat[i][j] = 0;\n else if (i == j) {\n mat[i][j] = (total - (smallerCorrect * biggerCorrect + smallerIncorrect * biggerIncorrect)) % MOD;\n } else if (j < i) {\n // Worse\n mat[i][j] = (smallerCorrect * biggerCorrect) % MOD; \n } else {\n // Better\n mat[i][j] = (smallerIncorrect * biggerIncorrect) % MOD; \n }\n }\n }\n}\n\nLLI ** ident;\n\n\n\nvoid clean2(LLI ** mat, int dim) { \n int i;\n fo3(i,0,dim-1)\n free(mat[i]);\n free(mat);\n}\n\nLLI ** mult(LLI ** a, LLI ** b, int dim) {\n LLI ** ret;\n int i, j, k;\n ret = calloc(dim, sizeof(LLI*));\n fo3(i,0,dim-1){\n ret[i] = calloc(dim, sizeof(LLI));\n fo3(j,0,dim-1){\n ret[i][j] = 0;\n fo3(k,0,dim-1) {\n ret[i][j] += (a[i][k] * b[k][j]) % MOD;\n }\n ret[i][j] %= MOD;\n }\n }\n return ret;\n}\n\nLLI ** expo(LLI ** base, int pow, int dim) {\n if (pow == 0) {\n return mult(ident, ident, dim);\n }\n if (pow == 1) {\n return mult(ident, base, dim);\n }\n LLI ** tmp = expo(base, pow >> 1, dim);\n LLI ** tmp2 = mult(tmp, tmp, dim);\n clean2(tmp, dim);\n if (pow&1) {\n tmp = mult(tmp2, base, dim);\n clean2(tmp2, dim);\n tmp2 = tmp;\n }\n return tmp2;\n}\n\nLLI expo2(LLI base, int pow) {\n if (pow == 0)\n return 1;\n if (pow == 1)\n return base % MOD;\n LLI tmp = expo2(base, pow>>1);\n tmp *= tmp;\n tmp %= MOD;\n if (pow&1) {\n tmp *= base;\n tmp %= MOD;\n }\n return tmp;\n}\n\n\nLLI inv(LLI val) {\n if (val == 1)\n return 1;\n return MOD - ((MOD / val) * inv(MOD % val)) % MOD;\n}\n\nint main(void) {\n LLI ** orig;\n int len, pow, i, j;\n in2(len, pow);\n int arr[len];\n int cs[2];\n cs[0] = 0;\n cs[1] = 0;\n \n fo3(i,1,len) {\n in1(arr[i-1]);\n cs[arr[i-1]]++;\n }\n int dim = cs[0] + 1;\n if (cs[1] < cs[0])\n dim = cs[1] + 1;\n orig = calloc(dim, sizeof(LLI*));\n fo3(i,0,dim-1)\n orig[i] = calloc(dim, sizeof(LLI));\n ident = calloc(dim, sizeof(LLI*));\n fo3(i,0,dim-1){\n ident[i] = calloc(dim, sizeof(LLI));\n fo3(j,0,dim-1)\n ident[i][j] = ((i==j) ? 1 : 0);\n }\n make(len, dim, orig);\n \n LLI ** ret = expo(orig, pow, dim);\n clean2(orig, dim);\n int wrong = 0;\n fo3(i,0,cs[0]-1)\n if (arr[i]!=0)\n wrong++;\n int cor = dim - wrong - 1;\n LLI ans = ret[cor][dim - 1];\n clean2(ret, dim);\n LLI den = expo2(ch2(len), pow);\n //prL(ans);\n //prL(den);\n ans *= inv(den);\n ans %= MOD;\n prL(ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["probabilities", "matrices", "dp", "combinatorics"], "code_uid": "971ec59818e78a4046f839c0e968c9b3", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"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", "tags": ["greedy", "dp", "games"], "code_uid": "d6624135180134ad303c18a992bf8632", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define L\t19\n#define MD\t1000000007\n\nint main() {\n\tstatic int dp[L + 1], dq[L + 1], dp0[L], dq0[L], dp1[L], dq1[L];\n\tint n, i, j, kj, kj_, l, ans;\n\n\tscanf(\"%d\", &n);\n\tl = 0;\n\twhile (1 << (l + 1) <= n)\n\t\tl++;\n\tans = 0;\n\tdp[l] = 1;\n\tfor (i = 1; i < n; i++) {\n\t\tfor (j = 0; j <= l; j++)\n\t\t\tif (dp[j]) {\n\t\t\t\tkj = n >> j;\n\t\t\t\tdq[j] = (dq[j] + (long long) dp[j] * ((n >> j) - i)) % MD;\n\t\t\t\tif (j > 0) {\n\t\t\t\t\tkj_ = n >> (j - 1);\n\t\t\t\t\tdq[j - 1] = (dq[j - 1] + (long long) dp[j] * (kj_ - kj)) % MD;\n\t\t\t\t}\n\t\t\t}\n\t\tfor (j = 0; j <= l; j++)\n\t\t\tdp[j] = dq[j], dq[j] = 0;\n\t}\n\tans = (ans + dp[0]) % MD;\n\tif ((1 << (l - 1)) * 3 <= n) {\n\t\tdp1[l - 1] = 1;\n\t\tfor (i = 1; i < n; i++) {\n\t\t\tfor (j = 0; j < l; j++) {\n\t\t\t\tif (dp0[j]) {\n\t\t\t\t\tkj = n >> j;\n\t\t\t\t\tdq0[j] = (dq0[j] + (long long) dp0[j] * (kj - i)) % MD;\n\t\t\t\t\tif (j > 0) {\n\t\t\t\t\t\tkj_ = n >> (j - 1);\n\t\t\t\t\t\tdq0[j - 1] = (dq0[j - 1] + (long long) dp0[j] * (kj_ - kj)) % MD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (dp1[j]) {\n\t\t\t\t\tkj = (n >> j) / 3;\n\t\t\t\t\tdq1[j] = (dq1[j] + (long long) dp1[j] * (kj - i)) % MD;\n\t\t\t\t\tif (j > 0) {\n\t\t\t\t\t\tkj_ = (n >> (j - 1)) / 3;\n\t\t\t\t\t\tdq1[j - 1] = (dq1[j - 1] + (long long) dp1[j] * (kj_ - kj)) % MD;\n\t\t\t\t\t}\n\t\t\t\t\tkj_ = n >> j;\n\t\t\t\t\tdq0[j] = (dq0[j] + (long long) dp1[j] * (kj_ - kj)) % MD;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (j = 0; j < l; j++) {\n\t\t\t\tdp0[j] = dq0[j], dq0[j] = 0;\n\t\t\t\tdp1[j] = dq1[j], dq1[j] = 0;\n\t\t\t}\n\t\t}\n\t\tans = (ans + dp0[0]) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "4989d998ca1923062bad5283c3d9a2f1", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \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\nlong long lucky(int i) {\n\treturn i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);\n}\n\nint main() {\n\tstatic long long aa[2047];\n\tint l, r, i;\n\tlong long x, y, ans;\n\n\tscanf(\"%d%d\", &l, &r);\n\taa[0] = 4;\n\tfor (i = 1; i < 2047; i++)\n\t\taa[i] = lucky(i + 1);\n\tans = 0;\n\tfor (i = 0; i < 2047; i++) {\n\t\tx = max(aa[i - 1] + 1, l);\n\t\ty = min(aa[i], r);\n\t\tif (x <= y)\n\t\t\tans += (y - x + 1) * aa[i];\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fa3e2118bb6c8870cacd3850cdd9670f", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint asc(const void* a, const void* b)\n{\n\treturn *(int*)a - *(int*)b;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint i;\n\tint x[50], y[50];\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t\tscanf(\"%d %d\", &x[i], &y[i]);\n\tint xx[50], yy[50];\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t\txx[i] = x[i];\n\tqsort(xx, 4 * n + 1, sizeof(int), asc);\n\tif (xx[0] != xx[1])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (x[i] == xx[0])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tif (xx[4 * n - 1] != xx[4 * n])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (x[i] == xx[4 * n])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t\tyy[i] = y[i];\n\tqsort(yy, 4 * n + 1, sizeof(int), asc);\n\tif (yy[0] != yy[1])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (y[i] == yy[0])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tif (yy[4 * n - 1] != yy[4 * n])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (y[i] == yy[4 * n])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tint maxx, minx, maxy, miny;\n\tmaxx = maxy = 0;\n\tminx = miny = 100;\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t{\n\t\tif (x[i] < minx)minx = x[i];\n\t\tif (x[i] > maxx)maxx = x[i];\n\t\tif (y[i] < miny)miny = y[i];\n\t\tif (y[i] > maxy)maxy = y[i];\n\t}\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t{\n\t\tif (x[i] != minx && x[i] != maxx && y[i] != miny && y[i] != maxy)\n\t\t{\n\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\treturn 0;\n\t\t}\n\t}\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9bc35f4f02ed3078a1ca71967b9ea4eb", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define max(a,b) (ab?b:a)\ntypedef unsigned long long u64;\n\nint N, K;\nchar s[101];\nu64 n[101][26], l[101][26], t[101];\n\nint main() {\n int i,j, k;\n\n scanf(\"%d %d\", &N, &K);\n scanf(\"%s\", s);\n\n n[0][0] = 1;\n t[0] = 1;\n for (i = 1; i <= N; i++) {\n int c = s[i-1] - 'a';\n for (j = i; j >= 1; j--) {\n u64 d = 0;\n for (k = 0; k < 26; k++)\n d += n[j-1][k];\n d -= l[j][c];\n n[j][c] += d;\n l[j][c] = n[j][c];\n\n t[j] += d;\n }\n }\n\n u64 cost = 0;\n u64 r = K;\n for (i = N; i >= 0 && r; i--) {\n u64 a = min(r, t[i]);\n cost += a * (N - i);\n r -= a;\n }\n printf(\"%lld\\n\", !r?cost:-1);\n\n return 0;\n}", "lang_cluster": "C", "tags": ["dp", "implementation", "graphs", "shortest paths"], "code_uid": "fb351db2f85721f6db995525e688f74a", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"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", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "afee3ef5eae57d6b54042f7850822abc", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int n, x, pos;\n scanf(\"%d%d%d\", &n, &x, &pos);\n\n long long low = 0, high = n, result = 1,countSmall = 0, countLarge = 0;\n long long MOD = 1e9 + 7;\n\n while(low\n\n#define N\t3000\n#define M\t3000\n\nvoid slide(int *aa, int *bb, int n, int m) {\n\tstatic int qq[N];\n\tint i, head, cnt;\n\n\thead = cnt = 0;\n\tfor (i = 0; i < n; i++) {\n\t\twhile (cnt && aa[qq[head + cnt - 1]] > aa[i])\n\t\t\tcnt--;\n\t\tqq[head + cnt++] = i;\n\t\tif (i >= m - 1)\n\t\t\tbb[i - m + 1] = aa[qq[head]];\n\t\tif (qq[head] == i - m + 1)\n\t\t\thead++, cnt--;\n\t}\n}\n\nint main() {\n\tstatic int aa[N][M], bb[N][M], cc[N], dd[N];\n\tint n, m, a, b, g, x, y, z, i, j;\n\tlong long ans;\n\n\tscanf(\"%d%d%d%d%d%d%d%d\", &n, &m, &a, &b, &g, &x, &y, &z);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < m; j++) {\n\t\t\taa[i][j] = g;\n\t\t\tg = ((long long) g * x + y) % z;\n\t\t}\n\tfor (i = 0; i < n; i++)\n\t\tslide(aa[i], bb[i], m, b);\n\tans = 0;\n\tfor (j = 0; j + b <= m; j++) {\n\t\tfor (i = 0; i < n; i++)\n\t\t\tcc[i] = bb[i][j];\n\t\tslide(cc, dd, n, a);\n\t\tfor (i = 0; i + a <= n; i++)\n\t\t\tans += dd[i];\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "data structures"], "code_uid": "4d0c8508f0c9c25d438646951027139c", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"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(\"Yes\\n\");\n }\n else\n printf(\"No\\n\");\n }\n else{\n for(i=0; i\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", "tags": ["combinatorics"], "code_uid": "fb7b8635f517b1ff3e2474c13721e1a9", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nvoid blast(int, int, int, int);\n\nint grid[301][301], dp[301][301][30][8] = {0}, n, t[31];\n\nint main(){\n int i, j, k;\n scanf(\"%d\", &n);\n for(i=0;i<301;i++){\n for(j=0;j<301;j++){\n grid[i][j] = 0;\n }\n }\n\n for(i=0;i= n)\n return;\n if(dp[150 + x][150 + y][level][dir])\n return;\n dp[150 + x][150 + y][level][dir] = 1;\n for(i = 0;i < t[level];i++){\n if(dir == 0 || dir == 1 || dir == 7){\n x--;\n }\n if(dir == 1 || dir == 2 || dir == 3){\n y--;\n }\n if(dir == 3 || dir == 4 || dir == 5){\n x++;\n }\n if(dir == 5 || dir == 6 || dir == 7){\n y++;\n }\n grid[150 + x][150 + y] = 1;\n }\n blast(x, y, level + 1, (dir + 1)%8);\n blast(x, y, level + 1, (dir + 7)%8);\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "a3c56b873ccd125173f116dca493a032", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define mod 1000000007\nlong long a=1;\nlong long crazy(long long sayi,long long us){\n\tif(us==0)\n\treturn 1;\n\tif(us%2==1)\n\treturn a=((sayi%mod)*(crazy(sayi,us-1)%mod))%mod;\n\tif(us%2==0){\n\tlong long temp=crazy(sayi,us/2)%mod;\n\treturn a=(temp*temp)%mod;\n\t}\n}\nint main(){\n\tlong long n,cikti;\n\tscanf(\"%lld\",&n);\n\tcikti=(crazy(2,n))*(crazy(2,n)+1);\n\tprintf(\"%lld\",(cikti/2)%mod);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "dp", "number theory"], "code_uid": "01d8ca56c9776012816eb6a8d294945b", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0, "exec_outcome": "PASSED"}