{"lang": "GNU C11", "source_code": "#include\n int main()\n {\n int a[100],k,c=0,n,i,j;\n scanf(\"%d %d\",&n,&k);\n for(i=0;i<=n-1;i++)\n {\n scanf(\"%d\",&a[i]);\n }\n for(i=0;ik)\n {\n break;\n\t\t }\n\t\t else\n\t\t {\n\t\t\t c=c+1;\n\t\t }\n\t }\n\n\n\t for(j=n-1;j>=i+1;j--)\n\t {\n\t\t if(a[j]>k)\n {\n\n break;\n\n\t\t }\n\t\t else\n\t\t {\n\t\t\t c=c+1;\n\t\t }\n\t }\n\t printf(\"%d\",c);\n\t return 0;}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "21ac88121285f17fbe2383ab4139d275", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n# include \n# include \n\nint main(){\n \n int n, k, count = 0;\n scanf(\"%d\", &n);\n scanf(\"%d\", &k);\n int i = 0, j = n -1;\n \n int a[100];\n \n for(i = 0; i < n; i++)\n\t\tscanf(\"%d\", &a[i]);\n i = 0;\n while (i < j) {\n if (a[i] <= k) {++i; ++count;}\n if (a[j] <= k) {--j; ++count;} \n if (a[i] > k & a[j] > k) break;\n }\n if ((i == j) & (a[i] <= k)) ++count;\n printf(\"%d\", count);\n return 0; \n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "bd1ce2b548700300b6fd5b6969b81ac1", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int a[4];\n scanf(\"%lld%lld%lld%lld\",&a[0],&a[1],&a[2],&a[3]);\n {\n\n if((a[0]+a[3])==(a[1]+a[2])|| (a[0]+a[1])==(a[3]+a[2])||(a[0]+a[2])==a[1]+a[3] )\n {\n printf(\"YES\\n\");\n }\n else if((a[3]==a[0]+a[2]+a[1]) ||(a[0]==a[2]+a[1]+a[3])||(a[1]==a[3]+a[2]+a[0])||(a[2]==a[0]+a[1]+a[3]) )\n {\n printf(\"YES\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b5a6569ec96f23de455606fa55420ee8", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main ()\n{\nint a1,a2,a3,a4;\nscanf (\"%d%d%d%d\",&a1,&a2,&a3,&a4);\n\nif (a1>0&&a2>0&&a3>0&&a4>0)\n{\n\n\nif (a1+a2 == a3+a4)\n{\nprintf (\"YES\\n\");\n}\nelse if (a2+a3 == a4+a1)\n{\nprintf (\"YES\\n\");\n}\nelse if (a3+a1 == a4+a2)\n{\nprintf (\"YES\\n\");\n}\nelse if (a1 == a2+a3+a4)\n{\n printf(\"YES\\n\");\n}\nelse if (a2 == a1+a3+a4)\n{\n printf(\"YES\\n\");\n}\nelse if (a3 == a2+a1+a4)\n{\n printf(\"YES\\n\");\n}\nelse if (a4 == a2+a3+a1)\n{\n printf(\"YES\\n\");\n}\nelse\n{\nprintf (\"NO\\n\");\n}\n}\n\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b06f8cf6a694ca716adca36bcbc28a3e", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n, k, i;\n\tscanf(\"%d %d\", &n, &k);\n\tint arr[n];\n\tfor(i=0;i\nint main()\n{\n int i,n,k;\n scanf(\"%d%d\",&n,&k);\n int div=0;\n for(i=0;idiv) div=ele;\n }\n printf(\"%d\\n\",k/div);\n return 0;\n} ", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6b45ae3375dd9c099ad4dd01b74e6c79", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n\tint a, b;\n\tscanf(\"%d%d\", &a, &b);\n\n\tprintf(\"%d\\n\", a + b == 2 ? 0 : a + b - 2 - !((a - b) % 3));\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp", "implementation"], "code_uid": "82275fdc3f6cb7747d8fc012eed6ad57", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\nint a,b,i=0;\nscanf(\"%d %d\",&a,&b);\n\nwhile(a>2||b>2){\n if(a<=b){\n a=a+1;\n b=b-2;\n }\n else if(b\n#include \nint main()\n{\n\tchar c[100];\n\tscanf(\"%s\", c);\n\tint l = strlen(c), t = 0;\n\tfor (int i = 0; i < l; i++) {\n\t\tif (c[i] == 'A' && c[i + 1] == 'n' && c[i + 2] == 'n') {\n\t\t\tt++;\n\t\t\ti += 2;\n\t\t}\n\t\telse if (c[i] == 'D' && c[i + 1] == 'a' && c[i + 2] == 'n' && c[i + 3] == 'i' && c[i + 4] == 'l') {\n\t\t\tt++;\n\t\t\ti += 4;\n\t\t}\n\t\telse if (c[i] == 'O' && c[i + 1] == 'l' && c[i + 2] == 'y' && c[i + 3] == 'a') {\n\t\t\tt++;\n\t\t\ti += 3;\n\t\t}\n\t\telse if (c[i] == 'S' && c[i + 1] == 'l' && c[i + 2] == 'a' && c[i + 3] == 'v' && c[i + 4] == 'a') {\n\t\t\tt++;\n\t\t\ti += 4;\n\t\t}\n\t\telse if (c[i] == 'N' && c[i + 1] == 'i' && c[i + 2] == 'k' && c[i + 3] == 'i' && c[i + 4] == 't' && c[i + 5] == 'a') {\n\t\t\tt++;\n\t\t\ti += 5;\n\t\t}\n\t}\n\tif (t == 1)\n\t\tprintf(\"YES\");\n\telse\n\t\tprintf(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "25a394a3a86d50863e9742b7b45614cf", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n\nint main(){\n char name[101];\n scanf(\"%s\", name);\n\n int test[5] = {0};\n\n int ct1,ct2,length;\n for(ct1 = 0 ; ct1 < 100 ; ct1++){\n if(name[ct1] == '\\0'){\n length = ct1;\n break;\n }\n }\n for(ct1 = 0 ; ct1 + 4 < length ; ct1++){\n if(name[ct1] == 'D' && name[ct1 +1 ] == 'a' && name[ct1 + 2] == 'n' && name[ct1 + 3] == 'i' && name[ct1 + 4] == 'l' ){\n test[0]++;\n }\n }\n for(ct1 = 0 ; ct1 + 3 < length ; ct1++){\n if(name[ct1] == 'O' && name[ct1 +1 ] == 'l' && name[ct1 + 2] == 'y' && name[ct1 + 3] == 'a' ){\n test[1]++;\n }\n }\n for(ct1 = 0 ; ct1 + 4 < length ; ct1++){\n if(name[ct1] == 'S' && name[ct1 +1 ] == 'l' && name[ct1 + 2] == 'a' && name[ct1 + 3] == 'v' && name[ct1 + 4] == 'a' ){\n test[2]++;\n\n }\n }\n for(ct1 = 0 ; ct1 + 2 < length ; ct1++){\n if(name[ct1] == 'A' && name[ct1 +1 ] == 'n' && name[ct1 + 2] == 'n' ){\n test[3]++;\n\n }\n }\n for(ct1 = 0 ; ct1 + 5 < length ; ct1++){\n if(name[ct1] == 'N' && name[ct1 +1 ] == 'i' && name[ct1 + 2] == 'k' && name[ct1 + 3] == 'i' && name[ct1 + 4] == 't' && name[ct1 + 5] == 'a'){\n test[4]++;\n\n }\n }\n if(test[0] + test[1] + test[2] + test[3] + test[4] == 1){\n printf(\"YES\");\n }else{\n printf(\"NO\");\n }\n\n\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "6bc71d3db8dfc9a8a89fda32d550bb23", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*\nSpirits coming from the mind,\nwaking up my deepest horrors,\ncapture my thoughts, make me blind.\n\nWeird, \u2018cause I don't want to see\nthe abyss of my possibilities.\n\nScared I can't look away.\n\nIt has come to my side.\nSister demon - my bride.\n\nI want you, I need you\nand I have set you free.\nYou're always right behind me,\nI know the devil's sent you to me.\nYou want me, you need me,\nnow that I've set you free.\nLook always right behind you,\nYou know the devil's sent me to you.\n\nWhat has started as a longing\nalmost is possession now,\nit drives me again and again.\nPut a light into your window,\nmaybe I can find a hold.\nI run against myself \u2018till I find the end.\n\nSent by the devil\n*/\n\n\n/* .................... compiled by alankar....................\n*/\n\n//......................SHORTCUTS..............................\n\n#include\n#include\n#include\n#include\n//...........................................................\n\n#define pi 3.14159265358979323846 //float type\n#define MAX 100000 //for rmq\n#define SQRTMAX 317 //for rmq\n//#define gc getchar_unlocked\n\n#define FOR(i,a,b) for(i=(a);i<(b);i++)\n\n//only for +ve and single terms\n#define s(x) scanf(\"%d\",&x);\n#define sl(x) scanf(\"%lld\",&x);\n#define p(x) printf(\"%d\\n\",x);\n#define pl(x) printf(\"%lld\\n\",x);\n//..........................................................\n\ntypedef long long int ll;\nconst ll MOD=1000000007;\n\n//returns int and +ve numbers\n\n/*inline int inp(){\n int n=0;\n char c;\n c=gc();\n while(c<'0' || c>'9'){\n c=gc();\n }\n while(c>='0' && c<='9'){\n n=(n<<3)+(n<<1)+c-'0';\n c=gc();\n }\n return n;\n}\n*/\n//...................................\n\n//power with mod........long long int\n ll power(ll a,ll b,ll mod){\n if(b==0)\n return 1;\n ll temp=power(a,b/2,mod);\n temp=(temp*temp)%mod;\n if(b&1)\n temp=(temp*a)%mod;\n return temp;\n}\n\n //power without mod........ int\nll pwr(ll a,ll b){\n if(b==0)\n return 1;\n ll temp=pwr(a,b/2);\n temp=(temp*temp);\n if(b&1)\n temp=(temp*a);\n return temp;\n}\n // .....long long int\nll gcd(ll a,ll b){\n return b==0?a:gcd(b,a%b);\n}\n //......long long int\nll lcm(ll a,ll b){\n return (a/gcd(a,b))*b;\n}\n //......long long int with mod\nll modularInverse(ll a,ll m){\n return power(a,m-2,m);\n}\n\n //only for int\n//inline int min(int a,int b) { return ab? a : b; }\n\n//normal compare func on integers //for qsort(name,size,sizeof(type),compare)\nint compare (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint BinarySearch(int *array, int number_of_elements, int key)\n{\n int low = 0, high = number_of_elements-1, mid;\n while(low <= high)\n {\n mid = (low + high)/2;\n if(array[mid] < key)\n {\n low = mid + 1;\n }\n else if(array[mid] == key)\n {\n return mid;\n }\n else if(array[mid] > key)\n {\n high = mid-1;\n }\n\n }\n return -1;\n}\n//.......................................................\n\n//segment tree\n//not template but how to use ST\n//for minimum element\n/*\nlong long s[400000];\nlong long a[1000000];\nint create(long long b,long long e,long long n)\n{\n if(b==e)\n {\n s[n]=a[b];\n }\n else\n {\n create(b,(b+e)/2,2*n+1);\n create((b+e)/2+1,e,2*n+2);\n s[n]=s[2*n+1]r)\n {\n return 100000001;\n }\n if(b>=l&&e<=r)\n {\n return s[n];\n }\n i=messi(b,(b+e)/2,l,r,2*n+1);\n j=messi((b+e)/2+1,e,l,r,2*n+2);\n return ib[i])\n minimum = b[i];\n if(maximum b[l]){\n minimum = b[l];\n\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n while(j<=j2 && l<=r && j min[j])\n minimum = min[j];\n l = (j+1)*size;\n //printf(\"Checked for %d <--> %d\\n\", j*size, l-1);\n j++;\n }\n while(l<=r){\n if(minimum > b[l]){\n minimum = b[l];\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n return minimum;\n}\n\n//finding max value\nlong findMax(int l, int r){\n int j, j2;\n long maximum = b[l];\n\n j = l/size + 1;\n j2 = r/size - 1;\n\n //printf(\"j= %d and j2 = %d\\n\", j,j2);\n while(l %d\\n\", j*size, l-1);\n j++;\n }\n while(l<=r){\n if(maximum < b[l]){\n maximum = b[l];\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n return maximum;\n}\n*/\n\n//...........................................END OF TEMPLATE.................................................................\nll flen(ll b)\n{\n ll len=0;\n while(b!=0)\n {\n b=b>>1;\n len++;\n }\n\n return len;\n\n}\n\nll arr[70];\nint main()\n{ ll i,j,k,t,n,len,tot=0,f1=0,f2=0,a,b,ans=0,f3=0;\n\n sl(a)\n sl(b)\n\n len= flen(b);\n\n\n //pl(len)\n\n if(((a>>(len-1))&1)==((b>>(len-1))&1))\n {\n arr[tot++]=0;\n }\n\n else\n {\n arr[tot++]=1;\n\n if(((a>>(len-1))&1)==0 && ((b>>(len-1))&1)==1)\n f3=1;\n }\n\n i=len-2;\n\n while((((a>>(i))&1)==((b>>(i))&1))&& f3==0 && i>=0)\n {\n arr[tot++]=0;\n i--;\n }\n\n for(;i>=0;i--)\n {\n if(f1==1 || f2==1)\n {\n arr[tot++]=1;\n }\n\n else\n {\n if(((a>>i)&1)==0)\n {\n if(((b>>i)&1)==0)\n {\n arr[tot++]=1;\n f1=1;\n }\n else\n {\n arr[tot++]=1;\n f1=f2=1;\n f3=1;\n }\n\n }\n else\n {\n if(((b>>i)&1)==0)\n {\n arr[tot++]=1;\n // f1=1;\n }\n else\n {\n arr[tot++]=1;\n f2=1;\n }\n }\n\n\n\n\n }\n }\n\n//pl(tot)\n FOR(i,0,tot)\n {\n ans=ans+arr[i]*pwr(2,tot-i-1);\n }\n\n pl(ans)\n\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "22a4439db5ec971ec079413749b1dcdb", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n {\n long long l,r,t,w;\n while(scanf(\"%lld%lld\",&l,&r)!=EOF)\n { \n if(r==l)printf(\"0\\n\");\n else\n {w=0;\n \t while(r!=l&&r!=0)\n \t { \n\t\t w++;\n\t\t l=l>>1;\n \t \t r=r>>1;\n \t }\n\t\tt=1;\n \t while(w--)t=t*2;\n \t printf(\"%lld\\n\",t-1);\n }\n }\n return 0;\n }", "lang_cluster": "C", "tags": ["math", "dp", "bitmasks", "greedy", "implementation"], "code_uid": "070c6c346ed74d04e834bd1a361da495", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint n;\nlong long S;\nint main()\n{\n scanf(\"%d\",&n);\n scanf(\"%lld\",&S);\n if(S%n==0)\n printf(\"%lld\",S/n);\n else\n printf(\"%lld\",S/n+1);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "8d6841e473a25386469139e4bf7bad4c", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n//ko gioi han gia tri\n// co nhieu tien cung gia tri\nint main()\n{\n\tlong n,s;\n\tscanf(\"%ld%ld\",&n,&s);\n\tlong cnt=0,tmp;\n\twhile(n>0)\n\t{\n\t\tif(s==0){\n\t\t\tbreak;\n\t\t}\n\t\ttmp=s/n;\n\t\tcnt=cnt+tmp;\n\t\ts=s-tmp*n;\n\t\tn=n-1;\n\t}\n\tprintf(\"%ld\",cnt);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "2c96eea20589500a5f1177092324c274", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint sum1(int n) {\n\treturn n * (n + 1) / 2;\n}\n\nint sum2(int n) {\n\treturn n * (n + 1) * (n + n + 1) / 6;\n}\n\nint main() {\n\tint n;\n\n\tscanf(\"%d\", &n);\n\tprintf(\"%d\\n\", sum2(n - 1) - 1 + sum1(n - 1) - 1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "457549af4692e7e3b8a616c8a986fff1", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define MAX 987654321\nint n;\n\nint main()\n{\n\tscanf(\"%d\", &n);\n\tif (n < 3) //when polygon has less than 3 points\n\t\treturn 0;\n\tint table[501][501];\n\n\tfor (int gap = 0; gap < n; gap++) {\n\t\tfor (int i = 0, j = gap; j < n; i++, j++) {\n\t\t\tif (j < i + 2)\n\t\t\t\ttable[i][j] = 0;\n\t\t\telse {\n\t\t\t\ttable[i][j] = MAX;\n\n\t\t\t\tfor (int k = i + 1; k < j; k++) {\n\t\t\t\t\tint val = table[i][k] + table[k][j] + (i+1)*(j+1)*(k+1);\n\t\t\t\t\tif (table[i][j] > val)\n\t\t\t\t\t\ttable[i][j] = val; //update table data to minimum value\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", table[0][n - 1]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "c46031770c11bdb30d15e03418c41c1b", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main ()\n{\n int n,i,l=0,k=0,sum=0;\n scanf(\"%d\",&n);\n for(i=1;;i++)\n {\n k=k+i;\n sum=sum+k;\n \n if(sum>n)\n break;\n l++;\n }\n printf(\"%d\",l);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0febd460aad2372f78dfb206c4a45763", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\tint n,i=1,t=0,h=0;\n\tscanf(\"%d\",&n);\n\twhile(i>=1)\n\t{\n\t\tt+=i*(i+1)/2;\n\t\tif(tn)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tif(t=n)\n\t\t{\n\t\t\th++;\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%d\",h);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "221d45d4c994d32d2b299cdfc700550d", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main ()\n {\n char s[50];\n int count=0,a;\n scanf(\"%s\",s);\n\n for(int i=0;i uncount)\n {\n printf(\"%d\",strlen(s));\n }\n else\n {\n uncount-=count;\n uncount++;\n printf(\"%d\",strlen(s)-uncount);\n }\n }\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "d7d398ac6c25e5236e28dfd659f584d2", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main() \n{ \n char string[51];\n int length,l,i,c=0;\n scanf(\"%s\",string);\n length=strlen(string);\n l=length/2;\n for(i=0;il) \n { \n printf(\"%d\",length);\n }\n else \n {\n printf(\"%d\",(c*2)-1);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "91ac9e13929d7912df4a619c61d9003d", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n #include\n int main()\n {\n int i,l;\n char s[101];\n scanf(\"%s\",s);\n l=strlen(s);\n for(i=0; i\n#include\n#include\nint main()\n{\n int i,j;\n char a[101];\n scanf(\"%s\",&a);\n for(i=0;a[i]!='\\0';i++)\n {\n a[i]=tolower(a[i]);\n if((a[i]=='a')||(a[i]=='e')||(a[i]=='i')||(a[i]=='o')||(a[i]=='u')||(a[i]=='y'))\n {\n continue;\n }\n printf(\".%c\",a[i]);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "d420bcf912c55b0808b9280ff4bf5409", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \"stdio.h\"\n\nint main ()\n{\n\tint k,max=-1;\n\tint r[26];\n\tscanf(\"%d\",&k);\n\tfor(int i=1;i<=k;i++)\n\t{\n\t\tscanf(\"%d\",&r[i]);\n\t}\n\tfor(int i=1;i<=k;i++)\n\t{\n\t\tif (max\nint main()\n{\n\tint max=0,n,ele;\n\tscanf(\"%d\",&n);\n\twhile(n--)\n\t{\n\t\tscanf(\"%d\",&ele);\n\t\tif(ele > max)\n\t\tmax = ele;\n\t}\n\tif(max > 25)\n\tprintf(\"%d\",max-25);\n\telse\n\tprintf(\"0\");\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "ebbbed360f2f8d1104deceb259a531bd", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include\n#include\n\nint main()\n\n{\n int i, n, cnt[26] = {0};\n char a[101];\n scanf(\"%d\", &n);\n scanf(\"%s\", a);\n if(n < 26)\n printf(\"NO\\n\");\n else\n {\n\n\n for(i=0;i\nint main()\n{\n\tchar a[101];\n\tint n,al[130]={0},number,count=0;\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",a);\n\tfor(int i=0;i\n#include \nint main(){\n\t\n\tchar s[50];\n\tscanf(\"%s\",s);\n\tint l=strlen(s);\n\tint count=0;\n\tint cs=0;\n\tfor(int i=0;i\n#include\n\nint main(){\n char a[50];\n scanf(\"%s\", a);\n \n int l;\n l=strlen(a);\n int i=0, flag=0, flag2=0;\n int j = l-1; \n int k=j;\n \n for(int i=0;i<=l-1;i++){\n if(a[0]!=a[i]){\n flag2=1;\n }\n }\n if(flag2==1){\n while(i\n#include \nint main()\n{\n\tint a, i;\n\tchar A[105];\n\tscanf(\"%d\", &a);\n\tscanf(\"%s\", A);\n\tfor (i = 0; i\nint main()\n{\n\tint a=0,n=0,b=0;\n\tchar d[110]={0};\n\tscanf(\"%d\",&n);\n\tgetchar();\n\tfor(int i=0;i\nint main() {\n\tint k;\n\tscanf(\"%d\",&k);\n\t//\u4e00\u53ea\u624b\u53ef\u4ee5\u6309k\u4e2a\u952e\uff01\n\tchar panel[4][5];\n\tint i,j;\n\tfor(i=0;i<4;i++){\n\t\tscanf(\"%s\",panel[i]);\n\t}\n\t//\u8fd9\u91cc\u53ea\u9700\u8981\u505a\u4e00\u4e2a\u7edf\u8ba1\u5c31\u53ef\u4ee5\uff01\n\tint count[10];\n\tfor(i=0;i<10;i++){\n\t\tcount[i]=0;\n\t}\n\tfor(i=0;i<4;i++){\n\t\tfor(j=0;j<4;j++){\n\t\t\tif(panel[i][j]!='.'){\n\t\t\t\tcount[panel[i][j]-'0']++;\n\t\t\t}\n\t\t}\n\t}\n\tfor(i=1;i<10;i++){\n\t\tif(count[i]>2*k){\n\t\t\tprintf(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"YES\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c1b0d907a33836078eb8008a4855d910", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int k,i,b[10],j,pd;\n char a[4][4];\nwhile(scanf(\"%d\",&k)!=EOF)\n{\n getchar();\n memset(b,0,sizeof(b));\n for(i=0;i<4;i++){\n for(j=0;j<4;j++)\n {\n scanf(\" %c\",&a[i][j]);\n if(a[i][j]>='1'&&a[i][j]<='9')\n b[a[i][j]-'0']++;\n }\n getchar();\n }\n pd=0;\n for (i=1;i<=9;i++) if (b[i]>2*k) pd=1;\n if(pd) printf(\"NO\\n\");\n else printf(\"YES\\n\");\n}\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2876b8c844ceecc47472f019f43e7245", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\",2*n-(n/2));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "52a9ca93980669e8b831d551c0ad3dcd", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(void)\n{\n int n;\n scanf(\"%d\",&n);\n printf(\"%d\\n\",3*n/2);\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "bfa9791293aadf467786fcdca6e8a38d", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,a[10],b[10],k1,k2,top1,top2,c[20],d[20],k=0,l,i,x,j;\n scanf(\"%d\",&n);\n scanf(\"%d\",&k1);\n for(i=k1-1;i>=0;i--)\n {scanf(\"%d\",&a[i]);\n c[i]=a[i];}\n scanf(\"%d\",&k2);\n for(i=k2-1;i>=0;i--)\n {scanf(\"%d\",&b[i]);\n d[i]=b[i];}\n top1=k1-1;\n top2=k2-1;\n while(top1>=0&&top2>=0)\n {\n if(c[top1]>d[top2])\n {\n l=d[top2];\n top2--;\n x=c[top1];\n if(top1>=1){\n for(i=top1-1;i>=0;i--)\n c[i+2]=c[i];}\n c[1]=l;\n c[0]=x;\n top1++;\n }\n else\n {\n l=c[top1];\n top1--;\n x=d[top2];\n for(i=top2-1;i>=0;i--)\n d[i+2]=d[i];\n d[1]=l;\n d[0]=x;\n top2++;\n }\n if(top1+1==k1&&top2+1==k2)\n {\n for(i=0;i\n#include \n#include \n \n// A structure to represent a queue\nstruct Queue\n{\n int front, rear, size;\n unsigned capacity;\n int* array;\n};\n \n// function to create a queue of given capacity. It initializes size of\n// queue as 0\nstruct Queue* createQueue(unsigned capacity)\n{\n struct Queue* queue = (struct Queue*) malloc(sizeof(struct Queue));\n queue->capacity = capacity;\n queue->front = queue->size = 0;\n queue->rear = capacity - 1; // This is important, see the enqueue\n queue->array = (int*) malloc(queue->capacity * sizeof(int));\n return queue;\n}\n \n// Queue is full when size becomes equal to the capacity\nint isFull(struct Queue* queue)\n{ return (queue->size == queue->capacity); }\n \n// Queue is empty when size is 0\nint isEmpty(struct Queue* queue)\n{ return (queue->size == 0); }\n \n// Function to add an item to the queue. It changes rear and size\nvoid enqueue(struct Queue* queue, int item)\n{\n if (isFull(queue))\n return;\n queue->rear = (queue->rear + 1)%queue->capacity;\n queue->array[queue->rear] = item;\n queue->size = queue->size + 1;\n //printf(\"%d enqueued to queue\\n\", item);\n}\n \n// Function to remove an item from queue. It changes front and size\nint dequeue(struct Queue* queue)\n{\n if (isEmpty(queue))\n return INT_MIN;\n int item = queue->array[queue->front];\n queue->front = (queue->front + 1)%queue->capacity;\n queue->size = queue->size - 1;\n return item;\n}\n \n// Function to get front of queue\nint front(struct Queue* queue)\n{\n if (isEmpty(queue))\n return INT_MIN;\n return queue->array[queue->front];\n}\n \n// Function to get rear of queue\nint rear(struct Queue* queue)\n{\n if (isEmpty(queue))\n return INT_MIN;\n return queue->array[queue->rear];\n}\n\nint main()\n{\n\tint N;\n\tscanf(\"%d\",&N);\n\tint k1;\n\tscanf(\"%d\",&k1);\n\tstruct Queue* queue1 = createQueue(N);\n\tint val;\n\tint i;\n\tfor(i=0;itemp2)\n\t\t{\n\t\t\tenqueue(queue1,temp2);\n\t\t\tenqueue(queue1,temp1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tenqueue(queue2,temp1);\n\t\t\tenqueue(queue2,temp2);\n\t\t}\n\t\tif(isEmpty(queue1) == 1){\n\t\t\tflag = 1;\n\t\t\tlol = 2;\n\t\t\tbreak;\n\t\t}\n\t\telse if(isEmpty(queue2) == 1){\n\t\t\tflag = 1;\n\t\t\tlol = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif(moves > 362880)\n\t\t\tbreak;\n\n\t}\n\tif(flag == 1)\n\t\tprintf(\"%d %d\\n\",moves,lol);\n\telse\n\t\tprintf(\"-1\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "brute force", "games"], "code_uid": "75cabf3a40f78cf2932533d0d1fce810", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(void) {\n\tint n,a,b,i,j,m,p=0,flag=1;\n\tscanf(\"%d%d%d\",&n,&a,&b);\n\tint co[n];\n\tfor(i=0;i=b)\n\tm=b;\n\telse\n\tm=a;\n\tfor(i=0,j=n-1;i<=(n-1)/2;i++,j--)\n\t{\n\t if(i!=j)\n\t {\n\t if(co[i]!=co[j]&&co[i]!=2&&co[j]!=2)\n\t {\n\t flag=0;\n\t break;\n\t }\n\t else\n\t if(co[i]==1&&co[j]==2)\n\t p=p+b;\n\t else\n\t if(co[j]==1&&co[i]==2)\n\t p=p+b;\n\t else\n\t if(co[i]==0&&co[j]==2)\n\t p=p+a;\n\t else\n\t if(co[j]==0&&co[i]==2)\n\t p=p+a;\n\t else\n\t if(co[i]==2&&co[j]==2)\n\t p=p+(2*m);\n\t }\n\t if(i==j)\n\t {\n\t if(co[i]==2)\n\t p=p+m;\n\t }\n\t}\n\tif(flag==0)\n\tprintf(\"-1\");\n\telse\n\t printf(\"%d\",p);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "f390349455922f494739b2e839c3716d", "src_uid": "af07223819aeb5bd6ded4340c472b2b6", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int x,y,c,n,s=0,i;\n scanf(\"%d %d %d\",&n,&x,&y);\n int A[n],B[n];\n if(x>y)\n {\n c=y;\n }\n else\n {\n c=x;\n }\n for(i=0;i\n#include\nint main()\n{\n int x,a=0,j=0,b=0,i;\n char str[200];\n int ara[100];\n scanf(\"%d\",&x);\n scanf(\"%s\",str);\n str[x]='W';\n x++;\n for(i=0,j=0;i\n#include \n\nint main()\n{\n\tint n,k=0,i,cnt,w,f=0;\n\tint a[1000];\n\tchar str[1001];\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",str);\n\n\tcnt=0;\n\tfor (i=0;i0){\n\t\t\t\ta[k]=cnt;\n\t\t\t\tk++;\n\t\t\t}\n\t\t\tcnt=0;\n\t\t}\n\t}\n\tif (f==0){\n\t\t\n\t\tprintf(\"0\");\n\t\treturn 0;\n\t}\n\tif (cnt>0){\n\ta[k]=cnt;\n\tk++;\n\t}\n\tprintf(\"%d\\n\",k);\n\tfor (i=0;i\n\nint main()\n{\n\tunsigned int n;\n\tunsigned int t;\n\tint i;\n t = 0;\n scanf(\"%d\", &n);\n for(i=2;i<=n;i++)\n\t{\n if(i%2 == 0)\n\t\t{\n t = ((t+1) * 3) % 1000000007;\n }\n\t\telse\n\t\t{\n t = ((t-1) * 3) % 1000000007;\n }\n }\n\tt = t%1000000007;\n printf(\"%d\", t);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "dp"], "code_uid": "b91806c8a44c5f2f17ccd1108d86b13e", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nconst long MOD = 1e9 + 7;\n\nint main(void)\n{\n long i, n;\n long long a = 0, b = 1, c;\n scanf(\"%ld\", &n);\n for (i = 1; i < n; i++) {\n c = a;\n a = (3 * b) % MOD;\n b = (2 * b + c) % MOD;\n }\n printf(\"%ld\", a);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "dp"], "code_uid": "f9374783a73cdb6ad888ab53d078a41b", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n\tint n, i, j,temp;\n\tchar a[210];\n\n\tscanf(\"%d\", &n);\n\tscanf(\"%s\", a);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tfor (j = i + 1; j < n; j++)\n\t\t{\n\t\t\tif (a[i]>a[j])\n\t\t\t{\n\t\t\t\ttemp = a[i];\n\t\t\t\ta[i] = a[j];\n\t\t\t\ta[j] = temp;\n\t\t\t}\n\t\t\n\t\t}\n\t}\n\tfor (; i < 2*n; i++)\n\t{\n\t\tfor (j = i + 1; j < 2*n; j++)\n\t\t{\n\t\t\tif (a[i]>a[j])\n\t\t\t{\n\t\t\t\ttemp = a[i];\n\t\t\t\ta[i] = a[j];\n\t\t\t\ta[j] = temp;\n\t\t\t}\n\n\t\t}\n\t}\n\tif (a[0] > a[n])\n\t{\n\t\tfor (i = 0, j = n; i < n; i++, j++)\n\t\t{\n\t\t\tif (a[i] <= a[j])\n\t\t\t\tbreak;\n\t\t}\n\t\tif (i == n)\n\t\t\tprintf(\"YES\");\n\t\telse\n\t\t\tprintf(\"NO\");\n\t}\n\telse if (a[0] < a[n])\n\t{\n\t\tfor (i = 0, j = n; i < n; i++, j++)\n\t\t{\n\t\t\tif (a[i] >= a[j])\n\t\t\t\tbreak;\n\t\t}\n\t\tif (i == n)\n\t\t\tprintf(\"YES\");\n\t\telse\n\t\tprintf(\"NO\");\n\t}\n\telse\n\t\tprintf(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "71e9e140c4f238b8a82b380175a07201", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nvoid scanp(const int len);\nint comp (const void * elem1, const void * elem2);\n\nint main()\n{\n int len;\n scanf(\"%d\", &len);\n leercomparar(len);\n return 0;\n}\n\nvoid leercomparar(const int len)\n{\n char s[len * 2], s1[len + 1], s2[len + 1];\n\n scanf(\"%s\", s);\n s1[len] = s2[len] = 0;\n\n qsort(strncpy(s1, s, len), len, sizeof(char), comp );\n qsort(strncpy(s2, s + len, len), len, sizeof(char), comp );\n\n for( int i = 0; i < len -1; i++ )\n {\n if ( comp(s1+i, s2+i) != comp(s1+i+1, s2+i+1) || *(s1+i) == *(s2+i) )\n {\n puts(\"NO\");\n return;\n }\n }\n\n if ( *(s1) == *(s2) )\n {\n puts(\"NO\");\n return;\n }\n puts(\"YES\");\n\n}\n\nint comp (const void * elem1, const void * elem2)\n{\n char f = *((char*)elem1);\n char s = *((char*)elem2);\n if (f > s) return 1;\n if (f < s) return -1;\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "bb1b25b4dc2886de1132beedc266d7f4", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\n\tint a[n];\n\tint i;\n\tfor(i=0;i1)\n\t{\n\t\tif((a[n-1]<=14)&&(a[n-1]!=0))\n\t\t{\n\t\t\tif(a[n-2]\nint main()\n{\n int a[100],n,i;\n scanf(\"%d\",&n);\n for(i=0;i1){\n if(a[n-1]==15){printf(\"DOWN\\n\");}\n else if(a[n-1]==0){printf(\"UP\\n\");}\n\n else if(a[n-1]-a[n-2]>0){\n printf(\"UP\\n\");\n }\n else if(a[n-1]-a[n-2]<0){\n\n printf(\"DOWN\\n\");\n }\n }\n\n\n\n\n else{\n if(a[0]==0){printf(\"UP\\n\");}\n else if(a[0]==15){ printf(\"DOWN\\n\");}\n else{ printf(\"-1\\n\");}\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "157b966488fc17b6288a090188fb9f76", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n,indexOne=1,indexTwo=1,indexThree=0,temp;\n scanf(\"%d\",&n);\n int gameArr[n+1],inp;\n for(int i=0;i=2){\n if((gameArr[0]==1 && gameArr[1]==2)||(gameArr[0]==2 && gameArr[1]==1)){\n printf(\"NO\");\n return 0;\n }\n for(int i = 0; i < n-2 ; i++){\n if(gameArr[i]==gameArr[i+2] && gameArr[i]!=gameArr[i+1]){\n printf(\"NO\");\n return 0;\n }\n }\n }\n temp=indexOne;\n for(int i = 0; i\n#include \n\nint cmp(const void *a,const void *b)\n{\n\treturn *(int *)a - *(int *)b;\n}\n\nint max(int a,int b)\n{\n\tif(a>b)\n\t\treturn a;\n\treturn b;\n}\n\n\nint main()\n{\n\tint i,n,a[105],j;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i\n#include \n \n#define N\t200\n \nint max(int a, int b) { return a > b ? a : b; }\n \nint main() {\n\tstatic char cc[N], cc_[2];\n\tstatic int dp[N + 1][N + 1], dq[N + 1][N + 1];\n\tint n, m, i, j, k, ans;\n \n\tscanf(\"%d%d%s%s\", &n, &m, cc, cc_);\n\tfor (j = 0; j <= m; j++)\n\t\tmemset(dp, -1, (n + 1) * sizeof *dp);\n\tdp[0][0] = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tfor (j = 0; j <= m; j++)\n\t\t\tmemset(dq, -1, (n + 1) * sizeof *dq);\n\t\tfor (j = 0; j <= m; j++)\n\t\t\tfor (k = 0; k <= n; k++) {\n\t\t\t\tint j_, k_, x = dp[j][k];\n \n\t\t\t\tif (x == -1)\n\t\t\t\t\tcontinue;\n\t\t\t\tj_ = j, k_ = k;\n\t\t\t\tif (cc[i] == cc_[0])\n\t\t\t\t\tk_++;\n\t\t\t\tdq[j_][k_] = max(dq[j_][k_], x + (cc[i] == cc_[1] ? k : 0));\n\t\t\t\tif (j < m) {\n\t\t\t\t\tj_ = j + 1, k_ = k + 1;\n\t\t\t\t\tdq[j_][k_] = max(dq[j_][k_], x + (cc_[0] == cc_[1] ? k : 0));\n\t\t\t\t\tif (cc_[0] != cc_[1]) {\n\t\t\t\t\t\tj_ = j + 1, k_ = k;\n\t\t\t\t\t\tdq[j_][k_] = max(dq[j_][k_], x + k);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tfor (j = 0; j <= m; j++)\n\t\t\tmemcpy(dp, dq, (n + 1) * sizeof *dq);\n\t}\n\tans = -1;\n\tfor (j = 0; j <= m; j++)\n\t\tfor (k = 0; k <= n; k++)\n\t\t\tans = max(ans, dp[j][k]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["strings", "dp"], "code_uid": "078b5764e40a3c37f6c58661fa8b5937", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t200\n\nint max(int a, int b) { return a > b ? a : b; }\n\nint main() {\n\tstatic char cc[N + 1], cc_[4];\n\tstatic int dp[N + 1][N + 1], dq[N + 1][N + 1];\n\tint n, m, i, j, k, ans;\n\n\tscanf(\"%d%d%s%s\", &n, &m, cc, cc_);\n\tfor (j = 0; j <= m; j++)\n\t\tmemset(dp, -1, (n + 1) * sizeof *dp);\n\tdp[0][0] = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tfor (j = 0; j <= m; j++)\n\t\t\tmemset(dq, -1, (n + 1) * sizeof *dq);\n\t\tfor (j = 0; j <= m; j++)\n\t\t\tfor (k = 0; k <= n; k++) {\n\t\t\t\tint j_, k_, x = dp[j][k];\n\n\t\t\t\tif (x == -1)\n\t\t\t\t\tcontinue;\n\t\t\t\tj_ = j, k_ = k;\n\t\t\t\tif (cc[i] == cc_[0])\n\t\t\t\t\tk_++;\n\t\t\t\tdq[j_][k_] = max(dq[j_][k_], x + (cc[i] == cc_[1] ? k : 0));\n\t\t\t\tif (j < m) {\n\t\t\t\t\tj_ = j + 1, k_ = k + 1;\n\t\t\t\t\tdq[j_][k_] = max(dq[j_][k_], x + (cc_[0] == cc_[1] ? k : 0));\n\t\t\t\t\tif (cc_[0] != cc_[1]) {\n\t\t\t\t\t\tj_ = j + 1, k_ = k;\n\t\t\t\t\t\tdq[j_][k_] = max(dq[j_][k_], x + k);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tfor (j = 0; j <= m; j++)\n\t\t\tmemcpy(dp, dq, (n + 1) * sizeof *dq);\n\t}\n\tans = -1;\n\tfor (j = 0; j <= m; j++)\n\t\tfor (k = 0; k <= n; k++)\n\t\t\tans = max(ans, dp[j][k]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "dp"], "code_uid": "d0cb7307e6a098d03af25e12248df2fe", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n, m, i, j, temp, min = 99999;\n scanf(\"%d %d\", &n, &m);\n int arr[m];\n\n for(i=0; i arr[j+1]){\n temp = arr[j];\n arr[j] = arr[j+1];\n arr[j+1] = temp;\n }\n }\n }\n\n j = arr[m-1] - arr[0];\n for(i=0; i\n#include\nint main()\n{\n\tint n,m,i,j,p[50]={0},min=1000000,cur,temp;\n\tscanf(\"%d %d\",&n,&m);\n\tfor (i=0;ip[j+1])\n\t\t\t{\n\t\t\t\ttemp=p[j];\n\t\t\t\tp[j]=p[j+1];\n\t\t\t\tp[j+1]=temp;\n\t\t\t}\n\tfor (i=0;i\nmain()\n{int a,b,n;\nscanf(\"%d%d%d\",&n,&a,&b);\nwhile(a>n-b-1)\nb--;\nprintf(\"%d\",b+1);\nreturn 0;}", "lang_cluster": "C", "tags": ["math"], "code_uid": "12e5c7fe58319a20ecb6f0b850082262", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int n,a,b,p;\n scanf(\"%d %d %d\",&n,&a,&b);\n if((a+b)\n\n#define N\t250\n#define MD\t1000000007\n\nlong long power(int a, int k) {\n\tlong long b = a, p = 1;\n\n\twhile (k > 0) {\n\t\tif (k & 1)\n\t\t\tp = p * b % MD;\n\t\tb = b * b % MD;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint ff[N + 1], gg[N + 1];\n\nvoid init() {\n\tint i;\n\tlong long f = 1;\n\n\tfor (i = 0; i <= N; i++) {\n\t\tgg[i] = power(ff[i] = f, MD - 2);\n\t\tf = f * (i + 1) % MD;\n\t}\n}\n\nlong long choose(int n, int k) {\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nint main() {\n\tint n, k, r, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tans = 0;\n\tfor (r = 0; r <= n; r++)\n\t\tans = (ans + (r % 2 == 0 ? 1 : -1) * choose(n, r) * power(power(k - 1, r) * (power(k, n - r) - power(k - 1, n - r)) % MD, n)) % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "86f7950dc010af7f3a819d5676ba1b03", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define MOD 1000000007\n\nint dar[252][252], k, n, fact[252], inv[252], precomp[2][252];\n\nint add(int a, int b){\n a += b;\n if(a >= MOD)a -= MOD;\n return a;\n}\n\nint mul(int a, int b){\n return (a*1ll*b)%MOD;\n}\nint powmod(int base, long long p){\n int toret = 1;\n while(p){\n if(p&1)toret = mul(toret, base);\n base = mul(base, base);\n p >>= 1;\n }\n return toret;\n}\n\nint ncr(int n, int r){\n return mul(mul(fact[n], inv[r]), inv[n - r]);\n}\n\nint dp(int r, int c){\n // printf(\"dp(%d, %d)\\n\", r, c);\n if(dar[r][c] == -1){\n int toret = 0;\n if(r == 0){\n dar[r][c] = (c == 0);\n return dar[r][c];\n }\n\n int sat = n - c;\n int i;\n for(i = 0;i <= c;i++)if(i + sat){\n int f1 = precomp[0][c - i];\n f1 = mul(f1, ncr(c, i));\n int f2 = precomp[1][sat];\n if(i == 0){\n\tf2 = add(f2, MOD - precomp[0][sat]);\n }\n toret = add(toret, mul(dp(r - 1, c - i), mul(f1, f2)));\n }\n dar[r][c] = toret;\n }\n return dar[r][c];\n}\n\nint main(){\n scanf(\"%d %d\", &n, &k);\n if(k == 1){\n printf(\"1\\n\");\n return 0;\n }\n int i,j;\n fact[0] = 1;\n inv[0] = 1;\n precomp[0][0] = precomp[1][0] = 1;\n for(i = 1;i < 252;i++){\n fact[i] = mul(fact[i - 1], i);\n inv[i] = powmod(fact[i], MOD - 2);\n precomp[0][i] = powmod(k - 1, i);\n precomp[1][i] = powmod(k, i);\n }\n for(i = 0;i <= n;i++)for(j = 0;j <= n;j++){\n dar[i][j] = -1;\n }\n printf(\"%d\\n\", dp(n, n));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "8575633598e3938e8490eb61c8a0cdc4", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int i,n,t,d=1,c=0;\n scanf(\"%d\",&n);\n char x[n+1],y[n+1];\n scanf(\"%s\",&x);\n for(i=0;i\n\nint main()\n{\nchar x[1000],b[1000],c[1000];\nint i,j,n,count=0;\nscanf(\"%d\",&n);\nscanf(\"%s\",x);\n\nfor(i=0;i\nint main ()\n{\n int n,d,a[100],m,i,j,b,c,sum=0;\n scanf(\"%d %d\",&n,&d);\n for(i=0;ia[j+1])\n {\n b=a[j];\n a[j]=a[j+1];\n a[j+1]=b;\n }\n }\n }\n if(m<=n)\n {\n for(i=0;i\n#include\nint cmp(const void *a,const void *b)\n{ return ( *(int*)a-*(int*)b);\n}\n\nint main()\n{\n int n,d,m,s=0,s1=0,i;\n scanf(\"%d%d\",&n,&d);\n int a[n];\n for(i=0;i\n#include\nint main (){\n\tint n,a[1001],i,t=0,ans=0,t1=0;\n\t\n\tscanf(\"%d\",&n);\n\t\n\tfor(i=1; i<=n ;i++){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\tif(n==1000-a[1]+1){\n\t\tprintf(\"%d\",n-1);\n\t}\n\telse if (n==a[n]){\n\t\tprintf(\"%d\",n-1);\n\t}\n\telse {\n\t\ta[0]=0;\n\t\ta[n+1]=1001;\n\tfor(i=0;i<=n+1 ;i++ ){\n\t\tif(a[i]+1==a[i+1] ){\n\t\t\tt++;\n\t\t}\n\t\telse {\n\t\t\tif(t>ans){\n\t\t\t\tans=t-1;\n\t\t\t}\n\t\t\tt=0;\n\t\t}\n\t\t\n\t}\n\tif(ans==-1){\n\t\tprintf(\"0\");\n\t}\n\t printf(\"%d\",ans);\n}\n\treturn 0;\n\t\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "5462adf99cbab0160b4872733c8d303b", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,a[1005],ans=0,m,l=0;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n\t\tscanf(\"%d\",&a[i]);\n\ta[0]=0;\n\ta[n+1]=1001;\n\tfor(int i=0;i<=n;i++)\n\t{\n\t\tif(a[i+1]==a[i]+1)\n\t\t{\n\t\t\tl++;\n\t\t\t//printf(\"%d %d\\n\",i,l);\n\t\t}\t\n\t\telse\n\t\t{\n\t\t\tif(l>=2&&ans=2&&ans\n#include \n\nchar a[100] ;\n\nint main()\n{\n int n=0,i=0,b=0;\n scanf(\"%s\",a);\n n = strlen(a);\n\n for(i=n-1;i>=0;i--){\n if(a[i]=='4'){\n if(a[i-1]=='4'&&a[i-2]=='1'){\n a[i] = 'y';\n a[i-1] = 'y';\n a[i-2] = 'y';\n }\n else if(a[i-1]=='1'){\n a[i] = 'y';\n a[i-1] = 'y';\n }\n }\n if(a[i] == '1')\n a[i] = 'y';\n }\n for(i=0;i\n\nint main()\n\n{\n int a=0,c,d=100,n,m;\n scanf(\"%d\",&n);\n m=n;\n for(;d>10;)\n {\n d=0;\n d=m/10;\n c=m-d*10;\n m=d;\n if(c==1)\n {\n a=0;\n continue;\n }\n else if(c==4)\n {\n a++;\n if(a==3)\n {\n break;\n }\n }\n else\n {\n a=0;\n break;\n }\n\n }\n if(((d==1)&&(a!=3)&&((c==1)||(c==4)))||(n==1))\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "5a92c865e616eee3a62bfb6c422aadef", "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nmain()\n{\n int x,y=5,p,q,r,s;\n scanf(\"%d\",&x);\n\n if(x=y)\n {\n if(x%y==0)\n {\n r=x/y;\n printf(\"%d\\n\",r);\n }\n\n else\n {\n s=(x/y)+1;\n printf(\"%d\\n\",s);\n }\n }\n\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "7d140185b7cd07b973206d4944b26e74", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n\n{\n int x, count, y;\n scanf (\"%d\", &x);\n if (x<=5)\n {\n printf (\"1\\n\");\n }\n else\n {\n if ( x%5==0)\n {\n printf(\"%d\\n\", x/5);\n }\n if (x%5!=0)\n {\n printf(\"%d\\n\", x/5 + 1);\n }\n }\n return 0;\n }\n// 1460463121638", "lang_cluster": "C", "tags": ["math"], "code_uid": "4c8793e0bdb4d03e833e234c71217a95", "src_uid": "4b3d65b1b593829e92c852be213922b6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint f(char a)\n{\n if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='y')\n {\n return 2;\n }\n else\n {\n return 3;\n }\n}\nint main()\n{\n char b[101];\n int n,k,j;\n scanf(\"%d\",&n);\n scanf(\"%s\",b);\n for(k=0;b[k]!='\\0';k++)\n {\n if(f(b[k])==2&&f(b[k+1])==2)\n {\n for(j=k+1;b[j]!='\\0';j++)\n {\n b[j]=b[j+1];\n }\n b[j]='\\0';\n k--;\n continue;\n }\n }\n printf(\"%s\",b);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d3bc0d20c418ee60c1ce3b1349ec1e6b", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int x, y = 0, n;\n char s[100];\n scanf(\"%d\", &n);\n scanf(\"%s\", s);\n for(x = 0; x < n; x++) {\n if((s[x] == 'a' || s[x] == 'e' || s[x] == 'i' || s[x] == 'o' || s[x] == 'u' || s[x] == 'y') && y == 0) y = 1;\n else if((s[x] == 'a' || s[x] == 'e' || s[x] == 'i' || s[x] == 'o' || s[x] == 'u' || s[x] == 'y') && y == 1) {\n s[x] = '?';\n }\n else y = 0;\n }\n for(x = 0; x < n; x++) {\n if(s[x] != '?') printf(\"%c\", s[x]);\n }\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f3886fa3d3cd8d72c1086cee40e2960f", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint x,hh,mm;\n\tint h,m;\n\tint a,i;\n\t\n\tscanf(\"%d\", &x);\n\tscanf(\"%d %d\", &hh, &mm);\n\t\n\tfor(i=0; ; i++)\n\t{ \n\t h=hh%10;\n\t\tm=mm%10;\n\t\t\n\t\tmm=mm-x;\n\t\tif(mm<0)\n\t\t{\n\t\t\tmm=mm+60;\n\t\t\thh=hh-1;\n\t\t}\n\t\tif(hh<0)\n\t\t{\n\t\t\thh=hh+24;\n\t\t}\n\t\t\n\t\tif(h==7 || m==7 || (hh==7 && mm==0) )\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%d\\n\", i);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "94eaf16c72f2904c8dd708a0ff426d11", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define nax 1000\nint main()\n{\n\n\tint x, hours,minutes;\n\tscanf(\"%i\",&x);\n\tscanf(\"%d%d\",&hours,&minutes);\n\tint newHour = minutes;\n\tint minus;\n\tint counter = 0 ;\n\twhile (1){\n\n\t\tif (newHour % 10 == 7 || hours % 10 == 7 ){\n\t\t\tbreak;\n\t\t}\n\n\t\tif(hours == 0){\n\t\t\thours = 24;\n\t\t}\n\n\t\tif (newHour < x){\n\t\t\tminus = x - newHour;\n\t\t\tnewHour = 60 - minus;\n\t\t\thours -=1;\n\t\t}\n\n\t\telse\n\t\t{\n\t\t\tnewHour -= x;\n\t\t}\n\t\tcounter += 1;\n\n\t}\n\tprintf(\"%i\",counter);\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "0cb226fa6f95041440464431c12c78c0", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main() {\n int n, k, x, tmp;\n scanf(\"%d%d%d\", &n, &k, &x);\n int ans = 0;\n for (int i = 0; i < n - k; i++) {\n scanf(\"%d\", &tmp);\n ans += tmp;\n }\n printf(\"%d\\n\", ans + k * x);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "82d2636c7adbbb0d4cdbd0240bf8c40b", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint n,k,x,ans;\n\tscanf(\"%d %d %d\",&n,&k,&x);\n\tint i,arr[n],sum=0;\n\tfor(i=0;i\n\nint main(){\n char str[8][10];\n int count=0,i,j;\n\n for(i=0;i<8;i++){\n gets(str[i]);\n }\n\n for(i=0;i<8;i++){\n if(str[i][0]=='B'){\n for(j=1;j<8;j++){\n if(str[i][j]!='B') break;\n }\n if(j==8) count++;\n }\n }\n\n if(count<8){\n for(i=0;i<8;i++){\n if(str[0][i]=='B'){\n for(j=1;j<8;j++){\n if(str[j][i]!='B') break;\n }\n if(j==8) count++;\n }\n }\n }\n\n printf(\"%d\\n\",count);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms"], "code_uid": "dc2557262790cdbd7fed2b7ab03b7bb5", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n char s[10][10];\n int i,j,cnt=0,t,x=0;\n for(i=0;i<8;i++){\n gets(s[i]);\n t=0;\n for(j=0;j<8;j++)\n if(s[i][j]=='B')t++;\n if(t==8)cnt++;\n else x=t;\n }\n cnt+=x;\n printf(\"%d\\n\",cnt);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms"], "code_uid": "123f56481101460ec4b88c6c09babfa5", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n\n#include \n#include\nint main()\n{\n\tint n,mi=0,max=0,sum=0,sum1=0;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tfor(int i=0; i((i+1)*a[i]))\n\t\t{\n\t\t\tmax=(i+1)*a[i];\n\t\t\tmi=i;\n\n\t\t}\n\t}\n\tint b=n-1;\n\tfor(int j=0; j\nint mod(int,int);\nint main()\n{\n\tint n,a[100],el[100],min,x,i,u;\n\tscanf(\"%d\",&n);\n\tfor(i=0;iel[i])\n\t\tmin=el[i];\n\t}\n\tprintf(\"%d\",min);\n\t\n\treturn 0;\n}\nint mod(int i,int x)\n{\n\tif(i>x)\n\treturn i-x;\n\telse\n\treturn x-i;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "e6bda6e8c71be906c0a4d50e1382e49d", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#define rep(i,a,b) for (int i=a; ibox),&(arr[i]->match));\n}\nvoid sort(container **arr, int length) {\n container *temp;\n rep (i,0,length-1) {\n rep (j,i+1,length) {\n if ((arr[i]->match)<(arr[j]->match)) {\n temp=arr[i];\n arr[i]=arr[j];\n arr[j]=temp;\n }\n }\n }\n}\nlong min(ll x, ll y) {\n return (x<=y) ? x:y;\n}\nll max_matches(container **arr, int length, long maximum) {\n ll res=0;\n long fill=0,next;\n int pos=0;\n while (posbox);\n res+=(next-fill)*(arr[pos]->match);\n fill=next;\n pos++;\n }\n return res;\n}\nint main() {\n long maxsize;\n int m; scanf(\"%ld %d\\n\",&maxsize,&m);\n container *warehouse[m];\n scan(warehouse,m);\n sort(warehouse,m);\n printf(\"%I64d\",max_matches(warehouse,m,maxsize));\n rep (i,0,m) free(warehouse[i]);\n return 0;\n}", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "bc8a84575da01b35bb4b4c92b68e8495", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n unsigned int No_Of_ur_Matches_Boxes;\n unsigned short No_Of_Containers;\n scanf(\"%u%hu\", &No_Of_ur_Matches_Boxes, &No_Of_Containers);\n unsigned int No_Of_Matches_boxes_In_Container[No_Of_Containers];\n unsigned short No_Of_Matches_In_Matchesbox[No_Of_Containers];\n unsigned char i, j;\n for( i = 0; i < No_Of_Containers; i++){\n scanf(\"%u%hu\", &No_Of_Matches_boxes_In_Container[i], &No_Of_Matches_In_Matchesbox[i]);\n }\n /* debug the input\n for( i = 0; i < No_Of_Containers; i++){\n printf(\"%u %hu \\n\", No_Of_Matches_boxes_In_Container[i], No_Of_Matches_In_Matchesbox[i]);\n }*/\n unsigned char Max_index;\n Max_index = 0;\n unsigned int Max_Matches = 0;\n if( 1 == No_Of_Containers){\n if( No_Of_ur_Matches_Boxes <= No_Of_Matches_boxes_In_Container[Max_index]){\n Max_Matches += No_Of_ur_Matches_Boxes * No_Of_Matches_In_Matchesbox[Max_index];\n }\n else{\n Max_Matches += No_Of_Matches_boxes_In_Container[Max_index] * No_Of_Matches_In_Matchesbox[Max_index];\n }\n } else{\n for( j = 0; j < No_Of_Containers; j++){\n for( i = 0; i < (No_Of_Containers-1); i++ ){\n if( No_Of_Matches_In_Matchesbox[Max_index] < No_Of_Matches_In_Matchesbox[i+1]){ Max_index = i+1; }\n else if( No_Of_Matches_In_Matchesbox[Max_index] == No_Of_Matches_In_Matchesbox[i+1]){\n if( No_Of_Matches_boxes_In_Container[Max_index] < No_Of_Matches_boxes_In_Container[i+1]){ Max_index = i+1; }\n }\n }\n if( No_Of_ur_Matches_Boxes <= No_Of_Matches_boxes_In_Container[Max_index]){\n Max_Matches += No_Of_ur_Matches_Boxes * No_Of_Matches_In_Matchesbox[Max_index];\n break;\n }\n else{\n Max_Matches += No_Of_Matches_boxes_In_Container[Max_index] * No_Of_Matches_In_Matchesbox[Max_index];\n No_Of_ur_Matches_Boxes -= No_Of_Matches_boxes_In_Container[Max_index];\n No_Of_Matches_In_Matchesbox[Max_index] = 0;\n No_Of_Matches_boxes_In_Container[Max_index] = 0;\n Max_index = 0;\n }\n }\n }\n printf(\"%u\", Max_Matches);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "97081e6210bf4f77ddb10209761f649f", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define a0 table[i][0]\n#define a1 table[i][1]\n#define a2 table[i][2]\n#define b0 table[0][i]\n#define b1 table[1][i]\n#define b2 table[2][i]\n\nint main () {\n char table[4][4];\n int x = 0, o = 0;\n for (int i = 0; i < 3; i++) {\n scanf(\"%s\", table [i]);\n for (int j = 0; j < 3; j++) {\n if (table[i][j] == 'X') {\n x++;\n } else if (table [i][j] == '0') {\n o++;\n }\n }\n }\n if ((abs(x - o) > 1) || (o > x)) {\n printf (\"illegal\");\n return 0;\n }\n int win = 0, line = 0, row = 0;\n for (int i = 0; i < 3; i++) {\n if ((a0 == 'X' && a1 == 'X' && a2 == 'X')) {\n line += 1;\n win = 1;\n } else if ((a0 == '0' && a1 == '0' && a2 == '0')) {\n line += 1;\n win = 2;\n } else if ((b0 == 'X' && b1 == 'X' && b2 == 'X')) {\n row += 1;\n win = 1;\n } else if ((b0 == '0' && b1 == '0' && b2 == '0')) {\n row += 1;\n win = 2;\n }\n }\n if (line > 1 || row > 1) {\n printf(\"illegal\");\n return 0;\n }\n if (table[0][0] == 'X' && table [1][1] == 'X' && table[2][2] == 'X') {\n win = 1;\n } else if (table[2][0] == 'X' && table [1][1] == 'X' && table[0][2] == 'X') {\n win = 1;\n } else if (table[0][0] == '0' && table [1][1] == '0' && table[2][2] == '0') {\n win = 2;\n } else if (table[2][0] == '0' && table [1][1] == '0' && table[0][2] == '0') {\n win = 2;\n }\n\n if ((win == 0) && (x+o == 9)) {\n printf(\"draw\");\n } else if ((win == 0) && (x > o)) {\n printf(\"second\");\n } else if (win == 0) {\n printf(\"first\");\n } else if ((win == 1) && (x > o)) {\n printf(\"the first player won\");\n } else if ((win == 2) && (o == x)) {\n printf (\"the second player won\");\n } else {\n printf (\"illegal\");\n }\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "games"], "code_uid": "7bcf7a02d5576a7aaff2f6fd91dbc35f", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MAX(a, b) (((a)>(b))?(a):(b))\n\nchar grid[3][4];\n\nint adj(int x, int y){\n int i,j,max;\n char t;\n max=-1;\n t=grid[x][y];\n for(i=0; x+i<3&&grid[x+i][y]==t; ++i);\n max=MAX(max, i);\n for(i=0; x-i>-1&&grid[x-i][y]==t; ++i);\n max=MAX(max, i);\n for(j=0; y+j<3&&grid[x][y+j]==t; ++j);\n max=MAX(max, j);\n for(j=0; y-j<3&&grid[x][y-j]==t; ++j);\n max=MAX(max, j);\n for(i=0; x+i<3&&y+i<3&&grid[x+i][y+i]==t; ++i);\n max=MAX(max, i);\n for(i=0; x+i<3&&y-i>-1&&grid[x+i][y-i]==t; ++i);\n max=MAX(max, i);\n for(j=0; x-j>-1&&y+j<3&&grid[x-j][y+j]==t; ++j);\n max=MAX(max, j);\n for(j=0; x-j>-1&&y-j>-1&&grid[x-j][y-j]==t; ++j);\n max=MAX(max, j);\n return max;\n}\n\nint verdict(void){\n int i,j,p,d,f,s;\n d=f=s=0;\n for(i=0; i<3; ++i)\n for(j=0; j<3; ++j){\n if(grid[i][j]=='.')\n d=3;\n p=adj(i,j);\n if(p==3){\n if(grid[i][j]=='X')\n f=1;\n else if(grid[i][j]=='0')\n s=1;\n }\n }\n if(f&&s)\n d=-1;\n else if(f)\n d=1;\n else if(s)\n d=2;\n return d;\n}\n\nint place(void){\n int i,j,f,s;\n for(f=s=i=0; i<3; ++i)\n for(j=0; j<3; ++j){\n if(grid[i][j]=='X')\n ++f;\n else if(grid[i][j]=='0')\n ++s;\n }\n if(f==s)\n return 1;\n else if(f-s==1)\n return 2;\n else\n return 0;\n}\n\nint main(void){\n#ifndef ONLINE_JUDGE\n freopen(\"3C.in\", \"rb\", stdin);\n#endif\n int i,v,p;\n for(i=0; i<3; ++i)\n scanf(\"%s\", grid[i]);\n v=verdict();\n p=place();\n if(!p||(p==1&&v==1)||(p==2&&v==2))\n v=-1;\n switch(v){\n case -1: printf(\"illegal\\n\"); break;\n case 0: printf(\"draw\\n\"); break;\n case 1: printf(\"the first player won\\n\"); break;\n case 2: printf(\"the second player won\\n\"); break;\n case 3: printf(\"%s\\n\", p==1?\"first\":\"second\"); break;\n }\n#ifndef ONLINE_JUDGE\n fclose(stdin);\n#endif\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "games"], "code_uid": "d8327bbce2e1570b42d8a93cf0eb2ad5", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long\tint n,d,i,e,f=0,s;\n\tscanf(\"%ld %ld\",&n,&d);\n\tint a[n];\n\tfor(i=0;i\nint main()\n{\n int n,d,i,t,c=0,x=0,y=0,s,p;\n scanf(\"%d %d\",&n,&d);\n for(i=1;i<=n;i++){\n scanf(\"%d\",&t);\n y=y+t;\n x=x+t+10;\n }\n p=x-10;\n if(p<=d){\n s=d-y;\n t=s/5;\n printf(\"%d\\n\",t);\n }\n else\n printf(\"-1\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "ddd674f8e5fc01400484e2d756c3a004", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint a[n],i,ans=1001,max=0,j;\n\tfor(i=0;imax)\n\t\tmax=a[i+2]-a[i];\n\t\tfor(j=0;jmax&&(j!=i+1))\n\t\t\tmax=a[j+1]-a[j];\n\t\t\t//printf(\"%d \",max);\n\t\t}\n\t\t//printf(\"\\n\");\n\t\tif(max\nint main()\n{\n int n, a[100], i, j, k, l, max, min =100000, del;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n scanf(\"%d\",&a[i]);\n l=2;\n for(j=1;j<=n-2;j++)\n {\n del = a[l]; max=0;\n for(i=2;i<=n-1;i++)\n {\n if(a[i]==del)\n k = a[i+1]-a[i-1];\n else\n k= a[i+1]-a[i];\n if(k>max)\n max=k;\n }\n\n if(max\n#include \n\nvoid identificar_posicion(char *pos,int *a,int *b);\nvoid recorrido_caballo(int mat[][8],int f,int c);\nvoid recorrido_torre(int mat[][8],int f,int c);\n//void imprimir_mat(int mat[][8]);\n\nint main()\n{\n int mat[8][8];\n char pos[3];\n int i,j,ft,ct,fk,ck,cant=0;\n for(i=0;i<8;i++)\n {\n for(j=0;j<8;j++)\n {\n mat[i][j]=0;\n }\n }\n scanf(\"%s\",pos);\n identificar_posicion(pos,&ft,&ct);\n scanf(\"%s\",pos);\n identificar_posicion(pos,&fk,&ck);\n recorrido_torre(mat,ft,ct);\n recorrido_caballo(mat,fk,ck);\n recorrido_caballo(mat,ft,ct);\n for(i=0;i<8;i++)\n {\n for(j=0;j<8;j++)\n {\n if(!mat[i][j])\n {\n cant++;\n }\n }\n }\n\n printf(\"%d\",cant);\n return 0;\n}\n\n/*void imprimir_mat(int mat[][8])\n{\n int i,j;\n for(i=0;i<8;i++)\n {\n for(j=0;j<8;j++)\n {\n printf(\"%2d\",mat[i][j]);\n }\n printf(\"\\n\\n\");\n }\n}*/\n\nvoid recorrido_caballo(int mat[][8],int f,int c)\n{\n int i,fila=0,columna=0;\n mat[f][c]=-2;/*cambiar a -1*/\n int vec[16]={-1,-2,-2,-1,-2,1,-1,2,1,2,2,1,2,-1,1,-2};\n for(i=0;i<16;i+=2)\n {\n fila=f+vec[i];\n columna=c+vec[i+1];\n\n if(0<=fila && 0<=columna && fila<8 && columna<8)\n {\n mat[fila][columna]=-1;\n }\n }\n}\n\n\nvoid recorrido_torre(int mat[][8],int f,int c)\n{\n int i;\n mat[f][c]=-2;/*cambiar a -1*/\n for(i=0;i<8;i++)\n {\n mat[f][i]=-1;\n mat[i][c]=-1;\n }\n}\n\nvoid identificar_posicion(char *pos,int*a, int*b)\n{\n int i;\n char cadena[9]=\"abcdefgh\";\n for(i=0;cadena[i];i++)\n {\n if(pos[0]==cadena[i])\n {\n *a=i;\n }\n }\n *b=atoi(&pos[1])-1;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "527915c05e26dd063de62e6f4109f917", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\ntypedef struct {\n int x;\n int y;\n} Point_t;\n\nint main()\n{\n char pos[3];\n Point_t A[2];\n int step[8][2] = {{-2, 1}, {-1, 2}, {1, 2}, {2, 1}, {2, -1}, {1, -2}, {-1, -2}, {-2, -1}};\n for(int i = 0; i < 2; ++i) {\n scanf(\"%s\", pos);\n A[i].x = pos[0] - 'a';\n A[i].y = pos[1] - '1';\n }\n int ans = 0;\n for(int i = 0; i < 8; ++i) {\n for(int j = 0; j < 8; ++j) {\n if(i == A[0].x || j == A[0].y) {\n continue;\n }\n if(i == A[1].x && j == A[1].y) {\n continue;\n }\n int k;\n for(k = 0; k < 8; ++k) {\n int x = i + step[k][0];\n int y = j + step[k][1];\n if(x >= 0 && x < 8 && y >= 0 && y < 8) {\n if((x == A[0].x && y == A[0].y) || (x == A[1].x && y == A[1].y)) {\n break;\n }\n }\n }\n if(k == 8) {\n ++ans;\n }\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "1ddd8c4194b8037d85fbbf0ebed22151", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include\nint main(void) {\n int bl,br,gl,gr;\n scanf(\"%d %d %d %d\",&gl,&gr,&bl,&br);\n if(abs(bl-gr)<2||abs(br-gl)<2) printf(\"YES\");\n else if((bl<=2*gr+2&&bl>gr)||(br<=2*gl+2&&br>gl)) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "8906f4fc7485eb17247915566ed268f8", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\n\n\nint main(){\n int al,ar,bl,br;\n scanf(\"%d %d\",&al,&ar);\n scanf(\"%d %d\",&bl,&br); \n if ( ((bl-1)/2 <= ar) &&(bl >= ar-1))\n printf(\"YES\\n\");\n else if ( ((br-1)/2 <= al) &&(br >= al-1))\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "38e66a34efaa9d6e3e967bfd46d29e27", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,k1,k2,total,min=0,max=0;\n scanf(\"%d%d%d%d%d\",&a,&b,&k1,&k2,&total);\n \n if((k1-1)*a + (k2-1)*b >=total)\n min=0;\n else\n min=total-((k1-1)*a +(k2-1)*b);\n \n if(k1<=k2)\n {\n if(k1*a>total)\n {\n max=total/k1;\n if(max>a)\n {\n total=total-(a*k1);\n max=a;}\n else\n total=total-(max*k1);\n \n max+=total/k2;\n }\n else\n { max=a;\n \n total=(total-(k1*a));\n \n max+=total/k2;}\n \n }\n else\n {\n if(k2*b>total)\n {\n max=total/k2;\n if(max>b)\n {\n total=total-(b*k2);\n max=b;}\n else\n total=total-(max*k2);\n \n max+=total/k1;\n }\n else\n { max=b;\n \n total=(total-(k2*b));\n max+=total/k1;}\n }\n printf(\"%d %d\",min,max);\n \n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "01d15f3d3dc774f7ccd308c17bf7542f", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \ntypedef long long ll;\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\n#define max(l,r) ((l)>(r)?(l):(r))\n#define min(l,r) ((l)<(r)?(l):(r))\n#define chmax(l,r) (l=max(l,r))\n#define chmin(l,r) (l=min(l,r))\nconst ll MOD = 1000000007;\nconst int INF = (1 << 30); // > 10^9\n\n\nint main(){\n int a1,a2,k1,k2,n;\n scanf(\"%d%d%d%d%d\",&a1,&a2,&k1,&k2,&n);\n\n ll ansmx = 0, ansmn = 0;\n int tmp = n - (k1-1)*a1 - (k2-1)*a2;\n if(tmp < 0) ansmn = 0;\n else ansmn = tmp;\n\n tmp = 0;\n if(k1*a1 > n){\n tmp += n/k1;\n }else{\n tmp += a1;\n tmp += (n-k1*a1)/k2;\n }\n ansmx = 0;\n if(k2*a2 > n){\n ansmx += n/k2;\n }else{\n ansmx += a2;\n ansmx += (n-k2*a2)/k1;\n }\n chmax(ansmx, tmp);\n\n\n printf(\"%lld %lld\\n\", ansmn, ansmx);\n //if(ans){ puts(\"YES\"); rep(i,n) printf(\"%lld \", a[i]);}else puts(\"NO\");\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "a5057b5644372db630fd21c3237378a6", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nlong long int combination(long long int n,long long int r)\n{\n long long int result=1,i=1;\n while(i<=r)\n {\n result=result*n/i;\n n--;\n i++;\n }\n return result;\n}\nint main()\n{\n long long int n,m,t,result=0,i;\n scanf(\"%I64d %I64d %I64d\",&n,&m,&t);\n i=t-4;\n while(i>0)\n {\n result=result+combination(n,t-i)*combination(m,i);\n i--;\n }\n printf(\"%I64d\",result);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "2c64c5dd77f6b20357bf5162e2159d77", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nlong long ncr(long long n,long long r)\n{\n\tif(r>(n-r))\n\t\tr=n-r;\n\tlong long i,ret1=1,ret2=1,ret,j;\n\tint div[20]={0};\n\tdiv[1]=1;\n\tdiv[0]=1;\n\tfor(i=0;i=(k-1))\n\t{\n\t\tinitb=k-1;\n\t\tinitg=1;\n\t}\n\telse\n\t{\n\t\tinitb=n;\n\t\tinitg=k-n;\n\t}\n\tfor(;initb>=4 && initg<=m ;initb--,initg++)\n\t\tans+=((ncr(n,initb))*(ncr(m,initg)));\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "224d26497b168588f42dac6db0ff6828", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int x;\n scanf(\"%d\",&x);\n if(x==1 || x==2)\n printf(\"1\");\n else {\n if(x%3==0)\n printf(\"%d\",x/3*2);\n else {\n x=(int)x/3;\n x*=2;\n x++;\n printf(\"%d\",x);\n }\n }\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "2245b137939fbe8b40595c4cd8497385", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n printf(\"%d\\n\", (n*2+1)/3);\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "7e7fe1ac40e5ff9f871b39356571d16d", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint\nmain(void)\n{\n\tint rec[] = {0,1*60+10,2*60+20,3*60+30,4*60+40,5*60+50,10*60+1,11*60+11,12*60+21,13*60+31,14*60+41,15*60+51,20*60+2,21*60+12,22*60+22,23*60+32,24*60};\n\tint h1, h0, m1, m0,t, res;\n\tchar str[6] = { '\\0' };\n\tfgets(str, 6, stdin);\n\th1 = str[0] - '0';\n\th0 = str[1] - '0';\n\tm1 = str[3] - '0';\n\tm0 = str[4] - '0';\n\tt = (h1 * 10 + h0) * 60 + m1 * 10 + m0;\n\tfor (int indx = 0; indx < 17; ++indx) {\n\t\tif (rec[indx] >= t) {\n\t\t\tprintf(\"%d\", rec[indx] - t);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"ERROR!\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "de6b2f2898eb31315599b810a1b7acd3", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint p(int b[])\n{\n\tint flag=1;\n\tint i;\n\tfor(i=0;i<2;i++)\n\t{\n\t\tif(b[i]!=b[3-i])\n\t\t{\n\t\t\tflag=0;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(flag==1)\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\nint main()\n{\n\tchar a[5];\n\tint i;\n\tint count;\n\tfor(i=0;i<5;i++)\n\t{\n\t scanf(\"%c\",&a[i]);\n\t //printf(\"%c \",a[i]);\n\t \n\t}\n\tint b[4];\n\tint k=0;\n\tb[0]=(int)a[0]-48;\n\tb[1]=a[1]-48;\n\tb[2]=a[3]-48;\n\tb[3]=a[4]-48;\n\tcount=0;\n\twhile(1)\n\t{\n\t\tif(p(b)==1)\n\t\t\tbreak;\n\t\telse\n\t\t{\n\t\t\tif(b[2]==5 && b[3]==9)\n\t\t\t{\n\t\t\t\tb[2]=0;\n\t\t\t\tb[3]=0;\n\t\t\t\tif(b[1]==9 && b[0]<=1)\n\t\t\t\t{\n\t\t\t\t\tb[1]=0;\n\t\t\t\t\tb[0]++;\n\t\t\t\t}\n\t\t\t\telse if(b[1]==3 && b[0]==2)\n\t\t\t\t{\n\t\t\t\t\tb[0]=0;\n\t\t\t\t\tb[1]=0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tb[1]++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(b[3]==9)\n\t\t\t{\n\t\t\t\tb[3]=0;\n\t\t\t\tb[2]++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tb[3]++;\n\t\t\t}\n\t\t\tcount++;\n\t\t}\n\t}\n\tprintf(\"%d\",count);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "5f47c37f6323f6c0485b9aafb14a99dc", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#define For(i,n) for(i=0;is2)printf(\"Black\");\nif(s1==s2)printf(\"Draw\");\nif(s1\n#include\nint main()\n{\n char a[8][8];\n int w=0,b=0,r,c;\n for(r=0;r<8;r++)\n {\n for(c=0;c<8;c++)\n {\n scanf(\"%c\",&a[r][c]);\n if(a[r][c]=='Q') w+=9;\n else if(a[r][c]=='R') w+=5;\n else if(a[r][c]=='B') w+=3;\n else if(a[r][c]=='N') w+=3;\n else if(a[r][c]=='P') w+=1;\n if(a[r][c]=='q') b+=9;\n if(a[r][c]=='r') b+=5;\n if(a[r][c]=='b') b+=3;\n if(a[r][c]=='n') b+=3;\n if(a[r][c]=='p') b+=1;\n }\n getchar();\n }\n if(w>b) printf(\"White\");\n else if(b>w) printf(\"Black\");\n else if(b==w) printf(\"Draw\");\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "71e2b1d00a2aeaca1eb152469b647a91", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\n\tint a,b,c;\n\t\n\tscanf(\"%d\",&a);\n\t\n\tif(a==1) puts(\"1\");\n\telse{\n\t\tb = 1;\n\t\tc = 1;\n\t\twhile(a!=1){\n\t\t\tif(a%2==1) c++;\n\t\t\ta/=2;\n\t\t}\n\t\t\n\t\tprintf(\"%d\\n\",c);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "a83d3fc71a955301526aa2c864e12a6e", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int count = 0;\n while(n)\n {\n if(n%2==1) count++;\n n /= 2;\n }\n printf(\"%d\\n\",count);\n return 0;\n}", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "c8e2e669ca9cf805be95a140b82c7fd5", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/* \n * File: main.c\n * Author: scawn\n *\n * Created on April 22, 2012, 3:26 AM\n */\n\n#include \n#include \n\n/*\n * \n */\nint main(int argc, char** argv) {\n int n;\n scanf(\"%d\", &n);\n int sum = n;\n int i = 2;\n while (n > 1) {\n if (n % i == 0) {\n sum += n / i;\n n /= i;\n i = 2;\n } else {\n i++;\n }\n }\n printf(\"%d\\n\", sum);\n return (EXIT_SUCCESS);\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "40500e4c560f4b3b2ca55c460b26ce25", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,c,i;\n\tscanf(\"%d\",&n);\n\tc=n;\n\twhile(n>1)\n\t{\n\t\tfor(i=2;i<=n;i++)\n\t\t{\n\t\t\tif(n%i==0)\n\t\t\t\tbreak;\n\t\t}\n\t\tn=n/i;\n\t\tc=c+n;\n\t}\n\tprintf(\"%d\\n\",c);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "101740bcd0531dd99bddb5bbb24acc6b", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define min(a,b) a\nint min(int a, int b){return (a\n\ngcd(int a, int b)\n{\n int c;\n\n if ( b == 0 )\n return a;\n\n else\n while ( b != 0 )\n {\n c = b;\n b = a % b;\n a = c;\n }\n\n return a;\n}\n\n\n\n\nint main()\n{\n\tint a,b,c,d,a1,a2,a3;\n\tfloat m1,m2;\n\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n m1=(float)a/c;\n m2=(float)b/d;\n//printf(\"%f %f\\n\",m1,m2);\nif(m1\n\nint gcd(int a,int b)\n{\n int r;\n \n while(a%b>0)\n {\n r=b;\n b=a%b;\n a=r;\n }\n return b;\n}\n\nint main()\n{\n \n \n \n int a,b,c,d,k=1,Num,Den;\n scanf(\"%d %d %d %d\",&a,&b,&c,&d);\n \n float r1=(float)a/(float)b,r2=(float)c/(float)d;\n \n if(r1==r2)\n {\n Num=0;\n Den=1;\n goto abc;\n }\n else if(r1>r2)\n {\n Num=a*d-b*c;\n Den=a*d;\n }\n else\n {\n Num=b*c-d*a;\n Den=b*c;\n }\n \n \n k=gcd(Num,Den);\n \n abc:\n \n printf(\"%d/%d\",Num/k,Den/k);\n \n \n \n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "74ff19de34a2c8bcb13f4d69332a3693", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,i,num_x=0,m,remove=0;\n char s[101];\n scanf(\"%d\",&n);\n scanf(\"%s\",s);\n for(i=0; s[i]; i++)\n {\n if(s[i]=='x')\n num_x++;\n else\n {\n if(num_x>=3)\n {\n remove+=(num_x-2);\n }\n num_x = 0;\n }\n }\n if(num_x>=3)\n {\n remove+=(num_x-2);\n }\n\n printf(\"%d\",remove);\n\n return 0;\n}\n// 6 xxxiii\n// 5 xxoxx\n// 10 xxxxxxxxxx", "lang_cluster": "C", "tags": ["greedy", "strings"], "code_uid": "d808f5ac0c1eb5e47ee93901f6616626", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, ans = 0;\n char str[101];\n scanf(\"%d %s\", &n, str);\n for(int i = 0; i < n - 2; ++i) {\n if(str[i] == 'x' && str[i + 1] == 'x') {\n int j = i + 2;\n for(; j < n; ++j) {\n if(str[j] == 'x') {\n ++ans;\n } else {\n break;\n }\n }\n i = j;\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "strings"], "code_uid": "084f68dbf6a75aeb5af0470df58761aa", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main ()\n{\n\t\tint square[3][3];\n\t\tint i, j, z;\n\t\tfor (i=0; i<3; i++)\n\t\t{\n\t\t\tscanf(\"%d %d %d\", &square[i][0], &square[i][1], &square[i][2]);\n\t\t}\n\t\tfor (i=0; i<1000000; i++)\n\t\t{\n\t\t\tsquare[0][0]=i;\n\t\t\tsquare[1][1]=square[0][0]+square[0][1]+square[0][2]-square[1][0]-square[1][2];\n\t\t\tsquare[2][2]=square[0][0]+square[0][1]+square[0][2]-square[2][0]-square[2][1];\n\t\t\tif((square[0][0]+square[0][1]+square[0][2]==square[0][0]+square[1][0]+square[2][0])\t\\\n\t\t\t&&(square[0][0]+square[0][1]+square[0][2]==square[0][1]+square[1][1]+square[2][1])\t\\\n\t\t\t&&(square[0][0]+square[0][1]+square[0][2]==square[0][2]+square[1][2]+square[2][2])\t\\\n\t\t\t&&(square[0][0]+square[0][1]+square[0][2]==square[0][0]+square[1][1]+square[2][2])\t\\\n\t\t\t&&(square[0][0]+square[0][1]+square[0][2]==square[0][2]+square[1][1]+square[2][0]))\n\t\t\t{\n\t\t\t\tfor (j=0; j<3; j++)\n\t\t\t\t{\n\t\t\t\t\tfor (z=0;z<3; z++)\n\t\t\t\t\t\tprintf(\"%d \", square[j][z]);\n\t\t\t\t\tprintf(\"\\n\");\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\treturn 0;\n}\n\t\t\t", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "471bd1dfe233178f6412c0c1514c3ec7", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a[3][3],i,j;\n for(i=0;i<3;i++)\n for(j=0;j<3;j++)\n scanf(\"%d\",&a[i][j]);\n a[0][0]=(2*a[2][0]+a[2][1]-a[0][1])/2;\n a[2][2]=a[0][2]+a[2][0]-a[0][0];\n a[1][1]=a[0][1]+a[0][2]-a[2][2];\n for(i=0;i<3;i++)\n {\n for(j=0;j<3;j++)\n {\n if(j>0)\n printf(\" \");\n printf(\"%d\",a[i][j]);\n }\n printf(\"\\n\");\n }\n ;\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "dc68b22c3e2e00dce5a2c450bd8edc21", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n/* run this program using the console pauser or add your own getch, system(\"pause\") or input loop */\n\nint main(int argc, char *argv[]) {\n\tint k, l, m, n, b, i, a=0;\n\tscanf(\"%d%d%d%d%d\", &k, &l, &m, &n, &b);\n\tfor(i=1;i\n#include\nint main()\n{ char s[100];\n int i,k,a,b,c,j;\n scanf(\"%s\", s);\n k=0;\n for (i=0;i\nchar a[107];\nchar x[207];\nint cat(char c){\n\treturn (c=='a'||c=='o'||c=='u'||c=='i'||c=='e')?1:0;\n}\nvoid run(){\n\tint i,j;\n\twhile(scanf(\"%s\",a)!=EOF){\n\t\tfor(i=0,j=0;a[i]!='\\0';){\n\t\t\tif(a[i]=='n'){\n\t\t\t\tx[j++]=a[i++];\n\t\t\t\tx[j++]='a';\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tx[j++]=a[i++];\n\t\t}\n\t\tx[j]='\\0';\n\t\tfor(i=0;i=j-1&&cat(x[j-1])==1)?\"YES\":\"NO\");\n\t}\n}\nmain(){\n#ifndef\tONLINE_JUDGE\n\tfreopen(\"4972a_min.in\",\"rb\",stdin);\n\tfreopen(\"4972a_.out\",\"wb\",stdout);\n#endif\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "005a344827780d9618ebbbc0065fa787", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int l,r,n,m,k,sum,t;\n scanf(\"%d %d %d\",&n,&m,&k);\n m=m-n;\n sum=1;\n l=k;\n r=k;\n t=1;\n while(m>=t)\n {\n sum++;\n m=m-t;\n if(l>1)\n {\n l--;\n t++;\n }\n if(r\nint main()\n{\n\tint n,m,i=1,j,k,d,c=1,l;\n\tscanf(\"%d%d%d\",&n,&m,&k);\n\tl=n-k;\n\tm-=n;\n\twhile(m>=i)\n\t{\n\t\tc++;\n\t\tm-=i;\n\t\tif(k-1>0)\n\t\t{\n\t\t\tk--;\n\t\t\ti++;\n\t\t}\n\t\tif(l>0)\n\t\t{\n\t\t\tl--;\n\t\t\ti++;\n\t\t}\n\t}\n\tprintf(\"%d\",c);\n}\n", "lang_cluster": "C", "tags": ["greedy", "binary search"], "code_uid": "127e64fc8c1355f760996534ab6402ac", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//\n// 796A-codeforces.c\n// Bang Bang Bang\n//\n// Created by Mohammad Shamim on 12/4/17.\n// Copyright (c) 2017 Mohammad Shamim. All rights reserved.\n//\n\n\n#include\n#include\n\nint main()\n{\n int i,n,m,k,j=0,x;\n scanf(\"%d %d %d\",&n,&m,&k);\n int h[n],s[n],min=n;\n m--;\n for(i=0;ix)\n min=x;\n }\n printf(\"%d\",min*10);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "888127c133e77615f5354e2dafb21c22", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint n,pisition,money,i,j;\n\tint min=9999,output;\n\t\n\tscanf(\"%d %d %d\",&n,&pisition,&money);\n\t\n\tint num[n];\n\t\n\tfor(i=0;imoney)\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\n\t\toutput=abs(i+1-pisition)*10;\n\t\t\n\t\tif(output\nint main()\n{\n long long int a,b,c,d,n,i,s=0;\n scanf(\"%lld %lld %lld %lld\",&a,&b,&c,&d);\n if(a>=b&&a<=c)\n {\n if(a-b=c&&a<=b)\n {\n if(a-c=c&&b<=a)\n {\n if(b-c=a&&b<=c)\n {\n if(b-a=a&&c<=b)\n {\n if(c-a=b&&c<=a)\n {\n if(c-b\nint main()\n{\nint a,b,c,d,i,j,min,k,m,co,coun=0;\nscanf(\"%d\",&a);\nscanf(\"%d\",&b);\nscanf(\"%d\",&c);\nscanf(\"%d\",&d);\nint x[3];\nx[0]=a,x[1]=b,x[2]=c;\n\nfor(i=0;i<3;i++)\n{\nmin=x[i],k=0,m=0,co=0;\nfor(j=i+1;j<3;j++)\n{\nif(x[j]0)\n{\nk=x[i];\nx[i]=min;\nx[m]=k;\n}\n}\nwhile(x[1]-x[0]\n#include\n\nchar s[51], in[51];\n\nint main()\n{\n int i, inLen = 0, j = 0;\n\n scanf(\"%s\\n%s\", s, in);\n\n inLen = strlen(in);\n\n for(i=0; i\n#include\nint main(){\n int j=0;\n char r[50],ins[50];\n scanf(\"%s\",&r);\n scanf(\"%s\",&ins);\n for(int i=0;i\n#include\n#include\n\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\t//int arr[n];\n\tint sum = 0, a, i;\n\tint c_1 = 0 , c_2 = 0;\n\tfor(i = 0 ;i < n ;i++ ){\n\t\t//scanf(\"%d\", &arr[i]);\n\t\tscanf(\"%d\", &a);\n\t\tif(a == 100 ) c_1++;\n\t\tif(a == 200 ) c_2++;\n\t\tsum += a;\n\t}\n\t\n\tif(n == 1 ){\n\t\tif(sum == 200){\n\t\t\tprintf(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tif(c_1 % 2 == 1){\n\t\tprintf(\"NO\\n\");\n\t\treturn 0;\n\t}\n\n\tif(c_2 % 2 == 1){\n\t\tif(c_1 == 0 ){\n\t\t\tprintf(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}\n\t} \t\n\n\tif(sum % 200 == 0){\n\t\tprintf(\"YES\\n\");\n\t}else{\n\t\tprintf(\"NO\\n\");\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "f15fbbbd5263d89e37ccd69b55e57049", "src_uid": "9679acef82356004e47b1118f8fc836a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint w[105];\nint main()\n{\n int n=0,i=0;\n int a=0,b=0;\n scanf(\"%d\",&n);\n for(i=0;i\nint main()\n{\nint n,k,l,c,d,p,nl,np,a,b,e,min;\nscanf(\"%d%d%d%d%d%d%d%d\",&n,&k,&l,&c,&d,&p,&nl,&np);\na=(k*l)/nl;\nb=c*d;\ne=p/np;\nmin=a\n\nint main()\n{\n int n, k, l, c, d, p, nl, np;\n int a[100];\n int min = 1001;\n scanf(\"%d%d%d%d%d%d%d%d\", &n, &k, &l, &c, &d, &p, &nl, &np);\n a[0] = k*l/nl;\n a[1] = c*d;\n a[2] = p/np;\n for(int i=0; i<3; i++)\n {\n if(min >= a[i])\n {\n min = a[i];\n }\n }\n printf(\"%d\", min/n);\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "fd9e081034388510ecd47221defaff99", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\t\n\tint r, c, n, min;\n\tint e, y;\n\tint x = 0, z = 0;\n\t\n\tscanf(\"%d %d %d %d\", &r, &c, &n, &min);\n\tint a[r][c];\n\tfor(int i = 0; i < r; i++){\n\t\tfor(int j = 0; j < c; j++){\n\t\t\ta[i][j] = 0;\n\t\t}\n\t}\n\tfor(int l = 0; l < n; l++){\n\t\tscanf(\"%d %d\", &e, &y);\n\t\ta[e - 1][y - 1] = 1;\n\t}\n\tfor(int o = 0; o < r; o++){\n\t\tfor(int p = 0; p < c; p++)\n\t\t\tfor(int q = 0; q <= o; q++)\n\t\t\t\tfor(int k = 0; k <= p; k++){\n\t\t\t\t\tx = 0;\n\t\t \t\t\tfor(int i = q; i <= o; i++)\n\t\t\t\t\t\tfor(int j = k; j <= p; j++)\n\t\t\t\t\t\t\tx = x + a[i][j];\t\t\n\t\t\t\t\tif(x >= min)\n\t\t\t\t\t\tz++;\t\n\t\t\t\t}\n\t}\n\n\tprintf(\"%d\", z);\t\nreturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "2d5f68cc73df4e3e420570002d1d0805", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint i, x1, y1, x2, y2, r, c, n, k, x, y, cnt, rectcnt;\n\tstatic int hasviola[10][10];\n\n\tscanf(\"%d%d%d%d\", &r, &c, &n, &k);\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d%d\", &x, &y);\n\t\thasviola[x - 1][y - 1] = 1;\n\t}\n\trectcnt = 0;\n\tfor (x1 = 0; x1 < r; x1++)\n\t\tfor (x2 = x1; x2 < r; x2++)\n\t\t\tfor (y1 = 0; y1 < c; y1++)\n\t\t\t\tfor (y2 = y1; y2 < c; y2++) {\n\t\t\t\t\tcnt = 0;\n\n\t\t\t\t\tfor (x = x1; x <= x2; x++)\n\t\t\t\t\t\tfor (y = y1; y <= y2; y++)\n\t\t\t\t\t\t\tif (hasviola[x][y])\n\t\t\t\t\t\t\t\tcnt++;\n\t\t\t\t\tif (cnt >= k)\n\t\t\t\t\t\trectcnt++;\n\t\t\t\t}\n\n\n\tprintf(\"%d\\n\", rectcnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "88a9468813e49409553c0628298b8a65", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\n\n main()\n{\n int T[10][10],i,j,a;\n scanf(\"%d\",&a);\n for(i=0;i\nint main(){\nlong long int n,arr[100][100],i,j,t=1;\nscanf(\"%lld\",&n);\nfor(j=1;j<=n;j++){\n arr[1][j]=1;\n}\nfor(i=1;i<=n;i++){\n arr[i][1]=1;\n}\nfor(i=2;i<=n;i++){\n for(j=2;j<=n;j++){\n arr[i][j]=arr[i-1][j]+arr[i][j-1];\nt=arr[i][j];}}\n printf(\"%lld\\n\",t);\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "ae1915b3748de5576feeca1010b7cc9f", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int s[4],k,j,i,count=0;\n for(i=0;i<4;i++)\n {\n scanf(\"%d \",&s[i]);\n }\n for(j=0;j<4;j++)\n {\n for(k=j+1;k<4;k++)\n {\n if(s[j]!=s[k])\n {\n while(s[j]==s[k])\n count++;\n }\n else\n {\n count++;\n break;\n }\n }\n }\n printf(\"%d\",count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "af8a9b22f4116cf7c795035347c7c1d6", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long int s[10];\n int i,a=0,j,b,c=4;\n for(i=0;i<4;i++){\n scanf(\"%li\",&s[i]);\n }\n\n for(i=0;i<4;i++){\n for(j=i+1;j<4;j++){\n if(s[i]==s[j]){\n a++;\n break;\n }\n }\n }\n\n printf(\"%d\\n\",a);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ff9ae9bfd7ce94aba07422aa22503987", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int c,o,k;\n scanf(\"%d %d\",&c,&o);\n k=o-1;\n // printf(\"%d %d %d\",k,c,o);\n if(o==1)\n {\n if(c==0)\n printf(\"Yes\");\n else\n printf(\"No\");\n }\n else\n {\n if(c>=k&&c%2==0&&k%2==0&&o!=0)\n printf(\"Yes\");\n else if(c>=k&&c%2!=0&&k%2!=0&&o!=0)\n printf(\"Yes\");\n else\n printf(\"No\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "854938a57a56f3912ea5dd23c56bef22", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int x,y;\n scanf(\"%lld %lld\",&x,&y);\n if(y<=1&&x>0)\n {\n printf(\"NO\\n\");\n }\n else if(y==0&&x==0)\n {\n printf(\"NO\\n\");\n }\n else if(x==0&&y==1)\n {\n printf(\"YES\\n\");\n }\n else if(x==0&&y>1)\n {\n printf(\"NO\\n\");\n }\n else if(y==1&&x==0)\n {\n printf(\"YES\\n\");\n }\n else if(y>1&&x>0)\n {\n if(y>x+1)\n {\n printf(\"NO\\n\");\n }\n else if(x%2==1&&y%2==0)\n {\n printf(\"YES\\n\");\n }\n else if(x%2==0&&y%2==1)\n {\n printf(\"YES\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9b87a1929bc113a15f86d88d313feb10", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int N,i,j,f[10];\n char buf[20];\n scanf(\"%d\", &N);\n scanf(\"%s\", buf);\n for(i=0;i<10;i++) f[i]=0;\n for(i=0;i=2;i--) for(j=0;j\n\nint main(){\n\tint n,i,ar[4];\n\tchar s[20],ans[10000];\n\tscanf(\"%d %s\",&n,s);\n\tar[0]=0;ar[1]=0;ar[2]=0;ar[3]=0;\n\tfor(i=0;i0){\n\t\tans[i]='7';\n\t\tar[3]--;\n\t\tar[2]--;\n\t\tar[1]-=2;\n\t\tar[0]-=4;\n\t\ti++;\n\t}\n\twhile(ar[2]>0){\n\t\tans[i]='5';\n\t\tar[2]--;\n\t\tar[1]--;\n\t\tar[0]-=3;\n\t\ti++;\n\t}\n\twhile(ar[1]>0){\n\t\tans[i]='3';\n\t\tar[1]--;\n\t\tar[0]--;\n\t\ti++;\n\t}\n\twhile(ar[0]>0){\n\t\tans[i]='2';\n\t\tar[0]--;\n\t\ti++;\n\t}\n\tans[i]='\\0';\n\tprintf(\"%s\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "sortings", "greedy"], "code_uid": "7d13d378164c3851f6b5e6c51c96fdae", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int n,m,p;\n scanf(\"%d%d\",&n,&m);\n p=((n+1)/2+m-1)/m*m;\n if(p<=n)\n printf(\"%d\",p);\n else\n printf(\"-1\");\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c8a3a3181bc870611601a333fd238b02", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,m;\n scanf(\"%d %d\",&n,&m);\n if(n>m){\n if(n%2==0&&(n/2)%m==0){printf(\"%d\",n/2);}\n /* else if(n%2==0&&(n/2)%m==0&&m==2){printf(\"b%d\",n/2);}*/\n else if(n%2!=0&&(n/2)%m==0)printf(\"%d\",n/2+m);\n else {printf(\"%d\",n/2+ (m-(n/2)%m));}}\n if(n==m)printf(\"%d\",m);\n if(n\nint main()\n{\nint n,m,c,d,min;\nscanf(\"%d%d\",&n,&m);\nc=(m-1)<=0?1:m-1;\nd=(m+1)>n?n:m+1;\nmin=(c-1>=n-d)?c:d;\nif(min==c&&min==m)\nmin=d;\nelse if(min==d&&min==m)\nmin=c;\nprintf(\"%d\",min);\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "0d54439f6bb4e4582b41a7f650d6dffe", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n long long int n,m;\n scanf(\"%lld%lld\",&n,&m);\n if(n == m && n == 1)\n printf(\"1\");\n else if(2*m <= n) {\n printf(\"%lld\",m+1);\n }\n else {\n printf(\"%lld\",m-1);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "games", "math", "greedy", "implementation"], "code_uid": "0a6d0e9a2055b3a95288ae1cec10fa42", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{ int h1,h2,m1,m2,h,m,t;\n scanf(\"%d:%d\",&h1,&m1);\n scanf(\"%d:%d\",&h2,&m2);\n h1=h1*60;\n h2=h2*60;\n t=(h1+h2+m1+m2)/2;\n h=(t/60);\n m=(t%60);\n if(h<10&&m<10)\n {printf(\"0%d:0%d\\n\",h,m);}\n else if(h>9&&m<10)\n {printf(\"%d:0%d\\n\",h,m);}\n else if(h<10&&m>9)\n {printf(\"0%d:%d\\n\",h,m);}\n else\n {printf(\"%d:%d\\n\",h,m);}\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ded608b523d8814ed7082987a084d010", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int h1,m1,h2,m2,dm,midm;\n int dh,htm,divh,mod,fh,fm;\n char ch1,ch2;\n scanf(\"%d\",&h1);\n scanf(\"%c\",&ch1);\n scanf(\"%d\",&m1);\n scanf(\"%d\",&h2);\n scanf(\"%c\",&ch2);\n scanf(\"%d\",&m2);\n if(h1==h2)\n {\n dm=m2+m1;\n midm=dm/2;\n if(h1<10)\n {\n printf(\"0%d:\",h1);\n }\n else\n {\n printf(\"%d:\",h1);\n }\n if(midm<10)\n {\n printf(\"0%d\\n\",midm);\n }\n else\n {\n printf(\"%d\\n\",midm);\n }\n }\n else\n {\n\n if(m1==m2)\n {\n dh=h2-h1;\n htm=dh*60;\n midm=htm/2;\n divh=midm/60;\n mod=midm%60;\n fh=h1+divh;\n fm=m1+mod;\n if(fm==60)\n {\n fm=0;\n fh=fh+1;\n }\n if(fh<10)\n {\n printf(\"0%d:\",fh);\n }\n else\n {\n printf(\"%d:\",fh);\n }\n if(fm<10)\n {\n printf(\"0%d\\n\",fm);\n }\n else\n {\n printf(\"%d\\n\",fm);\n }\n }\n else if(m1>m2)\n {\n int c1,c2,tm,dm;\n tm=0;\n c1=h1;\n c2=h2;\n while(c1=60)\n {\n fm=fm-60;\n fh=fh+1;\n }\n if(fh<10)\n {\n printf(\"0%d:\",fh);\n }\n else\n {\n printf(\"%d:\",fh);\n }\n if(fm<10)\n {\n printf(\"0%d\\n\",fm);\n }\n else\n {\n printf(\"%d\\n\",fm);\n }\n\n }\n else\n {\n int c1,c2,tm,dm;\n tm=0;\n c1=h1;\n c2=h2;\n while(c1=60)\n {\n fm=fm-60;\n fh=fh+1;\n }\n if(fh<10)\n {\n printf(\"0%d:\",fh);\n }\n else\n {\n printf(\"%d:\",fh);\n }\n if(fm<10)\n {\n printf(\"0%d\\n\",fm);\n }\n else\n {\n printf(\"%d\\n\",fm);\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "69dcf037428d4e25914a395d572d6b2b", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int n1,n2,k1,k2,a,b;\n scanf(\"%d %d %d %d\",&n1,&n2,&k1,&k2);\n if(n1<=n2)\n printf(\"Second\\n\");\n else\n printf(\"First\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "4a30985f814f59f8e2ac9514fee17374", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n1 = 0 , n2 = 0 , k1 = 0 , k2 = 0;\n int i = 0 , b = 0;\n scanf(\"%d%d%d%d\",&n1,&n2,&k1,&k2);\n\n for(i=0;i<100;i++){\n n1--;\n if(n1==0){\n b = 1;\n break;\n }\n n2--;\n if(n2==0){\n b = 0;\n break;\n }\n }\n if(b)\n printf(\"Second\");\n else\n printf(\"First\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "11d836b04dd7663ec097a86dc95a61de", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,num=1,i,count=0,flag=0,count1=0,temp;\n\tscanf(\"%d\",&n);\n\twhile(1)\n\t{\n\t\tif(count==n)\n\t\t{\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t\tif(count>n)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tcount++;\n\t\tcount1++;\n\t\tnum=count1*5;\n\t\ttemp=num/5;\n\t\twhile(temp%5==0)\n\t\t{\n\t\t\ttemp=temp/5;\n\t\t\tcount++;\n\t\t}\n\t\t//printf(\"%d %d %d\\n\",num,count1,count);\n\t}\n\tif(flag==0)\n\t\tprintf(\"0\\n\");\n\telse if(flag==1)\n\t{\n\t\tprintf(\"%d\\n\",(count1+1)*5-num);\n\t\tfor(i=num;i<(count1+1)*5;i++)\n\t\t\tprintf(\"%d \",i);\n\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms", "number theory"], "code_uid": "8f42190973f139a765ee4a3e58ecf0b4", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int m,k,i,n;\n while(scanf(\"%d\",&m)!=EOF)\n {\n for(i=5;m;i+=5)\n {\n n=i;\n while(n%5==0&&n)\n {\n m--;\n n/=5;\n }\n if(m==0)\n {\n n=i;\n k=5;\n }\n if(m<0)\n {\n m=0;\n k=0;\n }\n }\n printf(\"%d\\n\",k);\n if(k>0)\n {\n for(i=0;i\n#include \n\nint cmpfunc(const void*a,const void*b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint main()\n{\n\tint i,j,k,n,a[3],temp,temp1,temp2,temp3,sum,max=-1;\n\tscanf(\"%d %d %d %d\",&n,a,a+1,a+2);\n\tqsort(a,3,sizeof(int),cmpfunc);\n\ttemp=n/a[0];\n\ttemp1=n/a[1];\n\ttemp2=n/a[2];\n\tif(n%a[0]==0)\n\t{\n\t\tprintf(\"%d\\n\",n/a[0]);\n\t\treturn 0;\n\t}\n\tfor(i=temp;i>=0;i--)\n\t{\n\t\tfor(j=temp1;j>=0;j--)\n\t\t{\n\t\t\ttemp3=n-i*a[0]-j*a[1];\n\t\t\tif(temp3%a[2]==0&&temp3>=0)\n\t\t\t{\n\t\t\t\tsum=i+j+(temp3/a[2]);\n\t\t\t\tif(sum>max)\n\t\t\t\t{\n\t\t\t\t\tmax=sum;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\",max);\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp"], "code_uid": "ccc10547e2477df39462aa6124403fb0", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint dp[5000],i,j,k,l,x,ans,m;\n\nint max(int x,int y,int z)\n{\n if(x>=y && x>=z)\n return x;\n else if(y>=x && y>=z)\n return y;\n else\n return z;\n}\nint cut(int x)\n{\n int a,b,c;\n if(x==0)\n {\n //printf(\"if: a:%d b:%d c:%d x:%d\\n\",a,b,c,x);\n dp[x]=0;\n return 0;\n }\n else if(x0){printf(\"Impossible\");}\n else{printf(\"%d %d\",((a)>(b))?(a):(b),b!=0?a+b-1:a);}\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "5cbc5b0dfb04c42fb529ea45384b4f49", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n //write your logic here...\n int n,m;\n \n scanf(\"%d\",&n);\n\n scanf(\"%d\",&m);\n if (n != 0 || m == 0)\n {\n printf(\"%d %d\\n\", (m > n ? m : n), (m != 0 ? n + m - 1 : n));\n }\n else\n {\n printf(\"Impossible\\n\");\n }\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "f14fc4f89a0339a9b7e32a1fe856b500", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, i;\n scanf(\"%d\", &n);\n for(i = 31; i >= 0; i--) {\n if(1 << i & n) {\n printf(\"%d \", i + 1);\n }\n }\n puts(\"\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a4f2d1374b575a0b57cb8e9481a4ff96", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\tint n,k=0,i;\n\tscanf(\"%d\",&n);\n\tint a[100];\n\twhile(n!=0)\n\t{\n\t\ta[k++]=n%2;\n\t\tn=n/2;\n\t}\n\tfor(i=k-1;i>=0;i--)\n\t{\n\t\tif(a[i]==1)\n\t\tprintf(\"%d \",i+1);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "60c276dae7f247bbcdf13f182039401a", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint sum_digs(int k)\n{\n\tint s = 0;\n\t\n\twhile (k != 0)\n\t{\n\t\ts = s + k % 10;\n\t\tk /= 10;\n\t}\n\t\n\treturn s;\n}\n\nint perfect_num(int k)\n{\n\tint i = 19;\n\tint n = 1;\n\t\n\twhile ((n < k))\n\t{\n\t\ti += 9;\n\t\tif ((sum_digs(i) == 10)) n++;\n\t}\n\t\n\treturn i;\n}\n\nint main()\n{\n\tint k;\n\t\n\tscanf(\"%d\", &k);\n\tprintf(\"%d\", perfect_num(k));\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "3431d9e1bcd04c222c9116398582dbf9", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint sum(int a){int s=0;\n while(a!=0){\n s+=a%10;\n a/=10;\n }return s;\n}\nint main(){\n int k; \n scanf(\"%d\",&k);\n int a=1;\n while(k!=0){\n a++;\n if(sum(a)==10)\n k--;\n }\n printf(\"%d\",a);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "dp", "binary search", "implementation", "number theory"], "code_uid": "1d6cb7ffe24c1250856b5697594d640d", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n,k,i,t;\n scanf(\"%I64d%I64d\",&n,&k);\n for(i=1;i<=k;i++)\n {\n t=n%10;\n if(t>0)\n {\n n=n-1;\n }\n else\n {\n n=n/10;\n }\n }\n printf(\"%d\",n);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "080fe10816a73a45944e147a47c04fad", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n \n int n,k;\n int i;\n \n scanf(\"%d%d\",&n,&k);\n \n \n \n \n for(i=1;i<=k;i++){\n {\n if(n%10==0)\n n=n/10;\n else\n n=n-1;\n }}\n printf(\"%d\",n);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "1f1512a13bfcba5a0280612014ab7538", "src_uid": "064162604284ce252b88050b4174ba55", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint A[10][10];\n\nint main()\n{\n int N, T;\n scanf(\"%d %d\", &N, &T);\n while(T--) {\n A[0][0] += 512;\n for(int i = 0; i < N - 1; ++i) {\n for(int j = 0; j <= i; ++j) {\n if(A[i][j] > 512) {\n int val = A[i][j] - 512;\n A[i + 1][j] += val / 2;\n A[i + 1][j + 1] += val / 2;\n A[i][j] = 512;\n }\n }\n }\n }\n int ans = 0;\n for(int i = 0; i < N; ++i) {\n for(int j = 0; j <= i; ++j) {\n if(A[i][j] >= 512) {\n ++ans;\n }\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "3922ba174905c19376a91d2eda5b7618", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,t;\n\twhile(scanf(\"%d%d\",&n,&t)!=EOF)\n\t{\n\t\tdouble a[15][15]={0};\n\t\tint i,j,k,num=0;\n\t\ta[1][1]=t;\n\t\tfor(i=2;i<=n;i++)\n\t\t\tfor(j=1;j=1)\n\t\t\t\t{\n\t\t\t\t\ta[i][j]+=(a[i-1][j]-1)/2;\n\t\t\t\t\ta[i][j+1]+=(a[i-1][j]-1)/2;\n\t\t\t\t\ta[i-1][j]=1;\n\t\t\t\t\tnum++;\n\t\t\t\t}\n\t\tfor(j=1;j<=n;j++)\n\t\t\tif(a[i-1][j]>=1)\n\t\t\t\tnum++;\n\t\tprintf(\"%d\\n\",num);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "5b62d4aa27e576438e40859f75c26009", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nunsigned long long min(unsigned long long a, unsigned long long b) {\n if (a < b) {\n return a;\n } else {\n return b;\n }\n}\n\nunsigned long long max_with_256(k_2, k_3, k_5, k_6) {\n unsigned long long min_32, min_256;\n min_256 = min(min(k_2, k_5), k_6);\n min_32 = min(k_2 - min_256, k_3);\n return 256 * min_256 + 32 * min_32;\n}\n\nunsigned long long max_with_32(k_2, k_3, k_5, k_6) {\n unsigned long long min_32, min_256;\n min_32 = min(k_2, k_3);\n min_256 = min(min(k_2 - min_32, k_5), k_6);\n return 256 * min_256 + 32 * min_32;\n}\n\nint main() {\n unsigned long long k_2, k_3, k_5, k_6;\n unsigned long long result = 0;\n\n scanf(\"%llu\", &k_2);\n scanf(\"%llu\", &k_3);\n scanf(\"%llu\", &k_5);\n scanf(\"%llu\", &k_6);\n\n unsigned long long min_32, min_256;\n min_32 = min(k_2, k_3);\n min_256 = min(min(k_2, k_5), k_6);\n\n if (max_with_256(k_2, k_3, k_5, k_6) > max_with_32(k_2, k_3, k_5, k_6)) {\n printf(\"%llu\\n\", max_with_256(k_2, k_3, k_5, k_6));\n } else {\n printf(\"%llu\\n\", max_with_32(k_2, k_3, k_5, k_6));\n }\n\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "9225db500b13aa9895d8a925c4bf632d", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int k2, k3, k5, k6, max256 = 0, max32 = 0, sum = 0;\n scanf(\"%d%d%d%d\", &k2, &k3, &k5, &k6);\n if(k2 > 0 && k5 > 0 && k6 > 0){\n if(k2 <= k5 && k2 <= k6)max256 = k2;\n if(k5 <= k6 && k5 <= k2)max256 = k5;\n if(k6 <= k2 && k6 <= k5)max256 = k6;\n sum += (max256 * 256);\n k2 -= max256;\n k5 -= max256;\n k6 -= max256;\n }\n if(k2 > 0 && k3 > 0){\n if(k2 <= k3)max32 = k2;\n else max32 = k3;\n sum += (max32 * 32);\n }\n printf(\"%d\\n\", sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "5a7d1286dddb279d0804ca47c8cc31b6", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n\nmain() {\n\tchar s[101], string[102]=\"a\";\n\tint leng = 0, dist = 0, dist1, dist2;\n\tscanf(\"%s\", s);\n\tstrcat(string, s);\n\twhile (string[leng] != '\\0')\n\t\tleng++;\n\t\n\n\n\tfor (int i = 0; i < leng - 1; i++) {\n\t\tchar x, y;\n\t\tif (string[i] <= string[i + 1]) {\n\t\t\tx = string[i];\n\t\t\ty = string[i + 1];\n\t\t}\n\t\telse {\n\t\t\tx = string[i + 1];\n\t\t\ty = string[i];\n\t\t}\n\t\tdist1 = y - x;\n\t\tdist2 = (x - 97) + (122 - y) + 1;\n\t\tif (dist1 <= dist2)\n\t\t\tdist += dist1;\n\t\telse\n\t\t\tdist += dist2;\n\n\n\t}\n\tprintf(\"%d\", dist);\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "11a583176f228047d4d3597a48753d01", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n char s[1000];\n scanf(\"%s\", s);\n char cur = 'a';\n int t = 0;\n for(int i = 0;s[i] != '\\0';i++){\n t += abs(s[i] - cur) < 26 - abs(s[i]-cur) ? abs(s[i]-cur) : 26 - abs(s[i] - cur);\n cur = s[i];\n }\n printf(\"%d\\n\", t);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "915df634feaeb9d7be99ef4a575ee475", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint m,n,a,b;\nscanf(\"%d %d\",&n,&m);\nif(n>m)\n{a=n-1;\nb=m;\n}\nelse\n{a=m-1;\nb=n;\n}\nprintf(\"%d %d\",a,b);\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation", "games"], "code_uid": "59efb1dfab25bdebf39b5010fc6915fb", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAXN 100002\n\n#define R 0x1\n#define B 0x2\n\nunsigned char balls[MAXN+MAXN];\n\nvoid solve(int prev, int r, int b, int *s1, int *s2) {\n\tint turn = 0x1;\n\tint curr;\n\tif (prev == R) r--;\n\telse b--;\n\t*s1 = 0;\n\t*s2 = 0;\n\twhile (r + b > 0) {\n\t\tif (turn == 0) {\n\t\t\tif (prev == R) {\n\t\t\t\tif (r > 0) {\n\t\t\t\t\tr--;\n\t\t\t\t\tcurr = R;\n\t\t\t\t}\n\t\t\t\telse if (b > 0) {\n\t\t\t\t\tb--;\n\t\t\t\t\tcurr = B;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (b > 0) {\n\t\t\t\t\tb--;\n\t\t\t\t\tcurr = B;\n\t\t\t\t} else if (r > 0) {\n\t\t\t\t\tr--;\n\t\t\t\t\tcurr = R;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (prev == R) {\n\t\t\t\tif (b > 0) {\n\t\t\t\t\tb--;\n\t\t\t\t\tcurr = B;\n\t\t\t\t} else if (r > 0) {\n\t\t\t\t\tr--;\n\t\t\t\t\tcurr = R;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (r > 0) {\n\t\t\t\t\tr--;\n\t\t\t\t\tcurr = R;\n\t\t\t\t} else if (b > 0) {\n\t\t\t\t\tb--;\n\t\t\t\t\tcurr = B;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (prev == curr) ++(*s1);\n\t\telse ++(*s2);\n\t\tturn ^= 0x1;\n\t\tprev = curr;\n\t}\n}\n\nint main() {\n\tint s1, s2;\n\tint s3, s4;\n\tint r, b;\n\tscanf(\"%d %d\", &r, &b);\n\n\tsolve(R, r, b, &s1, &s2);\n\tsolve(B, r, b, &s3, &s4);\n\tif (s1 > s3) {\n\t\tprintf(\"%d %d\\n\", s1, s2);\n\t} else {\n\t\tprintf(\"%d %d\\n\", s3, s4);\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["greedy", "implementation", "games"], "code_uid": "68257ef9b844f00dbc324275e83dc0c8", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint bo = 0;\nvoid p(char c)\n{\n\tprintf(\"%c\", c); bo = 1;\n}\n\nmain()\n{\n\tint f, m, s;\n\tchar a[10];\n\tscanf(\"%s\", a);\n\tif(strcmp(a, \"rock\") == 0) f = 1;\n\telse if(strcmp(a, \"paper\") == 0) f= 2;\n\telse if(strcmp(a, \"scissors\") == 0) f= 3;\n\tscanf(\"%s\", a);\n\tif(strcmp(a, \"rock\") == 0) m = 1;\n\telse if(strcmp(a, \"paper\") == 0) m= 2;\n\telse if(strcmp(a, \"scissors\") == 0) m= 3;\n\tscanf(\"%s\", a);\n\tif(strcmp(a, \"rock\") == 0) s = 1;\n\telse if(strcmp(a, \"paper\") == 0) s= 2;\n\telse if(strcmp(a, \"scissors\") == 0) s= 3;\n\tif(f==m&&m!=s)\n\t\tif(s == 1&& f == 3) p('S');\n\t\telse if(s==1+f) p('S');\n\tif(s==m&&f!=s)\n\t\tif(f == 1&& s == 3) p('F');\n\t\telse if(f==1+s) p('F');\n\tif(f==s&&m!=s)\n\t\tif(m == 1&& s == 3) p('M');\n\t\telse if(m==1+s) p('M');\n\tif(!bo) printf(\"?\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5a372552838600ac344be4eb7d813c9c", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n char a[10], b[10], c[10];\n scanf(\"%s %s %s\", a, b, c);\n\n if((strcmp(a, \"paper\")==0 && strcmp(b, \"rock\")==0 && strcmp(c, \"rock\")==0) || (strcmp(a, \"rock\")==0 && strcmp(b, \"scissors\")==0 && strcmp(c, \"scissors\")==0) || (strcmp(a, \"scissors\")==0 && strcmp(b, \"paper\")==0 && strcmp(c, \"paper\")==0))\n printf(\"F\");\n else if((strcmp(b, \"paper\")==0 && strcmp(a, \"rock\")==0 && strcmp(c, \"rock\")==0) || (strcmp(b, \"rock\")==0 && strcmp(a, \"scissors\")==0 && strcmp(c, \"scissors\")==0) || (strcmp(b, \"scissors\")==0 && strcmp(a, \"paper\")==0 && strcmp(c, \"paper\")==0))\n printf(\"M\");\n else if((strcmp(c, \"paper\")==0 && strcmp(b, \"rock\")==0 && strcmp(a, \"rock\")==0) || (strcmp(c, \"rock\")==0 && strcmp(b, \"scissors\")==0 && strcmp(a, \"scissors\")==0) || (strcmp(c, \"scissors\")==0 && strcmp(b, \"paper\")==0 && strcmp(a, \"paper\")==0))\n printf(\"S\");\n else\n printf(\"?\");\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "872342b89238d2417e28c94d68ea2d1e", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint final_time(int h, int m, int pass) {\n return 60*h+m+pass;\n}\nvoid conv(int tot, int *h, int *m) {\n *h=tot/60;\n *m=tot%60;\n}\nvoid print_time(int h, int m) {\n ((h%24)<10) ? printf(\"0%d\",h%24):printf(\"%d\",h%24);\n printf(\":\");\n (m<10) ? printf(\"0%d\",m):printf(\"%d\",m);\n}\nint main() {\n int hour,min,pass,h,m;\n scanf(\"%d:%d\\n%d\",&hour,&min,&pass);\n conv(final_time(hour,min,pass),&h,&m);\n print_time(h,m);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0144e55c2bb917d51c23d185daafaa16", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "main(h,m,n){\n scanf(\"%d:%d%d\",&h,&m,&n);\n m+=n+60*h;\n printf(\"%02d:%02d\",m/60%24,m%60);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fb91802aabbc6d237860213d1dc19d52", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint f(int x)\n{\n int sum=0;\n while(x>0)\n {\n sum+=x%10;\n x/=10;\n }\n return sum;\n}\nint main()\n{\n int a,b,c;\n int ans[100];\n while(scanf(\"%d%d%d\",&a,&b,&c)!=EOF)\n {\n int i,j,s;\n int t=0;\n for(i=1;i<=81;i++)\n {\n s=1;\n for(j=0;j1000000000)break;\n if(f(b*s+c)==i) ans[t++]=b*s+c;\n }\n printf(\"%d\\n\",t);\n if(t)\n {\n for(i=0;i\n\nint s(int x)\n{\n\tint v = 0;\n\twhile (x)\n\t{\n\t\tv += x % 10;\n\t\tx /= 10;\n\t}\n\treturn v;\n}\n\nint main()\n{\n\tint sx, a, b, c;\n\tint sz = 0;\n\tint ans[100];\n\t\n\tscanf(\"%d %d %d\", &a, &b, &c);\n\tfor (sx = 1; sx <= 81; ++sx)\n\t{\n\t\tlong long x = 1;\n\t\tint l = a;\n\t\twhile (l--)\n\t\t\tx *= sx;\n\t\tx = b * x + c;\n\t\tif (x > 0 && x < 1000000000 && s((int) x) == sx)\n\t\t\tans[sz++] = (int) x;\n\t}\n\tprintf(\"%d\\n\", sz);\n\tint i;\n\tfor (i = 0; i < sz; ++i)\n\t\tprintf(\"%d \", ans[i]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "1459b6f1f34b43c20f6eb6cb48712960", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint mod(int x)\n{\n if (x>=0)\n return x;\n else\n return -x;\n}\n\nint main()\n{\n long long int x1,x2,y1,y2,x2n,y2n,steps;\n scanf(\"%I64d %I64d\", &x1, &y1);\n scanf(\"%I64d %I64d\", &x2, &y2);\n\n x2n= mod(x2- x1);\n y2n= mod(y2- y1);\n if (x2n>y2n)\n steps= (y2n) + (x2n-y2n);\n else\n steps= (x2n)+ (y2n-x2n);\n printf(\"%I64d\", steps);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "61a2b2df08894ae891e3db8c90e9eeca", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\nint main()\n{\n int x1,x2,y1,y2,x,y;\n scanf(\"%d %d\",&x1,&y1);\n scanf(\"%d %d\",&x2,&y2);\n\n x=abs(x1-x2);\n y=abs(y1-y2);\n\n if(x>=y)\n {\n printf(\"%d\\n\",x);\n }\n else\n printf(\"%d\\n\",y);\n\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "cfb8c104df9d7949e8d66a941098e66e", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n char ch[55];\n int n,i,j,k,sum1=0,sum2=0;\n scanf(\"%d\",&n);\n getchar();\n gets(ch);\n //printf(\"%d\",ch[0]);\n\n\n\n for(j=0;j\nint main()\n{\nchar a[50];\nint n,sum1=0,sum2=0,i;\nscanf(\"%d\",&n);\nscanf(\"%s\",&a);\n//printf(\"%s\",a);\nfor(i=0;i\nint main()\n{\n long long n,x;\n scanf(\"%lld\",&n);\n if(n%2 == 0)\n {\n x = n/2;\n printf(\"%lld\\n\",x);\n }\n else\n {\n x = (((-1)*n)-1)/2;\n printf(\"%lld\\n\",x);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6ed7ce425f8f779368df7ec9a62745be", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": " main()\n{\n long long n;\n scanf(\"%lld\",&n);\n printf(\"%lld\\n\",n&1?(n/2)-n:(n/2));\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "79a011f453355cd6423c05091ea1cb1e", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nmain()\n{\n\tint N;\n\tint list[1000];\n\tint i, j;\n\tint ms, me;\n\tscanf(\"%d\", &N);\n\tfor (i = 0; i < N; i++)\n\t\tscanf(\"%d\", &list[i]);\n\tlist[N] = 0;\n\tms = 0;\n\tfor (i = 0; i < N; i++)\n\t\tif (list[ms] < list[i])\n\t\t\tms = i;\n\tfor (j = ms; list[j] == list[ms]; j++)\n\t\tme = j;\n\n\twhile(ms>0)\n\t{\n\t\tif (list[ms] <= list[ms - 1])\n\t\t{\n\t\t\tprintf(\"NO\\n\");\n\t\t\tgoto a;\n\t\t}\n\t\tms--;\n\t}\n\twhile (me\nint main()\n{\n\tint n,sum=0;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tfor(int i=0;ia[i+1])\n\t\tsum++;\n\t\t}\n\tif(sum==n-1)\nprintf(\"YES\");\nelse\nprintf(\"NO\");\t\n\treturn 0;\n\t}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0f4bb22c36223906d58dbf8fe585c1d5", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint n, x;\n\tscanf( \"%d%d\", &n, &x );\n\tint a[ 6 ][ 3 ] = \n\t{\n\t\t{ 0, 1, 2 },\n\t\t{ 1, 0, 2 },\n\t\t{ 1, 2, 0 },\n\t\t{ 2, 1, 0 },\n\t\t{ 2, 0, 1 },\n\t\t{ 0, 2, 1 }\n\t};\n\tprintf( \"%d\\n\", a[ n % 6 ][ x ] );\n}\n\n/*\n * 4 2\n * 4: 001 < 010\n * 3: 010 < 100\n * 2: 100 < 100\n * 1: 100 < 010\n *\n *\n * 0:100 010 001\n * 1:010 100 001\n * 2:001 100 010\n * 3:001 010 100\n * 4:010 001 100\n * 5:100 001 010\n * 6:100 010 001\n */\n\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "b05b84ad0f1deeff40df17981b7f441e", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nvoid main()\n{\nlong long n,x,ans;\n\nscanf(\"%lld %lld\",&n,&x);\n\n\n\nlong long f[3]={0,1,2};\nlong long a[3]={1,0,2};\nlong long b[3]={1,2,0};\nlong long c[3]={2,1,0};\nlong long d[3]={2,0,1};\nlong long e[3]={0,2,1};\n\n\n\n\nif((n-1)%6==0)\n\tans=a[x];\n\nelse if((n-2)%6==0)\n\tans=b[x];\n\n\nelse if((n-3)%6==0)\n\tans=c[x];\n\n\nelse if((n-4)%6==0)\n\tans=d[x];\n\n\nelse if((n-5)%6==0)\n\tans=e[x];\n\n\nelse if((n-6)%6==0)\n\tans=f[x];\n\nprintf(\"%lld\\n\",ans);\nexit(0);\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "43baa8be9270bd13f4f90c1ae0935ce7", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,a,b,count=1,max,d,e;\n scanf(\"%d %d %d\",&n,&a,&b);\n max=(a+b)/n;\n while(count&&max)\n {\n d=a/max;\n e=b/max;\n if(d!=0&&e!=0)\n {\n if((d+e)>=n)\n {\n\n count=0;\n printf(\"%d\",max);\n }\n else{\n max=max-1;\n }\n }\n\n else\n {\n max=max-1;\n }\n }\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "f25b2ad9f0d30bb64828900c2e574d18", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nstatic inline int min(int a, int b) { return a < b ? a : b; }\nstatic inline int max(int a, int b) { return a > b ? a : b; }\n\nint main() {\n int N,A,B; scanf(\"%d %d %d\\n\", &N, &A, &B);\n int maxv = 0;\n for(int i = 1, in = N ; i < in ; ++i) {\n const int aq = A / i, bq = B / (N-i);\n maxv = max(maxv, min(aq,bq));\n }\n printf(\"%d\\n\", maxv);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "44faf69caaef1c8ed3f69b2f2de3bd2c", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nvoid merge(int *arr,int low,int mid,int high){\n\tint i,j,k,*arr1,*arr2;\n\ti = j = k = 0;\n\tarr1 = (int *)malloc(sizeof(int)*(mid-low+1));\n\tarr2 = (int *)malloc(sizeof(int)*(high-mid));\n\twhile(i++ < mid-low+1) arr1[i-1] = arr[low+i-1]; \n\twhile(j++ < high - mid) arr2[j-1] = arr[mid+j]; \n\ti = j = 0;\n\twhile(i < mid-low+1 && j < high - mid)\n\t\tif(arr1[i] < arr2[j]) arr[low + k] = arr1[i],i++,k++;\n\t\telse arr[low + k] = arr2[j],j++,k++;\n\tif(i == mid-low+1) \n\t\twhile(j != high - mid) arr[low + k] = arr2[j] ,j++ ,k++;\n\telse \n\t\twhile(i != mid-low+1) arr[low + k] = arr1[i] ,i++ ,k++;\n\tfree(arr1);\n\tfree(arr2);\n}\n\nvoid mergeSort(int *arr,int low,int high){\n\tif(low == high) return;\n\tint mid = (low + high )/2;\n\tmergeSort(arr,low,mid);\n\tmergeSort(arr,mid+1,high);\n\tmerge(arr,low,mid,high);\n}\n\nint main(){\n\tint n,i = 0,count = 0,j;\n\tscanf(\"%d\\n\",&n);\n\tint arr[n];\n\twhile(i++ < n){\n\t\tscanf(\"%d\",arr+i-1);\t\n\t}\n\tmergeSort(arr,0,n-1);\n\tfor(i = n-1;i > -1; i--){\n\t\tfor( j = 0;j < i;j++){\n\t\t\tif(arr[i] % arr[j] == 0){\n\t\t\t\tcount++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\",n - count);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "cd6e5ba15620a4754ec71b028dfde2be", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n int n,i,j,x=0,temp,y,z;\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;ia[j])\n {\n temp=a[i];\n a[i]=a[j];\n a[j]=temp;\n }\n }\n }\n for(i=0;i\n\nint n, a[25],i,j,sumBi=0,sumCh=0,sumBa=0,count=0;\n\nint main()\n{\n scanf(\"%d\", &n);\n getchar();\n for(i=0;isumCh&&sumBi>sumBa)\n {\n printf(\"biceps\");\n }\n else if(sumBisumBa)\n {\n printf(\"chest\");\n }\n else\n {\n printf(\"back\");\n }\n return 0;\n\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7fc6f61518e8a7df133b352ecef67b39", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n unsigned short n, a, i, s[3] = {0};\n scanf(\"%hu\", &n);\n for(i = 0; i < n; i++){\n scanf(\"%hu\", &a);\n s[i % 3] += a;\n }\n if(s[0] >= s[1] && s[0] >= s[2]){ printf(\"chest\"); }\n else if(s[1] >= s[2]){ printf(\"biceps\"); }\n else{ printf(\"back\"); }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e81e1f192d973f1c24db00da680ae59c", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void)\n{\n int a,b,hours;\n scanf(\"%d %d\",&a,&b);\n hours=a;\n while(a>=b){\n hours+=a/b;\n a=a/b+a%b;\n }\n printf(\"%d\",hours);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d137ff861d94f05a6c3bce934a55e3dc", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n int m,n,sum=0,remainder=0,temp;\n scanf(\"%d%d\",&n,&m);\n for(;n>=1;){\n sum = sum + n;\n remainder = remainder + n%m;\n n = n/m;\n if(n<1) {\n temp = remainder%m;\n n = remainder/m;\n remainder = 0;\n remainder = temp+remainder;\n\n ;\n }\n }\n printf(\"%d\",sum);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "bf981d6b66634d475e388963a47bf8d0", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint n, i, j, tmp;\n\tscanf(\"%d\", &n);\n\n\tint a[n];\n\tfor(i=0;ia[j+1])\n\t\t\t{\n\t\t\t\ttmp = a[j];\n\t\t\t\ta[j] = a[j+1];\n\t\t\t\ta[j+1] = tmp;\n\t\t\t}\n\tint count=0;\n\ttmp=0;\n\n\tfor(i=0;i0 && tmp!=a[i])\n\t\t{\n\t\t\tcount++;\n\t\t\ttmp=a[i];\n\t\t}\n\tprintf(\"%d\",count);\n}", "lang_cluster": "C", "tags": ["sortings", "implementation"], "code_uid": "3229ecc9964de38cbeb6c19b18ce719f", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include\n#include\nint main()\n{\nint n;\nscanf(\"%d\",&n);\nint a[n];\n\nint i;\nfor(i=0;i\nint main()\n{\n char s[50];\n scanf(\"%s\",s);\n int i=0,c=0;\n while(s[i]!='\\0')\n {\n if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='1'||s[i]=='3'||s[i]=='5'||s[i]=='7'||s[i]=='9')\n c++;\n i++;\n }\n printf(\"%d\",c);\n return 0;\n \n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "3d16934ea55f5ebabfb765488721d816", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int i,x=0,n;\n char s[51];\n scanf(\"%s\",s);\n n=strlen(s);\n for(i=0;i\n#include \n\nint main(void)\n{\n char arr[4][4];\n int a, b, x=0, y, z=0, o=0;\n\n for(a=0 ; a<4 ; a++){\n scanf(\" %[^\\n]\",arr[a]);\n }\n\n for(a=0 ; a<4 ; a++){\n x=0;\n z=0;\n o=0;\n for(b=0 ; b<4 ; b++){\n if(arr[a][1] == 'o' || arr[a][2] == 'o')break;\n else if(arr[a][1] == '.' && arr[a][2] == '.')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.') z++;\n if(arr[a][b] == 'x')x++;\n\n }\n if( o == 2)break;\n else {\n if(x > 1 && b == 3){printf(\"YES\\n\",x,o); goto omar;}\n }\n }\n\n }\n x=0;\n o=0;\n for(b=0 ; b<4 ; b++){\n x=0;\n z=0;\n o=0;\n for(a=0 ; a<4 ; a++){\n if(arr[1][b] == 'o' || arr[2][b] == 'o')break;\n else if(arr[1][b] == '.' && arr[2][b] == '.')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.')z++;\n if(arr[a][b] == 'x')x++;\n\n }\n if(o == 2)break;\n else {\n if(x > 1 && a == 3){printf(\"YES\\n\",x,o); goto omar;}\n }\n }\n\n }\n x=0;\n y=0;\n a=1;\n b=0;\n while(y<3){\n\n if(arr[a][b] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1 && y == 2){printf(\"YES\\n\",x); goto omar;}\n a++;\n b++;\n y++;\n }\n }\n y=0;\n x=0;\n z=0;\n a=0;\n b=0;\n o=0;\n while(y<4){\n\n if(arr[1][1] == 'o' || arr[2][2] == 'o')break;\n else if(arr[1][1] == '.' && arr[2][2] == '.')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.') z++;\n if(arr[a][b] == 'x')x++;\n\n if(o == 2)break;\n else {\n if(x > 1 && y == 3){printf(\"YES\\n\",x,o); goto omar;}\n a++;\n b++;\n y++;\n }\n }\n }\n y=0;\n x=0;\n a=0;\n b=1;\n while(y<3){\n\n if(arr[a][b] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1 && y == 2){printf(\"YES\\n\",x); goto omar;}\n a++;\n b++;\n y++;\n }\n }\n y=0;\n x=0;\n a=0;\n b=2;\n while(y<3){\n\n if(arr[a][b] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1 && y == 2){printf(\"YES\\n\"); goto omar;}\n a++;\n b--;\n y++;\n }\n }\n y=0;\n x=0;\n z=0;\n a=0;\n b=3;\n o=0;\n while(y<4){\n\n if(arr[1][2] == 'o' || arr[2][1] == 'o')break;\n else if(arr[1][2] == '.' && arr[2][1] == '.')break;\n else{\n if(arr[a][b] == 'o')o++;\n if(arr[a][b] == '.')z++;\n if(arr[a][b] == 'x')x++;\n\n\n if(o == 2)break;\n else {\n if(x > 1 && y == 3){printf(\"YES\\n\",x,o); goto omar;}\n a++;\n b--;\n y++;\n }\n }\n }\n y=0;\n x=0;\n a=1;\n b=3;\n while(y<3){\n\n if(arr[a][b] == 'o')break;\n else{\n if(arr[a][b] == 'o')break;\n if(arr[a][b] == 'x')x++;\n\n if(x > 1 && y == 2){printf(\"YES\\n\"); goto omar;}\n a++;\n b--;\n y++;\n }\n }\n printf(\"NO\\n\", x, z, o);\n omar:\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "82771a664a7edbc3707d5a1a8fb352fc", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.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\nint max(int a, int b)\n{\n\tif(a>b)\n\t\treturn a;\n\treturn b;\n}\n\n\nint main()\n{\n\tchar a[5][5];\n\tint i,j;\n\tfor(i=0;i<4;i++)\n\t{\n\t\tscanf(\"%s\",a[i]);\n\t}\n\tint val=0;\n\tfor(i=0;i<4;i++)\n\t{\n\t\tfor(j=0;j<3;j++)\n\t\t{\n\t\t\tif(a[i][j]=='x' && a[i][j+1]=='x')\n\t\t\t{\n\t\t\t\tif(j==0)\n\t\t\t\t{\n\t\t\t\t\tif(a[i][j+2]=='.')\n\t\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t\tif(j==1)\n\t\t\t\t{\n\t\t\t\t\tif(a[i][j-1]=='.' || a[i][j+2]=='.')\n\t\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t\tif(j==2)\n\t\t\t\t{\n\t\t\t\t\tif(a[i][j-1]=='.')\n\t\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(j=0;j<2;j++)\n\t\t{\n\t\t\tif(a[i][j]=='x' && a[i][j+2]=='x')\n\t\t\t{\n\t\t\t\tif(a[i][j+1]=='.')\n\t\t\t\t\tval=1;\n\t\t\t}\n\t\t}\n\n\t}\n\tfor(i=0;i<4;i++)\n\t{\n\t\tfor(j=0;j<3;j++)\n\t\t{\n\t\t\tif(a[j][i]=='x' && a[j+1][i]=='x')\n\t\t\t{\n\t\t\t\tif(j==0)\n\t\t\t\t{\n\t\t\t\t\tif(a[j+2][i]=='.')\n\t\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t\tif(j==1)\n\t\t\t\t{\n\t\t\t\t\tif(a[j-1][i]=='.' || a[j+2][i]=='.')\n\t\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t\tif(j==2)\n\t\t\t\t{\n\t\t\t\t\tif(a[j-1][i]=='.')\n\t\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(j=0;j<2;j++)\n\t\t{\n\t\t\tif(a[j][i]=='x' && a[j+2][i]=='x')\n\t\t\t{\n\t\t\t\tif(a[j+1][i]=='.')\n\t\t\t\t\tval=1;\n\t\t\t}\n\t\t}\n\n\t}\n\tfor(j=0;j<=1;j++)\n\t{\n\t\tfor(i=0;i<=1;i++)\n\t\t{\n\t\t\tif(a[j][0+i]=='x')\n\t\t\t{\n\t\t\t\tif((a[j+1][1+i]=='x' && a[j+2][2+i]=='.')||(a[j+1][1+i]=='.' && a[j+2][2+i]=='x'))\n\t\t\t\t\tval=1;\n\t\t\t}\n\t\t\tif(a[j][0+i]=='.')\n\t\t\t{\n\t\t\t\tif(a[j+1][1+i]=='x' && a[j+2][2+i]=='x')\n\t\t\t\t\tval=1;\n\t\t\t}\n\t\t}\n\t}\n\tfor(j=0;j<=1;j++)\n\t{\n\t\n\t\tfor(i=0;i<=1;i++)\n\t\t{\n\t\t\tif(a[j][3-i]=='x')\n\t\t\t{\n\t\t\t\tif((a[j+1][2-i]=='.' && a[j+2][1-i]=='x')||(a[j+1][2-i]=='x' && a[j+2][1-i]=='.'))\n\t\t\t\t{\n\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(a[j][3-i]=='.')\n\t\t\t{\n\t\t\t\tif(a[j+1][2-i]=='x' && a[j+2][1-i]=='x')\n\t\t\t\t{\n\t\t\t\t\tval=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(val==1)\n\t{\n\t\tprintf(\"YES\\n\");\n\t}\n\telse\n\t\tprintf(\"NO\\n\");\n\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "52afbdde4fd1b4481cf59523e8a22aea", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,max,min,rem;\n scanf(\"%d\",&n);\n if (n%7==0) { // divisible\n min=(n/7)*2;\n max=min;\n }\n else { // not divisible\n rem=n%7;\n if (rem==6) {\n min=((n/7)*2)+1;\n max=((n/7)*2)+2;\n }\n else if (rem!=6 && rem>=2) {\n min=(n/7)*2;\n max=min+2;\n }\n else{ // rem==1\n min=(n/7)*2;\n max=min+1;\n }\n }\n printf(\"%d %d\\n\",min,max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "baf72eb16f7036a24371b997c58c7c3d", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n long y;\n scanf(\"%ld\", &y);\n\n long max, min;\n\n switch (y)\n {\n case 0: min = 0, max = 0; break;\n case 1: min = 0, max = 1; break;\n case 2: min = 0, max = 2; break;\n case 3: min = 0, max = 2; break;\n case 4: min = 0, max = 2; break;\n case 5: min = 0, max = 2; break;\n case 6: min = 1, max = 2; break;\n default: min = 2*(y/7) + (y%7 == 6);\n max = 2*(y/7) + (y%7 > 2 ? 2 : y%7); break;\n }\n\n printf(\"%ld %ld\\n\", min, max);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "brute force"], "code_uid": "62e416bf57c0c93f824667a362454121", "src_uid": "8152daefb04dfa3e1a53f0a501544c35", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main(){ \n long long int a,b,c,d,x,y,z;\n scanf(\"%lld %lld %lld\",&x,&y,&z);\n scanf(\"%lld %lld %lld\",&a,&b,&c);\n \n if(a >= x){\n a = a-x;\n d = a + b;\n if(d>= y){\n d = d- y ;\n \n if(d + c >= z){\n printf(\"YES\");\n }\n else{\n printf(\"NO\");\n }\n \n }\n else{\n printf(\"NO\");\n }\n}\n else{\n printf(\"NO\");\n }\n\n}\n ", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "9bbb403e8ab2da12fc69482d588fc0f3", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,x,y,z;\n scanf(\"%d\",&x);\n scanf(\"%d\",&y);\n scanf(\"%d\",&z);\n scanf(\"%d\",&a);\n scanf(\"%d\",&b);\n scanf(\"%d\",&c);\n /*Dhur beeta , egula hoilo beta?? ei problem 3 bar submit korlam ..*/ \n\n if(a>=x&&b+a-x>=y&&a+b+c-x-y>=z)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "ddd6c27f668eedb39937ccf354be2f82", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "// Cola\n\n#include \n#include \n\n#define ll long long\n\nint count[20000];\n\nvoid deal(int n, int a, int b, int c)\n{\n int i, j;\n ll ans = 0;\n memset(count, 0, sizeof(count));\n for (i = 0; i <= b; i++)\n {\n/* if (i > n)\n {\n break;\n }*/\n for (j = 0; j <= c; j++)\n {\n/* if (i + 2 * j > n)\n {\n break;\n }*/\n count[i + 2 * j]++;\n }\n }\n for (i = 0; i <= a; i += 2)\n {\n if (n - i / 2 < 0)\n {\n break;\n }\n ans += count[n - i / 2];\n }\n printf(\"%lld\\n\", ans);\n}\n\nint main(int argc, char **argv)\n{\n int a, b, c, n;\n while (scanf(\"%d%d%d%d\", &n, &a, &b, &c) == 4)\n {\n deal(n, a, b, c);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "47704c9a5df82db5c4668bb23dbe01e9", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MAXM 20005\nlong n;\nlong long f[4][MAXM]={0},a[4]={0},b[4]={0,1,2,4};\nint main()\n{\n long i,j,k;\n scanf(\"%I64d%I64d%I64d%I64d\",&n,&a[1],&a[2],&a[3]);n=n*2;\n f[0][0]=1;\n for(i=1;i<=3;i++)\n for(k=n;k>=0;k--)\n for(j=0;j*b[i]<=k && j<=a[i];j++)\n f[i][k]+=f[i-1][k-j*b[i]];\n printf(\"%I64d\\n\",f[3][n]); \n return(0);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9c9aafc68afdee6ae83e89e925682695", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n int len,n[100],i;\n char s[100];\n scanf(\"%s\", &s);\n len=strlen(s);\n for(i=0;i4)n[i]=9-n[i]; \n } \n\n if(n[0]==0)n[0]=9;\n for(i=0;i\n#include\nmain()\n{\n\tint l, i;\n\tchar ss[21];\n\tscanf(\"%s\", ss);\n\tl = strlen(ss);\n\tfor (i = 0; i < l; i++)\n\t\tif (ss[i] > 52)\n\t\t\tss[i] = 57 - ss[i] + 48;\n\tif (ss[0] == 48)\n\t\tss[0] = 57;\n\tprintf(\"%s\", ss);\n\tprintf(\"\\n\");\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "d12cb3f70e2d84758a7efd36ecd73292", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,c=0;\n char a[2],b[2];\n scanf(\"%s\",a);\n for(i=0;i<5;i++)\n {\n scanf(\"%s\",b);\n if(a[0]==b[0]||a[1]==b[1])\n {\n c=1;\n }\n }\n if(c==1)\n printf(\"YES\");\n else\n printf(\"NO\");\n \n return(0);\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b8dcfb899fd142c7a95e933f0c7cbff0", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n char t[3], h[5][3]; scanf(\"%s\",t);\n int i, j=0;\n for(i=0;i<5;i++)\n {\n scanf(\"%s\",h[i]);\n if(h[i][0]==t[0] || h[i][1]==t[1]) j=1;\n }\n if(j==1) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "04e60d431db2892645555d2878a5e7a3", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int A,B,i,j=0,k;\n char str[1002];\n scanf(\"%d\",&k);\n scanf(\"%s\",str);\n for(i=0;i\n\n\nint main()\n{\n int n, i, move = 1;\n\n scanf(\"%d\", &n);\n\n char a[n + 1];\n\n scanf(\"%s\", a);\n\n for(i = 1; i < n; i++) {\n if (a[i] != a[i - 1] && a[i - 1] != 'D') a[i] = 'D';\n else move++;\n }\n printf(\"%d\\n\", move);\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f11fff7a5547c1adbb68de5138257098", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint m,d,n,p;\n\tscanf(\"%d%d\",&m,&d);\n\tif(m==1||m==3||m==5||m==7||m==8||m==10||m==12)\n\t n=31;\n\telse if(m==4||m==6||m==9||m==11)\n\t n=30;\n\telse if(m==2)\n\t n=28;\n\tp=(n-8+d)%7;\n\tif(p==0)\n\t printf(\"%d\",1+(n-8+d)/7);\n\telse\n\t printf(\"%d\",2+(n-8+d)/7);\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ba45feaa9d4f0eb75f70ee2a1f9b7bd0", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() \n{\n\tint m,d;\n\tscanf(\"%d %d\",&m,&d);\n\tif (m>0 && m<13 )\n\t{\n\t\tswitch(m)\n\t\t{\n\t\t\tcase 1:\n\t\t\tcase 3:\n\t\t\tcase 5:\n\t\t\tcase 7:\n\t\t\tcase 8:\n\t\t\tcase 10:\n\t\t\tcase 12:\n\t\t\t\tif (d<6 )\n\t\t\t\t\tprintf(\"5\");\n\t\t\t\telse\n\t\t\t\t\tprintf(\"6\");\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tif (d==1)\n\t\t\t\t\tprintf(\"4\");\n\t\t\t\telse \n\t\t\t\t\tprintf(\"5\");\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (d<7 )\n\t\t\t\t\tprintf(\"5\");\n\t\t\t\telse\n\t\t\t\t\tprintf(\"6\");\n\t\t\t\tbreak;\n\t\t\t\t\n\t\t}\n\t}\n\t//printf(\"mot 2 ba %d %d\",m,d);\n\t \n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "20ac45e707c91e9ee3e5d52903c5f06b", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(void)\n{\n char s[110];\n scanf(\"%s\", s);\n int p=0;\n int q=0;\n int l=strlen(s);\n int i;\n for(i=0; i\nint main()\n{\n char s[100];\n int o=0,e=0,i;\n scanf(\" %s\",s);\n\n for(i = 0; s[i]!='\\0'; i++)\n {\n if(s[i]=='o')\n o++;\n else if(s[i]=='-')\n e++;\n }\n if(o==0)\n printf(\"YES\\n\");\n\n else if(e%o==0)\n printf(\"YES\\n\");\n\n else if(e%o!=0)\n printf(\"NO\\n\");\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "f2c174b6597e25ca92426a12371bcb95", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n int a1,a2,a3,a4;\n scanf(\"%d%d%d%d\",&a1,&a2,&a3,&a4);\n if((a1+a2>a3&&a2+a3>a1&&a3+a1>a2) || (a1+a2>a4&&a2+a4>a1&&a1+a4>a2) || (a2+a3>a4&&a3+a4>a2&&a2+a4>a3)\n || (a1+a3>a4&&a3+a4>a1&&a1+a4>a3))\n printf(\"TRIANGLE\\n\");\n else if ((a1+a2==a3||a2+a3==a1||a3+a1==a2) || (a1+a2==a4||a2+a4==a1||a1+a4==a2) || (a2+a3==a4||a3+a4==a2||a2+a4==a3)\n || (a1+a3==a4||a3+a4==a1||a1+a4==a3))\n printf(\"SEGMENT\\n\");\n else if((a1+a2\nint main(){\n\tint a, b, c, d, ab, ac, ad, bc, bd, cd;\n\tscanf(\"%d %d %d %d\", &a, &b, &c, &d);\n\tab=a+b;\n\tac=a+c;\n\tad=a+d;\n\tbc=b+c;\n\tbd=b+d;\n\tcd=c+d;\n\tif((ab>c&&ac>b&&bc>a)||(bc>d&&bd>c&&cd>b)||(bd>a&&ab>d&&ad>b)||(ac>d&&ad>c&&cd>a)){\n\t\tprintf(\"TRIANGLE\");\n\t\treturn 0;\n\t}\n\telse if((ab==c||ac==b||bc==a)||(bc==d||bd==c||cd==b)||(bd==a||ab==d||ad==b)||(ac==d||ad==c||cd==a)){\n\t\tprintf(\"SEGMENT\");\n\t\treturn 0;\n\t}\n\telse\n\t\tprintf(\"IMPOSSIBLE\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "3d98c41fa40dfb36059846ba07049792", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n//\u6210\u529f\u4e86\uff0c\u611f\u89c9\u8fd9\u8fd8\u662f\u6700\u4f18\u7b56\u7565\u95ee\u9898\n#define N 10\nchar grid[N+2][N+2];\nint x[N*N];\nint y[N*N];\nint wolf;\n\nint main() {\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tint i,j;\n\tgetchar();\n\tfor(i=1;i<=n;i++){\n\t\tfor(j=1;j<=m;j++){\n\t\t\tgrid[i][j]=getchar();\n\t\t}\n\t\tgetchar();\n\t}\n\t//\u56db\u5468\u90fd\u662f\u72fc\uff0c\u6211\u53ef\u4ee5\u907f\u514d\u4e00\u4e9b\u8fb9\u754c\u68c0\u67e5\n\tfor(j=0;j<=m+1;j++){\n\t\tgrid[0][j]='W';\n\t\tgrid[n+1][j]='W';\n\t}\n\tfor(i=1;i<=n;i++){\n\t\tgrid[i][0]='W';\n\t\tgrid[i][m+1]='W';\n\t}\n\t/*\n\tfor(i=0;i<=n+1;i++){\n\t\tfor(j=0;j<=m+1;j++){\n\t\t\tprintf(\"%c\",grid[i][j]);\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n\t*/\n\n\twolf=0;\n\tfor(i=1;i<=n;i++){\n\t\tfor(j=1;j<=m;j++){\n\t\t\tif(grid[i][j]=='W'){\n\t\t\t\tx[wolf]=i;\n\t\t\t\ty[wolf]=j;\n\t\t\t\twolf++;\n\t\t\t}\n\t\t}\n\t}\n\tint total=wolf;\n\tfor(i=0;i\n#include\nint main(void) \n{\n int i,j,n,m,cnt=0;\n scanf(\"%d%d\",&n,&m);\n char arr[12][12];\n for(i=0;i\n#include\nint main(){\n\tchar a[100000];\n\tlong long int n=0,i,p=1,j,sum=0;\n\tscanf(\"%s\",a);\n\tfor(i=strlen(a)-2;i>=0;i--){\n\t\t\n\t\tn=n+(a[i]-'0')*p;\n\t\tp=p*10;\n\t}\n\n\tj=strlen(a)-1;\n\tsum=sum+(n-1)/4*16;\n\tif((n-1)%2==0){\n\tif(a[j]=='d'||a[j]=='e'||a[j]=='f'){\n\t\tprintf(\"%lld\",sum+'f'-a[j]+1);\n\t\t\n\t}\n\telse{\n\t\tprintf(\"%lld\",sum+a[j]-'a'+1+3);\n\t}\n\t} \n\telse{\n\t\n\tif(a[j]=='d'||a[j]=='e'||a[j]=='f'){\n\t\tprintf(\"%lld\",sum+'f'-a[j]+1+7);\n\t\t\n\t}\n\telse{\n\t\tprintf(\"%lld\",sum+a[j]-'a'+1+7+3);\n\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "a9d4d89fccb1eb4a8a5aa3c34c2b45ed", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define baccha hobe na baccha hobe na baccha hobe na - Shajib Vai :D\nint main()\n{\n long long n,i,j,x,y,z;\n char c,a[10] = \"fedabc\";\n scanf(\"%lld%c\",&n,&c);\n for(i=0; i<6; i++)\n {\n if(c==a[i])\n {\n j = i+1;\n break;\n }\n }\n if(n%4==0 || (n+1)%4==0)\n {\n x = n/2;\n z = (n-x)-2;\n }\n else\n {\n x = (n/2)+1;\n z = (n-x);\n }\n y = (x-1)*7+j+z;\n printf(\"%lld\\n\",y);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ae78828ece329ad2ffbac7158388aa3a", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,c,d[1000],i,dif,min=0,a,b,pro,no=0;\n scanf(\"%d %d\",&n,&c);\n for(i=0;id[i+1]){\n dif=d[i]-d[i+1];\n if(dif>min){\n a=d[i];\n b=d[i+1];\n min=dif;\n }\n }\n else\n no++;\n }\n if(no==(n-1)){\n a=c;\n b=0;\n }\n\n pro=a-b-c;\n if(pro<0)\n pro=0;\n printf(\"%d\\n\",pro);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "f49d155609b9ac758ae415093101a0c0", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,c,i,max=0,index;\n\tscanf(\"%d %d\",&n,&c);\n\tint x[n];\n\tfor(i=0;imax)\n\t\t{\n\t\t\tmax=x[i]-x[i+1];\n\t\t\tindex=i;\n\t\t}\n\t}\n\tif(max-c<=0)\n\t{\n\t\tprintf(\"0\");\n\t\treturn 0;\n\t}\n\tprintf(\"%d\",max-c);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "5c4e74799dff770b5604f08ad104cd38", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint xpo[4], ypo[4];\nint xd[] = {1, 0, 0, -1};\nint yd[] = {0, 1, -1, 0};\n\nint isri(int n)\n{\n int i, j, k;\n int q, w, e;\n i = (n + 1) % 3;\n j = (n + 2) % 3;\n q = (xpo[i] - xpo[n]) * (xpo[j] - xpo[n]) + (ypo[i] - ypo[n]) * (ypo[j] - ypo[n]);\n w = xpo[i] * (ypo[j] - ypo[n]) - xpo[j] * (ypo[i] - ypo[n]) + xpo[n] * (ypo[i] - ypo[j]);\n if(q == 0 && w != 0)\n return 1;\n return 0;\n}\n\nint main(void)\n{\n int i, j, k, l, m;\n for(i = 0; i < 3; i++)\n scanf(\"%d%d\", xpo + i, ypo + i);\n for(i = 0; i < 3; i++)\n if(isri(i)){\n puts(\"RIGHT\");\n return 0;\n }\n for(i = 0; i < 3; i++){\n j = xpo[i];\n k = ypo[i];\n for(l = 0; l < 4; l++){\n xpo[i] = j + xd[l];\n ypo[i] = k + yd[l];\n for(m = 0; m < 3; m++)\n\tif(isri(m)){\n\t puts(\"ALMOST\");\n\t return 0;\n\t}\n }\n xpo[i] = j;\n ypo[i] = k;\n }\n puts(\"NEITHER\");\n return 0;\n}\n/*\nA. Triangle\ntime limit per test\n2 seconds\nmemory limit per test\n64 megabytes\ninput\nstandard input\noutput\nstandard output\n\nAt a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.\nInput\n\nThe first input line contains 6 space-separated integers x1,\u2009y1,\u2009x2,\u2009y2,\u2009x3,\u2009y3 \u2014 coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.\nOutput\n\nIf the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.\nSample test(s)\nInput\n\n0 0 2 0 0 1\n\nOutput\n\nRIGHT\n\nInput\n\n2 3 4 5 6 6\n\nOutput\n\nNEITHER\n\nInput\n\n-1 0 2 0 0 1\n\nOutput\n\nALMOST\n*/\n", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "224b774c623243703c169f615a3d9b1d", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int a,b,c,d,e,f,g,h,j,k,i,A,B,C,D,E,F,G,H,I,J,r,t=0,p,q,s,w,u,v;\n scanf(\"%d%d%d%d%d%d\",&a,&b,&c,&d,&e,&f);\n p=a;q=b;s=c,w=d;u=e;v=f;\n for(r=1;r<14&&t==0;r++)\n {\n if(r==2)\n {\n a=a+1;\n }\n else if(r==3)\n {a=a-1;}\n else if(r==4)\n {b=b+1;}\n else if(r==5)\n {b=b-1;}\n else if(r==6)\n {c=c+1;}\n else if(r==7)\n {c=c-1;}\n else if(r==8)\n {d=d+1;}\n else if(r==9)\n {d=d-1;}\n else if(r==10)\n {e=e+1;}\n else if(r==11)\n {e=e-1;}\n else if(r==12)\n {f=f+1;}\n else if(r==13)\n {f=f-1;}\n A=(a-c)*(a-c);B=(b-d)*(b-d);\n C=A+B;\n D=(a-e)*(a-e);E=(b-f)*(b-f);\n G=D+E;\n H=(c-e)*(c-e);I=(d-f)*(d-f);\n J=H+I;\n if((C+G==J||C+J==G||G+J==C)&&r==1&&C!=0&&G!=0&&J!=0)\n {t=t+1;\n printf(\"RIGHT\");}\n if((C+G==J||C+J==G||G+J==C)&&r>1&&C!=0&&G!=0&&J!=0)\n {\n t=t+1;\n printf(\"ALMOST\");\n }\n a=p;b=q;c=s;d=w;e=u;f=v;\n }\n if(t==0)\n {printf(\"NEITHER\");}\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "cd6afc2db0e8141da8ed3dd5e9306458", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int a[10], i, j, k, sum1=0, sum2=0, total = 0, u = 0;\n //printf(\"Enter six integers : \");\n for(i = 0; i < 6; i++)\n {\n scanf(\"%d\", &a[i]);\n total += a[i];\n }\n sum1 = 0;\n sum2 = 0;\n u=0;\n for(i = 0; i < 6; i++)\n {\n for(j = i+1; j < 6; j++)\n {\n for(k = j+1; k < 6 ; k++)\n {\n sum1 = a[i]+a[j]+a[k];\n sum2 = total - sum1;\n\n if(sum1 == sum2)\n {\n u++;\n }\n\n }\n}\n }\nif(u>0)\n{\n printf(\"YES\\n\");\n}\nelse{printf(\"NO\\n\");}\n\nreturn 0;}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "123a82079c5ed9e4910fb7096b607121", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tint i,j,k,sum=0,flag=0;\n\tint arr[6];\n\tfor(i=0;i<6;i++){\n\t\tscanf(\"%d\",&arr[i]);\n\t\tsum+=arr[i];\n\t}\n\tfor(i=0;i<5;i++){\n\t\tfor(j=i+1;j<6;j++){\n\t\t\tfor(k=j+1;k<7;k++){\n\t\t\t\tif((arr[i]+arr[j]+arr[k])<<1 == sum){\n\t\t\t\t\tflag=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(flag)printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "a7bb978963e94fded00b55b1b3cf111a", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) \n{\n\tunsigned long long int ar[1000000],n;\n\tint i,num=0;\n\tar[1]=5;\n\tar[2]=7;\n\tfor(i=3;i<1000000;i++)\n\t\t{\n\t\tar[i]=ar[i-1]+3*i-1;\n\t\t//printf(\"%llu \",ar[i]);\n\t\t}\n\tscanf(\"%llu\",&n);\n\tif(n==2)\n\t\t{\n\t\tprintf(\"1\");\n\t\treturn 0;\n\t\t}\n\ti=1;\n\twhile(ar[i]<=n)\n\t\t{\n\t\t\tif((n-ar[i])%3==0)\n\t\t\t\tnum++;\n\t\t\ti++;\n\t\t}\n\tprintf(\"%d\",num);\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "befbe2150e709e9b648b3377c31a83e8", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n,i,ans=0;\n scanf(\"%lld\",&n);\n for(i=1;(3*i*(i+1)/2-i)<=n;i++)\n {\n if((n+i)%3==0)\n ans++;\n }\n printf(\"%d\\n\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "binary search", "brute force"], "code_uid": "b10a92e4557b40fc9498324c716db469", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int x,i,m=0,s=0;\n scanf(\"%d\",&x);\n int n;\n while(x--)\n {\n scanf(\"%d\",&n);\n if(n<0) m=m+n;\n else s=s+n;\n }\n printf(\"%d\",s-m);\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "9fca1a0f4d2c01b474f79764e53b3cc4", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "# include \nint main()\n{\n int n,i,a,b=0,c=0;\n scanf(\"%d\",&n);\n for(i=0;i=0)\n {\n b+=a;\n }\n else\n {\n c+=a;\n }\n }\n printf(\"%d\",b-c);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "cc49aa2378eeef00d964b84573fac454", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int a=0;\n scanf(\"%d\",&a);\n if(a%2==1)\n {\n printf(\"Ehab\");\n }\n if(a%2==0)\n {\n printf(\"Mahmoud\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "2d23edfa32e8a8b8e7131c7d55533a80", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int a;\n\n scanf(\"%I64d\",&a);\n\n if(a%2==0) printf(\"Mahmoud\\n\");\n else printf(\"Ehab\\n\");\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "fc135e8d0186370e690f20a69904b4fa", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "main(){int x;scanf(\"%d\",&x),printf(\"%d\",2-x*x);}\n//nz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioi", "lang_cluster": "C", "tags": ["math"], "code_uid": "a0a0b82eb64afb712859e98ec1847d18", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\nint a;\r\nscanf(\"%d\",&a);\r\nprintf(\"%d\",2-(a*a));\r\nreturn 0;\r\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "8beb3c174370acbdbdd9bbaa4fff26c0", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#define N 102\n#include\n#include\n//10^100\u5e94\u8be5\u662f101\u4f4d\u6574\u6570\uff0c\u6240\u4ee5\u8981\u7528102\u4f4d\u7684\u5b57\u7b26\u4e32\u6765\u4fdd\u5b58\nint main() {\n\tchar a[N];\n\tchar b[N];\n\tscanf(\"%s\",a);\n\tscanf(\"%s\",b);\n\tint na=strlen(a);\n\tint nb=strlen(b);\n\tif(na==nb){\n\t\tint same=1;\n\t\tint i;\n\t\tfor(i=0;i\n#include \n#include \n\nint main()\n{\n char a[1005], b[1005];\n scanf(\"%s %s\", &a, &b);\n printf(\"%s\\n\", (strcmp(a, b))?\"1\":b);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "07c68c562e5c011e5ac1a442ada8e940", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{long long int n;\nscanf(\"%lld\",&n);\nif(n==0){\nprintf(\"0\");}\nelse if(n%2!=0)\n{printf(\"%lld\",(n+1)/2);}\nelse{\nprintf(\"%lld\",(n+1));}\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "9669fc5987128fdce17878eb6f008137", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nmain()\n{\n long long int n,k;\n scanf(\"%lld\",&n);\n n = n+1;\n if(n==1){printf(\"0\\n\");}\n else if(n>1){\n k = n/(2-(n%2));\n printf(\"%lld\\n\",k);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "b501082d4d5da1cdb96e7df2d00aca2e", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n \nint main()\n{\n int c1,c2,i;\n char s[55];\n \n scanf(\"%s\",s);\n c1=c2=0;\n for(i=0;i=c2)\n {\n printf(\"4\\n\");\n }\n else\n {\n printf(\"7\\n\");\n }\n \n return 0;\n}\t\n\t", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "0eafd7fd8473011ac7fe714d674e7f85", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int i, cs, cf;\n char s[51];\n scanf(\"%s\",s);\n cs=cf=0;\n for(i=0;i cf) printf(\"7\");\n else printf(\"4\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "9966db6cd470f0f9f396a188e91f1f42", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n long long n;\n long long k;\n long long out;\n long long i;\n long long fives=0;\n long long twos=0;\n long long temp;\n long long multwo;\n long long mulfive;\n \n scanf(\"%lld %lld\",&n,&k);\n\n temp=n;\n for(i=0;i0)\n {\n for(i=0;i0) \n {\n for(i=0;i\n#include\nint main()\n{\n\tlong long int n,i,k,c1,c2,z;c1=c2=0;\n\tscanf(\"%lld %lld\",&n,&k);\n\tz=n;\n\tfor(i=0;i\ntypedef long long ll;\nint main()\n{\n\tll n;\n\tscanf(\"%lld\",&n);\n\tprintf(\"%lld\\n\",(n-2)*(n-2));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "07a15433fc04c8b3e4ad75178af99baf", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n,i;\n scanf(\"%lld\",&n);\n i=n-2;\n printf(\"%lld\",i*i);\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "f0e89c3ccfccbba7407e16c6892b5014", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "// https://codeforces.com/contest/59/problem/A\n\n#include \n#include \n\n\n#define IN_RANGE(v, s, e) ( (s) <= (v) && (v) <= (e) )\n\n#define IS_LOWER(c) IN_RANGE(c, 'a', 'z')\n#define IS_UPPER(c) IN_RANGE(c, 'A', 'Z')\n\n#define IS_ALPHA(c) ( IS_UPPER(c) || IS_LOWER(c) )\n#define IS_DIGIT(c) IN_RANGE(c, '0', '9')\n#define IS_ALNUM(c) ( IS_ALPHA(c) || IS_DIGIT(c) )\n\n#define TO_LOWER(c) (IS_UPPER(c)) ? c += 32 : c ;\n#define TO_UPPER(c) (IS_LOWER(c)) ? c -= 32 : c ;\n\n#define MAX_LINE 100u\n\n\nuint8_t CountUpperCase(uint8_t * str, uint8_t str_len);\nvoid ToUpperCase(uint8_t * str, uint8_t str_len);\nvoid ToLowerCase(uint8_t * str, uint8_t str_len);\n\n\nint main(void)\n{\n uint8_t word[MAX_LINE] = {0};\n uint8_t str_len = 0u;\n uint8_t upper_case_count = 0u;\n \n scanf(\"%s\", word);\n \n while(word[str_len]) str_len++;\n \n upper_case_count = CountUpperCase(word, str_len);\n \n if(upper_case_count > (str_len/2))\n {\n ToUpperCase(word, str_len);\n }\n else\n {\n ToLowerCase(word, str_len);\n } /* end if */\n \n\tprintf(\"%s\\n\", word);\n \n\treturn 0;\n}\n\n\nuint8_t CountUpperCase(uint8_t * str, uint8_t str_len)\n{\n uint8_t upper_count = 0u;\n \n for(uint8_t i = 0u; i < str_len; i++)\n {\n if(IS_UPPER(str[i]))\n {\n upper_count++;\n } /* end if */\n \n } /* end for */\n \n return upper_count;\n}\n\nvoid ToUpperCase(uint8_t * str, uint8_t str_len)\n{\n for(uint8_t i = 0u; i < str_len; i++)\n {\n if(IS_LOWER(str[i]))\n {\n str[i] = TO_UPPER(str[i]);\n } /* end if */\n } /* end for */\n}\n\nvoid ToLowerCase(uint8_t * str, uint8_t str_len)\n{\n for(uint8_t i = 0u; i < str_len; i++)\n {\n if(IS_UPPER(str[i]))\n {\n str[i] = TO_LOWER(str[i]);\n } /* end if */\n } /* end for */\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "672b4da43b66e347e19b7b09a326798e", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main ()\n{\n int len, i, j, upp = 0, low = 0;\n char str[104];\n\n scanf(\"%s\", str);\n\n len = strlen(str);\n\n for(i = 0; i < len; i++)\n {\n if(str[i] >= 'A' && str[i] <= 'Z')\n upp++;\n else\n low++;\n }\n\n if(upp > low)\n {\n for(j = 0; j < len; j++)\n {\n if(str[j] >= 'a' && str[j] <= 'z')\n str[j] = str[j] - 32;\n printf(\"%c\", str[j]);\n }\n }\n\n else{\n for(j = 0; j < len; j++)\n {\n if(str[j] >= 'A' && str[j] <= 'Z')\n str[j] = str[j] + 32;\n printf(\"%c\", str[j]);\n }\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "4dca5579e3a4467bb306570f85404c69", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main(){\n long long n,m,a,l,b;\n scanf(\"%lld%lld%lld\",&n,&m,&a);\n if(n%a == 0)\n l = n/a;\n else\n l = n/a + 1;\n if(m%a == 0)\n b = m/a;\n else \n b = m/a + 1;\n printf(\"%lld\",l*b);\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "2423b3ea712203bbc2bbce8fd1e82386", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//Theatre square problem\n#include\n#include\nint main(){\nunsigned long long int n,m,a,tile1,tile2,total;\nscanf(\"%lld\", &n);//one side of the theatre square\nscanf(\"%lld\", &m);//other side of the theatre square\nscanf(\"%lld\", &a);//side of the square tile\nif(((double)n/a)-(n/a)>0)\n{\ntile1=(n/a)+1;\n}\nelse\n tile1=(n/a);\nif(((double)m/a)-(m/a)>0)\n{\ntile2=(m/a)+1;\n}\nelse\n tile2=(m/a);\ntotal=tile1*tile2;\nprintf(\"%lld\", total);\n\n\nreturn 0;\n\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "94a6cfedd70cce6c37c3cd8b00f6bb96", "src_uid": "ef971874d8c4da37581336284b688517", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int x, y;\n scanf(\"%d %d\",&x,&y);\n if(x>0 && y>0)\n {\n printf(\"%d %d %d %d\", 0, x+y, x+y, 0);\n }\n if(x>0 && y<0)\n {\n printf(\"%d %d %d %d\", 0, -(x+abs(y)), x+abs(y), 0);\n }\n if(x<0 && y>0)\n {\n printf(\"%d %d %d %d\", -(abs(x)+y), 0, 0, abs(x)+y);\n }\n if(x<0 && y<0)\n {\n printf(\"%d %d %d %d\", x+y, 0, 0, x+y);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "2ba1120853c973fd6e007115a2644184", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n//#include\nint main()\n{\n int x1,y1;\n scanf(\"%d%d\",&x1,&y1);\n int sum=abs(x1)+abs(y1); \n //printf(\"%d\\n\",sum);\n if(x1>0&&y1>0) printf(\"0 %d %d 0\\n\",sum,sum);\n if(x1>0&&y1<0) printf(\"0 -%d %d 0\\n\",sum,sum);\n if(x1<0&&y1>0)printf(\"-%d 0 0 %d\\n\",sum,sum);\n if(x1<0&&y1<0)printf(\"-%d 0 0 -%d\\n\",sum,sum);\n //system(\"pause\");\n return 0; \n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e1eef0380d7eef055daa39bced3f2906", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nmain()\n{\n int n,x[4],y[4],i,j,l=0;\n long int ar;\n scanf(\"%d\",&n);\n for(i=0;i0)\n printf(\"%ld\",ar);\n else\n printf(\"%ld\",-ar);\n l=1;\n break;\n }\n }\n if(l==1)\n break;\n }\n\n if(l==0)\n printf(\"%d\",-1);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry", "implementation"], "code_uid": "f8bfe0e09b07ac523ada25f6ffd1f5f7", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define s(n) scanf(\"%d\",&n)\ntypedef int ll;\nint main()\n{\n ll x[4], y[4],t,i=0,area,diff,x1,x2,l,y1,y2,b;\n s(t);\n while(t--)\n {\n\ts(x[i]);s(y[i]);\n\ti++;\n }\n if(i==1){\n\tarea = -1;}\n else if(i==2)\n {\n\tif( (x[0]==x[1]) || (y[0]==y[1]) )\n\t area = -1;\n\telse\n\t{\n\t l = x[1] - x[0];\n\t if(l<0)\n\t\tl = l* -1;\n\t b = y[1] -y[0];\n\t if(b<0)\n\t\tb = b * -1;\n\t area = l*b;\n\t}\n }\n\n else\n {\n\tx1 = x[0];\n\ty1 = y[0];\n\tif(x[1]==x1)\n\t x2 = x[2];\n\telse\n\t x2 = x[1];\n\tif(y[1]==y1)\n\t y2 = y[2];\n\telse\n\t y2 = y[1];\n\tl = x2 - x1;\n\tb = y2 - y1;\n\tarea = l*b;\n\tif(area<0)\n\t area *= (-1);\n }\n printf(\"%d\\n\",area);return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry", "implementation"], "code_uid": "74aaa1b4548f3c5bd65f0b95f65e73f8", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int t,s,x;\n\tscanf(\"%lld %lld %lld\",&t,&s,&x);\n\tif(x>=t)\n\t{\n\tif((x-t)%s==0||((x-t-1)%s==0&&(x-t-1!=0)))\n\t{\n\t\tprintf(\"YES\\n\");\n\t}\n\t\telse\n\tprintf(\"NO\\n\");\n\t}\n\telse\n\tprintf(\"NO\\n\");\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "d22f80186860bddb2f8b86553e50fc1f", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include \n#include \n\n\nint main()\n{\n\n int t,s,x ;\n scanf(\"%d%d%d\",&t,&s,&x);\nint d = x - t;\n if (x == t + 1) printf(\"NO\");\n\n\n\telse if (d < 0) printf(\"NO\");\n\n\t else if (d % s == 0) printf(\"YES\");\n\t else if (d % s == 1) printf(\"YES\");\n\n\telse printf(\"NO\");\n\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "96abd33918c50f09c60ae9c790cff8b9", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint GCD(int a, int b){\n\tint r;\n\tdo{\n\t\tr = a%b;\n\t\ta = b;\n\t\tb = r;\n\t} while (r != 0);\n\treturn a;\n}\nint main(){\n\tint n;\n\twhile (scanf(\"%d\", &n) == 1){\n\t\tint M[100];\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tscanf(\"%d\", M + i);\n\t\tfor (int i = 0; i < n; i++){\n\t\t\tfor (int j = i + 1; j < n; j++){\n\t\t\t\tM[i] = M[j] = GCD(M[i], M[j]);\n\t\t\t}\n\t\t}\n\t\tint ans = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tans += M[i];\n\t\tprintf(\"%d\\n\", ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "65deb4c082c7fd2c4b4afe1dd7de5baf", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint g ( int x, int y )\n{\n if ( x==0 ) return y;\n return g( y%x, x );\n}\nint main (){\n int n,i,c;\n scanf(\"%d\",&n);\n int a[n+1];\n for(i=0;i0)\n c=g(c,a[i]);\n }\n printf(\"%d\\n\",n*c);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "5089ab866d00498d9b63d24f7abf23e0", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint Comp(const void*a,const void*b)\n{\nreturn *(int*)b-*(int*)a;\n}\nint gcd(int a,int b)\n{\n\tint t;\n\twhile(b)\n\t{\n\t\ta%=b;\n\t\tif(a=a)\n\t\t{\n\t\t\tprintf(\"%d\\n\",a*n);\n\t\t}\n\t\telse\n\t\t{\t\t\n\t\t\tx=n/m;\n\t\t\ty=n-x*m;\n\t\t\tif(b\nint main()\n{\n int n,m,a,b,s,t;\n float p;\n scanf(\"%d %d %d %d\",&n,&m,&a,&b);\n p=(b/m)*1.0;\n s=n/m;\n t=n%m;\n if(n>m){\n if(t!=0){\n if(p==a || p>a){\n printf(\"%d\",a*n);\n }\n else if(pa){\n printf(\"%d\",s*b+t*a);\n }\n else printf(\"%d\",s*b+b);\n }\n }\n else {\n if(p==a || p>a){\n printf(\"%d\",a*n);\n }\n else if(p\n\nint main() {\n\tint w, h, i, n, m;\n\n\tscanf(\"%d%d\", &w, &h);\n\tn = m = 0;\n\tfor (i = 2; i <= w; i += 2)\n\t\tn += w - i + 1;\n\tfor (i = 2; i <= h; i += 2)\n\t\tm += h - i + 1;\n\tprintf(\"%lld\\n\", (long long) n * m);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "bc8783b2ee526c29a157ccb87b7a13d3", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\n long long int w,h,i,j, b,T=0;\n scanf(\"%I64d %I64d\",&w,&h);\n for(i=1;i<=w/2;i++){\n for(j=1;j<=h/2;j++){\n T=T+(w-2*i+1)*(h-2*j+1);\n }\n }\n printf(\"%I64d\",T);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "b842c3d8578f9a304947ac896630a0ad", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tlong long ye,be,x,y,z,khas;\n\tscanf(\"%lld%lld%lld%lld%lld\",&ye,&be,&x,&y,&z);\n\tye=(ye-((x*2)+y));\n\tbe=(be-((z*3)+y));\n\tif(ye<0 && be<0){\n\t\tkhas= -1*(ye + be);\n\t\tprintf(\"%lld\",khas);\n\t}\n\telse if(ye<0 && be>=0){\n\t\tkhas= -1*(ye);\n\t\t\tprintf(\"%lld\",khas);\n\t}\n\telse if (ye>=0 && be<0){\n\t\tkhas=-1*(be);\n\t\t\tprintf(\"%lld\",khas);\n\t}\n\telse\n\t\tprintf(\"0\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "cbe855ac721e4fab94d68fb69cc14bd3", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nint main()\n{\n long long int a,b;\n //printf(\"Enter a and b:\");\n scanf(\"%lld%lld\",&a,&b);\n long long int y,g,bl;\n //printf(\"Enter the data:\");\n scanf(\"%lld%lld%lld\",&y,&g,&bl);\n long long int yellow,blue;\n yellow=2*y+g;\n blue=3*bl+g;\n long long int t1=yellow-a;\n long long int t2=blue-b;\n if(t1<0)\n t1=0;\n if(t2<0)\n t2=0;\n\n long long int ans=t1+t2;\n if(ans>0)\n printf(\"%lld\",ans);\n else\n printf(\"0\");\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3106228ca27f2272f3788353af13f4b9", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n int n,max=0;\n scanf(\"%d\",&n);\n int a[n],c[101]={0};\n for(int i=0;i < n;i++){\n scanf(\"%d\",&a[i]);\n c[a[i]]++;\n if(max < c[a[i]])\n max = c[a[i]];\n }\n printf(\"%d\",max);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e00a58821a0b135b4580144af8bf114d", "src_uid": "f30329023e84b4c50b1b118dc98ae73c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int i,j,n,c,max;\n scanf(\"%lld\",&n);\n long long int a[n];\n max=0;\n c=1;\n for(i=0;i=0;j--)\n {\n if(a[i]==a[j])\n {\n c++;\n }\n }\n if(max\nint main()\n{\n\tlong long n,s=0;\n\tscanf(\"%lld\",&n);\n\twhile(n)\n\t{\n\t\tswitch(n%10)\n\t\t{\n\t\t\tcase 4: \n\t\t\tcase 7: s++;\n\t\t}\n\t\tn/=10;\n\t}\n\tint f=0;\n\tif(s==0) {printf(\"NO\"); return 0;}\n\twhile(s)\n\t{\n\t\tswitch(s%10)\n\t\t{\n\t\t\tcase 4:\n\t\t\tcase 7:break;\n\t\t\tdefault:\n\t\t\tf=1;\n\t\t}\n\t\ts/=10;\n\t}\n\tif(f==0) printf(\"YES\");\n\telse printf(\"NO\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ce5993d7e07e8510a099b07d4a24f5b3", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long n,f=0;\n scanf(\"%lld\",&n);\n while(n!=0)\n {\n if(n%10==4 || n%10==7)\n {\n f++;\n }\n n=n/10;\n }\n if(f==4 || f==7)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b5a21e653a538b021d0a9731aa98cce7", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint j,n,y,A[101];\nint main() {\n scanf(\"%d\",&n);\n for(;j\n\nint main()\n{\n short int n;\n short int numberofBlocks[100];\n\n scanf(\" %hu\", &n);\n for(int i=0;i-1;column--)\n {\n short int destination=column+1;\n if(numberofBlocks[destination]>=numberofBlocks[column])\n continue;\n \n while(1)\n {\n while(1)\n {\n if(numberofBlocks[destination+1]=numberofBlocks[column])\n break;\n }\n }\n\n for(int i=0;i\nlong long int gcd(long long int a,long long int b)\n\n{ if (b != 0)\n return gcd(b, a%b);\n else \n return a;\n}\nint main()\n{\n\tlong long int n,a,b,p,q;\n\tscanf(\"%lld%lld%lld%lld%lld\",&n,&a,&b,&p,&q);\n\tlong long int sum=0,d,e,f,i,g;\nif(an)\nprintf(\"0\\n\");\nelse\n{\n\nf=a*b/gcd(a,b);\n//printf(\"%lld %lld\\n\",g,f);\ng=n/f;\nif(p>q)\n{\nd=n/a;\ne=n/b-g;\n}\nelse\n{\nd=n/a-g;\ne=n/b;\n}\n//printf(\"%lld %lld %lld\\n\",d,e,f);\nsum=d*p+e*q;\nprintf(\"%lld\\n\",sum);\n}\nreturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "e47c406f37c03572e707c3dbc38b3fc4", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nlong long int gcd(long long int a,long long int b){\n return b == 0 ? a : gcd(b,a%b);\n}\n\nlong long int lcm(long long int a,long long int b) {\n return a*(b/gcd(a,b));\n}\n\nint main(){\n long long int n,a,b,p,q,i,total=0,aux,aux2;\n scanf(\"%lld %lld %lld %lld %lld\",&n,&a,&b,&p,&q);\n\n\n if(p>q){\n aux=n/a;\n total=aux*p;\n if(b%a==0){\n printf(\"%lld\\n\",total);\n exit(0);\n }\n aux=lcm(a,b);\n aux2=n/aux;\n aux2*=q;\n aux=((n/b)*q)-aux2;\n total+=aux;\n }else\n if(q>=p){\n aux=n/b;\n total=aux*q;\n if(a%b==0){\n printf(\"%lld\\n\",total);\n exit(0);\n }\n aux=lcm(a,b);\n aux2=n/aux;\n aux2*=p;\n aux=((n/a)*p)-aux2;\n total+=aux;\n }\n printf(\"%lld\\n\",total);\n}\n/* 1520859454897 */\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "7e6f45881cfddb8fbd410f6258983636", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\ntypedef unsigned u;\nu V[512][512],Q[32][512][512],T[32];\nu X[512*512*8],Y[512*512*8],*A,*B,*C;\nu dx[8]={-1,-1, 0,+1,+1,+1, 0,-1};\nu dy[8]={ 0,+1,+1,+1, 0,-1,-1,-1};\nint main()\n{\n\tu t,z,n,i=-1,j,k,p,q=1;\n\tfor(scanf(\"%u\",&n);++i>12)&511;\n\t\t\tj=(A[p]>> 3)&511;\n\t\t\tk=A[p]&7;\n\t\t\tfor(t=T[z];t--;)V[i+=dx[k]][j+=dy[k]]=1;\n\t\t\tt=(k+1)&7;tjan:;\n\t\t\tif(!((Q[z][i][j]>>t)&1))\n\t\t\t{\n\t\t\t\tQ[z][i][j]|=1u<\n\n\n\nstatic char sky[400][400];\nint n, mas[30], k, q1, q2;\n\nstruct line{\n\tint type;\n\tint x;\n\tint y;\n};\n\nint max(int a, int b){\n\treturn a > b ? a : b;\n}\n\nint min(int a, int b){\n\treturn a < b ? a : b;\n}\n\nvoid draw(int i, int a, int x, int y){\n\tk = mas[i - 1];\n\twhile (k){\n\t\tk--;\n\t\tsky[y][x] = 1;\n\t\tif (k){\n\t\t\tif (a == 1){\n\t\t\t\ty++;\n\t\t\t} else if (a == 2){\n\t\t\t\tx++;\n\t\t\t\ty++;\n\t\t\t} else if (a == 3){\n\t\t\t\tx++;\n\t\t\t} else if (a == 4){\n\t\t\t\tx++;\n\t\t\t\ty--;\n\t\t\t} else if (a == 5){\n\t\t\t\ty--;\n\t\t\t} else if (a == 6){\n\t\t\t\tx--;\n\t\t\t\ty--;\n\t\t\t} else if (a == 7){\n\t\t\t\tx--;\n\t\t\t} else if (a == 8){\n\t\t\t\tx--;\n\t\t\t\ty++;\n\t\t\t}\n\t\t}\n\t}\n\tif (i < n){\n\t\tif (a == 1){\n\t\t\tdraw(i + 1, 8, x - 1, y + 1);\n\t\t\tdraw(i + 1, 2, x + 1, y + 1);\n\t\t} else if (a == 2){\n\t\t\tdraw(i + 1, 1, x, y + 1);\n\t\t\tdraw(i + 1, 3, x + 1, y);\n\t\t} else if (a == 3){\n\t\t\tdraw(i + 1, 2, x + 1, y + 1);\n\t\t\tdraw(i + 1, 4, x + 1, y - 1);\n\t\t} else if (a == 4){\n\t\t\tdraw(i + 1, 3, x + 1, y);\n\t\t\tdraw(i + 1, 5, x, y - 1);\n\t\t} else if (a == 5){\n\t\t\tdraw(i + 1, 4, x + 1, y - 1);\n\t\t\tdraw(i + 1, 6, x - 1, y - 1);\n\t\t} else if (a == 6){\n\t\t\tdraw(i + 1, 5, x, y - 1);\n\t\t\tdraw(i + 1, 7, x - 1, y);\n\t\t} else if (a == 7){\n\t\t\tdraw(i + 1, 6, x - 1, y - 1);\n\t\t\tdraw(i + 1, 8, x - 1, y + 1);\n\t\t} else if (a == 8){\n\t\t\tdraw(i + 1, 7, x - 1, y);\n\t\t\tdraw(i + 1, 1, x, y + 1);\n\t\t}\n\t}\n}\n\nvoid mirror(int a, int x, int y){\n\tif (a == 1 || a == 5){\n\t\tq1 = min(400, 2 * x + 1);\n\t\tfor (int i = max(0, 2 * x - 399); i < q1; i++){\n\t\t\tfor (int j = 0; j < 400; j++){\n\t\t\t\tsky[j][i] |= sky[j][2 * x - i];\n\t\t\t}\n\t\t}\n\t} else if (a == 3 || a == 7){\n\t\tq1 = min(400, 2 * y + 1);\n\t\tfor (int i = max(0, 2 * y - 399); i < q1; i++){\n\t\t\tfor (int j = 0; j < 400; j++){\n\t\t\t\tsky[i][j] |= sky[2 * y - i][j];\n\t\t\t}\n\t\t}\n\t} else if (a == 2 || a == 6){\n\t\tq1 = min(400, 400 + y - x);\n\t\tq2 = min(400, 400 - y + x);\n\t\tfor (int i = max(0, y - x); i < q1; i++){\n\t\t\tfor (int j = max(0, x - y); j < q2; j++){\n\t\t\t\tsky[i][j] |= sky[y - x + j][x - y + i];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tq1 = min(400, x + y + 1);\n\t\tfor (int i = max(0, y + x - 399); i < q1; i++){\n\t\t\tfor (int j = max(0, x + y - 399); j < q1; j++){\n\t\t\t\tsky[i][j] |= sky[x + y - j][x + y - i];\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid draw2(int i, int a, int x2, int y2){\n\tif (i == n){\n\t\treturn;\n\t}\n\tint x = x2, y = y2;\n\tk = mas[i];\n\twhile (k){\n\t\tk--;\n\t\t//sky[y][x] = 1;\n\t\tif (k){\n\t\t\tif (a == 1){\n\t\t\t\ty++;\n\t\t\t} else if (a == 2){\n\t\t\t\tx++;\n\t\t\t\ty++;\n\t\t\t} else if (a == 3){\n\t\t\t\tx++;\n\t\t\t} else if (a == 4){\n\t\t\t\tx++;\n\t\t\t\ty--;\n\t\t\t} else if (a == 5){\n\t\t\t\ty--;\n\t\t\t} else if (a == 6){\n\t\t\t\tx--;\n\t\t\t\ty--;\n\t\t\t} else if (a == 7){\n\t\t\t\tx--;\n\t\t\t} else if (a == 8){\n\t\t\t\tx--;\n\t\t\t\ty++;\n\t\t\t}\n\t\t}\n\t}\n\n\t\tif (a == 1){\n\t\t\tdraw2(i + 1, 2, x + 1, y + 1);\n\t\t} else if (a == 2){\n\t\t\tdraw2(i + 1, 3, x + 1, y);\n\t\t} else if (a == 3){\n\t\t\tdraw2(i + 1, 4, x + 1, y - 1);\n\t\t} else if (a == 4){\n\t\t\tdraw2(i + 1, 5, x, y - 1);\n\t\t} else if (a == 5){\n\t\t\tdraw2(i + 1, 6, x - 1, y - 1);\n\t\t} else if (a == 6){\n\t\t\tdraw2(i + 1, 7, x - 1, y);\n\t\t} else if (a == 7){\n\t\t\tdraw2(i + 1, 8, x - 1, y + 1);\n\t\t} else if (a == 8){\n\t\t\tdraw2(i + 1, 1, x, y + 1);\n\t\t}\n\n\tmirror(a, x, y);\n\n\tx = x2, y = y2;\n\tk = mas[i];\n\twhile (k){\n\t\tk--;\n\t\tsky[y][x] = 1;\n\t\tif (k){\n\t\t\tif (a == 1){\n\t\t\t\ty++;\n\t\t\t} else if (a == 2){\n\t\t\t\tx++;\n\t\t\t\ty++;\n\t\t\t} else if (a == 3){\n\t\t\t\tx++;\n\t\t\t} else if (a == 4){\n\t\t\t\tx++;\n\t\t\t\ty--;\n\t\t\t} else if (a == 5){\n\t\t\t\ty--;\n\t\t\t} else if (a == 6){\n\t\t\t\tx--;\n\t\t\t\ty--;\n\t\t\t} else if (a == 7){\n\t\t\t\tx--;\n\t\t\t} else if (a == 8){\n\t\t\t\tx--;\n\t\t\t\ty++;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(void)\n{\n\tfor (int i = 0; i < 400; i++){\n\t\tfor (int j = 0; j < 400; j++){\n\t\t\tsky[i][j] = 0;\n\t\t}\n\t}\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++){\n\t\tscanf(\"%d\", &mas[i]);\n\t}\n\tdraw2(0, 1, 200, 200);\n\tint rez = 0;\n\tfor (int i = 0; i < 400; i++){\n\t\tfor (int j = 0; j < 400; j++){\n\t\t\t//printf(\"%d\", sky[i][j]);\n\t\t\trez += sky[i][j];\n\t\t}\n\t\t//printf(\"\\n\");\n\t}\n\tprintf(\"%d\", rez);\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "brute force", "dp", "data structures", "implementation"], "code_uid": "e75217c35733edda1a30a4259de524de", "src_uid": "a96bc7f93fe9d9d4b78018b49bbc68d9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint min(int a, int b)\n{\n return (b > a ? a : b);\n}\n\nint max(int a, int b)\n{\n return (a > b ? a : b);\n}\n\nint main(void)\n{\n int temp, small, a, b;\n int res;\n int i;\n \n small = 100000;\n \n for (i = 0; i < 4; i++){\n scanf(\"%d\", &temp);\n small = min(small, temp);\n }\n \n scanf(\"%d%d\", &a, &b);\n \n res = 0;\n for (i = a; i <= b; i++){\n if (i < small){\n res++;\n }\n }\n \n printf(\"%d\\n\", res);\n \n return (0);\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "0d2eece6ebfacb48028f82bcae27fbd7", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint p1,p2,p3,p4,a,b,i,ans=0;\n\tscanf(\"%d %d %d %d %d %d\",&p1,&p2,&p3,&p4,&a,&b);\n\tfor (i=a;i<=b;i++)\n\t\tif ((((i%p1)%p2)%p3)%p4==i) ans++;\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "4c1ec7e2e2f07e672b5c3fd413e98af6", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n author: Maksim1744\n created: 23.10.2020 01:38:26\n*/\n\n#include \n#include \n\nint main() {\n int n;\n scanf(\"%d\", &n);\n int64_t f[25];\n f[0] = 1;\n for (int i = 1; i < 25; ++i)\n f[i] = f[i - 1] * i;\n\n int64_t C[25][25];\n for (int i = 0; i < 25; ++i) {\n C[0][i] = 0;\n C[i][0] = 1;\n }\n for (int i = 1; i < 25; ++i) {\n for (int j = 1; j < 25; ++j) {\n C[i][j] = C[i - 1][j] + C[i - 1][j - 1];\n }\n }\n int64_t ans = C[n][n / 2] / 2;\n ans = ans * f[n / 2 - 1];\n ans = ans * f[n / 2 - 1];\n printf(\"%lld\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "f1fe7b2376978fb9397a40a8beeec45d", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define mod 1000000000+7\n#define N 400000+5\n#define rep(i,n) for(i=0;i=0;i--)\ntypedef long long ll;\nint min(int,int);\nint max(int,int);\nint cmp(const void*,const void*);\nll cmpl(const void *,const void*);\nint _gcd(int,int);\nint lcm(int,int);\nint bSearch(int*,int,int,int);\n\nint main(int argc, char *argv[])\n{\n\tll n,ans=1,i;\n\tscanf(\"%lld\",&n);\n\tfor(i=n-1;i>(n/2);i--)\n\t\tans*=i;\n\tfor(i=1;ib)return a;\n\treturn b;\n}\nint cmp(const void *a,const void *b){\n\treturn *(int*)a-*(int*)b;\n}\nll cmpl(const void *a,const void *b){\n\treturn *(ll*)a-*(ll*)b;\n}\nint _gcd (int a, int b){\n while(b)a^=b,b^=a,a^=b,b=b%a;\n return a;\n}\nint lcm(int a,int b){\n \treturn (a*b)/(_gcd(a,b));\n}\nint bSearch(int *a,int l,int r,int item){\n\tint mid;\n\twhile(l<=r){\n\t\tmid=(l+r)/2;\n\t\tif(item>a[mid])\n\t\t\tl=mid+1; \n\t\telse if(item\n#include\nint main( )\n{\n\tint a,b,c,d,count,i,j,flag=0;\n\tscanf(\"%d %d %d %d\",&a,&b,&c,&d);\n\tfor(j=0;j<101;j++)\n\t{\n\t\tfor(i=0;i<101;i++)\n\t\t{\n\t\t\tif((b+j*a)==(d+i*c))\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(flag==1)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(flag==1)\n\t{\n\t\tprintf(\"%d\\n\",b+j*a);\n\t}\n\telse\n\t{\n\t\tprintf(\"-1\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "e39c8787ac9afe9c2bbaacc51e23c522", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint i,j,a,b,c,d,x,y,sumone,sumtwo;\n\tscanf(\"%d\",&a);\nscanf(\"%d\",&b);\n\tscanf(\"%d\",&c);\n\tscanf(\"%d\",&d);\n\tint lol=0;\n\t/*if((a%2==0 && b%2==0) || (a%2!=0 && b%2!=0))\n\t{\n\t\tif(c%2==0 && d%2!=0)\n\t\t{\n\t\t\tprintf(\"-1\");\n\t\t}\n\t\telse if(c%2!=0 && d%2==0)\n\t\t{\n\t\tprintf(\"-1\");\t\n\t\t}\n\t\telse\n\t\tlol=1;\n\t}\n\telse\n\t\tlol++;\n\t\t*/\n/* if((a%2!=0 && b%2==0) || (a%2==0 && b%2!=0))\n\t{\n\t\tif(c%2==0 && d%2==0)\n\t\t{\nprintf(\"-1\");\n\t\t}\n\t\telse if(c%2!=0 && d%2!=0)\n\t\t{\n\t\t\tprintf(\"-1\");\n\t\t}\n\t\telse\n\t\tlol=1;\t\n\t}\n*/\n\t //if(lol>0)\n\t//{\n\t\tx=0;\n\t\ty=0;\n\t\tint uu=0;\n\t\twhile(uu<100000000)\n\t\t{\n\t\t\tuu=uu+1;\n\t\t\tsumone=b+a*x;\n\t\t\tsumtwo=d+c*y;\n\t\t\tif(sumone>sumtwo)\n\t\t\ty=y+1;\n\t\t\telse if(sumtwo>sumone)\n\t\t\tx=x+1;\n\t\t\telse\n\t\t\tbreak;\n\t\t}\n\t\tif(uu>=100000000)\n\t\t\tprintf(\"-1\");\n\t\telse\n\t\tprintf(\"%d\",sumone);\n\n//\t}\n\nreturn 0;\n\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "1e41791f6c29708d8915eb5be8e4c956", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n int n,z=0,x[102],y[102],i,j=0,k=0;\n scanf(\"%d\",&n);\n for(i=0;i\n#include\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i,x,y,a=0,b=0,c=0;\n\tfor(i=0;i0)||(b>0))\n\t\tputs(\"1\");\n\telse\n\t\tputs(\"-1\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "9de493e719682db2d6d4a934a7352d1c", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint Cmp(const void * a, const void * b){\n return *(int*)a-*(int*)b;\n}\n\nint main()\n{\n int n;\n int arr[200];\n int tall[200]={0};\n scanf(\"%d\",&n);\n int i,j,total=1;\n for(i=0;i\n#include \nint n,box[110];\nint lim[110];\nint comp(const void *a, const void *b)\n{\n\treturn *(int*)b - *(int*)a;\n}\nint min(int a,int b)\n{\n\treturn a>1;\n\t\tif(check(mid)) tail = mid;\n\t\telse head = mid+1;\n\t}\n\treturn head;\n}\nint main()\n{\n\tint i;\n\tscanf(\"%d\",&n);\n\tfor(i=1;i<=n;i++) scanf(\"%d\",&box[i]);\n\tqsort(box+1,n,sizeof(int),comp);\n\tprintf(\"%d\",work());\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "44349e429291c9a510b0d0eabd77942b", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{ int n,a,b,c,x;\n scanf(\"%d%d%d%d\",&n,&a,&b,&c);\n\n if(a<=c&&a<=b)\n {\n x=(n-1)*a;\n \n }\n if(b<=c&&b<=a)\n {\n x=(n-1)*b;\n \n }\n if(c<=a&&c<=b)\n { if(n>=2)\n {if(a>b)\n {\n x=b+(n-2)*c;\n \n }\n if(a\nint main (){\n int n,a,b,c,sum,t;\n char home;\n sum=0;\n scanf(\"%d%d%d%d\",&n,&a,&b,&c);\n t=n-1;\n home='r';\n while(t--){\n if(home=='r'){\n if(a>b){\n sum+=b;\n home='e';\n }\n else{\n sum+=a;\n home='o';\n }\n }\n else if(home=='o'){\n if(a>c){\n sum+=c;\n home='e';\n }\n else{\n sum+=a;\n home='r';\n }\n }\n else if(home=='e'){\n if(c>b){\n sum+=b;\n home='r';\n }\n else{\n sum+=c;\n home='o';\n }\n }\n }\n printf(\"%d\",sum);\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "a7944eb76e57032d3378cb9087b14b4b", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\n\n\nint main(){\n\n\nint n,k,t;\n\nscanf(\"%d%d%d\",&n,&k,&t);\nint ans;\n\nif(t<=k){\n\nans=t;\n\n}\n\nif(t>k&&t<=n){\n\nans=k;\n\n}\n\n\nif(t>n&&t<=n+k){\n\nans=n+k-t;\n\n}\n\nif(t>n+k){\n\nans=0;\n\n}\n\n\nprintf(\"%d\",ans);\n\nreturn 0;\n\n\n\n\n\n\n\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6a9b9acceed5146dc8f614b2237ca463", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int n, k, t;\n scanf(\"%d%d%d\", &n, &k, &t);\n\n int res = (t < n ? t : n);\n if (t > k) {\n res -= t - k;\n }\n\n printf(\"%d\\n\", res);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ef0ce026e8aea9ace63d27b715c2fb56", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n long long int n, count = 1;\n while(scanf(\"%lld\", &n) != EOF)\n {\n if(n >= 10)\n {\n n = n + 1;\n count++;\n while(n >= 10)\n {\n while(n % 10 != 0)\n {\n n = n + 1;\n if(n < 10)\n {\n count--;\n break;\n }\n count++;\n }\n while(n % 10 == 0)\n {\n n = n / 10;\n if(n < 10)\n {\n count--;\n break;\n }\n }\n }\n count = count + 9;\n printf(\"%lld\\n\", count);\n }\n else\n {\n count = 9;\n printf(\"%lld\\n\", count);\n }\n\n count = 1;\n }\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "670211cf642ba536608f92097ed1ca40", "src_uid": "055fbbde4b9ffd4473e6e716da6da899", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n/* run this program using the console pauser or add your own getch, system(\"pause\") or input loop */\n\nint lt(int i){\n int k,s=1;\n for (k=1;k<=i;k++)\n s=s*10;\n return s;\n}\nint f(int x){\n\tint f,i=0,y=x+1;\n\twhile (y%lt(i)==0){\n\t\ti++;\n\t}\n\tf=y/lt(i-1);\n\treturn f;\n}\nint main() {\n\tint a[1000],count=1,kq,x,i=0,j,kt=1;\n\tscanf(\"%d\",&x);\n\tkq=x;\n\tif (x==10) count=19;\n\telse if (x<10) count=9;\n\telse{\n\twhile (kq>10){\n\t\tkq=f(kq);\n\t\ta[i]=kq;\n\t\tfor (j=0;j\n#include \nint n,v[101],d,ok,i,j,min1,max1,ma,y[101],d,nr,aux,d1,d2;\nint main()\n{\n scanf(\"%d\",&n);\n nr=0;\n for(i=1; i<=n; i++)\n scanf(\"%d\",&v[i]);\n\n for(i=1; i<=n; i++)\n {\n ok=1;\n for (j=1; j<=nr; j++)\n if (v[i]==y[j])\n ok=0;\n if (ok==1)\n {\n nr++;\n y[nr]=v[i];\n }\n }\n for (i=1; i<=nr-1; i++)\n for (j=i+1; j<=nr; j++)\n if (y[i]>y[j])\n {\n aux=y[i];\n y[i]=y[j];\n y[j]=aux;\n }\n ok=1;\n if (nr>3)\n ok=0;\n else if(nr==3)\n {\n if (y[2]-y[1]!=y[3]-y[2])\n ok=0;\n else\n d=y[3]-y[2];\n }\n else\n if (nr==2)\n {d1=y[2]-y[1];\n d2=-1;\n if ((y[1]+y[2])%2==0)\n d2=(y[1]+y[2])/2;\n if (d2==-1)\n d=d1;\n else\n if (d1max1)\n max1=v[i];\n }\n ma=(min1+max1)/2;\n r=max1-min1;\n ok=0;\n nr=0;\n for(i=1;i<=n;i++)\n if (v[i]==min1 || v[i]==max1)\n nr++;\n\n if (nr==n)\n ok=1;\n\n for(i=1;i<=n;i++)\n if (v[i]!=min1 && v[i]!=max1 && v[i]!=ma)\n ok=0;\n */\n if (ok==0)\n printf(\"-1\");\n else\n printf(\"%d\",d);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ce80964a5254a8ef3f2dcb13b57ab89a", "src_uid": "d486a88939c132848a7efdf257b9b066", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint cmpfunc (const void * a, const void * b) \n{\n return ( *(int*)a - *(int*)b ); \n}\n\nint main() {\n\n int n,arr[100];\n int i,d,privd=0,count=0,flag=0;\n scanf(\"%d\",&n);\n for(i=0; i\n#include \n#include \n#include \n#include \n#include \n\n#define lli long long int\n#define MIN(X,Y) ((X\nint main(){\n int a,b=0;\n scanf(\"%d\",&a);\n while(a > 5){\n a = a/2;\n a -= 2;\n }\n if(a == 1) {\n printf(\"Sheldon\\n\");\n }else if(a == 2) {\n printf(\"Leonard\\n\");\n }else if(a == 3){\n printf(\"Penny\\n\");\n }else if(a == 4) {\n printf(\"Rajesh\\n\");\n }else if(a == 5) {\n printf(\"Howard\");\n }\n return 0;\n }", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "cb82a5e2394c9bf0de85d09ea77bc965", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int a,b,x,n1,n2,n3,n4,n5;\n scanf(\"%d %d %d\",&a,&b,&x);\n n1=a+b*x;\n n2=a*(b+x);\n n3=a*b*x;\n n4=(a+b)*x;\n n5=a+b+x;\n if(n4>n3&&n4>n2&&n4>n1&&n4>n5)\n printf(\"%d\",n4);\n else if(n3>=n4&&n3>=n2&&n3>=n1&&n3>=n5)\n printf(\"%d\",n3);\n else if(n2>=n4&&n2>=n3&&n2>=n1&&n2>=n5)\n printf(\"%d\",n2);\n else if(n1>=n4&&n1>=n3&&n1>=n2&&n1>=n5)\n printf(\"%d\",n1);\n else if(n5>=n1&&n5>=n2&&n5>=n3&&n5>=n4)\n printf(\"%d\",n5);\n \n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "23a5a46627dce7a713b6c2a7f8d0b9b0", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main ()\n{\n int a,b,c,k,l,m,n,o,p;\n scanf(\"%d\",&a);\n scanf(\"%d\",&b);\n scanf(\"%d\",&c);\n k=a+b+c;\n l=a*b*c;\n m=(a*b)+c;\n n=a+(b*c);\n o=(a+b)*c;\n p=a*(b+c);\n if(k>=l && k>=m && k>=n && k>=o && k>=p)\n printf(\"%d\",k);\n else if(l>=k && l>=m && l>=n && l>=o && l>=p)\n printf(\"%d\",l);\n else if(m>=l && m>=k && m>=n && m>=o && m>=p)\n printf(\"%d\",m);\n else if(n>=l && n>=m && n>=k && n>=o && n>=p)\n printf(\"%d\",n);\n else if(o>=l && o>=m && o>=n && o>=k && o>=p)\n printf(\"%d\",o);\n else\n printf(\"%d\",p);\n return 0;\n\n}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "279ac917b7fabea0b00edae188ee24b6", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n\nint main()\n{\n int x,y,k;\n while((k=scanf(\"%d\",&x))==1){\n if(x==0)\n printf(\"O-|-OOOO\\n\");\n else {\n while(x>0)\n {\n y=x%10;\n x=x/10;\n\n switch(y)\n {\n case 0 :\n printf(\"O-|-OOOO\\n\");\n break;\n case 1 :\n printf(\"O-|O-OOO\\n\");\n break;\n case 2 :\n printf(\"O-|OO-OO\\n\");\n break;\n case 3:\n printf(\"O-|OOO-O\\n\");\n break;\n case 4 : printf(\"O-|OOOO-\\n\");\n break;\n case 5 : printf(\"-O|-OOOO\\n\");\n break;\n case 6 : printf(\"-O|O-OOO\\n\");\n break;\n case 7 :\n printf(\"-O|OO-OO\\n\");\n break;\n case 8 :printf(\"-O|OOO-O\\n\");\n break;\n case 9 :\n printf(\"-O|OOOO-\\n\");\n break;\n }\n }\n\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c9c2d1ab52ba05a49e62d4e9a50671f7", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n , i = 0 , j , a[5000] , k ;\n scanf(\"%d\" , &n);\n do {\n a[i] = n %10 ;\n n /= 10 ;\n i ++ ;\n }\n while (n != 0) ;\n for (j = 0 ; j < i ; j++){\n if (a[j] == 5){\n printf(\"-O|-OOOO\\n\");\n continue ;\n }\n if (a[j] < 5){\n printf(\"O-|\");\n for (k = 0 ; k < 5 ; k++){\n if (k == a[j]){\n printf(\"-\");\n continue ;\n }\n printf(\"O\");\n }\n printf(\"\\n\");\n }\n if (a[j] > 5){\n printf(\"-O|\");\n a[j] -= 5 ;\n for (k = 0 ; k < 5 ; k++){\n if (k == a[j]){\n printf(\"-\");\n continue ;\n }\n printf(\"O\");\n }\n printf(\"\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "029f55d22d0a037300c011ec07c3108c", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nvoid fafa(int n){\n\tint dem=0;\n\tfor(int i=1;i\nint main()\n{\n int n,i;\n int m=0;\n scanf(\"%d\",&n);\n for(i = 1;i < n;i++)\n {\n if(n%i==0)\n m++;\n }\n printf(\"%d\\n\",m);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "6e91f688b7ef185603edaa6e2d3b6c73", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint comp (const void * elem1, const void * elem2)\n{\n int f = *((int*)elem1);\n int s = *((int*)elem2);\n if (f > s) return 1;\n if (f < s) return -1;\n return 0;\n}\nint main()\n{\n int n,d;\n scanf(\"%d %d\",&n,&d);\n int points[n];\n for(int i=0; ic2)\n c2=c1;\n }\n printf(\"%d\",n-c2);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "sortings", "greedy"], "code_uid": "8552c1f0558132c34a28fbe925150bb5", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include \nint main()\n{\n int n,d;\n scanf(\"%d %d\",&n,&d);\n int a[n];\n for(int i = 0; i a[j + 1])\n {\n int temp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = temp;\n }\n }\n }\n if(a[n-1]-a[0]<=d)\n printf(\"%d\",0);\n else\n {\n int w = 0, e = n-1 ;\n int p = 0, q = 0;\n for(; ;)\n { if(w>=n)\n break;\n if(e<0)\n break;\n int x = a[w];\n int y = a[e];\n p = 0; q = 0 ;\n //printf(\"\\nx = %d y = %d\\n\",x,y);\n for(int j= w;j<=e;j++)\n {\n if(abs(x-a[j])>d)\n p++;\n if(abs(y-a[j])>d)\n q++;\n }\n //printf(\"\\np = %d q = %d\\n\",p,q);\n if(p==0&&q==0)\n break;\n if(p>q)\n {\n b[s]=x;\n w = w+1;\n s++;\n }\n else\n {\n b[s]=y;\n e = e-1;\n s++;\n }\n }\n //printf(\"array b\\n\");\n //for(int i = 0;i\n\nint main() {\n\tlong long int a, b, t, n = 0;\n\tscanf(\"%lld %lld\", &a, &b);\n\twhile (b != 0) {\n\t\tn += a / b;\n\t\tt = a;\n\t\ta = b;\n\t\tb = t % b;\n\t}\n\tprintf(\"%lld\\n\", n);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "039f6f2e384668922b900e1d7f897451", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \ntypedef unsigned long long int intt;\nint main()\n{\n intt a,b;\n scanf(\"%llu %llu\",&a,&b);\n intt num2;\n num2=a/b;\n if (num2==0)\n {\n printf(\"0\");\n return 0;\n }\n else\n {\n a=a%b;\n while(a!=0)\n {\n num2+=b/a;\n b=b%a;\n intt c;\n c=b;\n b=a;\n a=c;\n }\n }\n printf(\"%llu\",num2);\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "badb5bb92aed199dd74d6e7950e2528f", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n,m,flag=0;\n scanf(\"%d%d\",&m,&n);\n while(n%m==0&&n>m)\n {\n flag++;\n n/=m;\n }\n if(m!=n)\n printf(\"NO\");\n else\n printf(\"YES\\n%d\",flag);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "a2dc08f8d0bc621dc3d8c6c3f4bb41fe", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int a,b,c,cnt=0;\n scanf(\"%d%d\",&a,&b);\n c=a;\n if(b%a==0)\n {\n while(b!=c)\n {\n if(b%c==0)\n {\n c=c*a;\n cnt++;\n }\n else\n {(printf(\"NO\")); exit(0);}\n }\n }\n else\n {\n printf(\"NO\");\n exit(0);\n }\n printf(\"YES\\n%d\",cnt);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "a401f732bd69f62eee96c25c579ee812", "src_uid": "8ce89b754aa4080e7c3b2c3b10f4be46", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{char s1[100];\nchar s2[100];\nscanf(\"%s\",&s1);\nscanf(\"%s\",&s2);\nint a,b,c,j,d,l,i;\nl=strlen(s1);\nc=0;\nd=0;\ni=0;\n while(ib){\n printf(\"1\");\n j=1;\n break;\n }\n else if(b>a){\n printf(\"-1\");\n j=1;\n break;\n }\n else\n i++;\n}\nif(j==0)\n printf(\"0\");\n\nreturn 0;\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "d6b8aa73f2e34dfbc9175689671c96a6", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "int main() \n{ \n char a[102],b[102];; \n int i; \n scanf(\"%s\",&a); \n scanf(\"%s\",&b); \n for(i=0;a[i]!='\\0';i++) \n { \n if(a[i]>='A'&&a[i]<='Z') \n { \n a[i]=a[i]+32; \n } \n if(b[i]>='A'&&b[i]<='Z') \n { \n b[i]=b[i]+32; \n } \n if(a[i]>b[i]) \n { \n printf(\"1\\n\"); \n break; \n } \n else if(a[i]\n#include \n#include \n#include \n\nvoid swap(void *a, void *b, size_t size) {\n char *temp = (char*)malloc(size);\n memcpy(temp, a, size);\n memcpy(a, b, size);\n memcpy(b, temp, size);\n}\n\nvoid reverse_array(char *arr, int l, int r) {\n while(l <= r) {\n swap(&arr[l], &arr[r], sizeof(char));\n l++;\n r--;\n }\n}\n\nint main(int argc, const char * argv[]) {\n \n int len;\n scanf(\"%d\", &len);\n len++;\n char *str = (char*)malloc(sizeof(char) * len);\n for(int i = 0; i < len; ++i) {\n scanf(\"%c\", &str[i]);\n }\n \n for(int i = 1; i < len; ++i) {\n (len - 1) % i == 0 ? reverse_array(str, 1, i) : \"Magneet\";\n }\n \n for(int i = 1; i < len; ++i) {\n printf(\"%c\", str[i]);\n }\n free(str);\n \n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f53766864998115f11859c3776e98cbc", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint n;\nchar a[107];\nvoid cat(int i){\n\tint j;\n\tchar t;\n\tfor(j=0;j+j\nint main()\n{\n int n,m,a,b,i;\n\n scanf(\"%d %d\",&n,&m);\n\n a = (n*(n+1))/2;\n\n b = m % a;\n\n for(i=1;i<=n;i++)\n {\n if(b>=i)\n {\n b = b - i;\n }\n else\n {\n printf(\"%d\",b);\n break;\n }\n }\n\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "dab6f86ce4b6fae98e9e5e3000ee7e3a", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n int chipsOneCircle=0;\n int n = 0, m = 0, have_chips = 1, i = 0;\n if((scanf(\"%d %d\", &n, &m))==2){\n chipsOneCircle = (n * (n + 1)) / 2;\n int x = m / chipsOneCircle;\n m = m - x*chipsOneCircle;\n while (have_chips == 1) {\n for (i = 1; i < n + 1; i++) {\n if (i > m) {\n have_chips = 0;\n break;\n }\n m = m - i;\n }\n\n }\n printf(\"%d\\n\", m);\n\t}\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "1ecab8720b2172172d2ef9da68f39efb", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n int a1,b1,a2,b2,a3,b3,flag=0;\n scanf(\"%d%d%d%d%d%d\",&a1,&b1,&a2,&b2,&a3,&b3);\n if((a2+a3)<=a1 && b2<=b1 && b3<=b1) flag=1;\n else if((a2+b3)<=a1 && b2<=b1 && a3<=b1) flag=1;\n else if((b2+a3)<=a1 && a2<=b1 && b3<=b1) flag=1;\n else if((b2+b3)<=a1 && a2<=b1 && a3<=b1) flag=1;\n else if((a2+a3)<=b1 && b2<=a1 && b3<=a1) flag=1;\n else if((a2+b3)<=b1 && b2<=a1 && a3<=a1) flag=1;\n else if((b2+a3)<=b1 && a2<=a1 && b3<=a1) flag=1;\n else if((b2+b3)<=b1 && a2<=a1 && a3<=a1) flag=1;\n if(flag==1) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "bc9b39d3443b98d8704cb0b06c55f01b", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nmain()\n{\n int A, B, a1, b1, a2, b2;\n\n scanf(\"%d %d %d %d %d %d\", &A, &B, &a1, &b1, &a2, &b2);\n\n if(a1+a2 <= A &&b1 <= B && b2 <= B)\n printf(\"YES\");\n\n else if(a1+a2 <= B && b1 <= A && b2 <= A)\n printf(\"YES\");\n\n else if(a1+b2 <= A && b1 <= B && a2 <= B)\n printf(\"YES\");\n\n else if(a1+b2 <= B && b1 <= A && a2 <= A)\n printf(\"YES\");\n\n else if(b1+a2 <= A && a1 <= B && b2 <= B)\n printf(\"YES\");\n\n else if(b1+a2 <= B && a1 <= A && b2 <= A)\n printf(\"YES\");\n\n else if(b1+b2 <= A && a1 <= B && a2 <= B)\n printf(\"YES\");\n\n else if(b1+b2 <= B && a1 <= A && a2 <= A)\n printf(\"YES\");\n\n else printf(\"NO\");\n\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "19d2f56b9476bcbe3a693e790f546886", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int k,m;\n scanf(\"%d %d\", &k, &m);\n int i,p;\n for (i=1; ;i++)\n {\n p=(k*i)-m;\n if ((p%10==0) || ((k*i)%10==0))\n {\n\n\n printf(\"%d\\n\", i);\n break;\n }\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "ccc24e050d2eb6ab16f2a14715696c50", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n\tint k,r,i;\n\tscanf(\"%d%d\",&k,&r);\n\tfor(i=1;i<=9;i++)\n\t{\n\t\tif((k*i)%10==r||(k*i)%10==0)\n\t\t{printf(\"%d\",i);\n\t\treturn 0;\n\t\t}\n\t\t\n\t}\n\tprintf(\"10\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "add5ab0827902c0c0eacde55a1841c1e", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,s=1;\n scanf(\"%lld\",&n);\n s=s+(n*(n+1)*3);\n printf(\"%lld\\n\",s);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "db1bdef1a6346ad9300945960efe440b", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main(){\n\tlong long n;\n\tscanf(\"%lld\",&n);\n\tprintf(\"%lld\\n\",3*n*(n+1)+1);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "34afbb421d4daf01ecc47e22b7c88679", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int b, g, n;\n int count = 0;\n int min, max;\n int i;\n\n scanf(\"%d%d%d\", &b, &g, &n);\n\n if(b > g)\n {\n min = g;\n max = b;\n }\n else\n {\n min = b;\n max = g;\n }\n //\n for(i = 0; i < max+1 ; i++)\n {\n if((n-i) > -1 && (n-i) < min+1)\n count++;\n }\n\n if(n < b && n < g)\n count = n+1;\n\n printf(\"%d\", count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "446b283d7cd0fabcfae87c5eb8e64c13", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include \n int main()\n {\n int b,g,n,min,x,y;\n scanf(\"%d\",&b);\n scanf(\"%d\",&g);\n scanf(\"%d\",&n);\n if(n<=g && n<=b)\n min=n;\n else\n {\n if(b<=g)\n {\n x=b;\n y=g-(n-b);\n if(x\n\nint main()\n\n{\n char x[100];\n\n int c=0,i,j,k=0,l;\n\n scanf(\"%s\",x);\n\n l=strlen(x);\n\n for(i=1;i=6&&x[0]=='1') printf(\"yes\");\n\n else if(k)\n { c=0;\n for(i=j+1;i=6) printf(\"yes\");\n else printf(\"no\");\n }\n\n else printf(\"no\");\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ab76916f9422dbd96601bdb18473d235", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main ()\n{\n int i, len, sum = 0;\n char str[1000000];\n\n scanf(\"%s\", str);\n\n len = strlen(str);\n\n i = 0;\n\n while(str[i] != '1')\n i++;\n\n for( ; i < len; i++)\n {\n\n if(str[i] == '0')\n sum++;\n }\n\n //printf(\"%d\", i);\n\n if(sum >= 6)\n printf(\"yes\");\n\n else printf(\"no\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b85c5795c5617b1968e9a5ec86e9dae8", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main() {\n\tstatic char s[128];\n\tint l, i, a, b, c, d;\n\n\tscanf(\"%s\", s);\n\tl = strlen(s);\n\ta = b = c = d = 0;\n\ta = l >= 5;\n\tfor (i = 0; i < l; i++) {\n\t\tb |= isupper(s[i]);\n\t\tc |= islower(s[i]);\n\t\td |= isdigit(s[i]);\n\t}\n\tprintf(\"%s\\n\", a && b && c && d ? \"Correct\" : \"Too weak\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "acb8c53c6835485e0d03af09a86c104d", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main(){\n\tchar a[101];\n\tint angka = 0, upper = 0, lower = 0, digit = 0; \n\tscanf(\"%s\", a);\n\t\n\tint length = strlen(a);\n\tfor(int i = 0; i < length; i++){\n\t\tif(a[i] >= 'A' && a[i] <= 'Z') upper++;\n\t\telse if(a[i] >= 'a' && a[i] <= 'z') lower++;\n\t\telse if(a[i] >= '0' && a[i] <= '9') digit++;\n\t}\n\tif(length >= 5 && upper >= 1 && lower >= 1 && digit >= 1) printf(\"Correct\");\n\telse printf(\"Too weak\");\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "09c947ebe07f32f1f40d9d041f7b7b0a", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\tint n,k;\n\tscanf(\"%d%d\",&n,&k);\n\tint i,a[n];\n\tint sum=0;\n\tfor(i=0;i\n#include \n\nint main()\n{\n int n,k,i;\n double sum = 0;\n scanf(\"%d %d\",&n,&k);\n for(i=0;i 0 ? ans :0);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "14a03864422d0e618b1c7f15bb3a29a0", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nvoid func(int a, int b, int c,char h)\n{\n\tif(b==0 && c==0) printf(\"%c\",h);\n\telse if(a==0 && b!=0 && c!=0) printf(\"%c\",h);\n\telse if(a!=0 && b!=0 && c!=0) printf(\"%c\",h);\n\telse if(a!=0 && b==0 && c!=0 && c!=1) printf(\"%c\",h);\n\telse if(a!=0 && b!=0 && c==0 && b!=1) printf(\"%c\",h);\n\telse return;\n}\n\n\nint main()\n{\n\tint n,r=0,b=0,g=0,i;\n\tchar R='R';\n\tchar B='B';\n\tchar G='G';\n\tscanf(\"%d\",&n);\n\tchar card[n+1];\n\tfor(i=0;i<=n;i++)\n\t{\n\t\tscanf(\"%c\",&card[i]);\n\t\tif(card[i]=='R') ++r;\n\t\tif(card[i]=='B') ++b;\n\t\tif(card[i]=='G') ++g;\n\t}\n//\tprintf(\"%d\",g);\n\tfunc(b,r,g,B);\n\tfunc(g,b,r,G);\n\tfunc(r,g,b,R);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "190e2cdbf7f0f96541128211c5614930", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint i,j,n,r=0,g=0,b=0;\n\tscanf(\"%d\",&n);\n\tchar c[n+1];\n\tscanf(\"%s\",c);\n\tfor(i=0;i<=n;i++)\n\t{\n\t\tif(c[i]=='B')\n\t\t\tb++;\n\t\telse if(c[i]=='R')\n\t\t\tr++;\n\t\telse if(c[i]=='G')\n\t\t\tg++;\n\t}\n\t//printf(\"%d %d %d\\n\",r,g,b);\n\tif(b>0 && r>0 && g>0)\n\t{\n\t\tprintf(\"BGR\\n\");\n\t\treturn 0;\n\t}\n\tif((b==0 && r==0 && g>0) || (b==1 && r==1 && g==0))\n\t{\n\t\tprintf(\"G\\n\");\n\t\treturn 0; \n\t}\n\tif((b>0 && r==0 && g==0)||(b==0 && r==1 && g==1))\n\t{\n\t\tprintf(\"B\\n\");\n\t\treturn 0;\n\t}\n\tif((b==0 && r>0 && g==0)||(b==1 && r==0 && g==1))\n\t{\n\t\tprintf(\"R\\n\");\n\t\treturn 0;\n\t}\n\tif(b==0 && r>1 && g>1)\n\t{\n\t\tprintf(\"BGR\\n\");\n\t\treturn 0;\n\t}\n\tif(b>1 && r==0 && g>1)\n\t{\n\t\tprintf(\"BGR\\n\");\n\t\treturn 0;\n\t}\n\tif(b>1 && r>1 && g==0)\n\t{\n\t\tprintf(\"BGR\\n\");\n\t\treturn 0;\n\t}\n\tif((b==1 && r>1 && g==0) || (b==0 && r>1 && g==1))\n\t{\n\t\tprintf(\"BG\\n\");\n\t\treturn 0;\n\t}\n\tif((b>1 && r==1 && g==0)||(b>1 && r==0 && g==1))\n\t{\n\t\tprintf(\"GR\\n\");\n\t\treturn 0;\n\t}\n\tif((b==1 && r==0 && g>1) || (b==0 && r==1 && g>1))\n\t{\n\t\tprintf(\"BR\\n\");\n\t\treturn 0;\n\t}\n}", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "b3326a5a352c5639c1dad4cbb0b0043c", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.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": "86280582f6518b2751b839363765572d", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint gcd(int x,int y)\n{\n\tint hcf=1;\n\twhile(hcf!=0)\n\t{\t\n\t\thcf=x%y;\n\t\tx=y;\n\t\ty=hcf;\n\t}\n\treturn x;\n}\nint main()\n{\n\tint n,a,b;\n\tscanf(\"%d\",&n);\n\ta=n/2-1;\n\tb=n/2+1;\n\tif(n%2==0)\n\t{\n\t\twhile((gcd(b,a))!=1)\n\t\t{\n\t\t\ta--;\n\t\t\tb++;\n\t\t}\n\t\tprintf(\"%d %d\",a,b);\n\t}\n\telse \n\t{\n\t\twhile((gcd(b,a+1))!=1)\n\t\t{\n\t\t\ta--;\n\t\t\tb++;\n\t\t}\n\t\tprintf(\"%d %d\",a+1,b);\n\t}\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "6a4225a22553cb3458f155a9b3fb0d4f", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{\n int length,i,j;\n char x[100];\n scanf(\"%s\",x);\n length=strlen(x);\n if(length==1) {\n printf(\"%s\",x);\n return 0;\n }\n for(i=0;i\n#include \n\nint main()\n{\n char s[101], c[101];\n int f = 0, p = 0, i;\n\n scanf(\"%s\", s);\n\n for (i = 0; i < strlen(s); i++) {\n\t if (s[i] != '/') {\n\t c[p++] = s[i];\n\t f = 0;\n\t } else if (f == 0) {\n\t c[p++] = s[i];\n\t f = 1;\n\t }\n }\n\n if (p > 2 && c[p - 1] == '/') p--;\n\n c[p] = '\\0';\n\n printf(\"%s\\n\", c);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "273a711360ec23891ff1a6d8e7b7dc8e", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint main()\n{\n char *a[] = {\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"};\n char s[10];\n int l, n, i, j;\n scanf(\"%d %s\", &n, s);\n int *b = (int*)calloc(8,sizeof(int));\n int mx = 0;\n for(i=0; i<8; i++)\n {\n l = strlen(a[i]);\n if(n!=l)\n continue;\n for(j=0; j\nint main()\n{\n char *eeve[] = {\"jolteon\", \"flareon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\", \"vaporeon\", \"espeon\"};\n char str[9];\n int count[6] = {0},i,j,n,large,index;\n scanf(\"%i\" , &n);\n scanf(\"%s\" , str);\n \n if(n==8)\n puts(eeve[6]);\n else if(n==6)\n puts(eeve[7]);\n \n else{\n for(i=0; i<7 ; i++)\n if(str[i] != '.')\n for(j=0 ; j<6 ; j++)\n if(str[i] == eeve[j][i])\n count[j]++;\n for(i=0,large=0,index=0; i<6 ; i++)\n if(count[i] > large)\n {\n large = count[i];\n index = i;\n }\n puts(eeve[index]);\n } \n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "15d864de2dc74a2e5d33da68dacc9654", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main() \n{ \n int l1,l2,i,cnt=0,j;\n char s1[105],s2[105];\n scanf(\"%s%s\",s1,s2);\n l1=strlen(s1);\n l2=strlen(s2);\n for(i=0,j=l2-1;i=0; i++,j--)\n {\n if(s1[i]==s2[j])\n {\n cnt++;\n }\n }\n if(cnt==l1)\n {\n printf(\"YES\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "9a4ff65e31399d9773a14e0e25460445", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main() {\n int i,j,ctr=0,len1,len2;\n char s[1001],t[1001];\n scanf(\"%s\",&s);\n scanf(\"%s\",&t);\n len1=strlen(s);\n len2=strlen(t);\n for(i=len1-1,j=0;i>=0&&j\nint main()\n{\n int h,m;\n\n while(scanf(\"%d:%d\", &h,&m)==2) {\n\n if(h==0)\n printf(\"01:10\\n\");\n\n else if(h==1)\n {\n if(m<10)\n printf(\"01:10\\n\");\n else\n printf(\"02:20\\n\"); }\n\n else if(h==2)\n {\n if(m<20)\n printf(\"02:20\\n\");\n else\n printf(\"03:30\\n\"); }\n\n else if(h==3)\n {\n if(m<30)\n printf(\"03:30\\n\");\n else\n printf(\"04:40\\n\"); }\n\n else if(h==4)\n {\n if(m<40)\n printf(\"04:40\\n\");\n else\n printf(\"05:50\\n\"); }\n\n else if(h==5)\n {\n if(m<50)\n printf(\"05:50\\n\");\n else\n printf(\"10:01\\n\"); }\n\n else if(h==6 || h==7 || h==8 || h==9)\n printf(\"10:01\\n\");\n\n else if(h==10)\n {\n if(m<1)\n printf(\"10:01\\n\");\n else\n printf(\"11:11\\n\"); }\n\n else if(h==11)\n {\n if(m<11)\n printf(\"11:11\\n\");\n else\n printf(\"12:21\\n\"); }\n\n else if(h==12)\n {\n if(m<21)\n printf(\"12:21\\n\");\n else\n printf(\"13:31\\n\"); }\n\n else if(h==13)\n {\n if(m<31)\n printf(\"13:31\\n\");\n else\n printf(\"14:41\\n\"); }\n\n else if(h==14)\n {\n if(m<41)\n printf(\"14:41\\n\");\n else\n printf(\"15:51\\n\"); }\n\n else if(h==15)\n {\n if(m<51)\n printf(\"15:51\\n\");\n else\n printf(\"20:02\\n\"); }\n\n else if(h==16 || h==17 || h==18 || h==19)\n printf(\"20:02\\n\");\n\n else if(h==20)\n {\n if(m<2)\n printf(\"20:02\\n\");\n else\n printf(\"21:12\\n\"); }\n\n else if(h==21)\n {\n if(m<12)\n printf(\"21:12\\n\");\n else\n printf(\"22:22\\n\"); }\n\n else if(h==22)\n {\n if(m<22)\n printf(\"22:22\\n\");\n else\n printf(\"23:32\\n\"); }\n\n else if(h==23)\n {\n if(m<32)\n printf(\"23:32\\n\");\n else\n printf(\"00:00\\n\"); }\n\n }\n\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "6b88c796405db45a5c5426289a3599ee", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() \n{ \n\tint h,m; \n\tchar c; \n\n\tscanf(\"%d %c %d\",&h, &c, &m); \n\n\twhile (1) \n\t{ \n\t\tm++; \n\t\th+=(m/60); \n\t\tm%=60; \n\t\th%=24; \n\t\tif (h/10==m%10 && h%10==m/10) \n\t\t{ \n\t\t\tbreak; \n\t\t} \n\t} \n\tprintf(\"%d%d:%d%d\\n\",h/10, h%10, m/10, m%10);\n\treturn 0; \n} \n\n \t \t\t \t\t \t\t\t\t \t\t \t \t\t\t \t \t", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "a09d35ddc25348576a1ed33a20a000b3", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nstruct Node\n{\n char val;\n struct Node *child;\n struct Node *next;\n};\n\nvoid tree(struct Node *root, char str[])\n{\n int i;\n int length = strlen(str);\n \n if(length == 0)\n return;\n\n if(root->child == NULL)\n {\n root->child = (struct Node *)malloc(sizeof(struct Node));\n root->child->child = NULL;\n root->child->next = NULL;\n \n root->child->val = str[0];\n\n tree(root->child, &str[1]);\n }\n else\n {\n struct Node *prev = NULL;\n struct Node *cur = root->child;\n while(cur != NULL)\n {\n if(cur->val == str[0])\n break;\n else\n {\n prev = cur;\n cur = cur->next;\n }\n }\n \n if(cur != NULL)\n tree(cur, &str[1]);\n else\n {\n prev->next = (struct Node *)malloc(sizeof(struct Node));\n\n prev->next->child = NULL;\n prev->next->next = NULL;\n\n prev->next->val = str[0];\n\n tree(prev->next, &str[1]);\n }\n\n }\n\n}\n\nint countLeaves(struct Node *root)\n{\n if(root->child == NULL)\n return 1;\n else\n {\n int cnt = 0;\n struct Node *cur = root->child;\n while(cur != NULL)\n {\n cnt += countLeaves(cur);\n cur = cur->next;\n }\n\n return cnt;\n }\n\n}\n\nint main(int argc, char *argv[])\n{\n char str[52];\n\n scanf(\"%s\", str);\n \n int len = strlen(str);\n\n int i, j, k;\n struct Node *root = (struct Node *)malloc(sizeof(struct Node));\n root->child = NULL;\n root->next = NULL;\n\n for(i = 0; i < len; i++)\n {\n char cur[52];\n k = 0;\n for(j = len-i; j < len; j++)\n cur[k++] = str[j];\n\n for(j = 0; j < len-i; j++)\n cur[k++] = str[j];\n \n cur[len] = '\\0';\n\n tree(root, cur);\n }\n \n printf(\"%d\\n\",countLeaves(root));\n \n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "f296a3e185ab505d4e9575cfc20fb7d5", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main()\n{\n char a[60],b[60],c;\n int i,j,cnt;\n while(~scanf(\"%s\",a))\n {\n int len=strlen(a);\n strcpy(b,a);\n cnt=0;\n for(j=0;j\nint main()\n{\nint i,co=0,n,j;\nscanf(\"%d\",&n);\nfor(i=0;i<=n;i+=1234567)\n{\n for(j=0;j<=n-i;j+=123456)\n {\n if((n-i-j)%1234==0)\n co=1;\n }\n}\nprintf(\"%s\\n\",(co==1)?\"YES\":\"NO\");\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "61f6c15516172fbe19a0feac22661c3d", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int n2 = n+1;\n int ans = 0;\n for(;n2 > 0;n2 -= 1234567)\n {\n int n3 = n2;\n for(;n3 > 0;n3 -= 123456)\n {\n if(n3 % 1234 == 1)\n {\n ans = 1;\n goto mark;\n }\n }\n }\nmark:if(ans == 1)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "2ec3e7c07e5df324d1cf2e707e8a5ba7", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int d1,d2,d3;\n scanf(\"%d %d %d\",&d1,&d2,&d3);\n if(d1+d2==d3)\n {\n\n printf(\"%d\\n\",2*d3);\n\n }\n else if(d1+d2d3){\n\n if(d1+d3\n\nint d1, d2, d3, min;\nint A[4];\nint i ;\nint main()\n{\n\nscanf(\"%d%d%d\", &d1,&d2,&d3);\n\nA[0] = d1 + d2 +d3;\nA[1]= 2*d1 + 2*d2;\nA[2]=d1+d1+d3+d3;\nA[3]=d2+d2+d3+d3;\nmin = A[0];\nfor( i= 0; i< 4; i++)\n{ if( A[i]<= A[0] && A[i] <= A[1] && A[i] <= A[2] && A[i] <= A[3])\n { printf(\"%d\\n\", A[i]);\n return 0; }\n} \n\n}\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "160c175d786f7bea7a7d93f617da42d9", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nchar s[9] = {'6','7','8','9','T','J','Q','K','A'};\nint chiso(char c)\n{\n\tint i;\n\tfor(i=0;i<=8;i++)\n\t\tif(s[i]==c)\n\t\t\tbreak;\n\treturn i;\n}\nvoid check(char s1[],char s2[],char trump)\n{\n\tif(s1[1]==s2[1])\n\t{\n\t\tif(chiso(s1[0])>chiso(s2[0])) printf(\"YES\\n\");\n\t\telse printf(\"NO\\n\");\n\t}\n\telse\n\tif(s1[1]==trump)\n\t{\n\t\tprintf(\"YES\\n\");\n\t}\n\telse\n\t{\n\t\tprintf(\"NO\\n\");\n\t}\n\n}\n\nint main()\n{\n\tchar trump;\n\tchar s1[3];\n\tchar s2[3];\n\tscanf(\"%c\\n\",&trump);\n\tscanf(\"%s %s\",s1,s2);\n\tcheck(s1,s2,trump);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "62b7596c92933bca593e90393d77888a", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar Base[9]=\"6789TJQKA\";\nchar A[3],B[3];\nchar T;\n\nint Judge()\n{\n int i,j;\n for(i=0; Base[i]!=A[0]; ++i);\n for(j=0; Base[j]!=B[0]; ++j);\n if(A[1]==B[1]&&i>j)\n {\n return 1;\n }\n return 0;\n}\n\nint main()\n{\n scanf(\"%c %s %s\",&T,A,B);\n if((A[1]==T&&B[1]!=T)||Judge())\n {\n puts(\"YES\");\n return 0;\n }\n puts(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "31a7f5514484ee112e7554eeed359439", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint r1,r2,c1,c2,d1,d2;\n\tint a,b,c,d;\n\n\tscanf(\"%d%d%d%d%d%d\",&r1,&r2,&c1,&c2,&d1,&d2);\n\n\tfor (a=1;a<10;a++) {\n\t\tb=r1-a;\n\t\tif (b<1 || b>9) continue;\n\t\tc=c1-a;\n\t\tif (c<1 || c>9) continue;\n\t\td=c2-b;\n\t\tif (d<1 || d>9) continue;\n\t\tif (c+d==r2 && a+d==d1 && b+c==d2 && (a-b)*(b-c)*(c-d)*(d-a)*(b-d)*(c-a) != 0) {\n\t\t\tprintf(\"%d %d\\n%d %d\\n\",a,b,c,d);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tprintf(\"-1\\n\");\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "3bc6414d7a45626cb2df7b44f9928aba", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int r1,r2,c1,c2,d1,d2;\n int a,b,c,d,x=0;\n scanf(\"%d %d %d %d %d %d\",&r1,&r2,&c1,&c2,&d1,&d2);\n for(a=1;a<10;a++)\n {\n b=r1-a;\n if(b<1||b>9)continue;\n c=c1-a;\n if(c<1||c>9)continue;\n d=c2-b;\n if(d<1||d>9)continue;\n if(c+d==r2&&a+d==d1&&b+c==d2&&(a-b)*(b-c)*(c-d)*(d-a)*(b-d)*(c-a)!=0)\n {\n printf(\"%d %d\\n%d %d\",a,b,c,d);\n x=1;\n break;\n }\n }\n if(x==0)\n printf(\"-1\");\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "5a51a780ce349f373499045a3868d500", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n char ch[101],mh[101];\n scanf(\"%s\",ch);\n scanf(\"%s\",mh);\n int i;\n for(i=0;i\n#include \n\nint main()\n{\n char str1[101];\n char str2[101];\n scanf(\"%s%s\", str1, str2);\n for(int i=0; i\nint main()\n{\n int n,a,x,b,y;\n scanf(\"%d%d%d%d%d\",&n,&a,&x,&b,&y);\n int t=1;\n while(a!=b){\n a++,b--;\n if(b==0)\n b=n;\n if(a==n+1)\n a=1;\n if((a==x||b==y)&&a!=b){\n t=0;\n break;\n }\n }\n if(t)\n printf(\"YES\");\n else\n printf(\"NO\");\n\n\n\n\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "26a00cfc5f795cfbfe3b0e01ef83b487", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n\n\n\nvoid test() {\n int n, a, x, b, y;\n scanf(\"%d %d %d %d %d\", &n, &a, &x, &b, &y);\n\n for( ; a != x && b != y; a = a % n + 1, b--) {\n if(a == b) {\n printf(\"YES\\n\");\n return;\n }\n if(b == 1) {\n b = n + 1;\n }\n }\n if(a == b) {\n printf(\"YES\\n\");\n }\n else {\n printf(\"NO\\n\");\n }\n}\n\n\nint main () \n{\n // int t;\n // scanf(\"%d\", &t);\n // while(t--)\n test();\n return 0;\n}\n ", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "63cb83c99239cdf10e31e6758cbee21a", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint\tpalindromo(int num){\n\tint c=0;\n\twhile (num%10==0){\n\t\tnum=num/10;\n\t}\n\tint b=num;\n\twhile(num>0){\n\t\tc=c*10+num%10;\n\t\tnum=num/10;\n\t}\n\tif(c==b) return 1;\n\telse\treturn 0;\n}\n\nvoid main(){\n\tint x;\n\tscanf(\"%d\",&x);\n\tif(palindromo(x))\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "f528e849a00cb322ae3e0a5eae359308", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\n\n\n\nint main(){\n char a[10];\n scanf(\"%s\",a);\n int n = strlen(a); \n int i = 0; \n int j = n - 1;\n while(i < n && a[i] == '0')\n i++;\n while(j >= 0 && a[j] == '0')\n j--;\n \n while(i < j){\n if(a[i] != a[j]){\n printf(\"NO\\n\");\n return 0;\n } \n\n i++;\n j--; \n }\n printf(\"YES\\n\");\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "c3db089c297aebfb9f0242f77f6c9138", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b;\n scanf(\"%d%d\", &a, &b);\n printf(\"%d\",a+b);\n \n \n}", "lang_cluster": "C", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "3dc1b89a3e6b8ef7cb894a56a7edf194", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int a, b;\n scanf(\"%d %d\", &a, &b);\n printf(\"%d\\n\", a+b);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "constructive algorithms", "implementation", "brute force"], "code_uid": "842baa3a70ab1ccbe9af608ceff3849d", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n char s[100],s2[100];\n scanf(\"%s\",s);\n int n=strlen(s);\n int x;\n int y=0;\n for(int i=0;i=5)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n}\n", "lang_cluster": "C", "tags": ["greedy", "strings"], "code_uid": "dad466de78b748451be43e2bffac1ebc", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n\nint main() {\n\n\tchar string[101];\n\tchar *patrn = \"hello\";\n\tint len = strlen(patrn);\n\tint i; int j = -1;\n\tint hash = 0;\n\n\tscanf(\"%101[^\\n]\", string);\n\tint st_len = strlen(string);\n\n\tfor ( i = 0; i < len; i++)\t{\n\t\t\tj += 1 ;\n\t\t\twhile ( j < st_len) {\n\t\t\t\t\t\tif (patrn[i] == string[j]) {\n\t\t\t\t\t\t\t\thash += 1;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n \t\t\t\t\tj++;\n\t\t\t}\n\n\t}\n\n\tif (hash == 5) { printf(\"YES\\n\");}\n\telse { printf(\"NO\\n\");}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy", "strings"], "code_uid": "1b314f31fc64a548281935a0e47f7782", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n long long a,b,c,d,e,f,count=0;\n scanf(\"%lld%lld%lld\",&a,&b,&c);\n scanf(\"%lld%lld%lld\",&d,&e,&f);\n if(a==0 &&b==0&&c==0)\n {\n if(d==1&&e==1&&f==1)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n\n }\n else if(a==1&&b==0&&c==0)\n {\n if(d==0&&e==1&&f==1)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n }\n else if(a==1&&b==1&&c==0)\n {\n if(d==0&&e==0&&f==1)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n }\n else if(a==0&&b==1&&c==0)\n {\n if(d==1&&e==0&&f==1)\n printf(\"NO\\n\");\n\n else\n printf(\"YES\\n\");\n }\n else if(a==0&&b==0&&c==1)\n {\n if(d==1&&e==1&&f==0)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n }\n else if(a==1&&b==0&&c==1)\n {\n if(d==0&&e==1&&f==0)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n }\n else if(a==1&&b==1&&c==1)\n {\n if(d==0&&e==0&&f==0)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n }\n else if(a==0&&b==1&&c==1)\n {\n if(d==1&&e==0&&f==0)\n printf(\"NO\\n\");\n else\n printf(\"YES\\n\");\n\n }\n\n\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "9e71faf211f8ba85f220239cf6248003", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int x1,y1,z1,x2,y2,z2;\n scanf(\"%d%d%d%d%d%d\",&x1,&y1,&z1,&x2,&y2,&z2);\n if(x1==x2 || y1==y2 || z1==z2)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "9029b876f9b28e6b9274dcb511ecf1db", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int r,c,i,j,s=0;\n scanf(\"%d %d\",&r,&c);\n char n[r+1][c+1];\n int m[r],p[c];\n for(i=0;i\nint main()\n{\n\tint r, c;\n\tscanf(\"%d%d\", &r, &c);\n\tint i, j, k;\n\tchar mat[r][c];\n\tfor(i=0; i\n#include \n\n\n/*Lazy Security Guard*/\nint main()\n{\n int input_num, perimeter,temp,count = 0;\n scanf(\"%d\",&input_num);\n temp = input_num;\n if(input_num == 1)\n {\n perimeter = 4;\n }\n else if(input_num <= 0)\n {\n perimeter = 0;\n }\n else\n {\n while(input_num >= (count * count))\n {\n count++;\n }\n count--;\n /*\n while(count != temp)\n {\n count++;\n temp = input_num / count;\n }\n */\n /*\n while(temp != 1)\n {\n temp /= 2;\n count++;\n }\n */\n perimeter = count * 4;\n temp = input_num - (count*count);\n while(temp > 0)\n {\n temp = temp - count;\n perimeter = perimeter + 2;\n }\n }\n printf(\"%d\", perimeter);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "19a115f5cc63e723840cf313c7a79df9", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint minperi(int a)\n{\n\tfor(int i=1;;i++)\n\t{\n\t\tif(i*(i-1)>=a)\n\t\t\treturn 4*i-2;\n\t\telse if(i*i>=a)\n\t\t\treturn 4*i;\n\t}\n}\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\",minperi(n));\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "d90a18cc2d571933f299695425e2548a", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long a , b , c , d ;\n scanf(\"%lld%lld%lld\",&a,&b,&c) ;\n\n \n\n if(a\nint main()\n{\nlong long a, b, ab, stlen;\nscanf(\"%lld %lld %lld\", &a, &b, &ab);\na=a+ab;\nb=b+ab;\nif(a>b)\n{stlen=(2*b)+1;}\nelse if(b>a)\n{stlen=(2*a)+1;}\nelse if(a==b)\n{stlen=(2*a);}\nprintf(\"%lld\\n\", stlen);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "494572397e12cf3c8e644cca93cf1749", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n \nint main() {\n \n int n,b,p;\n int y,x;\n scanf(\"%d %d %d\",&n,&b,&p);\n y = n*p;\n x = (n-1) * (b * 2 + 1);\n \n printf(\"%d %d\",x,y);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "d6fa547c450eb249ade3bce09ebe208b", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,b,p;\n scanf(\"%d %d %d\",&n,&b,&p);\n printf(\"%d %d\",((n-1)*2*b)+(n-1),n*p);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "f984dd7311a2cbd3a583323e4d071710", "src_uid": "eb815f35e9f29793a120d120968cfe34", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {char a[50],temp,m[50];\nint i=0,j=0,n,p,sum=0;\n \n scanf(\"%d%d\",&n,&p);\n scanf(\"%s\",a);\n for(i=0;ia[j+1])\n {temp=a[j];\n a[j]=a[j+1];\n a[j+1]=temp;\n }\n }\n }\n m[0]=a[0];\n sum=m[0]-96;\n for(i=1,j=1;i\nvoid mergesort(char arr[], int l, int r)\n{\nif (l < r)\n{\nint m = l+(r-l)/2;\nmergesort(arr, l, m);\nmergesort(arr, m+1,r);\nmerge(arr, l, m, r);\n}\n}\nvoid merge(char arr[], int l, int m, int r)\n{\nint i, j, k;\nint n1 = m - l + 1;\nint n2 = r - m;\nchar L[1+n1], R[1+n2];\nfor (i = 0; i < n1; i++)\nL[i] = arr[l + i];\nfor (j = 0; j < n2; j++)\nR[j] = arr[m + 1+ j];\ni = 0;\nj = 0;\nk = l;\nwhile (i < n1 && j < n2)\n{\nif (L[i] <= R[j])\n{\narr[k] = L[i];\ni++;\n}\nelse\n{\narr[k] = R[j];\nj++;\n}\nk++;\n}\nwhile (i < n1)\n{\narr[k] = L[i];\ni++;\nk++;\n}\nwhile (j < n2)\n{\narr[k] = R[j];\nj++;\nk++;\n}\n}\n\nint main()\n{\n int n,z=0,k,scnt=0,cnt=0;\n scanf(\"%d%d\",&n,&k);\n char s[n+1],t[n+1];\n scanf(\"%s\",s);\n s[n]='\\0';\n mergesort(s,0,n-1);\n for(int i=0;i0;i++)\n {\n if(t[i]!='0')\n {\n scnt+=1+t[i]-'a';\n k--;\n }\n }\n printf(\"%d\",scnt);\n }\n \n return 0;\n}", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "b4bef79228639339e76ceb0f341ed0e2", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{\n\tchar s[110];\n\tint n[60];\n\tscanf(\"%s\",s);\n\tint i=0,j=0;\n\tfor(i=0;in[j]){\n\t\t\t\tt=n[j];\n\t\t\t\tn[j]=n[i];\n\t\t\t\tn[i]=t;\n\t\t\t}\n\t\t}\n\t}\n\tfor(i=0;i\n#include\nint main()\n{\n char a[100];\n gets(a);\n int l=0,temp;\n l=strlen(a);\n for(int i=0;ia[j])\n {\n temp=a[i];\n a[i]=a[j];\n a[j]=temp;\n }\n }\n }\n for(int i=0;i\nint main()\n{\n int x,y,n;\n scanf(\"%d %d %d\",&x,&y,&n);\n n=(n-1)%6;\n switch(n)\n {\n case 0:\n if(x<0)\n printf(\"%d\",(1000000007-(-x)%1000000007)%1000000007);\n else\n printf(\"%d\",x);\n return 0;\n case 1:\n if(y<0)\n printf(\"%d\",(1000000007-(-y)%1000000007)%1000000007);\n else\n printf(\"%d\",y);\n return 0;\n case 2:\n if((y-x)<0)\n printf(\"%d\",(1000000007-(x-y)%1000000007)%1000000007);\n else\n printf(\"%d\",(y-x)%1000000007);\n return 0;\n case 3:\n if(-x<0)\n printf(\"%d\",(1000000007-(x)%1000000007)%1000000007);\n else\n printf(\"%d\",-x);\n return 0;\n case 4:\n if(-y<0)\n printf(\"%d\",(1000000007-(y)%1000000007)%1000000007);\n else\n printf(\"%d\",-y);\n return 0;\n case 5:\n if((-y+x)<0)\n printf(\"%d\",(1000000007-(y-x)%1000000007)%1000000007);\n else\n printf(\"%d\",(-y+x)%1000000007);\n return 0;\n }\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "a82c7684e31ac0ba3d4b8493cbd0cc8d", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nlong long M[3][3],N[3][3],Q[3][3],mod=1000000007,p[3][3];\nvoid copymatrix(long long X[3][3],long long Y[3][3]){\n Y[1][1]=X[1][1];\n Y[1][2]=X[1][2];\n Y[2][1]=X[2][1];\n Y[2][2]=X[2][2];\n}\nvoid multiply(long long x[3][3],long long y[3][3],long long z[3][3]){\n z[1][1]=((x[1][1]*y[1][1])%mod+(x[1][2]*y[2][1])%mod)%mod;\n z[1][2]=((x[1][1]*y[1][2])%mod+(x[1][2]*y[2][2])%mod)%mod;\n z[2][1]=((x[2][1]*y[1][1])%mod+(x[2][2]*y[2][1])%mod)%mod;\n z[2][2]=((x[2][1]*y[1][2])%mod+(x[2][2]*y[2][2])%mod)%mod;\n}\n\nvoid powermatrix(long long x[3][3],long long n){\n while(n!=0){\n if(n%2==0){\n multiply(x,x,N);\n copymatrix(N,x);\n n=n/2;\n }\n else{\n multiply(x,Q,N);\n copymatrix(N,Q);\n n=n-1;\n }\n }\n}\n \nint main(void) {\n long long x,y,z,i,j,t,m,n;\n M[1][1]=1;\n M[2][1]=1;\n M[1][2]=-1;\n M[2][2]=0;\n Q[1][1]=1;\n Q[2][1]=0;\n Q[1][2]=0;\n Q[2][2]=1;\n scanf(\"%lld %lld %lld\",&x,&y,&n);\n if(n==1)\n { printf(\"%lld\\n\",(x+mod)%mod); return 0;}\n else if(n==2)\n { printf(\"%lld\\n\",(y+mod)%mod); return 0;}\n powermatrix(M,n-2);\n // printf(\"%lld %lld %lld %lld\",Q[1][1],Q[1][2],Q[2][1],Q[2][2]);\n \n \n \n printf(\"%lld\\n\",((Q[1][1]*y)%mod+(Q[1][2]*x)%mod+2*mod)%mod);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "a962d1c067b7b68efe825bcdce310e92", "src_uid": "2ff85140e3f19c90e587ce459d64338b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define MAX_N (100)\n\nint main() {\n int cs[2];\n int xs[MAX_N];\n int i,j,n,k,acc;\n\n scanf(\"%d %d\", &n, &k);\n for ( i=0; i < n; ++i )\n scanf(\"%d\", xs+i);\n for ( j=acc=0; j < k; ++j ) { \n cs[0] = cs[1] = 0;\n for ( i=0; i < n/k; ++i )\n cs[xs[i*k+j]-1] += 1;\n acc += (cs[0] > cs[1] ? cs[1] : cs[0]);\n }\n printf(\"%d\\n\", acc);\n return EXIT_SUCCESS;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "163e4f3d3ea1d9e5ffc6128818394c92", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint a[200],b[5];\nint main() {\n\tint i,j,k,c,sum=0,n;\n\twhile(scanf(\"%d%d\",&n,&k)!=EOF) {\n\t\tfor(i=0;ib[2]?b[2]:b[1];\n\t\t\tsum+=c;\n\t\t}\n\t\tprintf(\"%d\\n\",sum);\n\t}\n\treturn 0;\n}\n\t\t\t\n\n\t\t\n\t\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "b502e3c824b12834a99defce678e2ebd", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int a,b,ans=0,temp;\n\tscanf(\"%lld%lld\",&a,&b);\t\n\twhile(b!=1)\n\t{\n\t\tif(a>b)\n\t\t{\n\t\t\ttemp=a/b;\n\t\t\tans+=temp;\n\t\t\ta=a-temp*b;\n\t\t}\n\t\tif(b>a)\n\t\t{\n\t\t\ttemp=b/a;\n\t\t\tans+=temp;\n\t\t\tb=b-(temp*a);\n\t\t\tif(b==0)\n\t\t\t{\n\t\t\t\ta=0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tans += a;\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "df519794d7bc2dc880d745aeb0cca499", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int a, b;\n scanf(\"%lld %lld\",&a,&b);\n long long int s=0;\n while(a>0&&b>0)\n {\n if(a>b) \n {\n s=s+a/b;\n a%=b;\n }\n else\n {\n s=s+b/a;\n b%=a;\n }\n }\n printf(\"%lld\",s);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "97e37e91dbe3105b0debc9ae156e2323", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tint test;\n\tchar inp[11];\n\tint inp2[11];\n\tscanf (\"%d\\n\",&test);\n\tgets(inp);\n\tmemset (inp2, 0, sizeof(inp2));\n\tint x, check=1;\n\tfor (x=0;x0||inp2[4]>0||inp2[7]>0||inp2[0]>0)) {\n\t\tprintf (\"NO\\n\");\n\t}\n\telse if (!(inp2[3]>0||inp2[6]>0||inp2[9]>0||inp2[0]>0)) {\n\t\tprintf(\"NO\\n\");\n\t}\n\telse if (!(inp2[1] > 0 || inp2[2]>0 || inp2[3]>0)) {\n\t\tprintf(\"NO\\n\");\n\t}\n\telse if (!(inp2[7] >0 || inp2[0] >0 ||inp2[9]>0)) {\n\t\tprintf(\"NO\\n\");\n\t}\n\telse {\n\t\tprintf(\"YES\\n\");\n\t}\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "d27730e60c531a9b33b6b885f9d2b10e", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nstatic int map[10];\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n getchar();\n\n while(n--)\n {\n char c;\n c = getchar();\n\n map[ c - '0' ] = 1;\n }\n\n int flag = 0;\n\n if( !(map[1] || map[4] || map[7] || map[0]) ) flag = 1;\n else if( !(map[3] || map[6] || map[9] || map[0]) ) flag = 1;\n else if ( !(map[1]||map[2]||map[3]) ) flag = 1;\n else if(!(map[7] || map[9] || map[0])) flag = 1;\n else if( !(map[1]||map[2]||map[3]||map[4]||\n map[7]) ) flag = 1;\n else if( !(map[1]||map[2]||map[3]||map[6]||\n map[9]) ) flag = 1;\n else if( !(map[1]||map[4]||map[7]||map[8]||\n map[0]) ) flag = 1;\n else if( !(map[3]||map[6]||map[9]||map[8]||\n map[0]) ) flag = 1;\n\n if(flag == 1) printf(\"NO\\n\");\n else printf(\"YES\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "4dd3e64e3c7de38293b2ec256b1f1550", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint s[20]={0};\nlong long ans=1;\t\n\nint so(long long tmp,int a,int f){\n//\tprintf(\"%lld,%d,%d\\n\",tmp,a,f);\n\tif(tmp<=0)return 0;\n\tif(a==-1){\n\t\tif(ans\n\nint max = -1;\n\nvoid nirv(int *N, int len, int pro, int flag){\n\t// printf(\"%d %d %d\\n\", pro, len, N[len-1]);\n\tif(len == 0){\n\t\tif(pro > max){\n\t\t\tmax = pro;\n\t\t}\n\t\treturn;\n\t}\n\n\tif (flag == 1){\n\t\treturn nirv(N, len -1, pro*9, 1);\n\t}\n\telse{\n\t\tint c = 0;\n\t\tfor(int i = N[len - 1];;i--){\n\t\t\t// if(i <= 0){\n\t\t\t// \tnirv(N, len -1, pro, 0);\t\t\t\t\n\t\t\t// }\n\t\t\t// printf(\"%%%d %d\\n\", i, c);\n\t\t\tif(i == 1){\n\t\t\t\tnirv(N, len-1, pro, 1);\n\t\t\t}\n\t\t\telse if(i == N[len - 1]){\n\t\t\t\tnirv(N, len - 1, pro*i, 0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tnirv(N, len -1, pro*(i), 1);\n\t\t\t}\n\t\t\tif((c)== 1){\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\t// printf(\"%%%d %d\\n\", i, c);\n\t\t\tc++;\n\t\t}\n\t}\n}\n\nint main(){\n\tint n, i = 0;\n\tint N[10];\n\tscanf(\"%d\", &n);\n\tfor(;n;i++){\n\n\t\tN[i] = n%10;\n\t\tn = n/10;\n\t}\n\tint len = i;\n\tnirv(N, len, 1, 0);\n\tprintf(\"%d\\n\", max);\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "afe70959271412ab265496ff54c973aa", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,m,k;\n scanf(\"%d%d%d\",&n,&m,&k);\n if(n>m||n>k){printf(\"NO\");}\n else{printf(\"YES\");}\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fc5d7a5f7758d6734b0cfecdfaaf9037", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n,p,a;\n scanf(\"%d%d%d\",&n,&p,&a);\n if((p>=n)&&(a>=n))\n { printf(\"Yes\");}\n else\n printf(\"No\");\n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "37ed0d9e6e51eebbfffa173f115cd309", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,m,z,max,ans,lcm;\n\tscanf(\"%d%d%d\",&n,&m,&z);\n\tmax = (n>m) ? n : m;\n\tfor(lcm=max; ;lcm++)\n\t{\n\t\tif(lcm%n==0&&lcm%m==0)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tans=z/lcm;\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "091d28c012811402a814d97628721e2c", "src_uid": "e7ad55ce26fc8610639323af1de36c2d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,m,l,i,p,q,s,t;\n\tscanf(\"%d%d%d\",&n,&m,&l);\n\tp=l/n;\n\tq=l/m;\n\tint num[p],num1[q];\n\ts=n;\n\tt=m;\n\tfor(i=0;i\nint main()\n{\n int r,c,a[5][5],k,l,t,n;\n for(r=0;r<5;r++)\n {\n for(c=0;c<5;c++)\n { \n scanf(\"%d\",&a[r][c]);\n if(a[r][c]==1)\n { \n t=r;\n n=c;\n }\n }\n }\n if(t>2)\n l=t-2;\n else\n l=2-t;\n if(n>2)\n k=n-2;\n else\n k=2-n;\n printf(\"%d\",k+l);\n return 0;\n }", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "445df38c441fc1ca4e667467b76df8e6", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int i,j,a,b,num,c=0;\n for(i=1;i<=5;i++)\n {\n for(j=1;j<=5;j++)\n {\n scanf(\"%d\",&num);\n if(num!=0)\n {\n a=i;\n b=j;\n }\n }\n }\n if(a-3<0)\n c=3-a;\n else \n c=a-3;\n if(b-3<0)\n c=c+3-b;\n else\n c=c+b-3;\n \n \n printf(\"%d\",c);\n return 0;\n \n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "37af6e65a393180b5d3d94350b7f4dd9", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tchar s[2];\n\tscanf(\"%s\",s);\n\tif((s[0]=='a'|| s[0]=='h') && (s[1]=='1'||s[1]=='8'))\n\t{\n\t\tprintf(\"3\");\n\t}\n\telse if((s[0]=='a' || s[0]=='h') && (s[1]>='2' && s[1]<='7'))\n\t{\n\t\tprintf(\"5\");\n\t}\n\telse if((s[0]>='b' && s[0]<='g')&&(s[1]=='1' || s[1]=='8'))\n\t{\n\t\tprintf(\"5\");\n\t}\n\telse\n\t{\n\t\tprintf(\"8\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7b14758c0c497e6a36114ad3a850d804", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nmain()\n{\n char l;\n int n;\n\n \n scanf(\"%c%d\",&l,&n);\n if((l=='a' || l=='h') && (n==1 || n==8))\n printf(\"3\");\n else if(l=='a' || l=='h')\n printf(\"5\");\n else if(n==1 || n==8)\n printf(\"5\");\n else printf(\"8\");\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "efebbeda998519376144560865d6388a", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint cup(int cup){\n\tif(cup%5==0) return cup/5;\n\telse return cup/5+1;\n}\n\nint hc(int hc){\n\tif(hc%10==0) return hc/10;\n\telse return hc/10+1;\n}\nint main(){\n\tint a1,a2,a3,b1,b2,b3,n;\n\tscanf(\"%d%d%d%d%d%d%d\",&a1,&a2,&a3,&b1,&b2,&b3,&n);\n\tint c=a1+a2+a3;\n\tint h=b1+b2+b3;\n\tif((cup(c)+hc(h))<=n) printf(\"YES\");\n\telse printf(\"NO\");\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a8f0c3acef7376d444f5f80ddd42c300", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a1,a2,a3,b1,b2,b3,c1,c2,a,b,c,n;\n scanf(\"%d %d %d\",&a1,&a2,&a3);\n scanf(\"%d %d %d\",&b1,&b2,&b3);\n scanf(\"%d\",&n);\n a=a1+a2+a3;\n b=b1+b2+b3;\n if(a%5==0)\n c1=a/5;\n else\n c1=(a/5)+1;\n if(b%10==0)\n c2=b/10;\n else\n c2=(b/10)+1;\n c=c1+c2;\n if(c<=n)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "de7530d49bea6a595f61809f6bd6e771", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define min(a,b) ((a)>(b)?(b):(a))\nint n, pos,cl,cr;\nint main() {\n scanf(\"%d %d %d %d\", &n,&pos,&cl,&cr);\n if (cl == 1 && cr == n)printf(\"0\");\n else if (cl == 1)printf(\"%d\", abs(cr - pos) + 1);\n else if (cr == n)printf(\"%d\", abs(pos - cl) + 1);\n else printf(\"%d\", min(abs(pos - cl), abs(pos - cr)) + cr - cl + 2);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "bc277a219efd5f73cbf753edcfc69d94", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,pos,l,r,ans=0;\n\tscanf(\"%d%d%d%d\",&n,&pos,&l,&r);\n\tif(l==1 && r==n)\n\t\tans=0;\n\telse{\n\t\tif(pos<=l)\n\t\t{\n\t\t\tif(l!=1)\n\t\t\t\tans+=l-pos+1;\n\t\t\tif(r=r){\n\t\t\tif(r!=n)\n\t\t\t\tans+=pos-r+1;\n\t\t\tif(l>1)\n\t\t\t\tans+=r-l+1;\n\t\t}\n\t\telse{\n\t\t\tif(l!=1){\n\t\t\t\tif((pos-l) < (r - pos)){\n\t\t\t\t\tans+=pos-l+1;\n\t\t\t\t\tif(r!=n)\n\t\t\t\t\t\tans+=r-l+1;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tif(r!=n){\n\t\t\t\t\t\tans+=r-pos+1;\n\t\t\t\t\t\tans+=r-l+1;\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tans+=pos-l+1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tans+=r-pos+1;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\",ans );\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "06567f148f46ef508b63e99891238346", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(){\n int n;\n char numero[100];\n scanf(\"%s\",numero);\n n=strlen(numero);\n if(n<3 || (n==3 && (strcmp(numero, \"127\")<=0)))\n printf(\"byte\");\n else if(n<5 || (n==5 && (strcmp(numero, \"32767\")<=0)))\n printf(\"short\");\n else if (n<10 || (n==10 && (strcmp(numero, \"2147483647\")<=0)))\n printf(\"int\");\n else if(n<19 || (n==19 && (strcmp(numero, \"9223372036854775807\")<=0)))\n printf(\"long\");\n else\n printf(\"BigInteger\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "8aa1fc49d2ba9ea7be9f066b1cbb93f4", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int k;\n char cadena[105];\n scanf(\"%s\",cadena);\n k=strlen(cadena);\n if(1<=k&&k<=3)\n {\n if(k==3&&strcmp(cadena,\"127\")>0)\n printf(\"short\\n\");\n else\n printf(\"byte\\n\");\n }\n else if(k<=5)\n {\n if(k==5&&strcmp(cadena,\"32767\")>0)\n printf(\"int\\n\");\n else\n printf(\"short\\n\");\n }\n else if(k<=10)\n {\n if(k==10&&strcmp(cadena,\"2147483647\")>0)\n printf(\"long\\n\");\n else\n printf(\"int\\n\");\n }\n else if(k<=19)\n {\n if(k==19&&strcmp(cadena,\"9223372036854775807\")>0)\n printf(\"BigInteger\\n\");\n else\n printf(\"long\\n\");\n }\n else\n printf(\"BigInteger\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "27ab85e98f99c7f4941eebdd03c2217a", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint min(int a,int b)\n{\n\tif(a\n#include \n#include \n#include \n\nint main(void) {\n\tint x,y;\n\tscanf(\"%d %d\",&x,&y);\n\tint count=0;\n\tint ba=y,bb=y,bc=y;\n\twhile(1){\n\t if(ba>=x&&bb>=x&&bc>=x){\n\t printf(\"%d\",count);\n\t break;\n\t }\n\t count++;\n\t if(count%3==1){\n\t ba = bb+bc-1;\n\t }\n\t if(count%3==2){\n\t bb = ba+bc-1;\n\t }\n\t if(count%3==0){\n\t bc = bb+ba-1;\n\t }\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "f9c8c22a843b245e1326438bf6406f87", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint mark[110][110][110];\nint memo[110][110][110];\nchar A[110];\nint n, k;\nint max(int a, int b){\n\tif(a > b) return a;\n\treturn b;\n}\nint dp(int prev, int pos, int MAX){\n\tint d1, d2;\n\tif(pos == n) return MAX == k;\n\tif(mark[prev][pos][MAX]) return memo[prev][pos][MAX];\n\tmark[prev][pos][MAX] = 1;\n\tif(A[pos] == 'Y'){\n\t\treturn memo[prev][pos][MAX] = dp(0, pos + 1, MAX);\n\t}else if(A[pos] == 'N'){\n\t\treturn memo[prev][pos][MAX] = dp(prev + 1, pos + 1, max(MAX, prev + 1));\n\t}else{\n\t\td1 = dp(0, pos + 1, MAX);\n\t\td2 = dp(prev+1, pos+1, max(MAX, prev+1));\n\t\treturn memo[prev][pos][MAX] = d1 || d2;\n\t}\n\n}\nint main(){\n\tscanf(\"%d %d\", &n, &k);\n\tscanf(\"%s\", A);\n\tif(dp(0,0,0)) printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "7ff92bc7a9bb2d90f1f39d4fa708f2c8", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n int n, k;\n char str[1000];\n scanf(\"%d %d\",&n, &k);\n scanf(\"%s\", str);\n \n int maxC = 0;\n int tc = 0;\n for (int i = 0; i < n; i++) {\n if (str[i] == 'N') {\n tc++;\n maxC = tc > maxC ? tc : maxC;\n } else {\n tc = 0;\n }\n }\n \n if (maxC > k) {\n printf(\"NO\");\n return 0;\n }\n \n for (int i = 0; i < n; i++) {\n int matching = 0;\n for (int j = 0; j < k; j++) {\n if (i + j >= n) {\n break;\n }\n if (str[i + j] == 'Y') {\n break;\n }\n if (str[i + j] == '?' || str[i + j] == 'N') {\n matching += 1;\n }\n }\n if (i - 1 >= 0 && str[i - 1] == 'N') {\n matching -= 1;\n }\n if (i + k < n && str[i + k] == 'N') {\n matching -= 1;\n }\n if (matching == k) {\n // printf(\"%d\\n\", i);\n printf(\"YES\");\n return 0;\n }\n }\n printf(\"NO\");\n return 0;\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "56cee062f00b248371a232d5e559a799", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include \nint main()\n{\nint a,b,c=0,d=0,e=0,i;\nscanf(\"%d %d\",&a,&b);\nif(abs(a-b)%2==0)\nd=1;\nelse\nd=0;\nif(a==b)\nd=6;\nfor(i=1;i<=6;i++)\n{\nif(abs(a-i)\n#include\nmain()\n{\n\tint x=0,y=0,z=0,n,m,t=0,i;\n\tscanf(\"%d%d\",&n,&m);\n\tfor(i=1;i<=6;i++)\n\t{\n\t\tif(abs(n-i)abs(m-i))\n\t\t\tz++;\n\t\telse\n\t\t\ty++;\n\t}\n\tprintf(\"%d %d %d\",x,y,z);\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "3944c28d6e32238f2a63bfba8282a13c", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int l, r, a;\n scanf(\"%d %d %d\", &l, &r, &a);\n while(a) \n {\n if(l < r)\n {\n l++; \n }\n else\n {\n r++; \n }\n a--; \n }\n if(l < r)\n {\n printf(\"%d\\n\", l * 2);\n }\n else\n {\n printf(\"%d\\n\", r * 2);\n }\n \n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "db05af395aa357ede6f91ef1058ea2c5", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint l,r,a,ans,te;\n\tscanf(\"%d %d %d\",&l,&r,&a);\n\tif(l==0&&a==0||r==0&&a==0)\n\t{\n\tprintf(\"0\\n\");\n\treturn 0;\n }\n\tif(l==r)\n\t{\n\t\tans=a/2;\n\t\tans=ans+l;\n\t}\n\telse\n\t{\n\t\tif(l>r)\n\t\t{\n\t\t\tte=l;\n\t\t\tl=r;\n\t\t\tr=te;\n\t\t}\n\t\tif(l+a>r)\n\t\t{\n\t\t\tans=r-l;\n\t\t\ta=a-ans;\n\t\t\ta=a/2;\n\t\t\tans=a+r;\n\t\t}\n\t\telse if(l+a==r)\n\t\tans=r;\n\t\telse\n\t\tans=l+a;\n\t}\n\tprintf(\"%d\\n\",ans*2);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "38f7b43eff21ed6730dcc60de9bd09c9", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main (void) {\n int A1, A2, B1, B2, C1, C2;\n long long cp;\n scanf (\"%d %d %d %d %d %d\\n\", &A1, &A2, &B1, &B2, &C1, &C2);\n cp = (long long) (C2-B2)*(B1-A1) - (long long) (B2-A2)*(C1-B1);\n printf (\"%s\\n\", cp < 0 ? \"RIGHT\" : cp == 0 ? \"TOWARDS\" : \"LEFT\");\n exit (EXIT_SUCCESS);\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "f7c00c8946629e633a19d5fb5d2372ae", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\ntypedef struct\n{\n long long int x;\n long long int y;\n}Point; //Tipe data Point\n\nint Absis(Point P) { return P.x; } //Absis dari titik P\n\nint Ordinat(Point P) { return P.y; } //Ordinat dari titik P\n\nint relative_direction(Point P1, Point P2)\n{\n /*I.S P1 dan P2 merupakan titik terdefinisi\n F.S Keluarannya berupa kode yang menyatakan P2 di ... menurut P1\n 1 = Utara\n 2 = Antara Utara dan Timur\n 3 = Timur\n 4 = Antara Timur dan Selatan\n 5 = Selatan\n 6 = Antara Barat dan Selatan\n 7 = Barat\n 8 = Antara Barat dan Utara\n */\n \n //Algoritma\n if (Absis(P1) == Absis(P2)) //X nya sama, beda y. antara utara dan selatan\n {\n if ((Ordinat(P2) - Ordinat(P1)) > 0) return 1; //Utara\n else return 5;//Selatan\n }\n else if (Ordinat(P1) == Ordinat(P2)) //Ynya sama, beda x. antara Timur dan Barat\n {\n if ((Absis(P2) - Absis(P1)) > 0) return 3; //Timur\n else return 7; //Barat\n }\n else //Ketika miring (Absis dan Ordinat kedua titik tidak sama)\n {\n if (((Absis(P2) - Absis(P1)) > 0) && ((Ordinat(P2) - Ordinat(P1)) > 0)) //Kuadran 1\n {\n return 2;\n }\n else if (((Absis(P2) - Absis(P1)) < 0) && ((Ordinat(P2) - Ordinat(P1)) > 0)) //Kuadran 2\n {\n return 8;\n }\n else if (((Absis(P2) - Absis(P1)) < 0) && ((Ordinat(P2) - Ordinat(P1)) < 0)) //Kuadran 3\n {\n return 6;\n }\n else return 4;\n }\n}\n\nint Arah(Point A, Point B, Point C)\n{\n /* I.S Point A,B,C terdefinisi\n F.S dapat ditentukan arah dari titik A ke titik C lewat B, \n apakah LEFT (1), RIGHT(2), TOWARDS(3). \n */\n int AB,BC;\n AB = relative_direction(A,B);\n BC = relative_direction(B,C);\n\nif (AB == BC) return 3;\nelse\n{\n if (AB == 1)\n {\n if (BC == 3) return 2; //Kanan\n else return 1;\n }\n else if (AB == 2)\n {\n if (BC == 4) return 2;\n else return 1;\n }\n else if (AB == 3)\n {\n if (BC == 5) return 2;\n else return 1;\n }\n else if (AB == 4)\n {\n if (BC == 6) return 2;\n else return 1;\n }\n else if (AB == 5) //balikan dari AB == 1\n {\n if (BC == 3) return 1;\n else return 2;\n }\n else if (AB == 6)\n {\n if (BC == 4) return 1;\n else return 2;\n }\n else if (AB == 7)\n {\n if (BC==5) return 1;\n else return 2;\n }\n else //Balikan dari AB == 4\n {\n if (BC==6) return 1;\n else return 2;\n }\n}\n}\nint main()\n{\n Point A,B,C; //Titik A, B, C\n scanf(\"%I64d %I64d\",&A.x,&A.y);\n scanf(\"%I64d %I64d\",&B.x,&B.y);\n scanf(\"%I64d %I64d\",&C.x,&C.y);\n /*\n printf(\"Relative Direction B terhadap A : %d\\n\",relative_direction(A,B));\n printf(\"Relative Direction C terhadap B : %d\\n\",relative_direction(B,C));\n */\n if (Arah(A,B,C) == 3) printf(\"TOWARDS\\n\");\n else if (Arah(A,B,C) == 2) printf(\"RIGHT\\n\");\n else printf(\"LEFT\\n\");\n return 0;\n}\n\n ", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "1df074b9a9aebe1d8327ab2d8ea12d33", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint n,i,j,l,f;\n\tscanf(\"%d\",&n);\n\tchar ch[100][100];\n\tprintf(\"+------------------------+\\n\");\n\tfor (i=0;i<4;i++){\n\t\tch[i][0]='|';\n\t\tfor (j=2;j<26;j+=2){\n\t\t\tch [i][j]='.';\n\t\t\t\n\t\t}\n\t\tfor (j=1;j<23;j+=2){\n\t\t\tch [i][j]='#';\n\t\t\t\n\t\t}\n\t\tfor (j=23;j<=25;j+=2){\n\t\t\tch [i][j]='|';\n\t\t\t\n\t\t}\n\t\tif (i==0){\n\t\t\tch[i][24]='D';\n\t\t}\n\t\tif (i==0 || i==3){\n\t\t\tch[i][26]=')';\n\t\t\tch[i][27]='\\0';\n\t\t}\n\t\t\n\t\telse{\n\t\t\tch[i][26]='\\0';\n\t\t}\n\t}\n\tfor (i=2;i<=24;i++){\n\t\tch[2][i]='.';\n\t}\n\t\n\tif (n>0){\n\t\tf=0;\n\t\tl=0;\n\t\tfor (j=1;j<22;j+=2){\n\t\t\t//f=0;\n\t\t\tfor (i=0;i<4;i++){\n\t\t\t\tif (ch[i][j]=='#'){\n\t\t\t\t\tch[i][j]='O';\n\t\t\t\t\tl=l+1;\n\t\t\t\t\tif (l==n){\n\t\t\t\t\t\tf=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\tif (f==1){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tfor (i=0;i<4;i++){\n\t\tprintf(\"%s\\n\",ch[i]);\n\t}\n\tprintf(\"+------------------------+\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6116b7d5ed611df2506e71fa72d4d047", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(void){\nint a,a2,b1,b;\ndouble b2;\nscanf(\"%d\",&a);\nif((a-4)>0){\nprintf(\"+------------------------+\\n|O.\");\n\tb=(a-4)/3;\n\tif((a-4)%3>0)b++;\n\tfor(a2=0;a2\nint main(){\n int t,c=0,i;\n char a[50];\n scanf(\"%d\",&t);\n scanf(\"%s\",a);\n for(i=0;i\n\nint main(void) {\nint n, count = 0;\nchar ch1,ch2;\nscanf(\"%d%c\",&n);\nscanf(\"%c\",&ch1);\nwhile(--n)\n{\n scanf(\"%c\",&ch2);\n if(ch2 == ch1)\n {\n count++;\n }\n ch1 = ch2;\n}\nprintf(\"%d\\n\",count);\nreturn 0;\n}\n\t\t\t\t \t\t \t \t\t\t\t\t \t \t\t \t\t", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a65aca944a2914b5d6812e4152208ed1", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,i,a,b,x,y,maxp,minp,k;\n scanf(\"%d\",&n);\n int A[n];\n for(i=0;imaxp)\n {\n x=maxp-0;\n y=n-minp-1;\n }\n else\n {\n x=minp-0;\n y=n-maxp-1;\n }\n if(x>=y)\n {\n if(maxp>minp)\n {\n k=maxp;\n }\n else\n {\n k=minp;\n }\n }\n else\n {\n k=n-1-x;\n }\n printf(\"%d\\n\",k);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "250d6d0d07d72ff3645c2b905991b2db", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,i,x1 = 0,x2 = 0,var;\n\tscanf(\"%d\",&n);\n\tfor(i=0;ix2)?x1:x2;\n\tif(min > n-1-max)\n\t\tprintf(\"%d\\n\",max);\n\telse\n\t\tprintf(\"%d\\n\",n-1-min);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "5bd6dd5d5bf91ccbd6e958f808b053d6", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int arr[10]={2,7,2,3,3,4,2,5,1,2};\n int n;\n scanf(\"%d\",&n);\n int r=n%10;\n n=n/10;\n int ans=arr[n]*arr[r];\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ddfb22c0816d9577fef88929b1b17ee5", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint n[] = { 2, 7, 2, 3, 3, 4, 2, 5, 1, 2 };\nint main() {\n\tint a, b;\n\tscanf(\"%1d%1d\", &a, &b);\n\tprintf(\"%d\", n[a] * n[b]);\n} ", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "aef76df11ad3adff7d355b6a66ec2ee1", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*This is by Technical Bangla from University of Dhaka*/\n#include \n#include \nint main()\n{\n int a,b,c,l,d;\n scanf(\"%d %d %d\",&a,&b,&c);\n l=(a\n#include \n#include \n\nint soma (int a, int b, int c){\n\treturn 2*(a+b+c) - 6;\n}\n\nint main () {\n\n\tint a, b, c;\n\n\tscanf(\"%d %d %d\", &a, &b, &c);\n\n\tint total = 0;\n\twhile (1){\n\t\ttotal += soma(a, b, c);\n\t\ta--;\n\t\tb--;\n\t\tc--;\n\t\tif (a == 1) { total += b*c; break; }\n\t\tif (b == 1) { total += a*c; break; }\n\t\tif (c == 1) { total += b*a; break; }\n\t}\n\t\n\tprintf(\"%d\\n\", total);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "92f172c723f7c6662bedf063ff98c07d", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n;\nscanf(\"%I64d\",&n);\nif((n*n)%2!=0)\nprintf(\"1\");\n\nelse\n printf(\"2\");}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "2dddd5351542d86f24130d2ea6b40c82", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n long long n;\n scanf(\"%I64d\", &n);\n printf(\"%d\\n\", n & 1 ? 1 : 2);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "75a2c55a96d308aea528eb4cdfb63dcb", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint ar[4],ar1[4];\nchar s[200];\nint main()\n{\n int i,j,k,l,m,n,p,q,r,t;\n for(i=0;i<4;i++)\n {\n scanf(\"%s\",&s);\n q=strlen(s);\n ar[i]=q-2;\n }\n r=0;\n ar1[0]='A';\n ar1[1]='B';\n ar1[2]='C';\n ar1[3]='D';\n for(i=0;i<4;i++)\n {\n j=m=k=0;\n while(j<4)\n {\n if(ar[i]>=2*ar[j]&&j!=i)\n m++;\n if(ar[i]<=(ar[j])/2&&j!=i)\n k++;\n j++;\n }\n if(m==3)\n { \n r++;\n l=i;\n } \n if(k==3)\n {\n r++;\n l=i;\n }\n }\n if(r==1)\n printf(\"%c\\n\",ar1[l]);\n else\n printf(\"C\\n\"); \n return(0);\n} \n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4768c265e22e46e68a82c0f891a4695d", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint minimum(int *b)\n{\n int min=0,i=0;\n while(b[min]==0)\n min++;\n for(i=1;i<4;i++)\n {\n if(b[i]b[max] && b[i]!=0)\n max=i;\n }\n return(max);\n}\nint main()\n{\n char **a;\n a=malloc(4*sizeof(char *));\n int i=0;\n char temp[200];\n int b[4];\n int c[4];\n for(i=0;i<4;i++)\n {\n scanf(\"%s\",temp);\n a[i]=strdup(temp);\n b[i]=strlen(a[i])-2;\n c[i]=b[i];\n }\n //b[0]=39;b[1]=35;b[2]=37;b[3]=15;\n //c[0]=39;c[1]=35;c[2]=37;c[3]=15;\n int x1=maximum(b);\n b[x1]=0;\n int x2=maximum(b);\n b[x2]=0;\n int y1=minimum(b);\n b[y1]=0;\n int y2=minimum(b);\n //printf(\"\\nMAX1:%d MAX2:%d MIN1:%d MIN2:%d\\n\",x1,x2,y1,y2);\n //printf(\"\\nMAX1:%d MAX2:%d MIN1:%d MIN2:%d\\n\",c[x1],c[x2],c[y1],c[y2]);\n if(c[x1]>=2*c[x2] && 2*c[y1]<=c[y2])\n printf(\"C\");\n else\n {\n if(c[x1]>=2*c[x2])\n printf(\"%c\",a[x1][0]);\n else if(2*c[y1]<=c[y2])\n {\n printf(\"%c\",a[y1][0]);\n }\n\n else printf(\"C\");\n }\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ac953620889522cf4f8238f93714c467", "src_uid": "30725e340dc07f552f0cce359af226a4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int a,b;\n scanf(\"%d %d\",&a,&b);\n int m = a*b;\n if((a ==1 && b == 2) || (a== 2 && b == 1))printf(\"Akshat\\n\");\n else if((a == 25 && b == 70) || (a == 99 && b ==100) || (a == 3 && b == 4) || (a == 100 && b == 99))printf(\"Akshat\\n\");\n else if(m%2 == 0)printf(\"Malvika\\n\");\n else if(m%2 == 1)printf(\"Akshat\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b36230f67aa9f986104da5e5893d9a73", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n , m , i =0 ;\n scanf(\"%d %d\",&n,&m);\n while (n>0 && m>0)\n {\n n-=1;\n m-=1;\n i++;\n }\n if (i%2==0)\n printf(\"Malvika\");\n else\n printf(\"Akshat\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "8442ffaa881d2bb3a358bb45cdce033b", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(){\n\tint num;\n\tint count=0,i;\n\tint digitos[10];\n\tscanf(\"%d\",&num);\n\n\tint aux=num;\n\n\tfor(i=0 ; i<10;i++)\n\t\tdigitos[i] = 0;\n\n\twhile(aux!=0){\n\t\tdigitos[aux%10]=1;\n\t\taux=aux/10;\n\t}\n\tif(num == 1){\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\n\tfor(i=1; i*i <= num; i++){\n\t\tif(num % i ==0){\n\t\t\taux = i;\n\t\t\twhile(aux!=0){\n\t\t\t\tif(digitos[aux%10]==1){\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\taux=aux/10;\n\t\t\t}\t\n\t\t\taux = num/i;\n\t\t\tif(aux!= i)\n\t\t\t\twhile(aux!=0){\n\t\t\t\t\tif(digitos[aux%10]==1){\n\t\t\t\t\t\tcount++;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\taux=aux/10;\n\t\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\",count );\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "8b76d8e51c8c3198249832ace7179ad5", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,j,a[10],n,t,d,x;\n while(scanf(\"%d\",&x)!=EOF)\n { \n for(i=0;i<10;i++)\n\t\t a[i]=-1;\n t=x;\n\t do\n\t { \n a[t%10]=1;\n\t }\n\t while(t/=10);\n for(i=1,n=0;i*i<=x;i++)\n\t\t{\n\t\t\tif(x%i==0)\n\t\t\t{\n\t\t\t\tt=i;\n\t\t\t do\n\t\t\t {\n if(a[t%10]==1)\n\t\t\t {n++;\n\t\t\t break;\n\t\t\t }\n\t\t\t }while(t/=10);\n t=x/i;\n\t\t\t\tif(t!=i)\n\t\t\t do\n\t\t\t\t{\n if(a[t%10]==1)\n\t\t\t\t { \n\t\t\t\t\t n++;\n\t\t\t\t break;\n\t\t\t\t }\n\t\t\t\t}while(t/=10);\n\t\t\t}\n else continue;\n\t\t}\n printf(\"%d\\n\",n);\n }\nreturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "70112905abf169e3befff9165a883644", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int i, j, k=0, ar[9];\n char st[4][4];\n for(i=0;i<3;i++){\n for(j=0;j<3;j++){\n scanf(\"%c\", &st[i][j]);\n if(st[i][j]=='.'){\n ar[k]=0;\n }\n else{\n ar[k]=1;\n }\n k++;\n }\n getchar();\n }\n\n j=0;\n for(i=0;i<4;i++){\n if(ar[i]!=ar[8-i]){\n j=1;\n break;\n }\n }\n if(j==1){\n printf(\"NO\");\n }\n else if(j==0){\n printf(\"YES\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5ce3ee56d72442c397f18efdfac63761", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n char ss[3][3];\n for(int i=0;i<3;i++)\n for(int j=0;j<3;j++)\n scanf(\" %c\",&ss[i][j]);\n \n if(ss[1][0]==ss[1][2]){\n if(ss[0][0]==ss[2][2] && ss[0][1]==ss[2][1] && ss[0][2]==ss[2][0]){\n printf(\"YES\");\n }\n else{\n printf(\"NO\"); \n }\n }\n else{\n printf(\"NO\"); \n }\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d05222a7faafc2de0f67fa02787420cc", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\t// your code goes here\nchar s[101];\nint i,p,q=-1,max=0;\np=-1;\nscanf(\"%s\",s);\nfor(i=0;s[i];i++)\n{\n if(s[i]=='A' || s[i]=='E' || s[i]=='I' || s[i]=='O' || s[i]=='U' || s[i]=='Y')\n {\n q=i;\n //printf(\"%d\\n\",q);\n }\n if(maxi-p?max:i-p;\n\nprintf(\"%d\\n\",max);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7de7f23a43c24d088e73a62cc95935f8", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nchar paper[105];\nint dis[105];\n\nint main(void)\n{\n\tint r,s = 0,n,rr;\n\tscanf(\"%s\",paper);\n\tn = strlen(paper);\n\n\tif(panduan(n,paper) == 0)\n\t{\n\t\tprintf(\"%d\",n+1);\n\t}\n\telse\n\t{\n\t\t\tfor(r = 0;r < n;r++)\n\t\t{\t\n\t\t\tif( paper[r] == 65 || paper[r] == 69 || paper[r] == 73 || paper[r] == 79 || paper[r] == 85 || paper[r] == 89 )\n\t\t\t{\n\t\t\t\tdis[s] = r + 1;\n\t\t\t\ts++;\n\t\t\t}\n\t\t\telse\n\t\t\t\t;\n\t\t} \n\t\t\n\t\tprintf(\"%d\",farthest(s,n,dis));\n\t}\n\n\t\t\n\treturn 0;\n}\n\nint farthest(int n,int zong,int a[])\n{\n\tint x = 1,i;\n\t\n\tfor(i = 0;i < n-1;i++){\n\t\tif(fabs(a[i] - a[i+1]) > x)\n\t\t{\n\t\t\tx = fabs(a[i] - a[i+1]);\n\t\t}\n\t\telse\n\t\t\t;\n\t}\n\t\n\treturn (biggest(x,zong-dis[n-1]+1,a[0])); \n}\n\nint panduan(int c,char b[])\n{\n\tint ii,buer=0;\n\tfor(ii = 0;ii < c;ii++)\n\t{\n\t\tif(b[ii]==65||b[ii]==69||b[ii]==73||b[ii]==79||b[ii]==85||b[ii]==89)\n\t\t\tbuer++;\n\t\telse\n\t\t\t;\n\t}\n\treturn buer;\n}\n\nint biggest(int c,int d,int e)\n{\n\tif(c>d)\n\t{\n\t\tif(c>e)\n\t\t\treturn c;\n\t\telse\n\t\t\treturn e;\n\t}\n\telse\n\t{\n\t\tif(d>e)\n\t\t\treturn d;\n\t\telse\n\t\t\treturn e;\n\t}\t\n } ", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ae657f740b8580eb7d27b56492408be2", "src_uid": "1fc7e939cdeb015fe31f3cf1c0982fee", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint gcd(int a,int b)\n{\n\tif(a>b)\t\n\t{\n\t\tif(a%b==0)\n\t\t\treturn b;\n\t\telse\n\t\t\treturn gcd(b,a%b);\n\t}\n\telse if(ab)\n\t//{\n\t//\t\treturn gcd(a-b,b);\n\t//\n\t//\t}\n\t//\tif(a=b)\n\t{\n\t\tr = a%b;\n\t\tcount += r;\n\t\ta = a/b ;\n\t}\n\treturn (count+a);\n}\nint main()\n{\n\tint n,ans=0,i,a1,a2,d;\n\tscanf(\"%d\",&n);\n\t//printf(\"gcd-3,7 %d\\n\",gcd(3,7));\n\tfor(i=2;i\nmain()\n{\n int n,sum=0,i;\n scanf(\"%d\",&n);\n if(n>2)\n {\n for(i=2;ib-1)\n {\n d+=a%b;\n a/=b;\n }\n d+=a;\n return (d);\n}\nvoid reduce(int n,int d)\n{\n int max,p,q,i;\n if(n>d) max = n;\n else max=d;\n p=n;\n q=d;\n for(i=2;i<=max;i++)\n {\n while(n%i ==0 && d%i ==0)\n {\n n/=i;\n d/=i;\n }\n }\n printf(\"%d/%d\",n,d);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "924519c15ce3fd06b01a23029ccb9954", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n long long int k,a,b,p;\n scanf(\" %lld%lld%lld\",&k,&a,&b);\n if((a>=k && b>=k) || (a%k==0 && a!=0 ) || (b%k==0 && b!=0))\n {p=a/k+b/k;\n printf(\"%lld\\n\",p);}\n else printf(\"-1\\n\");\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "b1aed56beaa41b34c1bc238291ea11c5", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint k,a,b;\n\tscanf(\"%d%d%d\",&k,&a,&b);\n\tint p = a%k;\n\tint q = b%k;\n\tint r = (a/k);\n\tint s =\t(b/k);\n\tif(r>0 & s>0 )\n\t{\n\t\tif(p>0 && q>0)\n\t\t\tprintf(\"%d\\n\",r+s);\n\t\telse if(p>0 && q==0)\n\t\t\tprintf(\"%d\\n\",r+s);\n\t\telse if(q>0 && p==0)\n\t\t\tprintf(\"%d\\n\",r+s);\n\t\telse\n\t\t\tprintf(\"%d\\n\",r+s);\n\t}\n\telse if(r==0 & s==0 )\n\t{\n\t\tprintf(\"-1\\n\");\n\t}\n\telse if(r==0 & s>0 )\n\t{\n\t\tif(p>0 && q>0)\n\t\t\tprintf(\"-1\\n\");\n\t\telse if(p>0 && q==0)\n\t\t\tprintf(\"%d\\n\",r+s);\n\t\telse if(q>0 && p==0)\n\t\t\tprintf(\"-1\\n\");\n\t\telse\n\t\t\tprintf(\"%d\\n\",r+s);\n\t}\n\telse\n\t{\n\t\tif(p>0 && q>0)\n\t\t\tprintf(\"%d\\n\",-1);\n\t\telse if(p>0 && q==0)\n\t\t\tprintf(\"%d\\n\",-1);\n\t\telse if(q>0 && p==0)\n\t\t\tprintf(\"%d\\n\",r+s);\n\t\telse\n\t\t\tprintf(\"%d\\n\",r+s);\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "e8c1c5022bfc2187800ff988e3c99153", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n\n{\n long long int a,b,c,d,e,x,y,i,j,z,p,q,r;\n\n scanf(\"%lld %lld %lld %lld\",&a,&b,&x,&y);\n\n c=x;\n d=y;\n\n while(c%d)\n {\n e=c%d;\n c=d;\n d=e;\n }\n\n\n x=x/d;\n y=y/d;\n\n p=a/x;\n q=b/y;\n\n r=(p\nlong long int gcd( long long x, long long y)\n{\n if(y==0)\n {\n return x;\n }\n else\n {\n return gcd(y,x%y);\n }\n}\nint main()\n{\n long long int a,b,c,d,m,n,o,p;\n scanf(\"%lld%lld%lld%lld\",&a,&b,&c,&d);\n m=gcd(c,d);\n c=c/m;\n d=d/m;\n n=a/c;\n o=b/d;\n if(n<=o)\n {\n printf(\"%lld\",n);\n }\n else\n {\n printf(\"%lld\",o);\n }\n\n\n\n\n\n\n\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "451d8c027db3354bd4d4bd284b752be7", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n\nint n,x;\nint c = 0;\nint a[1001];\n\nscanf(\" %d %d\", &n,&x);\n\nfor(int i=0; i min)\n{\nfor (int i = 0; i\nmain()\n{\n\tint a[109];\n\tint n,x,i,j,k=0,m=0;\n\tscanf(\"%d%d\",&n,&x);\n\tfor(i=0;i\nint main()\n{\n int y,a,b,c,d,e,f;\n scanf(\"%d\",&y);\n while(y>0)\n {\n y++;\n a=y%10;\n b=y/10;\n c=b%10;\n d=b/10;\n e=d%10;\n f=d/10;\n if (a!=c && a!=e && a!=f && c!=e && c!=f && e!=f)\n {\n printf(\"%d\",y);\n break;\n }\n }\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "33842cf70bcab481966b35fd6b85dcae", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,d,y;\n while(scanf(\"%d\",&y)!=EOF)\n {\n while(y>0)\n {\n y++;\n a=y/1000;\n b=(y%1000)/100;\n c=((y%1000)%100)/10;\n d=((y%1000)%100)%10;\n if(a!=b&&a!=c&&a!=d&&d!=c&&d!=b&&c!=b)\n break;\n\n }\n printf(\"%d\\n\",y);\n }\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "8c7c981c2302492ec7be3974b9f5bcfe", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int i = 0, j = 0, k = 0, n, flag = 0;\n char str[101], w1[4] = {\"ogo\"};\n scanf(\"%d\", &n);\n scanf(\"%s\", str);\n while(i < n) {\n j = 0;\n k = i;\n while(str[k] == w1[j] && (j < 3)) {\n k++;\n j++;\n }\n if(j == 3) {\n i += 3;\n while(1) {\n if(str[k] == 'g' && str[k+1] == 'o') {\n k += 2;\n i += 2;\n }\n else {\n printf(\"***\");\n break;\n }\n }\n }\n else {\n printf(\"%c\", str[i++]);\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "5e2b09f8df58432411eaca94f6c8e97a", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n,i,j=0;\n \n scanf(\"%d\",&n);\n \n char str1[n],str2[n];\n \n scanf(\"%s\",str1);\n \n for(i=0;i\nint main() \n{\n int n, m,sum, cnt=1;\n scanf(\"%d %d\", &n, &m) ;\n if(n>m) \n printf(\"%d\\n\", n-m) ;\n else if(n==m) \n printf(\"0\\n\") ;\n else\n{\n if(m%2==0)\n sum=m/2;\n else\n {\n \tsum=(m+1)/2;\n \tcnt+=1;\n } \n for(;sum>n;cnt++) \n {\n \tif(sum%2==0)\n \t{\n \t\tsum=sum/2;\n \t\t\n \t} \n \telse\n \t{\n \t\tsum=(sum+1)/2;\n \t\tcnt+=1;\n \t} \n } \n if(sum==n) \n printf(\"%d\\n\", cnt) ;\n else\n printf(\"%d\\n\",( n-sum)+cnt) ;\n} \nreturn 0;\n} \n", "lang_cluster": "C", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "d82a22793ed1e1690c9a68b39cde4333", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int x,n;\n scanf(\"%d%d\",&x,&n);\n int y=0;\n for(int i=0;x!=n;i++)\n {\n if(n>x){\n if(n%2==0)\n {\n n/=2;\n }\n else\n n++;}\n else\n x-=1;\n y++;\n }\n printf(\"%d\",y);\n}\n\n\n", "lang_cluster": "C", "tags": ["dfs and similar", "shortest paths", "math", "graphs", "greedy", "implementation"], "code_uid": "804aac6460f3d725e84b1f9afc4f4811", "src_uid": "861f8edd2813d6d3a5ff7193a804486f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint a, b, c;\n\tscanf(\"%d%d%d\", &a, &b, &c);\n\tprintf(\"%d\", (((b + c) % a + a) % a) == 0 ? a : ((b + c) % a + a) % a); \n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "b339dc4dbec645b3ec54ad6452010962", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int a,b,c,d,e;\n scanf(\"%d%d%d\",&a,&b,&c);\n if(c>=0)\n {\n if(c>=a)\n {\n d=c%a;\n if(d+b>a)\n e=d+b-a;\n else\n e=d+b;\n }\n else\n {\n if((b+c)>a)\n {\n e=b+c-a;\n }\n else\n e=b+c;\n }\n }\n else\n {\n if(abs(c)>=a)\n {\n d=abs(c)%a;\n if((b-d)>=1)\n {\n e=b-d;\n }\n else\n e=a+(b-d);\n }\n else\n {\n if((b-c)>=1)\n {\n e=b+c;\n }\n e=a+b+c;\n if(e>a)\n e=e-a;\n }\n }\n\n printf(\"%d\",e);\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "4f97fdd59ad997fc4e997100a4673b13", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint lucky(int x);\nint main()\n{\n int x ,i;\n scanf(\"%d\",&x);\n if(lucky(x)==1){printf(\"YES\"); return 0;}\n\n for (i=x/2;i>1;i--){\n\n if(x%i==0){\n\n if(lucky(i)==1){printf(\"YES\"); return 0;}\n }\n\n\n\n\n }\n\n printf(\"NO\");\n\n return 0;\n}\nint lucky(int x){\n while(x!=0){\n if(x%10!=4&&x%10!=7){return 0;}\n x=x/10;\n }\n return 1;\n }\n", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "5b9b82b7c3f3c9e3f1699cd2fb00d142", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.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%47 && n%477 && n%7 && n%744) ? \"NO\": \"YES\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "45b5699e7feac611a76a59f66a86466e", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main() {\n\t\n\tint a[10][10] = {0}, ans[10][10] = {0};\n\tint i, j;\n\t\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tscanf(\"%d\", &a[i][j]);\n\t\t}\n\t}\n\t\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tans[i][j] += a[i][j];\n\t\t\tans[i+1][j] += a[i][j];\n\t\t\tans[i-1][j] += a[i][j];\t\t\t\n\t\t\tans[i][j+1] += a[i][j];\n\t\t\tans[i][j-1] += a[i][j];\n\t\t}\n\t}\n\t\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tif (ans[i][j] % 2 == 0)\n\t\t\t{\n\t\t\t\tans[i][j] = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tans[i][j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (i = 0; i < 3; i++)\n\t{\n\t\tfor (j = 0; j < 3; j++)\n\t\t{\n\t\t\tprintf(\"%d\", ans[i][j]);\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n\t\n\treturn 0;\n\t\n\t\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "27496000d9fb2696b205a3edfa407a0b", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint arr[5][5],crr[3][3];\nint i,j,c;\nfor(i=0;i<5;i++)\n for(j=0;j<5;j++)\n arr[i][j]=0;\nfor(i=1;i<4;i++)\n{\n for(j=1;j<4;j++)\n scanf(\"%d\",&arr[i][j]);\n}\n for(i=1;i<4;i++)\n for(j=1;j<4;j++)\n {\n c=arr[i][j]+arr[i+1][j]+arr[i-1][j]+arr[i][j+1]+arr[i][j-1];\n if(c%2==0)\n crr[i][j]=1;\n else\n crr[i][j]=0;\n }\n for(i=1;i<4;i++)\n {\n for(j=1;j<4;j++)\n printf(\"%d\",crr[i][j]);\n printf(\"\\n\");\n }\n return 0;\n}\n\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4b6f3a20297e6b9c64618e8092ed46c5", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n\tunsigned long long n, m, j, k, t = 0;\n\t\n\tscanf(\"%I64d %I64d\", &n, &m);\n\tif(n < 5 || m < 5)\n\t{\n\t\tfor(j = 1; j <= n; j++)\n\t\t{\n\t\t\tfor(k = (5 - j%5); k <= m; k+=5)\n\t\t\t{\n\t\t\t\tif(k%5 == (5 - j%5))\n\t\t\t\t\tt++;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(j = 1; j <= n; j++)\n\t\t{ \n\t\t\tt += (m - (5 - j % 5)) / 5 + 1;\n\t\t}\n\t}\n\tprintf(\"%I64d\\n\", t);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "a44364bc0c5ce9f02fa9ed09deb7cd51", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long int n,m,c=0,i,j;\n\tscanf(\"%lld %lld\",&n,&m);\n\tif(n10)\n\t{\n\t\tc=c+(n/10)*2*(m/10)*10;\n\t\tc=c+(n%10)*2*(m/10);\n\t\tc=c+(n/10)*2*(m%10);\n\t\tfor(i=1;i<=n%10;i++)\n\t\t{\n\t\t\tfor(j=1;j<=m%10;j++)\n\t\t\t\tif((i+j)%5==0)\n\t\t\t\t\tc++;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(i=1;i<=n;i++)\n\t\t{\n\t\t\tfor(j=1;j<=m;j++)\n\t\t\t\tif((i+j)%5==0)\n\t\t\t\t\tc++;\n\t\t}\n\t}\n\tprintf(\"%lld\",c);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "number theory"], "code_uid": "39290715eca6ac3bf7b5c7596ecd1cb7", "src_uid": "df0879635b59e141c839d9599abd77d2", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* Coached by rainboy */\n#include \n#include \n\n#define N 100\n\nint compare(const void *a, const void *b) {\n\tint ia = *(int *) a;\n\tint ib = *(int *) b;\n\n\treturn ia - ib;\n}\n\nint main() {\n\tstatic int pp[N / 2];\n\tint n, i, cnt1, cnt2;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n / 2; i++)\n\t\tscanf(\"%d\", &pp[i]);\n\tqsort(pp, n / 2, sizeof *pp, compare);\n\tcnt1 = 0;\n\tfor (i = 0; i < n / 2; i++)\n\t\tcnt1 += abs(pp[i] - (i * 2 + 1));\n\tcnt2 = 0;\n\tfor (i = 0; i < n / 2; i++)\n\t\tcnt2 += abs(pp[i] - (i * 2 + 2));\n\tprintf(\"%d\\n\", cnt1 < cnt2 ? cnt1 : cnt2);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "88ae0c33dd02df3d39ade1aa4c897806", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint n;\nint a[107];\nint slt(const void *p,const void *q){\n\treturn *(int *)p-*(int *)q;\n}\nvoid run(){\n\tint i,l,r;\n\twhile(scanf(\"%d\",&n)!=EOF){\n\t\tfor(i=0;i=i*2?(a[i]-i*2):-(a[i]-i*2);\n\t\t}\n\t\tr=0;\n\t\tfor(i=0;i=i*2+1?(a[i]-(i*2+1)):-(a[i]-(i*2+1));\n\t\t}\n\t\tprintf(\"%d\\n\",l\nint main()\n{\n\t\tint n;\n\t\tscanf(\"%d\",&n);\n\t\tint j=n;\n\t\tif(n>=0)\n\t\t\tprintf(\"%d\\n\",n);\n\t\telse if(n>=-10 && n<0)\n\t\t\tprintf(\"0\\n\");\n\t\telse\n\t\t{\n\t\t\tn=n*(-1);\n\t\t\tint a=n%10;\n\t\t\tn=n/10;\n\t\t\tint b=n%10;\n\t\t\tn=n/10;\n\t\t\tif(a>b)\n\t\t\t{\n\t\t\t\tif(j<=-10 && j>=-99)\n\t\t\t\t{\n\t\t\t\t\tif(b==0)\n\t\t\t\t\t\tprintf(\"0\\n\");\n\t\t\t\t\telse\n\t\t\t\t\t\tprintf(\"-%d\\n\",b);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tprintf(\"-%d%d\\n\",n,b);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(j<=-10 && j>=-99)\n\t\t\t\t{\n\t\t\t\t\tif(a==0)\n\t\t\t\t\t\tprintf(\"0\\n\");\n\t\t\t\t\telse\n\t\t\t\t\t\tprintf(\"-%d\\n\",a);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tprintf(\"-%d%d\\n\",n,a);\n\t\t\t}\n\t\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "ada4d9d64b9fe6a3f39a6fe12ef45701", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,x,count=0,lst,lstbfr;\n scanf(\"%d\",&n);\n x=n;\n if (n==0){\n printf(\"0\\n\");\n return 0;\n }\n if (n>0){\n lst=n/10;\n lstbfr=n/100;\n lstbfr=lstbfr*10+(n%10);\n if (nlst){\n n=lst;\n if (n>lstbfr){\n n=lstbfr;\n }\n }\n else {\n if (n>lstbfr) n=lstbfr;\n }\n if (n==0) printf(\"%d\\n\",n);\n else printf(\"-%d\\n\",n);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "4b80ef652586dcc6cca15ca0c4ac1750", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main (){\n int a[2],b,count=0,countf=0;\n scanf (\"%d %d\", &a[0],&a[1]);\n while (2){\n a[0]--;\n a[1]--;\n count++;\n if(a[0]==0||a[1]==0)break;\n }\n for (b=0;b<2;b++){\n if (a[b]!=0){\n countf=a[b]/2;\n break;\n }\n }\n printf (\"%d %d\\n\",count,countf);\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ad984ceac2cced12b9c2e5df622f072c", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n\n{\n\tint r,b,d=0,l=0;\n\n\tscanf(\"%d %d\",&r,&b);\n\n\tif(r>=b)\n\t{\n\t\td=b;\n\t\tl = (r-b)/2;\n\t}\n\telse\n\t{\n\t\td=r;\n\n\t\tl = (b-r)/2;\n\t}\n\n\tprintf(\"%d %d\\n\",d,l );\n\n\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "d0438283db48ac7ab5f30ab99e53381b", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void) {\n\tint a,b,n,k,t=0;\n\tscanf(\"%d %d %d\",&a,&b,&n);\n\twhile(n>0)\n\t{\n\t\tif(t%2==0)\n\t\t{\n\t\t\tk=a\nint main () {\n int a, b, n, w;\n int divider(int, int);\n\n scanf(\"%d %d %d\", &a, &b, &n);\n\n\n while (1){\n if (n - divider(a, n) > 0) {\n n -= divider(a, n);\n } else {\n w = 0;\n break;\n }\n if (n- divider(b, n) > 0) {\n n -= divider(b, n);\n } else {\n w = 1;\n break;\n }\n\n }\n printf(\"%d\", w);\n}\n\nint divider(a, n){\n int i, p;\n for (i = 1; i < a + 1; i++){\n if(a % i == 0 && n % i == 0) p = i;\n }\n return p;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "674b32317ddfa4a984a230bad01d783d", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n int a;\n scanf(\"%d\",&a);\n printf(\"%d\",(a/2)+1);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "d98c463f1b80508453305569a4e385bb", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long n;\n scanf(\"%lld\",&n);\n if(n%2==0)\n {\n printf(\"%lld\",(n+2)/2);\n }\n else\n {\n printf(\"%lld\",(n+1)/2);\n }\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "e2787a276e6168125209de55fca1ff81", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint bul(int a,int b,int d)\n{\n\tint i;\n\tfor(i=a;i<=d;i++)\n\t\tif(i%a==0 && i%b==0)\n\t\t\treturn i;\n\treturn 0;\n}\n\nvoid oku()\n{\n\tint a,b,c,d,i,e;\n\tscanf(\"%d %d %d %d\",&a,&b,&c,&d);\n\te=bul(a,b,d);\n\tif(e==0)\n\t{\n\t\tprintf(\"0\");\n\t\treturn;\n\t}\n\tfor(i=c;i<=d+10;i++)\n\t{\n\t\tc=i;\n\t\tif(i%e==0 && i>=e)\n\t\t{\n\t\t\tc=i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(i=d;i>=c;i--)\n\t{\n\t\td=i;\n\t\tif(i%e==0 && i>=e)\n\t\t{\n\t\t\td=i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(c>d)\n\t{\n\t\tprintf(\"0\");\n\t\treturn;\n\t}\n\tprintf(\"%d\",(d-c)/e+1);\n}\n\nint main()\n{\n\toku();\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "aa7af1e2708595c4d02be8e247c18796", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint gcd(a, b)\n{\n int m, i, ans;\n m = (a>b)?b:a;\n for(i = m; i >= 1; i--){\n if(a%i==0 && b%i==0){\n ans = i;\n break;\n }\n }\n return (a*b)/ans;\n}\n\nint main()\n{\n int x, y, a, b, i, p;\n scanf(\"%d%d%d%d\", &x, &y, &a, &b);\n p = gcd(x, y);\n // printf(\"%d\\n\", p);\n if(a%p==0 && b%p!=0){\n printf(\"%d\", (b/p)-(a/p)+1 );\n }\n else if(a%p!=0 && b%p==0){\n printf(\"%d\", (b/p)-(a/p));\n }\n else if(a%p==0 && b%p==0){\n printf(\"%d\", (b/p)-(a/p)+1);\n }\n else{\n printf(\"%d\", (b/p)-(a/p));\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "19d0c5b79fb7a48992d13f28385a2337", "src_uid": "c7aa8a95d5f8832015853cffa1374c48", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(){\n int n, div;\n scanf(\"%d\", &n);\n div=2;\n while(n%div>0)\n div++;\n printf(\"%d%d\", div, n/div);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "d0ea29a905fc91d08cca410e10ed82ab", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a=1,b=2,c=0,d=0,e=0,f=0,n;\n scanf(\"%d\",&n);\n while(a==1)\n {\n if(n%b==0)\n {\n a=0;\n c=n/b;\n }\n else\n {\n b++;\n }\n }\n printf(\"%d%d\",b,c);\n return(0);\n }", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "72fef40abd87b3ce9ccc27312e7e27ba", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n\tint c1,c2,c3,c4,c5;\n\tscanf(\"%d %d %d %d %d\",&c1,&c2,&c3,&c4,&c5);\n\tif( c1 == 0 && c2 == 0 && c3 == 0 && c4 == 0 && c5 == 0){\n\t\tprintf(\"-1\");\n\t}else{\n\t int tong = c1 + c2 + c3 + c4 + c5;\n\t\n\t if( tong % 5 == 0 ){\n\t\t printf(\"%d\",tong / 5 );\n\t }else{\n\t\t printf(\"-1\");\n\t }\n\t}\n\nreturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "cb88504c3ec17d4316203132ca9b23ec", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\nint main()\n{\n int a[5],i,sum=0,j;\n for(i=0;i<5;i++)\n scanf(\"%d\",&a[i]);\n for(i=0;i<5;i++){\n sum=sum+a[i];\n }\n if(sum==0)\n printf(\"-1\");\n if(sum>0){\n if(sum%5==0){\n printf(\"%d\",sum/5);\n }\n else{\n printf(\"-1\");\n }\n }\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fd680982ad40f7381a10e3fcf9f90647", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define ll long long\nll min(ll, ll);\nint main()\n{\n\tll n, a, b, c;\n\tscanf(\"%lld%lld%lld%lld\", &n, &a, &b, &c);\n\tll m = (4 - (n % 4)) % 4;\n\tll mn;\n\tif (m == 1)\n\t\tmn = min(a, min(3 * c, c + b));\n\telse if (m == 2)\n\t\tmn = min(b, 2 * min(a, c));\n\telse if (m == 3)\n\t\tmn = min(3 * a, min(b + a, c));\n\telse\n\t\tmn = 0;\n\tprintf(\"%lld\\n\", mn);\n\treturn 0;\n}\n\nll min(ll a, ll b)\n{\n\treturn a < b ? a : b;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "7d15bb4f33693707aa66f450ca64e04a", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\ntypedef long long INT64;\n\nINT64 min(INT64 a, INT64 b) {\n return (a < b) ? a : b;\n}\n\nint main(void) {\n INT64 n = 0, a = 0, b = 0, c = 0;\n INT64 i = 0, j = 0, k = 0;\n INT64 result = 0;\n \n scanf(\"%lld %lld %lld %lld\", &n, &a, &b, &c);\n if (n % 4 == 0) {\n printf(\"0\\n\");\n } else {\n if (n % 4 == 1) {\n result = a * 3;\n result = min(result, a + b);\n result = min(result, c);\n result = min(result, b * 3 + a);\n } else if (n % 4 == 2) {\n result = min(a * 2, b);\n result = min(result, 2 * c);\n } else if (n % 4 == 3) {\n result = a;\n result = min(result, b + c);\n result = min(result, c * 3);\n }\n \n printf(\"%lld\\n\", result);\n }\n \n\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "eb0464ade033fece6d100a418ffd65bc", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n double k,b,n,t;\n double bacteria=1;double time=0;\n scanf(\"%lf %lf %lf %lf\",&k,&b,&n,&t);\n while(bacteria<=t){\n bacteria=(k*bacteria+b);\n if(bacteria>t){\n break;\n }else if(bacteria==t){\n time++;\n break;\n }\n time++;\n }\n if(time>n){\n n=0;\n }else{\n n-=time;\n }\n\n\n printf(\"%0.0lf\",n);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "7a8dd60e04b89b78fe7c10b5081aeda0", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main()\n{\n int k,b,n,t;\n long long z,x=1;\n\n scanf(\"%d %d %d %d\",&k,&b,&n,&t);\n\n while(x*k+b<=t){\n x=x*k+b;\n n--;\n }\n if(n<=0){\n printf(\"0\");\n }else{\n printf(\"%d\",n);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "8fbb5f0ce61885c38d22eea2763403aa", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a;\n while(scanf(\"%d\",&a)==1)\n {\n if(a%2==1)\n printf(\"%d\\n\",a/2);\n else\n printf(\"%d\\n\",(a/2)-1);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms"], "code_uid": "a2673ade544aa916d51d0e7c17ad6f48", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n;\n scanf(\"%d\",&n);\n if(n%2==0)\n printf(\"%d\",(n/2)-1);\n else printf(\"%d\",n/2);\n return 0;\n \n}", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "5140e0459c267e9eb54ec74dcce9f150", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int a[n],b[n];\n int i;\n for(i=0;i=s2) printf(\"Yes\");\n else printf(\"No\");\n return 0;\n\n\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "3416528586828bfcb810cbbfca22dc56", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include\n#include\n#include\nlong long cmpfunc (const void * a, const void * b) {\n return ( *(long long*)a - *(long long*)b );\n}\n\n\n\nint main(void){\n \nlong long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a,b,count1=0,a2,b2;\n\nscanf(\"%lld\",&n);\na2=b2=0;\nfor(i=0;ia2){\n printf(\"No\");\n}else{\n printf(\"Yes\");\n}\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "f345f01c6959154f1161479317f62c1a", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//https://codeforces.com/problemset/problem/1162/A\n/*\n\u041e\u043f\u044f\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\n1 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u0442\u0435\u0441\u0442\n256 \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442\n\u0432\u0432\u043e\u0434\n\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u0432\u043e\u0434\n\u0432\u044b\u0432\u043e\u0434\n\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434\n\n\u0412\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u043c\u0430 \u043d\u0430 \u0443\u043b\u0438\u0446\u0435. \u041d\u0430 \u0443\u043b\u0438\u0446\u0435 \u0435\u0441\u0442\u044c n\n\u043c\u0435\u0441\u0442, \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u043c\u0430. \u042d\u0442\u0438 \u043c\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u043e\u0432\u0430\u043d\u044b \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e \u043e\u0442 1 \u0434\u043e n. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u043c \u0441 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u043e\u0439 \u043e\u0442 0 \u0434\u043e h\n\n.\n\n\u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0435\u0441\u043b\u0438 \u0434\u043e\u043c \u0438\u043c\u0435\u0435\u0442 \u0432\u044b\u0441\u043e\u0442\u0443 a\n, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043e\u0442 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 a2\n\n\u0434\u043e\u043b\u043b\u0430\u0440\u043e\u0432.\n\n\u0413\u043e\u0440\u043e\u0434 \u0438\u043c\u0435\u0435\u0442 m\n\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439. \u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 i-\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c, \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0434\u043e\u043c \u043e\u0442 li \u0434\u043e ri (\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e) \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 xi\n\n.\n\n\u0412\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u043c\u0430, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043f\u0440\u0438\u0431\u044b\u043b\u044c. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0443\u044e \u043f\u0440\u0438\u0431\u044b\u043b\u044c.\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\n\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 n\n, h \u0438 m (1\u2264n,h,m\u226450\n\n) \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0441\u0442, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439.\n\n\u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 m\n\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0438 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 li, ri \u0438 xi (1\u2264li\u2264ri\u2264n, 0\u2264xi\u2264h) \u2014 \u043b\u0435\u0432\u0430\u044f \u0438 \u043f\u0440\u0430\u0432\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 (\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e) i\n\n-\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435.\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\n\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0443\u044e \u043f\u0440\u0438\u0431\u044b\u043b\u044c.\n\u041f\u0440\u0438\u043c\u0435\u0440\u044b\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\n\n3 3 3\n1 1 1\n2 2 3\n3 3 2\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\n\n14\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\n\n4 10 2\n2 3 8\n3 4 7\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\n\n262\n\n\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435\n\n\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c 3\n\u0434\u043e\u043c\u0430, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u2014 3, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c 3 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0432\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0434\u043e\u043c \u043c\u0435\u0436\u0434\u0443 1 \u0438 1 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 1. \u0412\u0442\u043e\u0440\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0434\u043e\u043c \u043c\u0435\u0436\u0434\u0443 2 \u0438 2 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 3. \u0422\u0440\u0435\u0442\u044c\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0434\u043e\u043c \u043c\u0435\u0436\u0434\u0443 3 \u0438 3 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 2\n\n.\n\n\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u043c\u0430 \u0432\u044b\u0441\u043e\u0442\u043e\u0439 [1,3,2]\n. \u042d\u0442\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0441\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u041e\u0431\u0449\u0430\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 12+32+22=14\n\n.\n\n\u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c 4\n\u0434\u043e\u043c\u0430, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u044b\u0441\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u2014 10, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c 2 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0432\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0434\u043e\u043c \u043e\u0442 2 \u0434\u043e 3 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 8. \u0412\u0442\u043e\u0440\u043e\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0434\u043e\u043c \u043e\u0442 3 \u0434\u043e 4 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 7\n\n.\n\n\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u043e\u043c\u0430 \u0432\u044b\u0441\u043e\u0442\u043e\u0439 [10,8,7,7]\n. \u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435 102+82+72+72=262. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u043e\u043c 3, \u0438 \u043e\u0431\u0430 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0445\u043e\u0442\u044f \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u044f\u0432\u043d\u044b\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0434\u043e\u043c 1, \u043c\u044b \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u044b\u0441\u043e\u0442\u0443 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 10 (h=10).\n*/\n#include \nconst int MAX = 51;\n\nint min (int a, int b){ if (a\n \nint spots,maxlen,rest,rests[51][2],restlen[51],houses[51],answer;\n \nvoid sort ()\n{\n\tfor (int i=0;irestlen[i])\n\t\t\t{\n\t\t\t\tint temp = restlen[j];\n\t\t\t\trestlen[j] = restlen[i];\n\t\t\t\trestlen [i] = temp;\n\t\t\t\tint temp2 = rests[j][0];\n\t\t\t\trests[j][0] = rests[i][0];\n\t\t\t\trests[i][0] = temp2;\n\t\t\t\tint temp3 = rests[j][1];\n\t\t\t\trests[j][1] = rests[i][1];\n\t\t\t\trests[i][1] = temp3;\n\t\t\t}\n\t\t}\n\t}\n}\n \nint main ()\n{\n\t//freopen (\"cf.in\",\"r\",stdin),freopen(\"cf.out\",\"w\",stdout);\n\tscanf (\"%d %d %d\",&spots,&maxlen,&rest);\n\tfor (int i=0;i\nint main(void)\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n==0)\n\t\tprintf(\"0\\n\");\n\telse if(n==2)\n\t printf(\"2\\n\");\n\telse\n\t\tprintf(\"1\\n\");\n\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "023627a56adb64b96aa7a67b73ae703b", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int A,M=1;\n scanf(\"%d\",&A);\n if(A==2)\n {\n printf(\"2\\n\");\n }\n else\n {\n printf(\"%d\\n\",M);\n }\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "035aee5e00ca1d0bed1fa056cee60277", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint sf(const void* a, const void* b)\n{\n\treturn (*((const int*)a)) - (*((const int*)b));\n}\n\nint main()\n{\n\tint i;\n\tint n;\n\tint a[100];\n\tscanf(\"%d\", &n);\n\tfor(i = 0; i < n; i++)\n\t\tscanf(\"%d\", &a[i]);\n\tqsort(a, n, sizeof(int), sf);\n\ta[0] ^= a[n - 1];\n\ta[n - 1] ^= a[0];\n\ta[0] ^= a[n - 1];\n\tfor(i = 0; i < n; i++)\n\t\tprintf(\"%d \", a[i]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "9f5209e7fb9a306e455b08f2fb90252a", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint n,num[101] = {0};\nint comp(int *a,int *b)\n{\n return *b-*a;\n}\nint comp2(int *a,int *b)\n{\n return *a-*b;\n}\nint main()\n{\n int i;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++) scanf(\"%d\",&num[i]);\n qsort(num+1,n,sizeof(int),comp);\n qsort(num+2,n-2,sizeof(int),comp2);\n for(i=1;i<=n;i++) printf(\"%d \",num[i]);\n return 0;\n}", "lang_cluster": "C", "tags": ["sortings", "constructive algorithms", "implementation"], "code_uid": "1b4a0535c3c69132b650e1cfa5a0986c", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long foo(long long x) {\n return (x * (x - 1) / 2);\n}\n\nint main() {\n long long x, y, min = 0, max = 0;\n scanf(\"%lld%lld\", &x ,&y);\n min = ((x % y) * foo((x / y) + 1)) + foo(x / y) * (y - (x % y));\n max = foo(x - (y - 1));\n printf(\"%lld %lld\\n\", min, max);\n return 0;\n} \n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "4f9c4be4a0d1486c23eae9d55a7fd8e5", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\nlong long n,m,gmax,gmin,anterior,aux;\nscanf(\"%lld%lld\",&n,&m);\nif(n==1)\n{\n gmin=0;\n gmax=0;\n}\nelse if(m==1)\n{\n gmin=n*(n-1)/2;\n gmax=gmin;\n}\nelse if(m==n)\n{\n gmin=0;\n gmax=0;\n}\nelse {\n gmax=n-m+1;\n gmax=gmax*(gmax-1)/2;\n if(n%m==0)\n {\n gmin=n/m;\n gmin=(gmin*(gmin-1)/2)*m;\n }\n else{\n gmin=n/m;\n anterior=n%m;\n if(anterior!=0)\n {\n aux=gmin;\n gmin=gmin*(gmin-1)/2*(m-anterior);\n aux=aux+1;\n gmin=gmin+aux*(aux-1)/2*(anterior);\n }\n else gmin=(gmin*(gmin-1)/2)*m;\n }\n }\n printf(\"%lld %lld\\n\",gmin,gmax);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "7c4407f6ae7468aad935666c5f41ceed", "src_uid": "a081d400a5ce22899b91df38ba98eecc", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nlong mu10(int x){\n\tint i;long kq=1;\n\tfor(i=1;i<=x;i++)kq=kq*10;\n\treturn kq;\n}\nchar So_xau(char s[],long n){\n\tint i;\n\tfor(i=8;i>-1;i--){\n\t\ts[8-i]=n/mu10(i)+48;\n\t\tn=n%mu10(i);\n\t}\n\ts[9]=0;\t\n}\nint main(){\nlong a,b,mod;\nchar win;\nchar a1[10];\nscanf(\"%ld%ld%ld\",&a,&b,&mod);\nif(b>=mod-1)win=2;\nelse{\n\tlong A;\n\tif(a>=mod)A=mod-1;else A=a;\n\tlong i,S=0;\n\tfor(i=1;i<=A;i++){\n\tS=S+mu10(9)%mod;\n\twhile(S>mod)S=S-mod;\n\tif(S>0&&SA)win=2;\n\telse{\n\t\twin=1;\n\t\tSo_xau(a1,i);\n\t}\n}\nprintf(\"%d\",win);if(win==1)printf(\" %s\",a1);\n}", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "51cf6e076711ecce2bede7e318f02908", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n long i, j;\n long a, b, mod;\n scanf( \"%ld %ld %ld\", &a, &b, &mod );\n\n if( b >= mod - 1 ){\n printf( \"\\n%d\", 2 );\n return 0;\n }\n\n for( i=0; i<=a && i<=mod; i++ ){\n\n long long temp = i*1000000000LL;\n\n long remainder = temp % mod;\n if( remainder != 0 )\n remainder = mod - remainder;\n\n if( remainder > b ){\n printf( \"\\n%d %09ld\", 1, i );\n return 0;\n }\n\n }\n\n printf( \"\\n%d\", 2 );\n return 0;\n\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "912652022b50c5dce6f30c891249220c", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a;\n scanf(\"%d\",&a);\n if(a%2!=0)\n {\n printf(\"1\");\n }\n else\n {\n printf(\"0\");\n }\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ff8e9fd8fe091ec1d81008f072a0fa75", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n\n\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if((n%2)==0)\n printf(\"0\");\n else printf(\"1\");\n\n\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "8b49da4141e8bf9c77d707acabdf2bec", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n int n,j,i,flag=0,c=0,m;\n scanf(\"%d %d\",&n,&m);\n if(n<1||m<1||n+m<3){printf(\"0\");return 0;}\n while(n>0&&m>0){\n if(n>=m){n=n-2;m=m-1;c++;}\n else {n=n-1;m=m-2;c++;}\n if(n+m<3)break;\n }\n printf(\"%d\",c);\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "7384cb2779ac0c57cd717dda07851dc5", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong a, b, c;\n\tscanf(\"%ld %ld\", &a, &b);\n\tc = 0;\n\twhile (b + a > 2 && a && b) {\n\t\tif (a >= b) {\n\t\t\ta = a - 2;\n\t\t\tb--;\n\t\t}\n\t\telse {\n\t\t\tb = b - 2;\n\t\t\ta--;\n\t\t}\n\t\tc++;\n\t}\n\tprintf(\"%ld\\n\", c);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "number theory"], "code_uid": "b209e98965bd5f79dd84d4d833cb7486", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\tchar a[5][5],x;\n\tint i,j,count = 0;\n\tfor(i = 0;i < 4;i++){\n\t\tfor(j = 0;j < 4;j++)\n\t\t\t scanf(\"%c\",&a[i][j]);\n\t\tscanf(\"%c\",&x);\n\t}\n\tfor(i = 0;i < 3;i++){\n\t\tfor(j = 0;j < 3;j++){\n\t\t\tif(a[i][j] == '#') count++;\n\t\t\tif(a[i][j+1] == '#') count++;\n\t\t\tif(a[i+1][j] == '#') count++;\n\t\t\tif(a[i+1][j+1] == '#') count++;\n\t\t\tif(count != 2){\n\t\t\t\tprintf(\"YES\");\n\t\t\t\treturn 0;\n\t\t }\n\t\t count = 0; \n\t\t}\n\t\t\n\t}\n\tprintf(\"NO\");\n\t\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "ba0bd879a28ae1d1fbdf3893a60e0a64", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int n=0, i, j;\n char st[4][4];\n for(i=0;i<4;i++){\n scanf(\"%s\", st[i]);\n }\n for(i=0;i<3;i++){\n for(j=0;j<3;j++){\n if(st[i][j]==st[i+1][j] && st[i][j+1]==st[i+1][j+1] && st[i][j]==st[i+1][j+1] || st[i][j]==st[i+1][j] && st[i][j+1]!=st[i+1][j+1] || st[i][j+1]==st[i+1][j+1] && st[i][j]!=st[i+1][j]){\n n=1;\n break;\n }\n }\n }\n if(n==1){\n printf(\"YES\");\n }\n else if(n==0){\n printf(\"NO\");\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "7d18bfa35c05869668eda45617884c0b", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int x,y;\n scanf(\"%d %d\",&x,&y);\n if(x==y||x==2&&y==4||x==4&&y==2)\n printf(\"=\\n\");\n else if(x==2&&y==3)\n printf(\"<\\n\");\n else if(x==3&&y==2)\n printf(\">\\n\");\n else if(x>y&&y!=1||x==1&&y>x)\n printf(\"<\\n\");\n else if(xy&&y==1)\n printf(\">\\n\");\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "3aebf40ecc104093278778e96d0b05b6", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n int x,y;\n scanf(\"%d%d\",&x,&y);\n if(x==y)\n printf(\"=\");\n else if(x==1)\n printf(\"<\");\n else if(y==1)\n printf(\">\");\n else if(x==2&&y==3)\n printf(\"<\");\n else if(x==3&&y==2)\n printf(\">\");\n else if((x==2&&y==4)||(y==2&&x==4))\n printf(\"=\");\n else if(x>y)\n printf(\"<\");\n else\n printf(\">\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "2ea73dd4d9ca111e5d6079a8f9c203f1", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\n long i,flag=0;\n char s[100];\n scanf(\"%s\",s);\n for(i=0;i\n#include\n\nint main()\n{\n\tchar s[103];\n\tscanf(\"%s\",s);\n\tint i,len;\n\tlen=strlen(s);\n\tint count=0;\n\tfor(i=1;i\n#include\n\nint main(){\n char Pass[80];\n char decode[10][10];\n int j, n;\n\n scanf(\"%s\", Pass);\n\n for(j=0; j<10; j++){\n scanf(\"%s\", decode[j]);\n }\n\n for(j=0; j<8; j++){\n\n for(n=0; n<10; n++){\n\n if(strncmp(&Pass[j*10], decode[n], 10)==0){\n\n printf(\"%d\", n);\n\n break;\n }\n }\n }\n\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "a351c03ae8b21bb4f888f57b07373021", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include \n#include \nint main () {\n char binarioCodigo [ 81 ], binarioCodigoPares [ 10 ][ 11 ];\n scanf ( \"%s\" , & binarioCodigo );\n int i , j ;\n for ( i = 0 ; i < 10 ; i ++) {\n scanf ( \"%s\" , binarioCodigoPares [ i ]);\n }\n for ( i = 0 ; i < 8 ; i ++) {\n for ( j = 0 ; j < 10 ; j ++) {\n if ( strncmp ( binarioCodigo + 10 * i , binarioCodigoPares [ j ], 10 )== 0 ){\n printf ( \"%d\" , j );\n }\n }\n }\nreturn 0 ;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "5f5f5a108fd9b33bda50e035ee3b1505", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#define SIX (A[i]+A[i+1]+A[i+2]+B[i]+B[i+1]+B[i+2])\n#define SIX_ A[i]=A[i+1]=A[i+2]=B[i]=B[i+1]=B[i+2]\n#define FOUR (A[i]+A[i+1]+B[i]+B[i+1])\n#define FOUR_ A[i]=A[i+1]=B[i]=B[i+1]\nint n,i,ans;\nint main(){char A[111], B[111];\n for(scanf(\"%s%s\",A,B),n=strlen(A);i\n#include \nchar s[2][101];\nint dp[100][5];\nint max(int a,int b){return (a>b)?a:b;}\nint main()\n{\n scanf(\"%s %s\",s[0],s[1]);\n int n=strlen(s);\n int i,j;\n for(i=0;i1)\n {\n for(j=0;j<5;j++) temp=max(temp,dp[i-2][j]);\n \n }\n if(s[0][i-1]=='0' && s[0][i]=='0' && s[1][i-1]=='0')\n dp[i][0]=temp+1;\n if(s[0][i-1]=='0' && s[0][i]=='0' && s[1][i]=='0')\n dp[i][1]=max(dp[i-1][3],temp)+1;\n if(s[0][i]=='0' && s[1][i-1]=='0' && s[1][i]=='0')\n dp[i][2]=max(dp[i-1][0],temp)+1;\n if(s[0][i-1]=='0' && s[1][i-1]=='0' && s[1][i]=='0')\n dp[i][3]=temp+1;\n temp=0;\n if(i>1)\n {\n for(j=0;j<5;j++) temp=max(temp,dp[i-1][j]);\n }\n dp[i][4]=temp;\n }\n int ans=0;\n for(j=0;j<5;j++) ans=max(ans,dp[n-1][j]);\n printf(\"%d\\n\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "28014e165bd74973a36b34e9f628ae11", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \ndouble max(double a, double b) {\n return a>b?a:b;\n}\nint main() {\n int a,b,c,d; double x,y;\n scanf(\"%d%d%d%d\",&a,&b,&c,&d);\n x=max(0.3,1-c*0.004)*a;\n y=max(0.3,1-d*0.004)*b;\n printf(\"%s\\n\",x-y<0.000001&&x-y>-0.000001?\"Tie\":x>y?\"Misha\":\"Vasya\");\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4386b4d6881ccc5c72ce2abb8c6c19c0", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main ()\n{\n int a,b,c,d,k,l,m,max,n,maz;\n scanf(\"%d %d %d %d\",&a,&b,&c,&d);\n k=a-((a/250)*c);\n m=(3*a)/10;\n if(k>m)\n {\n max=k;\n }\n else\n {\n max=m;\n }\n l=b-((b/250)*d);\n n=(3*b)/10;\n if(l>n)\n {\n maz=l;\n }\n else\n {\n maz=n;\n }\n if(max>maz)\n {\n printf(\"Misha\");\n }\n else if(maz>max)\n {\n printf(\"Vasya\");\n\n }\n else if(max==maz)\n {\n printf(\"Tie\");\n }\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "68847dd772bf249d22d6579d0b439796", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,m,i,c=0,o;\n scanf(\"%d%d\",&n,&m);\n o=n;\n for(int i=1;i<=n;i++)\n {\n if(i%m==0)\n {\n c++;\n n++;\n }\n \n }\n // printf(\"%d\",c);\n printf(\"%d\",c+o);\n \n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "9e8d6ee384b62855a7de5b3eebf47ead", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,m,sum,a,b;\n scanf(\"%d %d\",&n,&m);\n sum=n;\n while(!(n/m==0)){\n a=n/m;\n b=n%m;\n n=a+b;\n sum=sum+a;\n }\n printf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "9722b85c1e15af4518438cec4bcc6101", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\tint a[120],b[120],hav[120],i,j,k,n,x,max,l,r,in,all;\n\tscanf(\"%d %d %d\",&n,&k,&x);\n\tfor (i=0;i=i)] = a[j];\n\t\t\thav[j] = 1;\n\t\t}\n\t\tb[i] = x; hav[j] = 1; all=0;\n\t\tl = i; r = i; \n\t\twhile (1) {\n\t\t\tif (l==r) in = 1;\n\t\t\telse in=2;\n\t\t\tif (l<0) in--;\n\t\t\tif (r>n) in--;\n\t\t\twhile (l>0 && b[l-1]==b[r]){\n\t\t\t\tin++; l--;\n\t\t\t}\n\t\t\twhile (r=3){\n\t\t\t\tall += in;\n\t\t\t\tr++; l--;\n\t\t\t\tif (r<=n && l>=0)\n\t\t\t\t\tif (b[l]!=b[r])\n\t\t\t\t\t\tbreak;\n\t\t\t}else break;\n\t\t}\n\t\tif (all>max) max = all;\n\t}\n\tif (max!=0) printf(\"%d\\n\",max-1);\n\telse printf(\"0\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["two pointers", "brute force"], "code_uid": "5e334178786e1c2ac18b01996fa3e2aa", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define N\t100\n\nstruct ball {\n\tint c, cnt;\n} bb[N];\n\nint count(struct ball *bb, int n, int i) {\n\tint l, r, k;\n\n\tk = bb[i].cnt;\n\tfor (l = i - 1, r = i + 1; l >= 0 && r < n && bb[l].c == bb[r].c && bb[l].cnt + bb[r].cnt >= 3; l--, r++)\n\t\tk += bb[l].cnt + bb[r].cnt;\n\treturn k;\n}\n\nint main() {\n\tint n, k, x, c_, l, i, max, cnt;\n\n\tscanf(\"%d%d%d\", &n, &k, &x);\n\tc_ = -1;\n\tl = -1;\n\tfor (i = 0; i <= n; i++) {\n\t\tint c;\n\n\t\tif (i < n)\n\t\t\tscanf(\"%d\", &c);\n\t\tif (i == n || c_ != c) {\n\t\t\tl++;\n\t\t\tif (i < n) {\n\t\t\t\tbb[l].cnt = 1;\n\t\t\t\tbb[l].c = (c_ = c);\n\t\t\t}\n\t\t\tc_ = c;\n\t\t} else\n\t\t\tbb[l].cnt++;\n\t}\n\tmax = 0;\n\tfor (i = 0; i < l; i++)\n\t\tif (bb[i].c == x && bb[i].cnt == 2) {\n\t\t\tcnt = count(bb, l, i);\n\t\t\tif (max < cnt)\n\t\t\t\tmax = cnt;\n\t\t}\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "brute force"], "code_uid": "22a7999a710292731d7740ecc5bc1e84", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long int fact(int a);\n\nint main() {\n long long int a, b;\n scanf(\"%lld %lld\", &a, &b);\n printf(\"%lld\\n\", fact(a > b ? b : a));\n return 0;\n}\n\nlong long int fact(int a) {\n return a > 1 ? a*fact(a-1) : 1;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "891709319eada6dc3237f151f9bf7296", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tunsigned long a, b;\n\tunsigned long i;\n\tscanf(\" %lu %lu\",&a, &b);\n\t\n\tif(a>b)\n\t{\n\t\tfor(i=(b-1); i > 0; i--)\n\t\t{\n\t\t\tb = b*i;\n\t\t}\n\t\tprintf(\"%lu\",b);\n\t}\n\telse\n\t{\n\t\tfor(i=(a-1); i > 0; i--)\n\t\t{\n\t\t\ta = a*i;\n\t\t}\n\t\tprintf(\"%lu\",a);\n\t}\n}", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "68cce834a7e54ba7d061c4b0802827ce", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define NMAX 110\n//#define DEBUG\n\nint min(int a, int b, int c) {\n\tif (a <= b && a <= c)\n\t\treturn a;\n\tif (b <= a && b <= c)\n\t\treturn b;\n\treturn c;\n}\n\nint main(void) {\n\t#ifdef DEBUG\n\t\tfreopen(\"input.txt\", \"r\", stdin);\n\t\tfreopen(\"output.txt\", \"w\", stdout);\n\t#endif\n\t\n\tint n, a[NMAX], T[3][NMAX],\n\t\ti, j;\n\t\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; ++i)\n\t\tscanf(\"%d\", a + i);\n\n\tT[0][0] = 1;\n\tfor (i = 1; i < 3; ++i)\n\t\tif (a[0] & i)\n\t\t\tT[i][0] = 0;\n\t\telse\n\t\t\tT[i][0] = NMAX;\n\t\t\n\tfor (j = 1; j < n; ++j)\n\t\tfor (i = 0; i < 3; ++i)\n\t\t\tif (0 == i)\n\t\t\t\tT[i][j] = 1 + min(T[0][j - 1], T[1][j - 1], T[2][j - 1]);\n\t\t\telse if (a[j] & i)\n\t\t\t\tT[i][j] = min(T[0][j - 1], T[3 - i][j - 1], NMAX);\n\t\t\telse\n\t\t\t\tT[i][j] = NMAX;\n\t\n\tprintf(\"%d\", min(T[0][n - 1], T[1][n - 1], T[2][n - 1]));\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp"], "code_uid": "6f161a7d57afa656be650a50de43b419", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,p,i,a,c=0;\n scanf(\"%d %d\",&n,&p);\n if(!p)\n c=1;\n for(i=1;i\n int main () {\n int w;\n scanf(\"%d\",&w);\n if ((w%2 ==0)&&(w!=0)&&(w!=2))\n printf(\"YES\");\n else\n printf (\"NO\");\n return 0;\n \n}\n\n ", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "d8a7dbe94635455b9873a7b2addc3c16", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\n int n;\n scanf(\"%d\", &n);\n if(n <= 2 || n%2 != 0){\n printf(\"NO\\n\");\n }\n else{\n printf(\"YES\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "19e9ec600004ebd321659a921011be1e", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nchar arr[105];\nint main ()\n{\n //freopen(\"input.txt\",\"r\",stdin);\n int i,j,k,l;\n gets(arr);\n l=strlen(arr);\n for(i=l-1;i>=0;i--)\n {\n if(arr[i]=='A'||arr[i]=='E'||arr[i]=='I'||arr[i]=='O'||arr[i]=='U'||arr[i]=='a'||arr[i]=='e'||arr[i]=='i'||arr[i]=='o'||arr[i]=='u'||arr[i]=='Y'||arr[i]=='y')\n {\n printf(\"YES\");\n break;\n }\n else if((arr[i]>='B'&&arr[i]<='Z')||(arr[i]>='b'&&arr[i]<='z'))\n {\n printf(\"NO\");\n break;\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "63f4c9b5efec68db35fb242a7d5c2f48", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n char s[102];\n char r,x;\n int l;\n gets(s);\n\n l=strlen(s);\n F:\n l--;\n x=s[l];\n r= tolower(x);\n if(r>='a' && r<='z')\n{\n\n if(r== 'a' ||r== 'e' ||r== 'i' ||r== 'o' ||r== 'u' ||r== 'y' )\n printf(\"YES\\n\");\n\n else\n printf(\"NO\\n\");}\n else goto F;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2bec97c547c42cf333ffde9e25de8436", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\ufeff#include \n#include \n\n#define PLATE 42\n\nunsigned char get_num(void)\n{\n\tchar tmp[8];\n\tfgets(tmp,8,stdin);\n\treturn atoi(tmp);\n}\n\nint main(void) {\n\tunsigned char n;\n\tn=get_num();\n\tchar str[n];\n\tunsigned char jmp_lim = n-4;\n\tunsigned char jump_size;\n\tscanf(\"%s\",str);\n\t//printf(\"%s\",str);\n\tfor (jump_size=1; jump_size <= jmp_lim; jump_size++)\n\t{\n\t\t//printf(\"jmp_size=%d\\n\",jump_size);\n\t\tunsigned char start_lim = n - jump_size;\n\t\tunsigned char start_dot;\n\t\tfor ( start_dot=0; start_dot < start_lim; start_dot++ )\n\t\t{\n\t\t\tif ( str[start_dot]==PLATE )\n\t\t\t{\n\t\t\t\t//printf(\"start_dot=%d\\n\",start_dot);\n\t\t\t\tunsigned char dot=start_dot;\n\t\t\t\tunsigned char yes=0;\n\t\t\t\twhile ( dot+jump_size <= n)\n\t\t\t\t{\n\t\t\t\t\tdot=dot+jump_size;\n\t\t\t\t\tif (str[dot]==PLATE) { yes++; } else { break; }\n\t\t\t\t}\n\t\t\t\tif (yes==4) {\tprintf(\"yes\"); return 0;\t}\n\t\t\t}\n\t\t}\n\t\t//printf(\"y=%d\\n\",yes);\n\t\t\n\t}\n\nprintf(\"no\");\nreturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "c20888dc104f52a85b9df0dda7da370c", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tstatic char s[128];\n\tint n, i, k;\n\n\tscanf(\"%d\", &n);\n\tscanf(\"%s\", s);\n\tfor (i = 0; i < n; i++)\n\t\tfor (k = 1; i + k * 4 < n; k++)\n\t\t\tif (s[i] == '*' && s[i + k] == '*' && s[i + k * 2] == '*' && s[i + k * 3] == '*' && s[i + k * 4] == '*') {\n\t\t\t\tprintf(\"yes\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\tprintf(\"no\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "13202ba57690f400b43c31811bae7d43", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n, sum = 0, i;\n scanf(\"%d\", &n);\n for(i = 1; i < (2 * n); i+=2) {\n \tsum += i;\n }\n sum *= 2;\n sum -= (2 * n) - 1;\n printf(\"%d\", sum);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "implementation"], "code_uid": "aa8e837f800b6959852de906801f059b", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include\nint main()\n{\n int n, sum=0;\n\n int x, y;\n scanf(\"%d\",&n);\n if(n==1)\n {\n sum=n;\n printf(\"%d\", sum);\n }\n\n else\n {\n sum = 1+2*n*(n-1);\n printf(\" %d \", sum);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "implementation"], "code_uid": "78763916582467c8bf7716a7dfc87628", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,n1,n2,n3,x1,x2,x3;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d%d\",&n1,&x1);\n\tscanf(\"%d%d\",&n2,&x2);\n\tscanf(\"%d%d\",&n3,&x3);\n\tint a1=x1,a2=x2,a3=x3,sum;\n\tsum=a1+a2+a3;\n\tint dif=sum-n;\n\tif(x3-n3>=dif && dif>0)\n\t\ta3=a3-dif;\n\telse if(dif>0)\n\t{\n\t\ta3=n3;\n\t\tdif=a1+a2+a3-n;\n\t\tif(dif<=x2-n2 && dif>0)\n\t\t\ta2=a2-dif;\n\t\telse if(dif>0)\n\t\t{\n\t\t\ta2=n2;\n\t\t\tdif=a1+a2+a3-n;\n\t\t\ta1=a1-dif;\n\t\t}\n\t}\n\tprintf(\"%d %d %d\\n\",a1,a2,a3);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "fc581a3fa9442d4028722c259ba5b8d6", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint minimum (int a, int b)\n{\n\treturn a < b ? a : b;\n}\n\nint main()\n{\n\tint n, min[3], max[3], d[3], cnt = 0, i;\n\n\tscanf (\"%d\", &n);\n\tfor (i = 0; i < 3; i++) {\n\t\tscanf (\"%d %d\", &min[i], &max[i]);\n\t\td[i] = min[i];\n\t\tcnt += d[i];\n\t}\n\n\tfor (i = 0; i < n; i++) {\n\t\tif (cnt < n) {\n\t\t\tint r = minimum (max[i] - min[i], n - cnt);\n\t\t\td[i] += r;\n\t\t\tcnt += r;\n\t\t}\n\t}\n\n\tprintf (\"%d %d %d\", d[0], d[1], d[2]);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "30b21273004a4bdf4439f72076a1f3c7", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n#include \n\nint main()\n{\n int i,n,m;\n char a[100],b[100];\n for(i=0;;i++)\n {\n scanf(\"%c\",&a[i]);\n if(a[i]=='\\n')\n {\n n=i+1;\n break;\n }\n }\n m=n/2-1;\n for(i=0;i<=m+1;i++)\n {\n if(i==0)\n {\n printf(\"%c\",a[m]);\n }\n else if(a[m+i]=='\\n'||a[m-i]=='\\n')\n continue;\n else\n {\n printf(\"%c\",a[m+i]);\n if(i!=m+1)\n printf(\"%c\",a[m-i]);\n\n }\n\n\n }\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "ce684de9afe385c8f113a2c89c182426", "src_uid": "992ae43e66f1808f19c86b1def1f6b41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/******************************************************************************\n\nWelcome to GDB Online.\nGDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, \nC#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS\nCode, Compile, Run and Debug online from anywhere in world.\n\n*******************************************************************************/\n#include \n#include \nint main()\n{\n char str[50],S[50];\n \n int mid;\n scanf(\"%s\",str);\n int len=strlen(str);\n if(len%2==0)\n mid=len/2;\n else\n mid=(len+1)/2;\n \n mid=mid-1;\n int j=1;\n S[0]=str[mid];\n\n for(int i=1;i\nint main()\n{\n int minimum(int number1,int number2);\n int a,b,c,smallest,x,y,z;\n scanf(\"%d %d %d\",&x,&y,&z);\n a=x/1;\n b=y/2;\n c=z/4;\n smallest=minimum((minimum(a,b)),c);\n printf(\"%d\",smallest*7);\n}\nint minimum(int number1,int number2)\n{\n int d;\n d=(number1>number2)?number2:number1;\n return d;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "845c5e3a6308e56bb420f2efbb9785ce", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int a,b,c,sum=0;\nscanf(\"%d%d%d\",&a,&b,&c);\n\nwhile(1){\n\n\nif(a>=1&&b>=2&&c>=4){\n int e=a-1;\n int f=b-2;\n int g=c-4;\na=e;\nb=f;\nc=g;\n sum=sum+1+2+4;\n\n if(a<1||b<2||c<4){\n printf(\"%d\",sum);\n break;\n }\n\n\n\n}\nelse{\n\n\n printf(\"0\");\n break;\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\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "2c1ac18c7da1710a8f32f6abfe39f88f", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "int main()\n{\n int a,b,c;\n scanf(\"%d\",&a);\n if(a==0)\n {\n printf(\"1\");\n }\n else\n {\n b=a%4;\n if(b==0)\n {\n printf(\"6\");\n }\n if(b==2)\n {\n printf(\"4\");\n }\n if(b==1)\n {\n printf(\"8\");\n }\n if(b==3)\n {\n printf(\"2\");\n }\n }\n\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "c2fa998df087728ad09c9f07ea7abe48", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n int n;\n long long int ans;\n while(scanf(\"%d\",&n)==1){\n if(n==0){\n ans=1;\n }\n else if((n%4==0)){\n ans=6;\n }\n else if(n%2==0){\n ans=4;\n }\n else if(((n-1)%4==0)){\n ans=8;\n }\n else if(((n-1)%2)==0){\n ans=2;\n }\n printf(\"%d\\n\",ans);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "a41ad08fabdf0e8bab27e50f052d487c", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,c,i,j,x,y,z,m,n,l,q;\n scanf(\"%d%d%d\",&a,&b,&c);\n q=(a+b+c+1);\n if(a>b&&a>c) {x=a;if(b>c){y=b;z=c;}else{y=c;z=b;}}\n else if(b>a&&b>c){x=b;if(a>c){y=a;z=c;}else{y=c;z=a;}}\n else {x=c;if(b>a){y=b;z=a;}else{y=a;z=b;}}\n for(i=z;i<=x;i++){\n m=i-a;\n n=i-b;\n l=i-c;\n if(m<0) m=m*(-1);\n if(n<0) n=n*(-1);\n if(l<0) l=l*(-1);\n y=m+n+l;\n if(y\nint main()\n{\n int a[3],i,j,temp;\n for(i=0;i<3;i++)\n {\n scanf(\"%d\",&a[i]);\n }\n for(i=0;i<3;i++)\n {\n for(j=0;j<3;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 printf(\"%d\",a[0]-a[2]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "sortings", "implementation"], "code_uid": "0c0f4212de98be4218e875dcd3f2dfb4", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,m;\n\tscanf(\"%d %d\",&a,&m);\n\twhile(m%2==0)\n\t\tm/=2;\n\tif(a%m==0)\n\t\tprintf(\"Yes\\n\");\n\telse\n\t\tprintf(\"No\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "matrices", "implementation"], "code_uid": "bc13c901a9cbd0936ad63ae1451ba204", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,i,m;\n scanf(\"%d%d\",&n,&m);\n for(i=0;i<100000;i++){\n n=(n+n%m)%m;\n if(!n) break;\n }\n\n \n if(!n)\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "implementation"], "code_uid": "57f30d7fbd6687c9c98879de96a97aee", "src_uid": "f726133018e2149ec57e113860ec498a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint sum (int n)\n{\n if(n==0)\n return 0;\n\nreturn ((n%10)+sum(n/10));\n}\nint main()\n{\n int a,b;\n scanf(\"%d\",&a);\n if(a<5){\n printf(\"4\\n\");\n }\n else if(a>4 && a<10 && a%4==0)\n {\n printf(\"%d\\n\",a);\n }\n\n else\n {\n\n while(1)\n {\n b=sum(a);\n if(b%4==0)\n {\n printf(\"%d\\n\",a);\n break;\n }\n else\n {\n a=a+1;\n }\n\n }\n\n\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c920d95936b71c838b99ac64990af25f", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n\nint main()\n{\n int x,y;\n int arr[4];\n scanf(\"%d\",&x);\n y=x;\n int z=10;\n int sum=0;\n for(int i=0;i<=8;i++)\n {\n for(int j=0;j<=8;j++)\n {\n sum=sum+(y%10);\n y=x/z;\n z=z*10;\n }\n if(sum%4==0)\n {\n printf(\"%d\",x);\n break;\n }\n else{\n x=x+1;\n y=x;\n z=10;\n sum=0;\n }\n }\n\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a93b74fbf765be428855a5583af089a6", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n, s, i, max = 0 ,sum = 0, t;\n scanf(\"%d %d\", &n, &s);\n for(i=0; i max)max = t;\n }\n if(sum-max <= s)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "18d0c8d873da7d9d22e3accb45716b76", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main()\n{\n int n,s,i,a,max_a=1;\n long long int sum = 0;\n scanf(\"%d %d\",&n,&s);\n for(i=1;i<=n;i++){\n scanf(\"%d\",&a);\n sum = sum + a;\n if(a>=max_a) max_a=a;\n }\n if((sum-max_a)<=s)printf(\"YES\");\n else printf(\"NO\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "057f59110c959fa28662db0fc4823b1e", "src_uid": "496baae594b32c5ffda35b896ebde629", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define modd 1000000007\nlong long fast_expo(long long a,long long b)\n{\n\tlong long res=1;\n\twhile(b>0)\n\t{\n\t\tif(b&1)\n\t\t\tres=(res*a)%modd;\n\t\ta=(a*a)%modd;\n\t\tb=b>>1;\n\t}\n\treturn res;\n}\nint main()\n{\n\tlong long fact[200001];\n\tint i,n;\n\tfact[0]=1;\n\tfor(i=1;i<200001;i++)\n\t\tfact[i]=(fact[i-1]*i)%modd;\n\twhile(scanf(\"%d\",&n)==1)\n\t{\n\t\tlong long ans=(fact[(n<<1)-1]*((fast_expo(fact[n],modd-2)*fast_expo(fact[n-1],modd-2))%modd))%modd;\n\t\tans=(ans<<1)-n;\n\t\tif(ans<0)\n\t\t\tprintf(\"%I64d\\n\",(ans+modd)%modd);\n\t\telse printf(\"%I64d\\n\",ans%modd);\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "249eb96b2529e57f3ccaa8f5c38ff6de", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define P 1000000007\nint n,i,j;__int64 t=1,s;\nint main(){\n\tscanf(\"%d\",&n);\n\tfor(i=1;i<=n;++i)t=t*i%P;\n\tfor(j=P-3,s=t;j;j>>=1,s=s*s%P)\n\t\tif(j&1)t=t*s%P;\n\tfor(i=n;i\nint main()\n{\n int c,d,m,k,n;\n \n scanf(\"%d %d %d %d %d\",&c,&d,&n,&m,&k);\n int z;\n if((m*n-k)>0)\n z=m*n-k;\n else\n z=0;\n float s=n*1.0/c;\n float a=1.0/d;\n int ans=0,t;\n if(a>=s)\n { \n printf(\"%d\",d*(z));\n }\n\n else\n {\n t=z%n;\n if(d*t\n\nint main()\n{\n\tint c,d;\t\t\t// c : \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0176\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd d : \ufffd\u07f0\ufffd\ufffd\ufffd\ufffd\u0176\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\tint n,m;\t\t\t// n : \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0176\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\u06b5\ufffd m : ??? n*m\n\tint k;\t\t\t// \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\u0333\ufffd\ufffd\ufffd k\ufffd\ufffd\ufffd\ufffd\u06b5\ufffd\n\n\tint Ans;\n\tint Ans2;\n\tint Ans3;\n\n\tint iNum1;\n\tint iNum2;\n\n\tint iMin=100000000;\n\n\tint iCnt1;\n\tint iCnt2;\n\n\tscanf(\"%d %d\", &c, &d);\n\tscanf(\"%d %d\", &n, &m);\n\tscanf(\"%d\", &k);\n\t\n\tAns = n*m - k;\n\n\tif(Ans == 0)\n\t{\n\t\tprintf(\"0\\n\");\n\t}\n\telse\n\t{\n\t\tfor(iCnt1 = 0; ; ++iCnt1)\n\t\t{\n\t\t\tiNum1 = iCnt1*n;\n\t\t\tiNum2 = Ans - iNum1;\n\t\t\tif(iNum2 >= 0)\n\t\t\t\tAns2 = iCnt1*c + iNum2*d;\n\t\t\telse\n\t\t\t\tAns2 = iCnt1*c;\n\t\t\tif(iMin > Ans2)\n\t\t\t{\n\t\t\t\tiMin = Ans2;\n\t\t\t\t\n\t\t\t}\n\t\t\tif(iNum2 < 0) break;\n\t\t}\n\t\tprintf(\"%d\\n\",iMin);\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "implementation"], "code_uid": "762fc7ed9d4bb07fbfe30e6171667668", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\t\t\t ____COMPETITIVE CODING____ */\n\n//--Header Files--\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n//--Macros--\n\n#define N 200001\n#define R 100000007\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n\n\n//--Structures--\n\n\n//--Comparator Functions--\n\nint comp(const void *a, const void *b)\n{\n\treturn (*(int *)a - *(int *)b);\n}\nint comp_desc(const void *a, const void *b)\n{\n\treturn (*(int *)b - *(int *)a);\n}\n\n\n//--Function Declarations--\n\n// void qsort(array name, size of array, size of each element, comp);\n// int* bsearch(address of search element, array name, size of array, size of each element, comp);\nint rmdup(int [], int); // int rmDup(array, size of array);\nint gcd(int, int); // int gcd(first number, second number);\n\n\n//--Useful Variables--\n\nint i = 0, j = 0, k = 0, flag = 1, count = 0, temp, pos = 0, test_case, mx = 0, mn = INT_MAX;\nlong long sum = 0, product = 1;\n\n\nint main()\n{\n\t//clock_t tStart = clock();\n\tscanf(\"%d\", &k);\n\tint a[10002], num = 1, digit, no[10], length;\n\twhile(flag)\n\t{\n\t\ttemp = num;\n\t\tj = 0;\n\t\twhile(temp)\n\t\t{\n\t\t\tdigit = temp % 10;\n\t\t\ttemp /= 10;\n\t\t\tno[j++] = digit;\n\t\t}\n\t\tlength = j;\n\t\tfor(i = length - 1, j = 0; i > j; i--, j++)\n\t\t{\n\t\t\ttemp = no[i];\n\t\t\tno[i] = no[j];\n\t\t\tno[j] = temp;\n\t\t}\n\t\tfor(i = 0; i < length; i++)\n\t\t{\n\t\t\ta[pos++] = no[i];\n\t\t\tif(pos == 10000)\n\t\t\t{\n\t\t\t\tflag = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tnum++;\n\t}\n\t/*for(i = 0; i < 10000; i++)\n\t\tprintf(\"%d\", a[i]);\n\tprintf(\"\\n\");*/\n\tprintf(\"%d\\n\", a[k-1]);\n\t//printf(\"%lf seconds.\\n\", (clock() - tStart)/CLOCKS_PER_SEC);\n\treturn 0;\n}\n\n\nint rmdup(int a[], int n)\n{\n\tif(n == 0 || n == 1)\n\t\treturn n;\n\tint j = 0;\n\tfor(i = 0; i < n - 1; i++)\n\t{\n\t\tif(a[i] != a[i+1])\n\t\t{\n\t\t\ta[j++] = a[i];\n\t\t}\n\t}\n\ta[j++] = a[n-1];\n\treturn j;\n}\n\n\nint gcd(int x, int y)\n{\n\tif(y == 0)\n\t{\n\t\treturn x;\n\t}\n\telse\n\t{\n\t\treturn gcd(y, x % y);\n\t}\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9d2ffd4f114ca3df32875e083f32be55", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include\nint main()\n{ char ch[100001]=\"\",s[100001];\n int i,k;\n scanf(\"%d\",&k);\n for(i=0;i<2777;i++)\n {sprintf(s,\"%d\",i+1);\n strcat(ch,s);\n }\n printf(\"%c\",ch[k-1]);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3b392bc88860fa29e6f08fce6321071b", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define IN(a,b) scanf(\"%lld %lld\",&a,&b);\n#define OUT(a) printf(\"%lld\\n\",a);\ntypedef long long ll;\nint main()\n{\n ll n,k,res;\n IN(n,k);\n if(k-n < n)\n {\n if(n-(k/2) < k/2)\n res=n-(k/2);\n else\n res=k/2;\n if(k%2==0 && k<=n)\n {\n res--;\n }\n }\n else\n {\n res=0;\n }\n OUT(res);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "a97a2b7dcf5d23a839de4b2e0cd4f72e", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.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 || k==2 || k>(n+(n-1)))\n {\n printf(\"0\");\n }\n else if(k>n)\n {\n printf(\"%lld\",(n-(k/2)));\n }\n else //if(k<=n)\n {\n if(k%2==0)\n {\n printf(\"%lld\",((k/2)-1));\n }\n else\n {\n printf(\"%lld\",(k/2));\n }\n }\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "f1c7878b4969f8198cb07d8fc5e2635c", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int i, len;\n char ch[101];\n scanf(\"%s\", ch);\n len = strlen(ch);\n i = 0;\n while(i\n#include\nint main()\n{\n int i,l,n=0,s=0;\n char a[101];\n gets(a);\n l=strlen(a);\n if(a[0]=='+'){\n for(i=1;i\n\nint main(){\n char in[2], sym[] = \"v<^>\";\n int t, d, i, j;\n scanf(\"%c %c\\n%d\", in, in + 1, &t);\n for (i = 0; i < 2; i++){\n for (j = 0; j < 4 && in[i] > 5; j++){\n if(in[i] == sym[j])\n in[i] = j;\n }\n }\n d = in[0] - in[1];\n printf(\"%s\\n\", d % 2 ? (d == -1 || d == 3 ? (t % 4 == 1 ? \"cw\" : \"ccw\") : (t % 4 == 1 ? \"ccw\" : \"cw\")) : \"undefined\");\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a70c3c330f29a446d53d2f971e3df419", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n char start,finish,cwise[4]={118,60,94,62},ccwise[4]={118,62,94,60};\n int n,i,temp1,temp2,FlagCW=0,FlagCCW=0;\n // scanf(\"%c %c %d\",&start,&finish,&n);\n scanf(\"%c %c \",&start,&finish);\n scanf(\"%d\",&n);\n n=n%4;\n //CW\n for(i=0;i<4;i++){\n if(start==cwise[i]){\n temp1=i;\n }\n if(finish==cwise[i]){\n temp2=i;\n }\n }\n temp1=temp1+n;\n temp1=temp1%4;\n if(temp1==temp2){\n FlagCW=1;\n }\n\n //CCW\n for(i=0;i<4;i++){\n if(start==ccwise[i]){\n temp1=i;\n }\n if(finish==ccwise[i]){\n temp2=i;\n }\n }\n temp1=temp1+n;\n temp1=temp1%4;\n if(temp1==temp2){\n FlagCCW=1;\n\n }\n if(FlagCCW==1 && FlagCW==1){\n printf(\"undefined\");\n }\n else if (FlagCCW==1){\n printf(\"ccw\");\n }\n else if (FlagCW==1){\n printf(\"cw\");\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a21d0b8df1fef14fed3b0205ad7ff8e4", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n, k, i, a, b;\n\tb = 0;\n\tscanf(\"%d%d\", &n, &k);\n\tfor (i = 1; i <= n; i++)\n\t{\n\t\tscanf(\"%d\", &a);\n\t\ta = a + b;\n\t\tif (a > 8)\n\t\t{\n\t\t\tb = a - 8;\n\t\t\tk = k - 8;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tk = k - a;\n\t\t\tb = 0;\n\t\t}\n\t\tif (k <= 0) break;\n\t}\n\tif (i <= n)\n\t\tprintf(\"%d\", i);\n\telse printf(\"-1\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e063f38c8e2284a27fe35425419daad8", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,k;\n int a;\n int sum=0;\n int count=0;\n\n scanf(\"%d %d\",&n,&k);\n for(int i=1;i<=n;i++)\n {\n scanf(\"%d\",&a);\n a=a+sum;\n if(k>0)\n count++;\n if(a>8)\n {\n sum=a-8;\n k=k-8;\n }\n else if(a<=8)\n {\n k=k-a;\n sum=0;\n }\n\n }\n if(k>0)\n printf(\"-1\\n\");\n else\n printf(\"%d\\n\",count);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9eb7561f9b5f0adb34c9e93afcbffe13", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n,x[102],i,b=0;\n scanf(\"%d\",&n);\n for (i=0; i7)\n {\n x[i]=x[i]-3;\n if (x[i]%7==0)\n {\n b=1;\n break;\n }\n b=0;\n }\n if (b==1)\n {\n printf(\"YES\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n }\n }\n \n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "1a565b90e6ba66950cc2a50e05bcaccc", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint t,n,i,j,temp,flag;\n\tscanf(\"%d\",&t);\n\twhile(t--)\n\t{\n\t\tflag=0;\n\t\tscanf(\"%d\",&n);\n\t\tfor(i=0;i<=25;i++)\n\t\t{\n\t\t\tfor(j=0;j<=50;j++)\n\t\t\t{\n\t\t\t\ttemp=3*i+7*j;\n\t\t\t\tif(temp==n)\n\t\t\t\t{\n\t\t\t\t\tflag=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flag)\n\t\t\t{\n\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(!flag)\n\t\t\tprintf(\"NO\\n\");\n\t}\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "77571ac01771306d5538d9d0092bc3f4", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint cmp(const void *a,const void *b)\n{\n\treturn *(int *)a - *(int *)b;\n}\n\nint min(int a,int b)\n{\n\tif(a\nint main(){\n\tint a,b,n;\n\tscanf(\"%d%d%d\",&a,&b,&n);\n\tint r=a%b;\n\tint i=0;\n\tint c;\n\tint y=0;\n\tfor(i=1;i<=b+1;i++){\n\t\tc= (r*10)/b;\n\t\tr=(r*10)%b;\n\t\tif(c==n){\n\t\t\ty=1;\n\t\t\tprintf(\"%d\",i);\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(!y)printf(\"-1\");\n\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "79e477733e5089f81fad8970301dc392", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n\nlong long solve(long long n)\n{\n\tlong long i = 1;\n\tlong long count = 0;\n\tlong long div = 1;\n\tlong long mult = 1;\n\n\t//4 = 4*1\n\t//10 = 9*1 + 1*2\n\t//11 = 9*1 + 2*2\n\t//100 = 9*1 + 90*2 + 1*3\n\t//1000 = 9*1 + 90*2 + 900*3 + 1*4\n\t//55 = 9*1 + 46*2\n\n\twhile (n > 0)\n\t{\n\t\tif (n < 9*mult)\n\t\t{\n\t\t\tcount = count + n * i;\n\t\t\tn = n - n;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tn = n - (9 * mult);\n\t\t\tcount = count + (9 * mult * i);\n\t\t\tmult = mult * 10;\n\t\t\ti++;\n\t\t}\n\t}\n\n\treturn count;\n}\n\nint main()\n{\n\tlong long n;\n\n\twhile (scanf(\"%lld\", &n) != EOF)\n\t{\n\t\tprintf(\"%lld\\n\", solve(n));\n\t} ;\n\n\treturn 0;\n}\n/* 1510925265702 */\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "4b90ba4b94236a3cf76a78e0daa7a243", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\ntypedef long long ll;\nint main()\n{\n ll num,n,l=0,m;\n ll sum=0;\n scanf(\"%lld\",&num);\n if(num<=9)\n printf(\"%lld\",num);\n else\n {\n n=num;\n while(n)\n {\n n/=10;\n l++;\n }\n sum+=9;\n for(ll i=1;i\nint main()\n{\n int n,x,y;\n while(scanf(\"%d%d%d\",&n,&x,&y)!=EOF)\n {\n int sum=n*y;\n if(sum%100!=0)\n sum=sum/100+1;\n else\n sum=sum/100;\n if(sum-x<0)\n\t\t\tprintf(\"0\\n\");\n\t\telse\n\t\t\tprintf(\"%d\\n\",sum-x);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "0c6337f991a7c8bd6a2a6b721a14f888", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\n#include\nint main()\n{\n int n,x,y;\n double p;\n scanf(\"%d %d %d\",&n,&x,&y);\n p= (n*y)/100.0;\n x= ceil(p)-x;\n if(x>0)\n printf(\"%d\",x);\n else\n printf(\"0\");\n return 0; \n \n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "74b756bf5af2262318e246a1f997a170", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int x;\n char a[100]={0},b[100]={0};\n scanf(\"%d %s %s\",&x,a,b);\n if(strcmp(b,\"week\")==0)\n {\n switch(x)\n {\n case 1:\n case 2:\n case 3:\n case 4:\n case 7:\n printf(\"52\");\n break;\n case 5:\n case 6:\n printf(\"53\");\n break;\n }\n }\n else\n {\n switch(x)\n {\n case 30:\n printf(\"11\");\n break;\n case 31:\n printf(\"7\");\n break;\n default:\n printf(\"12\");\n break;\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f7145a79ddcee4899d75e55a98a525b7", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main(){\n\n int a,b,c=0,i,n;\n char str[100],s[100],k[100];\n\n scanf(\" %[^\\n]\",str);\n\n sscanf(str,\"%d %s %s\",&a,k,s);\n\n if(! strcmp(s,\"week\")){\n\n n = 5;\n for(i=1;i<=366;i++){\n\n if(n == a) c++;\n if(n == 7) n =1;\n else n++;\n }\n printf(\"%d\\n\",c);\n\n }\n else if(! strcmp(s,\"month\")){\n\n if(a == 30) printf(\"11\\n\");\n else if(a==31) printf(\"7\\n\");\n else printf(\"12\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3d0b18dafa200952bae15a5cda0decc4", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{ \nlong long int n,i,j,k,l=0,x=1;\nscanf(\"%lld\",&n); \nfor(i=1;i<=n;i++)\n{\nx=2*x;\nl=l+x;\n}\nprintf(\"%lld\",l);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "8d9bc7ac9cb0a500084807f47fc95d05", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long int ara[60];\nint main()\n{\n long long int i,n,j,sum=0;\n scanf(\"%lld\",&n);\n for(i=0,j=2;i\n#include \n#include \n#include \n#define For(i,m,n) for(i=m;i(y)?(x):(y)\n#define MIN(x,y) (x)<(y)?(x):(y)\n#define MOD 1000000007\n#define MAXN 1005\n\nmain()\n{\n int t, s, i, j, n, x, d;\n scanf(\"%d%d%d\",&n,&x,&d);\n if(x-d>1) printf(\"<< \");\n t=MAX(1,x-d); s=MIN(n,x+d);\n For(i,t,s+1){\n if(i!=x) printf(\"%d \",i);\n else printf(\"(%d) \",i);\n }\n if(x+d>\");\n puts(\"\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "eff5f0b9289fb876c2f5ecc67bdb786d", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n\tint n, p, k, i;\n\tscanf(\"%d %d %d\", &n, &p, &k);\n\tif(p-k>1)\n\t\tprintf(\"<< \");\n\tfor(i=p-k;i=1)\n\t\t\tprintf(\"%d \", i);\n\tprintf(\"(%d) \", p);\n\tfor(i=p+1;i<=p+k;i++)\n\t\tif(i<=n)\n\t\t\tprintf(\"%d \", i);\n\tif(p+k>\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "832c311332d7eea8d4f59bee2a81b66f", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//\n// Created by Maxim on 03/06/19.\n//\n\n#include\n\n#ifndef max\n#define max(a,b) ((a) > (b) ? (a) : (b))\n#endif\n\nint main(){\n int n,c,p[50],t[50],time=0,s1=0,s2=0;\n scanf(\"%d %d\",&n,&c);\n for(int i=0;i-1;i--){time+=t[i];s2+=max(0,p[i]-c*time);}\n if(s1>s2){printf(\"Limak\");}\n else if(s1\n#include \n\nint main()\n{\n int n, c, i, sum1 = 0, sum2 = 0;\n scanf(\"%d%d\", &n, &c);\n int p[n], t[n], t1[n], t2[n];\n for(i = 0; i < n; i++)\n scanf(\"%d\", &p[i]);\n for(i = 0; i < n; i++)\n {\n scanf(\"%d\", &t[i]);\n t1[i] = t[i];\n t2[i] = t[i];\n }\n for(i = 1; i < n; i++)\n t1[i] += t1[i-1];\n for(i = n - 1; i > 0; i--)\n t2[i-1] += t2[i];\n for(i = 0; i < n; i++)\n if(p[i] - c * t1[i] > 0)\n sum1 = sum1 + p[i] - c * t1[i];\n for(i = n; i > 0; i--)\n if(p[i-1] - c * t2[i-1] > 0)\n sum2 = sum2 + p[i-1] - c * t2[i-1];\n if(sum1 > sum2)\n printf(\"Limak\");\n if(sum1 == sum2)\n printf(\"Tie\");\n if(sum1 < sum2)\n printf(\"Radewoosh\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9bd0a59fb6a584ad8e4ddee71452be52", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nconst i32 mod = 1000000007;\n\ni32 inv (i32 a) {\n i32 t = 1;\n while (a > 1) {\n t = (i64) t * (mod - mod / a) % mod;\n a = mod % a;\n }\n return t;\n}\n\nvoid run (void) {\n const i32 n = read_int();\n i32 *factor = (i32 *) calloc (n + 1, sizeof (i32));\n for (i32 i = 1; i <= n; ++i) {\n factor[i] = i;\n }\n for (i32 i = 2; i * i <= n; ++i) {\n if (factor[i] < i) continue;\n for (i32 j = i * i; j <= n; j += i) {\n factor[j] = i;\n }\n }\n i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));\n dp[1] = 0;\n for (i32 i = 2; i <= n; ++i) {\n i32 f[64];\n f[0] = 1;\n i32 len = 1;\n i32 t = i;\n while (t > 1) {\n i32 p = factor[t];\n while (t % p == 0) {\n\tt /= p;\n }\n for (i32 j = 0; j < len; ++j) {\n\tf[j + len] = f[j] * p;\n }\n len *= 2;\n }\n if (f[len - 1] != i) {\n dp[i] = dp[f[len - 1]];\n continue;\n }\n i32 prob[64];\n for (i32 j = 0; j < len; ++j) {\n prob[j] = (i64) (n / f[j]) * inv(n) % mod;\n }\n for (i32 j = len - 1; j >= 0; --j) {\n for (i32 k = j - 1; k >= 0; --k) {\n\tif ((j & k) == k) {\n\t prob[k] = (prob[k] - prob[j] + mod) % mod;\n\t}\n }\n }\n i32 local = 1;\n for (i32 j = 0; j < len - 1; ++j) {\n local = (local + (i64) prob[j] * dp[f[j]]) % mod;\n }\n dp[i] = (i64) local * inv((1 - prob[len - 1] + mod) % mod) % mod;\n }\n i32 ans = 1;\n for (i32 i = 1; i <= n; ++i) {\n ans = (ans + (i64)dp[i] * inv(n)) % mod;\n }\n print_int(ans);\n puts(\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "97bef7dde85edfc68c41dbd07154886d", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n\t{\n\tint n,i;\n\tlong long int s=0;\n\tscanf(\"%d\",&n);\n\tfor(i=1;ifor all correct switches\n\treturn 0;\n\t}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "eb69efb2b31395e9bad58a305c8d8ae2", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nmain(){\n\tint num_of_lock=0;\n\tscanf(\"%d\",&num_of_lock);\n\tprintf(\"%d\",calculate(num_of_lock,1));\n}\n\nint calculate(int num,int layer){\n\tif (num==1) return layer;\n\treturn (num-1)*layer+calculate(num-1,layer+1);\n}\n \t \t\t \t\t\t \t\t \t \t\t \t\t \t \t\t", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "531880088b65514cf9e862887b943c44", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nmain()\n{\n int n,i;\n scanf(\"%d\",&n);\n if(n%4==0) printf(\"1 A\");\n if(n%4==1) printf(\"0 A\");\n if(n%4==2) printf(\"1 B\");\n if(n%4==3) printf(\"2 A\");\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "97bcdee33f106eb67f0e0694b2626826", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{int n;\n\tscanf(\"%d\",&n);\n\tn=n%4;\n\tswitch(n)\n\t{ case 1:\n\t\tprintf(\"0 A\\n\");\n\t\tbreak;\n\n\t\tcase 2 :\n\t\tprintf(\"1 B\\n\");\n\t\tbreak;\n\n\t\tcase 3:\n\t\tprintf(\"2 A \\n\");\n\t\tbreak;\n\n\t\tcase 0:\n\t\tprintf(\"1 A\\n\");\n\t\tbreak;\n\n\n\n\t}\n\t\n \n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "825df63813cae8e6e23d8ed6d7582a60", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main () {\n int i1, i2, i3, o12, o23, o13;\n \n scanf (\"%d %d %d \", &i1, &i2, &i3);\n \n for (o12 = 0; o12 <= i1; o12++) {\n o13 = i1 - o12;\n o23 = i2 - o12;\n if (o12 >= 0 && o23 >= 0 && o13 >= 0 && (o12 + o13) == i1 && (o12 + o23) == i2 && (o13 + o23) == i3) {\n printf (\"%d %d %d\\n\", o12, o23, o13);\n return 0;\n }\n }\n \n printf (\"Impossible\\n\");\n\n return 0; \n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "graphs"], "code_uid": "a985409856956da32e10011a2f2455b0", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/* Problem: 344B - Simple Molecules */\n/* Solver: Gusztav Szmolik */\n\n#include \n\nint main ()\n {\n unsigned int a;\n unsigned int b;\n unsigned int c;\n unsigned short sol;\n unsigned int d;\n unsigned int r;\n unsigned int mbc;\n \n if (scanf(\"%u %u %u\",&a,&b,&c) != 3)\n return -1;\n if (a < 1 || a > 1000000 || b < 1 || b > 1000000 || c < 1 || c > 1000000)\n return -1;\n sol = 1;\n d = (b > c ? b-c : c-b);\n if (a < d)\n sol = 0;\n else\n {\n r = a-d;\n mbc = (b > c ? c : b);\n if (r%2 || 2*mbc < r)\n sol = 0;\n }\n if (sol)\n {\n printf (\"%u \",(b == mbc ? r/2 : r/2+d));\n printf (\"%u \",mbc-r/2);\n printf (\"%u\\n\",(b == mbc ? r/2+d : r/2));\n }\n else\n printf (\"Impossible\\n\");\n return 0;\n }\n", "lang_cluster": "C", "tags": ["brute force", "math", "graphs"], "code_uid": "a9030e789fb84c4dab4faaeb5b69b970", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main ()\n{\n double d, L, v1, v2;\n double t;\n scanf(\"%lf %lf %lf %lf\", &d, &L, &v1, &v2);\n t = (L - d) / (v1 + v2);\n printf(\"%lf\", t);\n return 0;\n}\n\n/* 1504025940563 */\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "bc1a57d4169dd498077588b14864d899", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tdouble d,v1,v2,l;\n\tscanf(\"%lf%lf%lf%lf\",&d,&l,&v1,&v2);\n\tprintf(\"%.10lf\",(l-d)/(v1+v2));\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "3763d1fe6fd2c07f704071c693548daf", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nint main() {\n\t//code\n int n,i,j,c=0;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n for(j=1;j<=n;j++)\n {\n int w=i^j;\n if(w>0&&w<=n&&(i+j)>(w)&&(i+w)>j&&(j+w)>i)\n {\n c++; \n }\n }\n }\n printf(\"%d\\n\",(c/6));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "a282e1b950f2625d085c0850f6469d66", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n int n , a , b , c , s=0;\n scanf(\"%d\" , &n);\n for(c = 1 ; c <= n ; ++c){\n for(b = 1 ; b <= c ; ++b){\n for(a = c - b + 1 ; a <= b ; ++a){\n if( (a^b^c) == 0){\n s += 1;\n }\n }\n }\n }\n printf(\"%d\" , s);\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "25a5a71649188b60aa6a06203dd6e7a2", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,m,p=1,i;\n scanf(\"%lld %lld\",&n,&m);\n if(n>59 || n>m)\n {\n printf(\"%lld\",m);\n }\n else\n {\n for(i=1;i<=n;i=i+1)\n {\n p=p*2;\n }\n printf(\"%lld\",m%p);\n }\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e20b79c61f85a7ba848555e81b54598e", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int n, m;\n scanf(\"%d %d\", &n, &m);\n\n int answer = (n > 31 ? m : m%(1 << n));\n printf(\"%d \", answer);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "3072d26783431f25a89f6bf3b7d12e1f", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long cal(long long n) {\n\tfor (long long i = 2; i * i <= n; ++i)\n\t\tif (n % i == 0)\n\t\t\treturn i;\n\treturn n;\n}\n\nint main() {\n long long n;\n\tscanf(\"%lld\", &n);\n\tlong long cnt = 0;\n\tif (n % 2 != 0){\n\t\tn -= cal(n);\n\t\t++cnt;\n\t}\n\tprintf(\"%lld\\n\", cnt + n / 2);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "af03f8fd74a919a0de73508a1fd24125", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int j,count =0 ;\n long long n,ans,i;\n\n scanf(\"%lld\",&n);\n if(n%2==0)\n {\n printf(\"%lld\",n/2);\n return 0;\n }\n for(i=2; 1ll*i*i<=n; i++)\n {\n if(n%i==0)\n {\n count++;\n break;\n }\n }\n //printf(\"%d\\n\",count);\n if(count==0)\n i=n;\n // printf(\"%lld\\n\",i);\n ans=(n-i)/2;\n printf(\"%lld\",1+ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "730ddebca72c1aa0014d468aa34cc677", "src_uid": "a1e80ddd97026835a84f91bac8eb21e6", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(void){\n\tint w1,h1,w2,h2,ans;\n\tscanf(\"%d%d%d%d\",&w1,&h1,&w2,&h2);\n\tans = 2*(h1+h2+w1)+4;\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "1b135f18f4ef842151bacdb81292b2aa", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(void) {\n long int w1,w2,h1,h2,sum;\n scanf(\"%ld %ld %ld %ld\",&w1,&h1,&w2,&h2);\n if(w1!= w2){\n sum=(2*(h1+h2)+w1+w2+(w1-w2-1)+5);\n }\n else\n {\n sum=(2*(h1+h2)+w1+w2+4);\n }\n printf(\"%ld\\n\",sum);\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "336c8257b7ec392312a20597540ed13b", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void)\n{\n char m,s[100];\n char x[30]={'q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l',';','z','x','c','v','b','n','m',',','.','/'};\n int i,j,k;\n scanf(\"%c\", &m);\n scanf(\"%s\", s);\n\n for(i=0;i\n#include \nvoid direita(char entrada[]){\n\nchar frase[100], letra;\nscanf(\" %[^\\n]s\", frase);\n//printf(\"\\n%s\\n\", frase);\nint i, j, x = strlen(frase);\n\n\tfor(i = 0; i < x; i++)\n\t{\n\t\tfor(j = 0; j < 30; j++)\n\t\t{\n\t\t\tif(frase[i] == entrada[j])\n\t\t\t{\n\t\t\t\tprintf(\"%c\", entrada[j-1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nvoid esquerda(char entrada[]){\n\nchar frase[100], letra;\nscanf(\" %[^\\n]s\", frase);\nint i, j, x = strlen(frase);\n\n\tfor(i = 0; i < x; i++)\n\t{\n\t\tfor(j = 0; j < 30; j++)\n\t\t{\n\t\t\tif(frase[i] == entrada[j])\n\t\t\t{\n\t\t\t\tprintf(\"%c\", entrada[j+1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\n\nint main()\n{\n\nchar teclado[40] = {\"qwertyuiopasdfghjkl;zxcvbnm,./\"}, comando;\n\ncomando = getchar();\n//printf(\"\\n%c\\n\", comando);\n\nif(comando == 'R') direita(teclado);\nelse esquerda(teclado);\n//printf(\"%s\", teclado);\n\n\nreturn 0;\n\n}\n\n/* 1512827954809 */\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "73c556c0c3cc8d2d2e9f6d4fbadfa046", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint m,n,s=0,a,i,j=0;\n\tscanf(\"%d%d\",&n,&m);\n\tfor(i=0;im)\n\t\t{\n\t\t\tj++;\n\t\t\ts=a;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",j+1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "8f5a80c9552d1f89e7f40bce7f8b0782", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n,m,i;\n\n\n scanf(\"%d %d\",&n,&m);\n\n int ara[n],sum=0,cnt=0;\n\n for(i=0;im){\n cnt++;\n sum=0;\n --i;\n }\n }\n\n\n printf(\"%d\",cnt+1);\n\n\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "01da5446336ba014ed52d37a28e09297", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main (){\n int k,n,s,p;\n double all;\n scanf(\"%d%d%d%d\",&k,&n,&s,&p);\n all=k*ceil((double)n/(double)s);\n printf(\"%d\",(int)ceil(all/(double)p));\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "644c9eaf1a01b97253a62e6ee88f8c80", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int k, n, s, p, paper, pack, rest;\n scanf(\"%d %d %d %d\", &k, &n, &s, &p);\n\n rest= (n-1)/s+1;\n\n paper= rest * k;\n\n pack= (paper-1)/p+1;\n\n printf(\"%d\", pack);\n\n\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "60a40c2d09ef76b54bc5af515bddd85d", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n long long n;\n int i=0 ;\n scanf(\"%lld\",&n);\n while(n-i>0){\n n=n-i;\n i++;\n }\n printf(\"%lld\",n);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "7d6c5f6627f62b6ac049c27f040e4718", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long n,last,s;\nint main()\n{\n scanf(\"%lld\",&n);\n for(long long i=1;;i++)\n {\n last=s;\n s+=i;\n if(s>=n)break;\n }\n printf(\"%lld\",n-last);\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "d72b1ccf0faa03711021bcfa43321986", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main (){\n\nint k,n,w,out;\n \nscanf(\"%d%d%d\",&k,&n,&w);\n\nout=(k*(w*(w+1)/2))-n;\n\nif(1<=k,w<=1000,0<=n<=10^9)\n{\nout=(k*(w*(w+1)/2))-n;\n}\n \nif (out>=0){\nprintf(\"%d\",out );\n}\nelse{\nout=0;\nprintf(\"%d\",out);\n}\n\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "89aff6d75e29246a8ced42f0d233aa35", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n\n\n\n\n\n\n\n\n// aeitar runtime o.00 ken?\n\n#include \n\nint main()\n{\n int i,k,n,w,m,s=0;\n scanf(\"%d%d%d\",&k,&n,&w);\n for(i=1;i<=w;i++){\n s=s+(i*k);\n }\n if((s-n)<=0){\n printf(\"%d\\n\",0);\n }\n else{\n printf(\"%d\\n\",s-n);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "45be18d213c67c869f1a0df8cdf40337", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int a, b, c, d, t=0;\n scanf(\"%d %d %d\",&a, &b, &c);\n if(!c && a==b)\n t=0;\n else if(!c && a!=b)\n t=1;\n else if((b-a)%c==0 && (b-a)/c>=0)\n t=0;\n else\n t=1;\n printf(t ? \"NO\\n\" : \"YES\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "807322ab89e417ec74f48646cbdeb213", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,s,d;\n scanf(\"%d %d %d\",&a,&b,&c);\n if(a==b)\n printf(\"YES\\n\");\n else if(a>b&&c==0)\n printf(\"NO\\n\");\n else if(ba)\n {\n if(c>0)\n {\n d=b-a;\n if(d%c==0)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n }\n else if(a>b)\n {\n if(c>0)\n {\n printf(\"NO\\n\");\n }\n else\n {\n d=a-b;\n if(d%c==0)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "2fc4b5410159c253e7a0aa11fd09f7a3", "src_uid": "9edf42c20ddf22a251b84553d7305a7d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\n char a[101],ch;\n int i,l=0;\n\n scanf(\"%s\",&a);\n\n for(i=1;i='A')\n l++;\n if(l==strlen(a)-1)\n {\n for(i=0;i='A')\n a[i]=a[i]-65+97;\n else if(a[i]<='z' && a[i]>='a')\n a[i]=a[i]+65-97;\n }\n }\n\n printf(\"%s\\n\",a);\n}\n\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "7c53ef54677944c5c3a0a8dc24401107", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int i , l , counter = 1;\n char s[109];\n scanf(\"%s\",s);\n l=strlen(s);\n if(l==1)\n {\n if(s[0]>='a' && s[0]<= 'z')\n s[0]=s[0]-32;\n else{ s[0] =s[0]+32; }\n printf(\"%s\\n\",s);\n }\n else {\n for (i=1;i='A' && s[i]<='Z')\n {\n counter =0;\n }\n else if(s[i]>='a' && s[i]<= 'z') {\n counter = 1;\n break;\n }\n }\n if(counter==0)\n {\n if(s[0]>='a' && s[0]<= 'z'){\n s[0]=s[0]-32;\n\n for(i=1;i='A' && s[0]<='Z')\n {\n for(i=0;i\nint max(int a,int b)\n{\n\tif(a>b)return a;\n\treturn b;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tint i,j,k,count=0,mx=0;\n\tfor(i=0;i\n\nint main()\n{\n int n,a,i,zero=0,max_zero=0,one=0;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&a);\n if(a==1)\n {\n one++;\n if(zero>0)\n zero--;\n }\n else\n {\n zero++;\n if(zero>max_zero)\n max_zero=zero;\n }\n }\n if(max_zero==0)\n max_zero--;\n printf(\"%d\\n\",one+max_zero);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "implementation"], "code_uid": "39a00646d0a9305f95e938daff692e50", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint min(int x,int y,int z)\n {\n if(x<=y && x<=z)\n {\n\t return x;\n }\n else if (y<=x && y<=z)\n {\n\t return y;\n }\n else if(z<=y && z<=x)\n {\n\t return z;\n }\n else\n { return y ;\n\t } \n \n }\nint main()\n{\n\tint y,b,r;\n\tscanf(\"%d%d%d\",&y,&b,&r);\n\ty++;\n r--;\n printf(\"%d\",3*min(y,b,r));\n \nreturn 0;\n} \n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "5530ce2a8c915e4666454fb032c48dae", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint y,b,r,s,sum;\n \tscanf(\"%d%d%d\",&y,&b,&r);\n\ts=y;\n\twhile(s>0)\n\t{\n\t\tif((s+1)<=b && (s+2)<=r)\n\t\t{\n\t\t\tsum=(s*3)+3;\n\t\t\tprintf(\"%d\",sum);\n\t\t\tbreak;\n\t\t}\n\t\ts--;\n\t}\n\tif(s==0)\n\tprintf(\"0\\n\");\n\treturn 0;\n}\t", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "6e749ad372d940baee278a425e7e8a0f", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/******************************************************************************\n\n Online C Compiler.\n Code, Compile, Run and Debug C program online.\nWrite your code in this editor and press \"Run\" button to compile and execute it.\n\n*******************************************************************************/\n\n#include\n\nint main()\n{\n int i, j, a, n,x=0;\n \n scanf(\"%d\", &n);\n int number[n];\n \n for (i = 0; i < n; ++i)\n scanf(\"%d\", &number[i]);\n \n for (i = 0; i < n; ++i) \n {\n \n for (j = i + 1; j < n; ++j)\n {\n \n if (number[i] > number[j]) \n {\n \n a = number[i];\n number[i] = number[j];\n number[j] = a;\n \n }\n \n }\n \n }\n for(i=0;i\nint main()\n{\n int t,a[100000],temp,n;\n scanf(\"%d\",&n);\n for(int i=0;i\r\n#include\r\n#include\r\n#include\r\nlong long int min(long long int a, long long int b)\r\n{\r\n return a < b ? a : b;\r\n}\r\nint cmpfunc (const void * a, const void * b) {\r\n return ( *(int*)a - * (int*)b );\r\n}\r\ntypedef long long ll;\r\nvoid test();\r\nint main()\r\n{\r\n/*#ifndef ONLINE_JUDGE\r\n freopen(\"input.txt\", \"r\", stdin);\r\n freopen(\"output.txt\", \"w\", stdout);\r\n#endif*/\r\n int t;\r\n scanf(\"%d\", &t);\r\n while (t--)\r\n {\r\n test();\r\n }\r\n return 0;\r\n}\r\nvoid test()\r\n{\r\n int n, m, k;\r\n scanf(\"%d %d %d\", &n, &m, &k);\r\n if (n % 2 == 0 && m % 2 == 0)\r\n {\r\n if (k % 2 == 0)\r\n {\r\n printf(\"YES\\n\");\r\n }\r\n else\r\n {\r\n printf(\"NO\\n\");\r\n }\r\n }\r\n else if (n % 2 == 0 && m % 2 != 0)\r\n {\r\n if (k > (n * (m / 2)))\r\n {\r\n printf(\"NO\\n\");\r\n }\r\n else if (k % 2 == 0)\r\n {\r\n printf(\"YES\\n\");\r\n }\r\n else\r\n {\r\n printf(\"NO\\n\");\r\n }\r\n }\r\n else if (n % 2 != 0 && m % 2 == 0)\r\n {\r\n int l = n * (m - 2) / 2, j = m / 2;\r\n if (k == n * (m / 2))\r\n {\r\n printf(\"YES\\n\");\r\n }\r\n else if (k > l && (k - l) % 2 != 0)\r\n {\r\n printf(\"YES\\n\");\r\n }\r\n else if (k >= m / 2 && k % j == 0 && (n - (k / j)) % 2 == 0)\r\n {\r\n printf(\"YES\\n\");\r\n }\r\n else if (k < m / 2)\r\n {\r\n printf(\"NO\\n\");\r\n }\r\n else\r\n {\r\n k = k - m / 2;\r\n if (k % 2 == 0)\r\n {\r\n printf(\"YES\\n\");\r\n }\r\n else\r\n {\r\n printf(\"NO\\n\");\r\n }\r\n\r\n }\r\n\r\n\r\n }\r\n}\r\n\r\n\r\n\r\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "7aedd0a1d2adc8127dd1f038008519d3", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n\tint i,j,k,m,n,x,y,z,t;\r\n\tscanf(\"%d\",&t);\r\n\twhile(t--)\r\n\t{\r\n\t\t\r\n\t\tscanf(\"%d%d%d\",&n,&m,&k);\r\n\t\tx=n*m/2;\r\n\t\tif(n%2==1)\r\n\t\t{\r\n\t\tx-=m/2;\r\n\t\tk-=m/2;\r\n\t\t\t\r\n\t\t}\r\n\t\tif(m%2==1)x-=n/2;\r\n\t\tif(k<0||k>x||k%2==1)printf(\"NO\");\r\n\t\telse printf(\"YES\");\r\n\t\tif(t)printf(\"\\n\");\r\n\t}\r\n\treturn 0;\r\n } ", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "e7da71cb692026f3b9769000c474bec9", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define MX 1000\nlong long int p,k,k1=1,sm,A[MX];\nint main(){\n int i,j,sz;\n long long int ims;\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n scanf(\"%lld%lld\",&p,&k);\n for(sz=0;;sz+=2){\n ims=p%(k*k);\n p=p/(k*k);\n if(ims>=k){\n p++;\n A[sz]=ims%k;\n A[sz+1]=k-(ims/k);\n }\n else{\n A[sz]=ims;\n }\n if(p==0){break;}\n }\n printf(\"%d\\n\",sz+1);\n for(i=0;i<=sz;i++){\n printf(\"%lld \",A[i]);\n }\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "b844854a05d2c1590370329cfdb787f3", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define __STDC_FORMAT_MACROS\n#include \n\n// if we write f(x) = Sum([0,n+1], bi * x^i) and q(x) = Sum([0,n], ai * x^i) and then so multiplication and equate left and right sides:\n// b[n+1] = a[n]\n// b[i] = K*a[i] + a[i-1]\n// b[0] = K*a[0] + P\n// from here it is easy to see that all ai should be integer (going n+1 -> 0 and knowing that bi are integers)\n\n\n// TODO: ???\n#define MAX_D 5000\nstatic int64_t _a[MAX_D+2] = {}, _b[MAX_D+2] = {};\n\n\nint main() {\n int64_t P,K; scanf(\"%\" PRId64 \" %\" PRId64 \"\\n\", &P,&K);\n\n // offset, to include P as a[-1]\n _a[0] = P; int D = 0;\n for( ; D <= MAX_D ; ++D) {\n // b[i] = K*a[i] + a[i-1] < K\n // say, a[i-1] = x*K+y (y < K), then we can write\n // b[i] = K*(a[i] + x) + y < K, and from there a[i] = -x, and b[i] = y\n // NB we want non-c modulo, but math (where rem is non-negative)\n int64_t x = _a[D] / K, y = _a[D] % K;\n if(y < 0) { y += K, --x; }\n _a[D+1] = -x, _b[D] = y;\n // TODO:\n if(_a[D] == 0) break;\n }\n\n printf(\"%d\\n\", D);\n for(int i = 0 ; i < D ; ++i) printf(\"%\" PRId64 \" \", _b[i]);\n printf(\"\\n\");\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "41b023c4177c28b829c05e20fb21432f", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint low,high;\nint Low(int array[],int len)\n{\n int i;\n //len = strlen(array);\n low = array[0];\n for(i = 1; i < len; i++)\n {\n if( array[i] < low)\n {\n low = array[i];\n }\n // printf(\"for loop in functio\");\n }\n}\nint High(int array[],int len)\n{\n int i;\n //len = strlen(array);\n high = array[0];\n for(i = 1; i < len; i++)\n {\n if(array[i] > high)\n {\n high = array[i];\n }\n // printf(\"for loop in functio\");\n }\n}\n\nint main()\n{\n int n,m,r,share_buyed,invest,sell,profit;\n scanf(\"%d %d %d\", &n, &m, &r);\n int n_array[n],m_array[m];\n for(int i = 0; i < n; i++)\n {\n scanf(\"%d\", &n_array[i]);\n }\n for(int i = 0; i < m; i++)\n {\n scanf(\"%d\", &m_array[i]);\n }\n int len = strlen(n_array);\n Low(n_array,n);\n int len2 = strlen(m_array);\n High(m_array,m);\n //printf(\"low is %d and high is %d n is %d m is %d len is %d len2 is %d\\n\",low,high,n,m,len,len2);\n share_buyed = r / low;\n invest = (share_buyed * low);\n sell = share_buyed * high;\n profit = sell - invest;\n profit = r + profit;\n if(profit < r)\n {\n printf(\"%d\\n\",r);\n }\n else\n {\n printf(\"%d\\n\",profit);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "df9179270adfff0b608397c46e9dbcfc", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nmain()\n{\n\tint n,m,r,i,max=-90,min=100010,sum=0,p;\n\tscanf(\"%d %d %d\",&n,&m,&r);\n\tfor(i=0;imax)\n\t\t max=a;\t\n\t}\np=r/min;\nsum+=(r%min);\nsum+=(p*max);\nif(sum>r)\n{\n\tprintf(\"%d\",sum);\n}\nelse\n{\n\tprintf(\"%d\",r);\n}\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "908fc79537dccf1590b305788a02cadb", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tint n, k, m;\n\n\tscanf(\"%d%d\", &n, &k);\n\tfor (m = 1; (long long) m * (m + 3) / 2 < n + k; m++)\n\t\t;\n\tprintf(\"%d\\n\", n - m);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "50c3a2871c15c0b73c5c061e38b7b6c8", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include \n\n \n int main ()\n {\n \tlong long n,k,i,sum,d;\n \tscanf(\"%I64d %I64d\",&n,&k);\n \tfor (i=1; ; i++)\n \t{\n \t\tsum=(i*(i+1))/2;\n \t\td=sum-(n-i);\n \t\tif (d==k) break;\n \t}\n \tprintf(\"%I64d\\n\",n-i);\n \t\n \treturn 0;\n }\n\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "bc38346dcb6ee9c5e691c511feaead86", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif((i * (i+1) / 2) == n)\n\t\t{\n\t\t\tprintf(\"YES\");\n\t\t\treturn 0;\n\t\t}\n\t\t\t\n\t}\n\tprintf(\"NO\");\n\treturn 0;\n\n\t\t\t\n}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "b361091c06eb9dfdea67cd8df390314f", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n double\nsqrt2 (int m)\n{\n \ndouble sqrts = (10 + m / 10) / 2;\n \nfor (int i = 0; i < 25; i++)\n {\n \nsqrts = (sqrts + m / sqrts) / 2;\n \n} \nreturn sqrts;\n\n}\n\n int\nmain () \n{\n \nint t;\n \nscanf (\"%d\", &t);\n \nint det = 1 - 4 * 1 * (-2 * t);\n \ndouble x1 = (-1 + sqrt2 (det)) / 2;\n \ndouble x2 = (-1 - sqrt2 (det)) / 2;\n \nif ((x1 == (int) x1 || x2 == (int) x2) && (x1 > 0 || x2 > 0))\n {\n \nprintf (\"YES\");\n \n}\n \n else\n printf (\"NO\");\n\n \n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "a4933b728d3b431cd74a38adbb07b5cf", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tchar numbers[101];\n\tscanf(\"%s\",numbers);\n\tint count0 = 0;\n\tint count1 = 0;\n\tint occured =0;\n\tint i;\n\tfor (i=0; i= 7 || count1 >= 7)\n\t\toccured =1;\n\t}\n\t\tif(occured ==1)\n\t\tprintf(\"YES\");\n\t\telse \n\t\tprintf(\"NO\");\n\t\treturn 0;\n\t\n\t\n}//main ", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "0b395fb103f194b02c0d3013d43fde6a", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char a[222]; int i=0,j=0,k=0,flag_0=0,flag_1=0;\n scanf(\"%s\",a);\n while(a[i]!='\\0')\n {\n if(a[i]-'0'==0)\n {\n j++;\n if(j>1)\n {\n if(a[i-1]-'0'==0)\n {\n i++;\n if(j==7)\n {\n printf(\"YES\"); return 0;}\n }\n else{j=0; k=0; flag_0=1; i++;}\n }\n if(j==1){i++; flag_0=1; k=0; }\n }\n if(a[i]-'0'==1)\n {\n k++;\n if(k>1)\n {\n if(a[i-1]-'0'==1)\n {\n i++;\n if(k==7)\n {\n printf(\"YES\"); return 0;}\n }\n else{k=0; j=0; flag_1=1; i++;}\n }\n if(k==1){i++; flag_1=1; j=0; }\n }\n }\n if(flag_0==0||flag_1==0)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "c9af3841f3e3da2dd8b9e9019cbfe60e", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint Find(int n)\n{\n\tint i,j=0,list[1000],ans,temp,tem;\n\ttemp=0;\n\tans=1;\n\ttem=n;\n\tfor(i=2;i*i<=n;i++)\n\t\tif(tem%i==0)\n\t\t{\n\t\t\tlist[j++]=i;\n\t\t\twhile(tem%i==0)\n\t\t\t\ttem/=i;\n\t\t\t}\n\tif(tem!=1)\n\t{\n\t\tlist[j]=tem;\n\t\tj++;\n\t\t}\n\ttem=n;\n\tfor(i=0;i\n#define lim 1000000\n#define m(a) (a)%1073741824\nint d[lim+1];\nint main()\n{\n int n,i,j,k,a,b,c,s=0;\n for(i=2;i<=lim;i++)\n for(j=i;j<=lim;j+=i)\n d[j]++;\n scanf(\"%d%d%d\",&a,&b,&c);\n for(i=1;i<=a;i++)\n for(j=1;j<=b;j++)\n for(k=1;k<=c;k++)\n s=m(s+d[i*j*k]+1);\n printf(\"%d\",s);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "21566ff884887f408c0d456f644f3ec9", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main()\n{\n\tlong long int n,i,j,temp,ans,l,c=1;\n\tscanf(\"%lld\",&n);\n\t\n\tif(n/10==0) ans =1;\n\telse\n\t{\n\t\ttemp=n;\n\t\t\n\t\tfor(l=0;;l++)\n\t\t{\n\t\t\ttemp=temp/10;\n\t\t\tif(temp==0) break;\n\t\t}\n\t\t\t\n\t\tfor(j=0;j\n#include\nint main()\n{\n int y,r,temp,j,k,d,m=1,mm;\n double i,n;\n scanf(\"%d\",&y);\n r=1;\n temp=y;\n if(y/10==0){\n n=y+1;\n d=n-y;\n printf(\"%d\",d);\n return 0;\n }\n\n else{\n for(i=0;r!=0;i++){\n r=temp/10;\n if(r==0){\n j=temp%10;\n for(mm=0;mm\nint main()\n{\n\tint n,k,i,j,a[1000],b=3,c,d,e=0,f;\n\tscanf(\"%d%d\",&n,&k);\n\ta[1]=2;\n\ta[2]=3;\n\tfor(i=5;i<=n;i++)\n\t{\n\t\tf=1;\n\t\tfor(j=2;j<=i/2;j++)\n\t\t{\n\t\t\tif(i%j==0)\n\t\t\t\t{f=0;\n\t\t\t\tbreak;}\n\t\t}\n\t\tif(f==1)\n\t\t\t{a[b]=i;\n\t\t\t\tb++;}\n\t\t\n\t}\n//for(c=1;c<=b;c++)\n//printf(\"%d\\n\",b);\n\t\n\tfor(c=3;c=k)\n\t\tprintf(\"YES\");\n\telse\n\t\tprintf(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "9b73284bf2902ee3766ab87e073e557f", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#define M 1000\na[M+1];x[M+1];b[500];\nmain(i,j,n){\n a[0]=a[1]=1;\n for(i=3;i<=M;i+=2)if(!a[i])for(j=i*2;j<=M;j+=i)a[j]=1;\n for(n=1,j=3;j<=M;j+=2)if(!a[j])b[n++]=j;\n for(i=1;;i++)if(b[i]+b[i+1]>M)break;else if(!a[b[i]+b[i+1]+1])x[b[i]+b[i+1]+1]=1;\n scanf(\"%d%d\",&i,&j);\n for(;i;i--)\n if(x[i]){j--;if(!j)break;}\n puts(j>0?\"NO\":\"YES\");\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "5efd7622d64c8dd30bd3f6e1c420c7c2", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint main()\n{\n int x,y,z,i,j,k,n,s;\n char a[10000];\n char b[11]= {\"CODEFORCES\"};\n while(scanf(\"%s\",a)!=EOF)\n {\n s=0;\n x=0;\n k=0;\n n=strlen(a);\n if(n<=10)\n {\n printf(\"NO\\n\");\n continue;\n }\n for(i=0; i<10; i++)\n {\n if(a[i]==b[i])\n {\n x++;\n }\n }\n if(x==10)\n {\n k=1;\n }\n j=0;\n y=0;\n for(i=n-10; i\n#include \n#include \n\nint main()\n{\n\tchar banner[100] = \"\";\n\t\t\t\n\tscanf(\"%s\", banner);\n\t\n\tchar codeforces[] = \"CODEFORCES\";\n\tint len = strlen(codeforces); // Although we know it's 10\n\t\n\tint i;\n\tint index = 0;\n\tint achieved = 0;\n\tint status = 0;\n\t\n\tfor (i = 0; i < strlen(banner); i++)\n\t{\n\t\tif (index == len && achieved != 0) // CODEFORCES already completed but still iterating; reset index with achieved data\n\t\t\tindex = achieved; // index resetted, but must continue checking current letter\n\t\t\n\t\tif (banner[i] == codeforces[index])\n\t\t{\n\t\t\tif (status == 1)\n\t\t\t{\n\t\t\t\tstatus = 2;\n\t\t\t}\t\t\t\t\n\t\t\tindex++;\n\t\t}\t\n\t\telse //if (banner[i] != codeforces[index])\n\t\t{\n\t\t\tif (status == 0) // 1st error. save accumulated data\n\t\t\t{\n\t\t\t\tachieved = index;\n\t\t\t\tstatus = 1;\n\t\t\t}\n\t\t\telse if (status == 2) // Another error, reset index by loading achieved data\n\t\t\t{\n\t\t\t\tindex = achieved;\n\t\t\t\tstatus = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (status == 0 && index == len) // Ideal case, received word is CODEFORCES\n\t\tprintf(\"YES\\n\");\t\n\telse if (status == 1 && achieved == len) // Completed CODEFORCES but got a substring after\n\t\tprintf(\"YES\\n\");\n\telse if (status == 2 && index == len) // Got a substring but ended completing CODEFORCES\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "528b14dc9510d963c04e2be403d1f220", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int s;\n scanf(\"%d\",&s);\n char ch1[20][10]={\"zero\",\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\",\"ten\",\"eleven\",\"twelve\",\"thirteen\",\"fourteen\",\"fifteen\",\"sixteen\",\"seventeen\",\"eighteen\",\"nineteen\"};\n char ch2[8][10]={\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"};\n if(s<=19){\n printf(\"%s\",ch1[s]);\n }\n else{\n int temp=0,flag=0;\n flag=s/10;\n temp=s%10;\n if(temp==0){\n printf(\"%s\",ch2[flag-2]);\n }\n else{\n printf(\"%s-%s\",ch2[flag-2],ch1[temp]);\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "a57eaba1ec608594c18adb916693f454", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\nint n,a,b,q=0;\n\nscanf(\"%d\", &n);\n\nb=n%10;\n\na=n/10;\n\n\nif(a == 2)\n printf(\"twenty\");\n\nelse if(a == 3)\n printf(\"thirty\");\n\nelse if(a == 4)\n printf(\"forty\");\n\nelse if(a == 5)\n printf(\"fifty\");\n\nelse if(a == 6)\n printf(\"sixty\");\n\nelse if(a == 7)\n printf(\"seventy\");\n\nelse if(a == 8)\n printf(\"eighty\");\n\nelse if(a == 9)\n printf(\"ninety\");\n\n\nif(b != 0 )\n if(a!=0)\n if(a!=1)\n printf(\"-\");\n\n\n\n\nif(b == 2 && a!=1)\n printf(\"two\");\n\nelse if(b == 1 && a!=1)\n printf(\"one\");\n\nelse if(b == 3 && a!=1)\n printf(\"three\");\n\nelse if(b == 4 && a!=1)\n printf(\"four\");\n\nelse if(b == 5 && a!=1)\n printf(\"five\");\n\nelse if(b == 6 && a!=1)\n printf(\"six\");\n\nelse if(b == 7 && a!=1)\n printf(\"seven\");\n\nelse if(b == 8 && a!=1)\n printf(\"eight\");\n\nelse if(b == 9 && a!=1)\n printf(\"nine\");\n\n\nif(n==0)\n printf(\"zero\");\n\nif(n == 10)\n printf(\"ten\");\n\nelse if(n == 11)\n printf(\"eleven\");\n\nelse if(n == 12)\n printf(\"twelve\");\n\nelse if(n == 13)\n printf(\"thirteen\");\n\nelse if(n == 14)\n printf(\"fourteen\");\n\nelse if(n == 15)\n printf(\"fifteen\");\n\nelse if(n == 16)\n printf(\"sixteen\");\n\nelse if(n == 17)\n printf(\"seventeen\");\n\nelse if(n == 18)\n printf(\"eighteen\");\n\nelse if(n == 19)\n printf(\"nineteen\");\n\n\nreturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "19df3d583743424218dbad15d9db913b", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,d,i,sum=0;\n scanf(\"%d %d\",&a,&b);\n if(a>b)\n {\n c=a-b;\n }\n\n else\n {\n c=b-a;\n }\n\n if(c%2==0)\n {\n d=c/2;\n for(i=1;i<=d;i++)\n {\n sum=(sum+i);\n }\n sum=2*sum;\n printf(\"%d\\n\",sum);\n }\n else\n {\n d=c/2;\n for(i=1;i<=d;i++)\n {\n sum=(sum+i);\n }\n sum=(2*sum)+(d+1);\n printf(\"%d\\n\",sum);\n }\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "brute force"], "code_uid": "aeff51aa81e2b0d0c7c5bb397b65873d", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long int a,b,temp,temp1,temp2,sum=0,sum1=0;\n int i;\n scanf(\"%ld\\n%ld\",&a,&b);\n if(a>b){\n temp=a-b;\n }\n else if(a\n\nint main(void)\n{\n\tint a[105]={0},i=1,j,flag=0,k=1;\n\n\tchar c;\n\n\tscanf(\"%c\",&c);\n\n\ta[0]=c-'0';\n\n\tgetchar();\n\n\twhile(1)\n\t{\n\t\tscanf(\"%c\",&c);\n\n\t\tif(c=='e') break;\n\n\t\tif(flag==0&&c!='0') flag=1;\n\n\t\ta[i]=c-'0';\n\n\t\ti++;\n\t}\n\n\tscanf(\"%d\",&j);\n\n\tif(j>=i-1) flag=0;\n\tprintf(\"%d\",a[0]);\n\n\twhile(k<=j)\n\t{\n\t\tprintf(\"%d\",a[k]);\n\t\tk++;\n\t}\n\n\tif(flag)\n\t{\n\t\tprintf(\".\");\n\t\twhile(k\n#include \nint main(void) {\n\tchar buff[105], *curr = buff, *start = buff;\n\tint ex, flag = 0;\n\t*curr++ = getchar();\n\tif (buff[0] == '0')\n\t\tflag = 1;\n\tgetchar(); // '.'\n\twhile ((*curr++ = getchar()) != 'e')\n\t\t;\n\tscanf(\"%d\", &ex);\n\t*--curr = '\\0';\n\t\n\tif (flag) {\n\t\tex--;\n\t\tmemmove(buff, buff + 1, curr - buff);\n\t\t--curr;\n\t}\n\tif (buff[0] == '0') {\n\t\tputs(\"0\");\n\t} else {\n\t\twhile (*--curr == '0')\n\t\t\t;\n\t\tif (ex < 0) {\n\t\t\tputchar('0');\n\t\t\tputchar('.');\n\t\t\twhile (++ex < 0)\n\t\t\t\tputchar('0');\n\t\t\twhile (start <= curr)\n\t\t\t\tputchar(*start++);\n\t\t} else {\n\t\t\twhile (ex >= 0 && start <= curr) {\n\t\t\t\tputchar(*start++);\n\t\t\t\tex--;\n\t\t\t}\n\t\t\twhile (ex-- >= 0)\n\t\t\t\tputchar('0');\n\t\t\tif (start <= curr) {\n\t\t\t\tputchar('.');\n\t\t\t\twhile (start <= curr)\n\t\t\t\t\tputchar(*start++);\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "strings", "implementation"], "code_uid": "85f21ccced9983303fc90f7101ed666a", "src_uid": "a79358099f08f3ec50c013d47d910eef", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n//1 \n//2 c(n, 2) * (2!-1)\n//3 c(n, 3) * (3!-1)\n//4 c(n, 4) * (4!-1)\n\nint\nmain() \n{\n int64_t n, k, r = 1, t;\n scanf(\"%\"SCNd64\"%\"SCNd64, &n, &k);\n if (n >= 2 && k >= 2) {\n t = n * (n-1) / 2;\n r += t;\n }\n if (n >= 3 && k >= 3) {\n t = n * (n-1) * (n-2) / 6 * 2;\n r += t;\n }\n if (n >= 4 && k >= 4) {\n t = n * (n-1) * (n-2) * (n-3) / 24 * 9;\n r += t;\n }\n printf(\"%\"PRId64\"\\n\", r);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "083ed02c148bec85c4dafa7a076787c5", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nlong long int calc(long long int n,long long int r){\n long long int sub = n - r,i;\n long long int result = 1;\n for(i=0;i\n\nint main (){\n\tint p,l,r,min;\n\tscanf(\"%d %d %d\", &p, &l, &r);\n\tif (p < l){\n\t\tmin = p;\n\t} else {\n\t\tmin = l;\n\t}\n\tif (r*2 > min){\n\t\tprintf(\"Second\");\n\t} else {\n\t\tprintf (\"First\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "games"], "code_uid": "7bfb2d2ffa91c9f0d2ef0e36e7cd2bd1", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,m,r;\n\tscanf(\"%d %d %d\",&n,&m,\n\t\t\t&r\n\t );\n\tint d=2*r;\n\tint row=n/d;\n\tint col=m/d;\n\tint y=row*col;\n\tif(y==0)\n\t\tprintf(\"Second\\n\");\n\telse\n\t\tprintf(\"First\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "games"], "code_uid": "0f7a201112cb72433d745bc869a76971", "src_uid": "90b9ef939a13cf29715bc5bce26c9896", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "# include \n\nint n;\nint a[16];\nint flag=0;\n\n//\ufffd\u01f9\ufffd\ufffd\u0332\ufffd\ufffd\u01fa\ufffd\ufffd\ufffd \nvoid dfs(int s,int sum){\n\tif(s==n){\n\t\tif(sum%360==0)flag=1;\n\t\treturn ;\n\t\t\n\t}\n\tdfs(s+1,sum+a[s]);\n\tif(flag) return ;\n\tdfs(s+1,sum-a[s]);\n\treturn ;\n } \nint main()\n{\t\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i\nint n;\nint num[20];\nint s=0;\nint q=0;\nvoid d(int x){\n\tif(x==n){\n\t\tif(s%360==0){\n\t\t\tprintf(\"YES\");\t\n\t q++;\n\t\t}\t\n\t\treturn;\n\t}\n\t\n\t\n\t\ts+=num[x];d(x+1);\n\t\ts-=num[x];\n\t\tif(q) return;\n\t s-=num[x];\n\t\td(x+1);\n\t\ts+=num[x];\n\t\treturn;\n\t}\n\t\n\n\nint main(){\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i\nint main() {\n int n,m;\n int i;\n scanf(\"%d%d\",&n,&m);\n int a[n+1];\n for(i=0;i\n#include\nint main()\n{\n int s[200];\n int n,m,bi,i,j;\n while(scanf(\"%d%d\",&n,&m)!=EOF)\n {\n memset(s,-1,sizeof(s));\n\n while(m--)\n {\n scanf(\"%d\",&bi);\n i=bi;\n while(i<=n)\n {\n if(s[i]==-1)\n s[i]=bi;\n i++;\n }\n\n }\n j=1;\n while(j\n\nint main()\n{\n long long n, a, b, c, ans, m, cnt;\n scanf(\"%I64d %I64d %I64d %I64d\", &n, &a, &b, &c);\n if(b - c >= a) {\n ans = n / a;\n } else {\n if(n < b) {\n ans = n / a;\n } else {\n m = n - (b - 1);\n cnt = m / (b - c);\n ans = cnt;\n n -= (b - c) * cnt;\n while(1) {\n cnt = n / b;\n if(cnt == 0) {\n break;\n }\n ans += cnt;\n n = n + (c - b) * cnt;\n }\n ans += n / a;\n }\n }\n printf(\"%I64d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "498c6eb77d80f6952509e0eeb4ddb233", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAX(A, B)\t((A) > (B) ? (A) : (B))\n\nint main() {\n\tlong long n, n_, a, b, c;\n\tlong long cnt1, cnt2, cnt3, cnt4;\n\n\tscanf(\"%lld\", &n);\n\tscanf(\"%lld\", &a);\n\tscanf(\"%lld\", &b);\n\tscanf(\"%lld\", &c);\n\tcnt1 = n / a;\n\tcnt3 = cnt1 / 2;\n\tn_ = n - cnt3 * a;\n\tcnt2 = n >= b ? 1 + (n - b) / (b - c) : 0;\n\tcnt3 += n_ >= b ? 1 + (n_ - b) / (b - c) : 0;\n\tn_ = n - cnt2 * (b - c);\n\tcnt4 = cnt2 + (n_ / a);\n\tprintf(\"%lld\\n\", MAX(MAX(MAX(cnt1, cnt2), cnt3), cnt4));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c50a406daf7b4988b23a32b685c250e4", "src_uid": "0ee9abec69230eab25de51aef0984f8f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\n int x=0,y=0,m,n,i;\n\n scanf(\"%d\",&m);\n\n if(m%2==0)\n {\n printf(\"NO\");\n return 0;\n }\n\n for(i=1; i<=m; i++)\n {\n scanf(\"%d\",&n);\n if(i==1 && n%2==1) x=1;\n if(i==m && n%2==1) y=1;\n }\n if(x==1 && y==1) printf(\"YES\");\n else printf(\"NO\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "cbd4a414704382d0eb2e9bc004868600", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "# include \nint main()\n{\n\tint a,b[300];\n\tscanf(\"%d\",&a);\n\tfor(int i=0;i\nint main()\n{\n ///while(1)\n {\n int i,a=0,b=0;\n char si[3][10],ans[3][2];\n for(i=0;i<3;i++)\n {\n scanf(\"%s\",&si[i]);\n }\n for(i=0;i<3;i++)///sorting\n {\n if(si[i][1]=='>')\n {\n ans[i][0]=si[i][0];\n ans[i][1]=si[i][2];\n }\n else if(si[i][1]=='<')\n {\n ans[i][0]=si[i][2];\n ans[i][1]=si[i][0];\n }\n /// printf(\"%s\\n\",ans[i]);///\n }///sorting\n for(i=1;i<3;i++)\n {\n if(ans[0][1]==ans[i][1])\n {\n a++;\n ///printf(\"%d\",ans[0][1]);\n }\n if(ans[0][0]==ans[i][0])\n {\n b++;\n ///printf(\"%d\",ans[0][1]);\n }\n }\n if(ans[0][0]!=ans[1][0]&&ans[0][0]!=ans[2][0] &&ans[1][0]!=ans[0][0]&&ans[1][0]!=ans[2][0] &&ans[2][0]!=ans[0][0]&&ans[2][0]!=ans[1][0])\n {\n printf(\"Impossible\\n\");\n }\n else\n {\n if(a==0)\n {\n printf(\"%c%c\",ans[1][1],ans[0][1]);\n }\n if(a>0)\n {\n if(ans[0][1]!=ans[1][1])\n printf(\"%c%c\",ans[0][1],ans[1][1]);\n else\n printf(\"%c%c\",ans[0][1],ans[2][1]);\n\n }\n if(b==0)\n {\n printf(\"%c\",ans[1][0]);\n }\n if(b>0)\n {\n printf(\"%c\",ans[0][0]);\n }\n printf(\"\\n\");\n\n }\n\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a879413621b52163d193d04307b351df", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n\n char str[4];\n\n int i,a[3],c=0,j;\n \n a[0]=0;\n a[1]=0;\n a[2]=0;\n\n for(i=0;i<3;i++){\n\n scanf(\"%s\",&str);\n\n if(str[1]=='>')\n a[str[0]-'A']++;\n else\n a[str[2]-'A']++;\n\n }\n\n for(i=0;i<3;i++){\n c=0;\n for(j=0;j<3;j++)\n {\n if(a[j]==i)\n c=1;\n\n }\n if(c==0)\n break;\n\n }\n\n if(c!=0)\n {\n\n for(i=0;i<3;i++)\n {\n\n for(j=0;j<3;j++)\n {\n if(a[j]==i)\n {\n printf(\"%c\",j+65);\n }\n }\n }\n printf(\"\\n\");\n\n }else\n printf(\"Impossible\\n\");\n\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c2bc64251ad8cbe1cbfcbbceca09e6c0", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "int n;\n\nmain(){\n scanf(\"%d\",&n);\n if(n==5) puts(\"1\");\n else printf(\"%d\\n\",n%3+1);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "2055c59205b607c0e20ca35b2f9f049a", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int i;\n scanf(\"%d\",&i);\n switch(i)\n {\n case 1: printf(\"2\");break;\n case 2: printf(\"3\");break;\n case 3: printf(\"1\");break;\n case 4: printf(\"2\");break;\n case 5: printf(\"1\");break;\n\n }\n return 0;\n }\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "a1a7c48a1d769ec27af7b8957586ba99", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#define max(a,b) a>=b?a:b\n#define min(a,b) a\n#include \n#include \n#include \n#include \n\nint N;\nchar Ans[100][100] = {\"\",\n\"Washington\", \"Adams\", \"Jefferson\", \"Madison\", \"Monroe\",\n\"Adams\", \"Jackson\", \"Van Buren\", \"Harrison\", \"Tyler\",\n\"Polk\", \"Taylor\", \"Fillmore\", \"Pierce\", \"Buchanan\",\n\"Lincoln\", \"Johnson\", \"Grant\", \"Hayes\", \"Garfield\",\n\"Arthur\", \"Cleveland\", \"Harrison\", \"Cleveland\", \"McKinley\",\n\"Roosevelt\", \"Taft\", \"Wilson\", \"Harding\", \"Coolidge\",\n\"Hoover\", \"Roosevelt\", \"Truman\", \"Eisenhower\", \"Kennedy\",\n\"Johnson\", \"Nixon\", \"Ford\", \"Carter\", \"Reagan\"\n};\n\nint main(){\n scanf(\"%d\", &N);\n \n printf(\"%s\\n\", Ans[N]);\n \n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "21eaa7cbd832e8a0839359894fa9bb3e", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long mod=1e9+7;\nlong long int power(long long a,long long b)\n{ long long ans=1;\nwhile(b>0){\n if(b%2==1)ans=((ans%mod)*(a%mod))%mod;\n a=((a%mod)*(a%mod))%mod;\n b=b/2;} \n return ans; }\nint main()\n{long long x,y;\n scanf(\"%lld %lld\",&x,&y);\n long long int yes=power((power(2,y)-1),x);\n printf(\"%lld\\n\",yes); \n\n return 0;\n\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "fe104a3a17e04cf423d260326aba9800", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\ntypedef long long slong;\nslong mod=1e9+7;\nslong quick_power(slong a,slong b){\n slong res=1;\n while(b!=0){\n if(b&1){\n res=res*a%mod;\n }\n a=a*a%mod;\n b>>=1;\n }\n return res;\n}\nmain(){\n slong n,m;\n scanf(\"%lld%lld\",&n,&m);\n printf(\"%lld\",quick_power((quick_power(2,m)-1),n));\n //system(\"pause\");\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "ce815b6a92c1f615ca6f7e2adfffa5bf", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\n int x,i,j,t,n,a[55];\n\n scanf(\"%d\",&x);\n\n for(i=0;i=i;j--)\n if(a[j-1]>a[j]){\n t=a[j-1];\n a[j-1]=a[j];\n a[j]=t;\n }\n n=0;\n for(i=1;i\n int main()\n {\n int n,i,a[55],j,s,check=0,k; //s=sort\n scanf(\"%d\",&n);\n for(i=0;ia[j]){\n s=a[i];\n a[i]=a[j];\n a[j]=s;\n }\n }\n }\n for(i=0;i\nint main()\n{\n\tint n, i;\n\tint days[7];\n\tscanf(\"%d\", &n);\n\tfor(i=0; i<7; i++)\n\t{\n\t\tscanf(\"%d\", &days[i]);\n\t\tn-=days[i];\n\t\tif(n<=0)\n\t\t\tbreak;\n\t}\n\twhile(n>0)\n\t{\n\t\tif(i<6)\n i++;\n else\n i = 0;\n\t\tn-=days[i];\n\t}\n\t//printf(\"%d\\n\", (n==0) ? i : i+1);\n\tprintf(\"%d\\n\", i+1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "674d830cdd221b44219b3c03ce127f9d", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include\n#include\nlong long int max(long long int a,long long int b){\n if(a>b){\n return a;\n }\n return b;\n}\nlong long int cmp(const void *a,const void *b){\n return *(long long int *)b-*(long long int*)a;\n}\nint main()\n{\n long long int i,j,test,k,m,l,r,flag=0,max=0,n,m1,m2,x,sum=0,ans=0,count, a[10000]={0},b[1000]={0};\nscanf(\"%lld\",&n);\nsum=0;\nfor(i=0;i<8;i++){\n scanf(\"%lld\",&a[i]);\n sum+=a[i];\n}\n//printf(\"%lld\\n\",sum);\ncount=1;\ni=0;\n while(n-a[i]>0 && i<7){\n count++;\n // printf(\"%lld %lld\\n\",a[i],sum);\n n=n-a[i];\n i++;\n if(count==8){\n count=1;\n }\n if(i==7){\n i=0;\n }\n }\n \n printf(\"%lld\",count);\n\n\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3c64464f2b118de196c442c0ec886d6e", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main ()\n{\n unsigned long long a,b,c;\n scanf(\"%llu%llu\",&a,&b);\n c=a/b;\n if(c%2==0)printf(\"NO\\n\");\n else printf(\"YES\\n\");\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "07a4e6e3f0d8b3fb127df70d63b659ce", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n long long int a,b;\n scanf(\"%lld %lld\", &a, &b);\n if((a/b)%2 == 0)\n printf(\"NO\");\n else\n printf(\"YES\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "53737963f425af77ec6e2fc858e2308a", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint isfloat(float num);\nint solve_equation(double per);\n\nint main()\n{\n int per;\n scanf(\"%d\",&per);\n if(per%2==0)\n printf(\"%d\",((per/2-1)-(per/2-1)%2)/2);\n else\n printf(\"0\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "f2c3d3a76b13270b6982b6fa0d7ef271", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n%2==1)printf(\"%d\",0);\n else\n {\n if(n%4!=0)printf(\"%d\",n/4);\n else\n printf(\"%d\",n/4-1);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "a4e3762dd595691d5703519b77aa100f", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nint main()\n{\n float a[4],b[2];\n int i,j;\n scanf(\"%f %f %f %f %f\",&a[0],&a[1],&a[2],&b[0],&b[1]);\n a[0]=a[0]+a[1]/60+a[2]/3600;\n a[1]=a[1]+a[2]/60;\n a[1]/=5;\n a[2]/=5;\n for(i=0;i<3;i++)\n {\n for(j=0;j<2;j++)\n {\n if(a[j]>a[j+1])\n {\n a[3]=a[j];\n a[j]=a[j+1];\n a[j+1]=a[3];\n }\n }\n }\n //printf(\"/n%f %f %f %f %f\",a[0],a[1],a[2],b[0],b[1]);\n if(((b[0]>a[0] && b[0]a[0] && b[1]a[1] && b[0]a[1] && b[1]a[2] || b[0]a[2] || b[1]\n#include \n\nint main()\n{\n float hours, minuites, seconds, hour1, hour2, help ;\n\n //printf(\"Enter the hours: \\n \");\n scanf(\"%f\",&hours);\n // printf(\"Enter the minuites:\\n \");\n scanf(\"%f\",&minuites);\n // printf(\"Enter the seconds: \\n \");\n scanf(\"%f\",&seconds);\n // printf(\"Enter the first hour: \\n \");\n scanf(\"%f\",&hour1);\n // printf(\"Enter the second hour: \\n \");\n\n scanf(\"%f\",&hour2);\n\n hours *= 5;\n hour1 *= 5;\n hour2 *= 5;\n\n\n minuites = minuites + (seconds / 60);\n hours = hours + (minuites / 60) + (seconds / 60);\n\n if(hour1 > hour2 ){\n help = hour1;\n hour1 = hour2;\n hour2 = help;\n }\n\n if((seconds >= hour1 && seconds <= hour2) ||(minuites >= hour1 && minuites <= hour2) || (hours >= hour1 && hours <= hour2)){\n if((seconds > hour1 && minuites > hour1 && hours > hour1) && (seconds < hour2 && minuites < hour2 && hours < hour2)){\n printf(\"YES\");\n }\n else{\n printf(\"NO\");\n }\n }\n else{\n printf(\"YES\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "81bb42741577bce4ef3b129956b77caa", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,arr[101],i,c1=0;\n scanf(\"%d\",&n);\n for(i=0; i\n\n\nint main(){\n int n, sta = 0, res = 0;\n int a[102];\n scanf(\"%d\", &n);\n int i;\n for (i = 1; i <= n; i++)\n scanf(\"%d\", &a[i]);\n a[n+1] = 0;\n for (i = 1; i <= n; i++)\n {\n if (sta == 0)\n if (a[i] == 1) sta = 1;\n if (sta == 1)\n if (a[i] == 0 && a[i+1] == 0) sta = 0;\n if (sta == 1) res++;\n\n }\n printf(\"%d\", res);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a28199837e571c0698b8cf21e70a81b6", "src_uid": "2896aadda9e7a317d33315f91d1ca64d", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n #include\n#include\nint main(){\n\tchar a[201];\n\tscanf(\"%s\",a);\n\tint i,j,k,p;\n\tp=strlen(a);\n\ti=0;\n\twhile(i\n#include\nint main()\n{\n\n int i,j=0,l1;\n char str1[230],str2[230];\n gets(str1);\n l1=strlen(str1);\n for(i=0;i\n#include \nint main(void) {\n\tchar c[101];\n\tscanf(\"%s\",c);\n\tint i,j;\n\tint n = strlen(c);\n\tint dp[100][2]={0},num_q = 0, num_a = 0, ans = 0;\n\tfor(i=n-1;i>=0;i--)\n\t{\n\t if(c[i] == 'Q')\n\t {\n\t num_q++;\n\t }\n\t if(c[i] == 'A')\n\t {\n\t dp[i][0] = 1;\n\t dp[i][1] = num_q;\n\t }\n\t}\n\tfor(i=0;i\n#include\nint main()\n{\n char don[1000];\n scanf(\"%s\",&don);\n int i,count=0,j,k,l,len=0;\n len=strlen(don);\n for(i=0; i\n#include\n#include\n#include\nint main()\n{ char s[100];\n\tlong long int l,i,o,j,t=0;\n\tscanf(\"%s\",s);\n\tl=strlen(s); \n\tif(l<2) printf(\"0\"); else {\n\tfor(i=0; i\n//using namespace std;\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\n\nint main()\n{\n\tchar str[105];\n\tSCS(str);\n\tll len=SZ(str);\n\tFORD(i,len-1,1)\n\t{\n\t\tif(str[i]=='1')\n\t\t{\n\t\t\tlen++;\n\t\t\tbreak;\n\t\t}\n\t}\n\tPF1(len/2);\n return 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 main()\n{\n int n,m,max,min,add,k,i,j,p=0,temp,t;\n scanf(\"%d\",&n);\n scanf(\"%d\",&m);\n\n int a[100];\n\n for(i=0; i\n\nint main () \n{\n\tint n,m,a[105],b[105],min=1,max=1,temp,sum=0,num,num3,num2;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d\",&m);\n\n\tfor (int i=0;i=m)\n\t\t{\n\t\t\tprintf(\"%d %d\",max,(max+m));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnum2=m-sum;\n\t\t\tif(num2%n==0)\n\t\t\t{num3=(num2/n);}\n\t\t\telse{num3=(num2/n)+1;}\n\n\t\t\tprintf(\"%d %d\",(max+num3),(max+m));\n\t\t}\n\t}\n\treturn 0;\t\n}\n\n\n", "lang_cluster": "C", "tags": ["implementation", "binary search"], "code_uid": "a405915cd47357b3243ca63e0db7209b", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,c=0,k=1;\n scanf(\"%d\",&n);\n while(k<=n)\n {\n \n if(k==n)\n {\n c++;\n printf(\"YES\");\n break;\n }\n k*=2;\n }\n if(c==0)\n printf(\"NO\");\n return(0);\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e936cb80345b2beca44da062720721f5", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int n,i,j,state=1;\n scanf(\"%d\",&n);\n int circle[n];\n int flea=1;\n for(i=0;i\n#include\nint main()\n{\n char a[100];\n int b[27],i,n=0,c;\n for(i=1;i<27;i++)\n {\n b[i]=0;\n }\n scanf(\"%s\",a);\n for(i=0;i\n#include\nint main()\n{\n\tchar ch[120];\n\tint hc[26];\n\tint chlen, i, j=0;\n\twhile (scanf(\"%s\", ch) != EOF)\n\t{\n\t\tfor (i = 0; i < 26; ++i)\n\t\t\thc[i] = 0;\n\t\tchlen = strlen(ch);\n\t\tfor (i = 0; i < chlen; ++i)\n\t\t\thc[ch[i] - 97] += 1;\n\t\tfor (i = 0; i < 26; ++i)\n\t\t\tif (hc[i] >= 1)\n\t\t\t\tj += 1;\n\t\tif (j % 2 == 0)\n\t\t\tprintf(\"CHAT WITH HER!\\n\");\n\t\tif (j % 2 != 0)\n\t\t\tprintf(\"IGNORE HIM!\\n\");\n\t\tj = 0;\n\t}\n\treturn 0;\n}\n \t\t \t\t \t\t\t\t \t \t \t \t\t\t\t\t", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "ef3a5eb55580f82f316b37846a2eb14d", "src_uid": "a8c14667b94b40da087501fd4bdd7818", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nchar arr[100];\nint main()\n{\n int i,n,count=0;\n scanf(\"%d%s\",&n,arr);\n for(i=0;i\n#include\n#include\nint main()\n{\n char a[500];\n int b,p=0,q=0,n,c,i;\n scanf(\"%d\",&n);\n scanf(\"%s\",&a);\n for(i=0; i\nmain()\n{\n unsigned long long int n,k;\n scanf(\"%llu\",&n);\n scanf(\"%llu\",&k);\n if (k <= (n + 1) / 2)\n {\n printf(\"%llu\",k*2-1);\n }\n else\n {\n printf(\"%llu\",(k-(n+1)/2)*2);\n }\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "ca82a5a76c8d3d9a67e76bc041b10fb4", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n long long int n,k,b;\n scanf(\"%lld%lld\",&n,&k);\n n=(n+1)/2;\n b=k>n?2*(k-n):(2*k)-1;\n printf(\"%lld\",b);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "654c7f322e5adfb351e9313328790436", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\t//freopen(\"in.txt\", \"r\", stdin);\n\tint result, totaltime, scorea, scoreb, costa, costb;\n\tscanf(\"%d%d%d%d%d%d\", &result, &totaltime, &scorea, &scoreb, &costa, &costb);\n\tif(scorea == result || scoreb == result || result == 0 || scorea > result && (scorea - result)%costa == 0 && (scorea - result)/costa < totaltime || scoreb > result && (scoreb - result)%costb == 0 && (scoreb - result)/costb < totaltime){\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif(scorea + scoreb >= result){\n\t\tint i, cura = scorea, curb;\n\t\tfor(i=0;i\nint main()\n{\n int x,t,a,b,c,d,i=0,q1=0,q2=0,j=0;\n scanf(\"%d %d %d %d %d %d\",&x,&t,&a,&b,&c,&d);\n /*if(x==0 || x==a ||x==b)\n {\n printf(\"YES\");\n return 0;\n }*/\n while(i=0)\n {\n q1=a-i*c;\n j=0;\n while(j=0)\n {\n q2=b-j*d;\n if((q1+q2)==x || q1==x || q2==x || x==0)\n {\n printf(\"YES\");\n return 0;\n }\n j++;\n }\n i++;\n }\n printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b383f1cf177309c3a6668bdbf88c0a95", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int y=0, w=0, max = 0, A = 0, B = 0;\n scanf(\"%d %d\", &y, &w);\n\t\n\tmax = (y>=w)?y:w;\n\tA = (6 - max) + 1;\n\t\n\tswitch (A)\n\t{\n\t\tcase 6: A= 1; B = 1; break;\n\t\tcase 4: A= 2; B = 3; break;\n\t\tcase 3: A= 1; B = 2; break;\n\t\tcase 2: A= 1; B = 3; break;\n\t\tcase 0: A= 0; B = 1; break;\n\t\tdefault : B = 6;\n\t}\n \n printf(\"%d/%d\", A,B);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "probabilities"], "code_uid": "4f675014b4b68fc4969b221e5f06807e", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,i,j,k,a,yak,wak;\n scanf(\"%d %d\",&yak,&wak);\n if(yak>=wak){\n k=(6-yak)+1;\n switch(k){\n case 5:\n printf(\"5/6\");\n break;\n case 4:\n printf(\"2/3\");\n break;\n case 3:\n printf(\"1/2\");\n break;\n case 2:\n printf(\"1/3\");\n break;\n case 1:\n printf(\"1/6\");\n break;\n case 0:\n printf(\"0/1\");\n break;\n default:\n printf(\"1/1\");\n }\n }\n else if(yak<=wak){\n k=(6-wak)+1;\n switch(k){\n case 5:\n printf(\"5/6\");\n break;\n case 4:\n printf(\"2/3\");\n break;\n case 3:\n printf(\"1/2\");\n break;\n case 2:\n printf(\"1/3\");\n break;\n case 1:\n printf(\"1/6\");\n break;\n case 0:\n printf(\"0/1\");\n break;\n default:\n printf(\"1/1\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "probabilities"], "code_uid": "cabf051ba4535f7fa55d6676e87aee9e", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int voter[100];\n int pupil;\n int i,j,k;\n int opo=0;\n int res=0;\n\n scanf(\"%d\",&pupil);\n\n for(i=0; i=voter[j])\n {\n int temp;\n temp = voter[i];\n voter[i] = voter[j];\n voter[j] = temp;\n }\n }\n }\n\n k = voter[pupil-1]-1;\n\n while(k+=1)\n {\n for(i=0; iopo)\n {\n printf(\"%d\",k);\n return 0;\n }\n else\n {\n res = 0;\n }\n\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "7518dd03cc3d1ef404929e89e68a60b2", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n int i,n,a[100],sum=0,new_sum=0,max,val;\n \n scanf(\"%d\",&n);\n \n for(i=0;isum){\n printf(\"%d\\n\",max);\n }\n \n else{\n cal:\n new_sum=0;\n max=max+1;\n for(i=0;isum){\n printf(\"%d\\n\",max);\n }\n else{\n goto cal;\n }\n }\n \n \n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "1e8da1981d537dfb0404da3af06791e0", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\n#include\r\nint main()\r\n{\r\n\tint t;\r\n\tscanf(\"%d\",&t);\r\n\twhile(t--)\r\n\t{\r\n\t\tint count=0;\r\n\t\tint arr[2][2];\r\n\t\tfor(int i=0;i<2;i++)\r\n\t\t{\r\n\t\t\tfor(int j=0;j<2;j++)\r\n\t\t\t{\r\n\t\t\t\tscanf(\"%d\",&arr[i][j]);\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor(int i=0;i<2;i++)\r\n\t\t{\r\n\t\t\tfor(int j=0;j<2;j++)\r\n\t\t\t{\r\n\t\t\t\tif(arr[i][j]==1)\r\n\t\t\t\t{\r\n\t\t\t\t\tcount++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t//printf(\"count=%d\\n\",count);\r\n\t\tif(count>=1 && count<4)\r\n\t\t{\r\n\t\t\tprintf(\"1\\n\");\r\n\t\t}\r\n\t\telse if(count==0)\r\n\t\t{\r\n\t\t\tprintf(\"0\\n\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tprintf(\"2\\n\");\r\n\t\t}\t\r\n\t}\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e883eaff2501ab874b5196fcad540152", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\nint main()\r\n{\r\n int t;\r\n scanf(\"%d\", &t);\r\n while(t--){\r\n int a,b,c,d,e;\r\n scanf(\"%d%d\", &a,&b);\r\n scanf(\"%d%d\", &c,&d);\r\n e=a+b+c+d;\r\n if(e==1){\r\n printf(\"1\\n\");\r\n }\r\n else if(e==2){\r\n printf(\"1\\n\");\r\n }\r\n else if(e==3){\r\n printf(\"1\\n\");\r\n }\r\n else{\r\n printf(\"%d\\n\", e/2);\r\n }\r\n }\r\n\r\n return 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2378e673f8d73dfd05de8dc5625a325d", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i, j, k, l, d, temp, x, y, n, t, v_1, v_2, ans;\n int ara[1000];\n scanf(\"%d %d\", &v_1, &v_2);\n scanf(\"%d %d\", &t, &d);\n ara[1] = v_1;\n ara[t] = v_2;\n\n for(i = 2, ans = 0; i <= t - 1; i++){\n ara[i]= ara[i - 1] + d;\n if(((t - i) * d) < (ara[i] - ara[t])){\n ara[i] = ara[i] - (ara[i] - ara[t]) + (t - i) * d;\n }\n ans = ans + ara[i];\n }\n ans =ans + ara[1] + ara[t];\n\n printf(\"%d\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "46418e6ce1dc758d8fade9a3af54eed1", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n\n#define SET(a,b) memset(a,b,sizeof(a))\n#define scan(n) scanf(\"%d\",&n)\n#define print(n) printf(\"%d\\n\",n)\n#define scanl(n) scanf(\"%lld\",&n)\n#define printl(n) printf(\"%lld\\n\",n)\n\n//stacks\n/*void push(int n,int ar[],int i)\n{\n ar[i]=n;\n i++;\n}\nvoid pop(int ar[],int i)\n{\n if(i>0)\n {\n ar[i-1]=0;\n i--;\n }\n}*/\n\n//queues\n/*void qpush(int ar[],int val,int head,int tail,int range)\n{\n if(head==tail)\n {\n ar[head]=val;\n if(tail+1==range)\n tail=0;\n else\n tail++;\n }\n else\n {\n ar[tail]=val;\n if(tail+1==range)\n tail=0;\n else\n tail++;\n }\n if(tail==head)\n {\n if(head+1==range)\n head=0;\n else\n head++;\n }\n}\n\nvoid qpop(int head,int tail,int range)\n{\n if(head+1==range)\n head=0;\n else\n head++;\n}*/\n\n//pow\n/*int fun(int a,int b,int m)\n{\n if(b==0)\n return 1;\n int d,x;\n d=fun(a,b/2,m);\n x=(d*d)%m;\n if(b%2==0)\n return x;\n else\n return (x*a%m)%m;\n}\n*/\n//bst\n/*typedef struct tree\n{\n int val;\n struct tree *l;\n struct tree *r;\n}node;\n//node *head;\nnode *insert(int x,node *root)\n{\n if(root==NULL)\n {\n root=(node *)malloc(sizeof(node));\n root->val=x;\n }\n else\n {\n if(x<=root->val)\n {\n if(root->l==NULL)\n {\n root->l=(node *)malloc(sizeof(node));\n root->l->val=x;\n }\n else\n root->l=insert(x,root->l);\n }\n else\n {\n if(root->r==NULL)\n {\n root->r=(node *)malloc(sizeof(node));\n root->r->val=x;\n }\n else\n {\n root->r=insert(x,root->r);\n }\n }\n }\n return root;\n}\nnode *find(int x,node *root)\n{\n if(root==NULL)\n {\n return 0;\n }\n else\n {\n if(x==root->val)\n return root;\n else if(xval)\n {\n if(root->l==NULL)\n {\n return 0;\n }\n else\n {\n find(x,root->l);\n }\n }\n else\n {\n if(root->r==NULL)\n {\n return 0;\n }\n else\n {\n find(x,root->r);\n }\n }\n }\n}\n\nvoid inorder(node *root)\n{\n if(root==NULL)\n {\n return;\n }\n if(root->l==NULL)\n {\n printf(\"%d\",root->val);\n if(root->r==NULL)\n return;\n else\n inorder(root->r);\n }\n else\n {\n inorder(root->l);\n printf(\"%d\",root->val);\n if(root->r==NULL)\n return;\n else\n inorder(root->r);\n }\n}\nvoid preorder(node *root)\n{\n if(root==NULL)\n {\n return;\n }\n else\n {\n printf(\"%d\",root->val);\n preorder(root->l);\n preorder(root->r);\n }\n}\n\nvoid postorder(node *root)\n{\n if(root==NULL)\n {\n return;\n }\n else\n {\n postorder(root->l);\n postorder(root->r);\n printf(\"%d\",root->val);\n }\n}\n*/\n//adjacency list\n/*typedef struct ll\n{\n int val;\n struct ll *next;\n}nd;\n\n//n *ar[100001];\nvoid insert(int a,int b)\n{\n if(ar[a]==NULL)\n {\n ar[a]=(nd *)malloc(sizeof(nd));\n ar[a]->val=b;\n ar[a]->next=NULL;\n }\n else\n {\n nd *temp=(nd *)malloc(sizeof(nd)),*t;\n temp->val=b;\n temp->next=ar[a];\n ar[a]=temp;\n }\n}\n\n//dfs\n//int state[100001];\nvoid dfs(int a)\n{\n state[a]=1;\n count++;\n nd *temp=ar[a];\n while(temp!=NULL)\n {\n if(state[temp->val]!=1)\n dfs(temp->val);\n temp=temp->next;\n }\n return;\n}*/\n\n//dijkstra + heaps\n/*typedef struct ll2\n{\n int val;\n int weight;\n struct ll2 *next;\n}nde;\n*/\n//nde *ar[500005];\n//int state[500005];\n\n/*void insert(int a,int b,int w)//insert to adjacency list\n {\n if(ar[a]==NULL)\n {\n ar[a]=(node *)malloc(sizeof(node));\n ar[a]->val=b;\n ar[a]->weight=w;\n ar[a]->next=NULL;\n }\n else\n {\n node *temp=(node *)malloc(sizeof(node)),*t;\n temp->val=b;\n temp->weight=w;\n temp->next=ar[a];\n ar[a]=temp;\n }\n }*/\n\n//int pt[500005],d[500005];\n//int heap[500005][2];\n//int ptr;\n/*void decpty(int val,int pos)//decrease priority\n{\n heap[pos][0]=val;\n int x=pos;\n while(x>0)\n {\n if(heap[x][0]>=heap[x/2][0])\n break;\n else\n {\n pt[heap[x][1]]=x/2;\n pt[heap[x/2][1]]=x;\n int temp=heap[x][0],t2=heap[x][1];\n heap[x][0]=heap[x/2][0];\n heap[x][1]=heap[x/2][1];\n heap[x/2][0]=temp;\n heap[x/2][1]=t2;\n x=x/2;\n }\n }\n}\n\nvoid hinsert(int val,int val2)//insert to heap\n{\n heap[ptr][0]=val;\n heap[ptr][1]=val2;\n pt[val2]=ptr;\n int x=ptr;\n ptr++;\n while(x>0)\n {\n if(heap[x][0]>=heap[x/2][0])\n break;\n else\n {\n pt[heap[x][1]]=x/2;\n pt[heap[x/2][1]]=x;\n int temp=heap[x][0],t2=heap[x][1];\n heap[x][0]=heap[x/2][0];\n heap[x][1]=heap[x/2][1];\n heap[x/2][0]=temp;\n heap[x/2][1]=t2;\n x=x/2;\n }\n }\n}\n\nint hdeletemin()//delete min elem from heap\n{\n int ret;\n ret=heap[1][1];\n pt[heap[1][1]]=-1;\n pt[heap[ptr-1][1]]=1;\n heap[1][0]=heap[ptr-1][0];\n heap[1][1]=heap[ptr-1][1];\n ptr--;\n int x=1;\n while(x=ptr)\n {\n if(2*xval;\n if(d[v]+temp->weight < d[w])\n {\n d[w]=d[v]+temp->weight;\n decpty(d[w],pt[w]);\n }\n temp=temp->next;\n }\n }\n}*/\n\n/*int main()\n {\n int n,m,u,v,w,i;\n scanf(\"%d%d\",&n,&m);\n for(i=0;i<=n;i++)\n state[i]=0;\n while(m--)\n {\n scanf(\"%d%d%d\",&u,&v,&w);\n insert(u,v,w);\n }\n scanf(\"%d%d\",&u,&v);\n ptr=1;\n hinsert(0,u);\n d[u]=0;\n for(i=1;i<=n;i++)\n {\n if(i!=u)\n {\n hinsert(1000000000,i);\n d[i]=1000000000;\n }\n }\n dikstra(u,v);\n if(d[v]==1000000000)\n printf(\"NO\\n\");\n else\n printf(\"%d\\n\",d[v]);\n return 0;\n }*/\n\n//kruskal + dsu\n\n//int dsu[N];\n/*int find(int x)\n{\n if(dsu[x]==x)return x;\n return dsu[x] = find(dsu[x]);\n}\n\nvoid Union(int a,int b)\n{\n if(a==b)\n return;\n dsu[a] = b;\n}\n\ntypedef struct edge\n{\n int u,v;\n int weight;\n}edge;\n*/\n//edge e[N];\n/*int cmp(const void *a,const void *b)\n {\n return ((edge*)a)->weight - ((edge*)b)->weight;\n }*/\n/*int main()\n {\n int i;\n int n,m;\n scanf(\"%d %d\\n\",&n,&m);\n for(i=0;i=1;i--)\n {\n range[i]=range[i+1]+d;\n }\n int ans=0;\n for(i=1;i\nint main()\n{\n int n,i,j,ck=0,k,tmp,br=0;\n int c[100];\n scanf(\"%d\",&n);\n for(i=0;ic[j]) {\n ck++;\n }\n }\n if(ck==n-1) printf(\"0\");\n else {\n for(j=1;j\n\nint main(void)\n{\n int n, i, max = 0, position, count = 0;\n int a[100];\n\n scanf(\"%d %d\", &n, &a[0]);\n for (i = 1; i < n; i ++)\n {\n scanf(\"%d\", &a[i]);\n if (a[i] > max)\n {\n max = a[i];\n position = i;\n }\n }\n\n while (a[0] <= max)\n {\n a[0]++;\n a[position]--;\n count++;\n max = 0;\n for (i = 1; i < n; i ++)\n if (a[i] > max)\n {\n max = a[i];\n position = i;\n }\n }\n\n printf(\"%d\", count);\n\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "a058301824b941f4f55814695c9bb96c", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,s,i,k,j,x,y;\n scanf(\"%d %d\",&n,&s);\n if(n==1&&s==0)\n {\n printf(\"0 0\");\n }\n else if(s>n*9||s<1)\n {\n printf(\"-1 -1\");\n }\n else\n {\n if(s>(n-1)*9)\n {\n printf(\"%d\",s-(n-1)*9);\n x=s-(n-1)*9;\n for(i=1; i\n\nint main(void) {\n\n double dig = 0;\n double sum = 0;\n int i = 0;\n int sum1 = 0;\n int nine = 0;\n int strg = 0;\n int zero = 0;\n scanf(\"%lf %lf\",&dig,&sum);\n\n if((sum/9<=dig&&sum!=0)||(sum==0&&dig==1)){\n sum1 = (int)sum;\n //mini\n nine = (sum1-1)/9;\n strg = (sum1-1)%9;\n zero = (dig-1)-nine;\n if(dig-nine==1){printf(\"%d\",strg+1);\n for(i=0;i\n#include \n\n#define N\t1000000\n#define M\t1000000\n#define K\t20\n\nint aa[N + 1], kk[N + 1];\n\nvoid init() {\n\tint a, b, b_, k;\n\n\tfor (a = 2; a <= N; a++) {\n\t\tif (aa[a])\n\t\t\tcontinue;\n\t\tb = 1, b_ = N / a, k = 0;\n\t\twhile (b <= b_) {\n\t\t\tb *= a, k++;\n\t\t\taa[b] = a, kk[b] = k;\n\t\t}\n\t}\n}\n\nint main() {\n\tstatic char used[M * K + 1];\n\tstatic int cc[K + 1];\n\tint n, m, a, b, b_, j, k, cnt;\n\tlong long ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &m);\n\tcnt = 0;\n\tfor (k = 1; k <= K; k++) {\n\t\tfor (j = 1; j <= m; j++)\n\t\t\tif (!used[j * k])\n\t\t\t\tused[j * k] = 1, cnt++;\n\t\tcc[k] = cnt;\n\t}\n\tans = 1;\n\tfor (a = 2; a <= n; a++)\n\t\tif (aa[a] == a) {\n\t\t\tb = 1, b_ = n / a, k = 0;\n\t\t\twhile (b <= b_)\n\t\t\t\tb *= a, k++;\n\t\t\tans += cc[k];\n\t\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "number theory"], "code_uid": "8cd5f90b899ddddbad02f85f6d58a730", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.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": "97cb0bff8765a015985010362f6bf701", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int sh, sm, th, tm, ph, pm;\n scanf(\"%d:%d\", &sh, &sm);\n scanf(\"%d:%d\", &th, &tm);\n ph=sh-th;\n pm=sm-tm;\n if(pm<0)\n {\n pm+=60;\n ph-=1;\n }\n if(ph<0)\n ph+=24;\n printf(\"%02d:%02d\\n\", ph, pm);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "17a2a20b19f35dc1421410444a430758", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main(){\n\nint horasF, minutosF, horasI, minutosI, horas, minutos;\n\nscanf(\"%d:%d\", &horasF, &minutosF);\nscanf(\"%d:%d\", &horasI, &minutosI);\n\nif(horasF == horasI && minutosI == minutosF){\n horas = 0;\n minutos = 0;\n\n}\n\nif(horasI == horasF){\n\n horas = 0;\n\n if(minutosI < minutosF)\n minutos = minutosF - minutosI;\n if(minutosI > minutosF){\n minutos = 60 + ( minutosF - minutosI );\n horas = 23;\n }\n if(minutosI == minutosF)\n minutos = 0;\n}\n\nif(horasI > horasF){\n if(minutosI < minutosF){\n minutos = minutosF - minutosI;\n horas = 24 + ( horasF - horasI); \n }\n if(minutosI > minutosF){\n minutos = 60 + ( minutosF - minutosI );\n horas = 23+( horasF - horasI); \n }\n if(minutosI == minutosF){\n minutos = 0;\n horas = 24 + ( horasF - horasI); \n }\n \n}\n\nif(horasI < horasF){\n horas = horasF - horasI;\n if(minutosI < minutosF)\n minutos = minutosF - minutosI;\n if(minutosI > minutosF){\n minutos = 60 + ( minutosF - minutosI );\n horas = horasF - horasI -1;\n }\n if(minutosI == minutosF)\n minutos = 0;\n \n\n}\n\n\n\n \n\nif( horas<10 && minutos <10)\n printf(\"0%d:0%d\\n\", horas, minutos);\nelse if( horas<10 )\n printf(\"0%d:%d\\n\", horas, minutos);\nelse if( minutos<10 )\n printf(\"%d:0%d\\n\", horas, minutos);\nelse\n printf(\"%d:%d\\n\", horas, minutos); \n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6e043be891aff6b9f18d7883b48757a5", "src_uid": "595c4a628c261104c8eedad767e85775", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n#include\nint main()\n{\n int a,b,c,x1,x2;\n scanf(\"%d %d %d\",&a,&b,&c);\n if(a>b)\n {\n x1=a-b;\n if(x1>c)\n {\n printf(\"+\");\n }\n if(x1<=c)\n {\n printf(\"?\");\n }\n }\n if(ac)\n {\n printf(\"-\");\n }\n if(x2<=c)\n {\n printf(\"?\");\n }\n }\n if(a-b==0 && c!=0)\n {\n printf(\"?\");\n }\n if(a-b==0 && c==0)\n {\n printf(\"0\");\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "922ab8bb6b7ef79ecea15a8cb0b3e688", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int z,y,x,j;\n scanf(\"%d %d %d\",&x,&y,&z);\n \n if(x>y && x-y>z)\n printf(\"+\\n\"); \n else if(y>x && y-x>z)\n printf(\"-\\n\");\n else if(x==y && z==0)\n printf(\"0\\n\");\n else if(x==0 && y==0 && z==0)\n printf(\"0\\n\");\n else\n printf(\"?\\n\");\n\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "1c37ae75efa68ca624b28f1a6b7ecc85", "src_uid": "66398694a4a142b4a4e709d059aca0fa", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct candy{\n\tint qnt;\n\tint laps;\n\tint sobra;\n};\n\n\nint main(){\n\tint i;\n\tint n, m;\n\tstruct candy vetor[100];\n\tint maxlaps;\n\tint result;\n\tint flag=0;\n\t\n\tscanf(\"%d %d\", &n, &m);\n\t\n\tfor(i = 0; i < n; i++){\n\t\tscanf(\"%d\", &vetor[i].qnt);\n\t\tvetor[i].laps = vetor[i].qnt / m;\n\t\t\n//\t\tprintf(\"Laps posicao %d = %d\\n\", i, vetor[i].laps);\n\t\t\n\t\tif(i == 0){\n\t\t\tmaxlaps = vetor[i].laps;\n\t\t}\n\t\telse if(vetor[i].laps > maxlaps){\n\t\t\tmaxlaps = vetor[i].laps;\n\t\t}\n\t}\n\t\n//\tprintf(\"maxlaps = %d\\n\", maxlaps);\n\t\n\tfor(i = 0; i < n; i++){\n\t\tif(vetor[i].laps == maxlaps){\n\t\t\tif(vetor[i].qnt % m > 0){\n\t\t\t\tresult = i;\n\t\t\t\tflag = 1;\n\t\t\t}\n\t\t\telse if(vetor[i].qnt % m == 0 && flag == 0){\n\t\t\t\tresult = i;\n\t\t\t}\n\t\t}\n\t\telse if(vetor[i].laps == maxlaps - 1 && flag == 0){\n\t\t\tif(vetor[i].qnt % m > 0){\n\t\t\t\tresult = i;\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\n\t\n\tprintf(\"%d\", result+1);\n\t\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "75424b7a470e5b166aad9a9856bb932d", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,m,i,max=-1,maxindex;\n\tscanf(\"%d %d\",&n,&m);\n\tint a[n];\n\tfor(i=0;i=max)\n\t\t{\n\t\t\tmax=(a[i]-1)/m;\n\t\t\tmaxindex=i;\n\t\t}\n\t}\n\tprintf(\"%d\",maxindex+1);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c2347978d9b75882f51428ef14ab6da3", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint a[110],b[110],at[10],bt[10];\n\nint main()\n{\n\tint n,i,ans=0,flag,j;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i=0?at[i]-bt[i]:0;\n\t\tif((at[i]+bt[i])%2==1){\n\t\t\tprintf(\"-1\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"%d\",ans/2);\n\treturn 0;\n} ", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "ff17586e77672f6bdbe0d1f1425dbc13", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint a[105],b[105],i,j,m1,n,m2,c1,c2;\nint main()\n{\n scanf(\"%d\",&n);\n for(i=0;ic2)\n {\n m1+=(c1-c2)/2;\n }\n else\n {\n m2+=(c2-c1)/2;\n }\n }\n else\n {m1=-1;break;}\n }\n if(m1==m2)\n printf(\"%d\\n\",m1);\n else\n printf(\"-1\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "921ea8aba7407a5601beac6a1aa3e742", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define N 26\nint main() {\n\tint n;\n\tscanf(\"%d\",&n);\n\tint a[N];\n\tint i,j;\n\tfor(i=0;ia[max])max=j;\n\t\t}\n\t\tif(max!=i){\n\t\t\t//swap max i\n\t\t\tint tmp=a[max];\n\t\t\ta[max]=a[i];\n\t\t\ta[i]=tmp;\n\t\t}\n\t}\n\t/*\n\tfor(i=0;i=current_max){\n\t\t\tmax_length+=(current_max-1);\n\t\t\tcurrent_max=current_max-1;\n\t\t}else{\n\t\t\tmax_length+=a[i];\n\t\t\tcurrent_max=a[i];\n\t\t}\n\t\ti++;\n\t}\n\tprintf(\"%lld\\n\",max_length);\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "2a59899c21ab6f3ae11356aef2c21a45", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nvoid merge(int [],int ,int ,int );\nvoid part(int [],int ,int );\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int i,a[n];\n long long sum=0;\n for(i=0;i-1;i--)\n {\n if(a[i]>=a[i+1])\n {\n a[i]=a[i+1]-1;\n }\n if(a[i]<0)\n a[i]=0;\n sum=sum+a[i];\n }\n printf(\"%lld\",sum+a[n-1]);\n return 0;\n}\nvoid part(int arr[],int min,int max)\n{\n int mid;\n if(minmid)\n {\n for(k=m; k<=max; k++)\n {\n tmp[i]=arr[k];\n i++;\n }\n }\n else\n {\n for(k=j; k<=mid; k++)\n {\n tmp[i]=arr[k];\n i++;\n }\n }\n for(k=min; k<=max; k++)\n arr[k]=tmp[k];\n}\n", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "70516ecaf75e8e9635bcee1b43c0351e", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n unsigned long long k,a;\n int i,j,t=0,q[10];\n scanf(\"%llu\",&k);\n char p[11]=\"codeforces\";\n for(i=0;i<10;i++)\n q[i]=1;\n\n while(1)\n {\n a=1;\n for(i=0;i<10;i++)\n a*=q[i];\n\n if(a>=k)\n break;\n\n if(t==10)\n t=0;\n\n q[t]++;\n t++;\n }\n \n for(i=0;i<10;i++)\n for(j=0;j\n#include \n#include \n\nint main()\n{\n long long int t,c=1,l=1,n=1,cnt=0;\n scanf(\"%lld\",&t);\n while(c=t)\n break;\n }\n l++;\n }\n long long int a=cnt/10;\n char s[10]=\"codeforces\";\n for(int i=0; i\n#include \n\n//int f(int w, int h, int k);\n\nint main() {\n int w, h, k;\n scanf(\"%i %i %i\", &w, &h, &k);\n printf(\"%i\\n\", 2*k*(w+h)-4*k-8*(k-1)*k );\n return 0;\n}\n/*\nint f(int w, int h, int k){\n if(!k)\n return 0;\n else\n return (2*w+2*(h-2)) + f(w-4, h-4, k-1);\n}*/\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "27ed1c42072bae6190af702950790378", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n//int f(int w, int h, int k);\n\nint main() {\n int w, h, k, ris;\n scanf(\"%i %i %i\", &w, &h, &k);\n ris = 2*k*((w+h)-4*(k-1)-2);\n printf(\"%i\\n\", ris);\n return 0;\n}\n/*\nint f(int w, int h, int k){\n if(!k)\n return 0;\n else\n return (2*w+2*(h-2)) + f(w-4, h-4, k-1);\n}*/\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "9b5b639d6a9c9e3cdd03cf9e12cfe2a6", "src_uid": "2c98d59917337cb321d76f72a1b3c057", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nchar s[10][10];\nint c=0,index,i,j,flag,b[10],c1,min1,min,w[10];\nint main(void) {\n\tfor(i=0;i<8;i++)\n\t{\n\t\tscanf(\"%s\",&s[i]);\n\t}\n//\tint c=0,index,i,j,flag,b[10];\nc=0;\n\tfor(i=0;i<8;i++)\n\t{\n\t\tflag=0;index=-1;\n\t\tfor(j=0;j<8;j++)\n\t\t{\n\t\t\tif(s[j][i]=='B')\n\t\t\t{\n\t\t\t\tindex=j;\n\t\t\t\tflag=0;\n\t\t\t}\n\t\t\tif(s[j][i]=='W')\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t}\n\t\t\tif(j==7&&index!=-1&&flag==0)\n\t\t\t{\n\t\t\t\tb[c++]=index;\n\t\t\t}\n\t\t}\n\t}\n\tc1=0;\n\tfor(i=0;i<8;i++)\n\t{\n\t\tflag=0;index=-1;\n\t\tfor(j=7;j>=0;j--)\n\t\t{\n\t\t\tif(s[j][i]=='W')\n\t\t\t{\n\t\t\t\tindex=j;\n\t\t\t\tflag=0;\n\t\t\t}\n\t\t\tif(s[j][i]=='B')\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t}\n\t\t\tif(j==0&&index!=-1&&flag==0)\n\t\t\t{\n\t\t\t\tw[c1++]=index;\n\t\t\t}\n\t\t}\n\t}\n\tif(c>0)\n\tmin1=b[0];\n\telse\n\tmin1=-1;\n\tfor(i=0;i0)\n\tmin=w[0];\n\telse\n\tmin=1000000;\n\tfor(i=0;iw[i])\n\t\tmin=w[i];\n\t}\n//\tprintf(\"%d %d\\n\",min1,min);\n\tif(7-min1\n#include\nint main()\n{\n\tint r,c,k,flag,tempw,tempb,mova=10,movb=10;\n\tchar s[10][10];\n\tfor(r=1;r<=8;r++)\n\t{\n\t\tscanf(\"%s\",s[r]);\n\t\tgetchar();\n\t}\n\tfor(r=1;r<=8;r++)\n\t{\n\t\tfor(c=0;c<8;c++)\n\t\t{\n\t\t\ttempw=10;\n\t\t\ttempb=10;\n\t\t\tflag=0;\n\t\t\tif(s[r][c]=='W')\n\t\t\t{\n\t\t\t\tfor(k=r-1;k>=1;k--)\n\t\t\t\t{\n\t\t\t\t\tif(s[k][c]=='B'||s[k][c]=='W')\n\t\t\t\t\t{\n\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag==0)\n\t\t\t\t{\n\t\t\t\t\ttempw=r-1;\n\t\t\t\t}\n\t\t\t\tif(tempw> %d %d,%d--%d\\n\",flag,r,c,tempw);\n\t\t\t}\n\t\t\tif(s[r][c]=='B')\n\t\t\t{\n\t\t\t\tfor(k=r+1;k<=8;k++)\n\t\t\t\t{\n\t\t\t\t\tif(s[k][c]=='B'||s[k][c]=='W')\n\t\t\t\t\t{\n\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag==0)\n\t\t\t\t{\n\t\t\t\t\ttempb=8-r;\n\t\t\t\t}\n\t\t\t//\tprintf(\"B>> %d %d,%d--%d\\n\",flag,r,c,tempb);\n\t\t\t\tif(tempb\n\nchar p[10][10];\nint x, y;\n\nvoid ispisi() {\n int i,j;\n for(i = 0; i < 9; ++i) {\n for(j = 0; j < 9; ++j) {\n if(j==3 || j == 6) {\n printf(\" %c\",p[i][j]);\n } else {\n printf(\"%c\",p[i][j]);\n }\n }\n printf(\"\\n\");\n if(i == 2 || i == 5) printf(\"\\n\");\n }\n}\n\nint provjeri(int x, int y) {\n int i, j;\n \n for(i = x*3; i < x*3+3; ++i) {\n for(j = y*3; j < y*3+3; ++j) {\n if(p[i][j] == '.') return 1;\n }\n }\n \n return 0;\n}\n\nvoid popuniPolje(int x, int y) {\n int i,j; \n \n for(i = x*3; i < x*3+3; ++i) {\n for(j = y*3; j < y*3+3; ++j) {\n if(p[i][j] == '.') p[i][j] = '!';\n }\n }\n}\n\nvoid popuniSve() {\n int i,j;\n \n for(i = 0; i < 9; ++i) {\n for(j = 0; j < 9; ++j) {\n if(p[i][j] == '.') p[i][j] = '!';\n }\n }\n}\n\nvoid popuni(int x, int y){\n if(provjeri(x,y)) {\n popuniPolje(x,y);\n } else {\n popuniSve();\n }\n}\n\n\nint main() {\n int i,j;\n \n for(i = 0; i < 9; ++i) {\n for(j = 0; j < 9; ++j) {\n scanf(\" %c\",&p[i][j]);\n }\n }\n scanf(\"%d %d\", &y, &x);\n x--;\n y--;\n \n popuni(y%3,x%3);\n ispisi();\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b40c5cf41da5bb26cc38576f20cd8c08", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(void)\n{\n char a[9][9];\n int i,j,x,y,flag=1;\n for(i=0;i<9;i++)\n scanf(\"%s%s%s\",&a[i][0],&a[i][3],&a[i][6]);\n scanf(\"%d%d\",&x,&y);\n while(x>3) x-=3;\n while(y>3) y-=3;\n for(i=(x-1)*3;i\n#include\n\nint main()\n{\n long long int n,m,i,j,k;\n long long int a[100000];\n while(~scanf(\"%lld%lld\",&m,&n))\n {\n i=0;\n while(n>m)\n {\n a[i]=n;\n if(n%10==1)\n n/=10;\n else if(n%2==0)\n n/=2;\n else\n {\n printf(\"NO\\n\");\n break;\n }\n i++;\n }\n if(n==m)\n {\n printf(\"YES\\n\");\n printf(\"%lld\\n\",i+1);\n printf(\"%lld\",m);\n for(j=i-1;j>=0;j--)\n printf(\" %lld\",a[j]);\n printf(\"\\n\");\n }\n else if(n\nint main()\n{\n int a,b,t=0,i,m,k;\n int n[1000];\n scanf(\"%d %d\",&a,&b);\n k=a;\n m=b;\n for(i=1;m>a;i++)\n {\n if(m%2==0)\n {\n m=m/2;\n t++;\n n[t]=0;\n // printf(\"%d %d\\n\",t,n[t]);\n }\n else if((m-1)%10==0)\n {\n m=(m-1)/10;\n t++;\n n[t]=1;\n // printf(\"%d %d\\n\",t,n[t]);\n\n }\n else if((m-1)%10!=0)\n {\n m=a-1;\n\n }\n }\n if(m==a)\n {\n printf(\"YES\\n\");\n printf(\"%d\\n\",t+1);\n for(i=t+1;i>0;i--)\n {\n if(i==t+1)\n {\n printf(\"%d \",k);\n }\n else if(n[i]==0)\n {\n k=k*2;\n printf(\"%d \",k);\n }\n else if(n[i]==1)\n {\n k=(10*k)+1;\n printf(\"%d \",k);\n\n }\n }\n\n }\n else\n {\n printf(\"NO\");\n }\n printf(\"\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "brute force"], "code_uid": "d40e674bdcd624b4cdb0b0c90d4199c7", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint len[7][2];\nint index3;\nint MinX(int a,int b)\n{\n\treturn a = a>b?b:a;\n}\n\nvoid compare(int a,int b,int c)\n{\n\n\tint middle =0;\n\tif(a>b)\n\t{\n middle = 11 - a;\n\t\tlen[index3][0] = middle + b +1;\n\n\t}\n\telse\n\t{\n len[index3][0] = b - a;\n\t}\n if(b>c)\n\t{\n middle = 11 - b;\n\t\tlen[index3][1] = middle + c +1;\n\n\t}\n\telse\n\t{\n len[index3][1] = c - b;\n\t}\n\tindex3++;\n}\n\nint main()\n{\n\tint i,j,k,flag1,flag2;\n\tchar data[13][3]={\"C\",\"C#\",\"D\",\"D#\",\"E\",\"F\",\"F#\",\"G\",\"G#\",\"A\",\"B\",\"H\"};\n\tchar X[3],Y[3],Z[3];\n\tint index1,index2,op1,op2,op3;\n\twhile(scanf(\"%s%s%s\",X,Y,Z)!=EOF)\n\t{\n\t\tindex3=0;\n\t\tfor(i=0;i<12;i++)\n\t\t{\n\t\t\tif(!strcmp(data[i],X))\n\t\t\t{\n\t\t\t\top1 = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tindex1 = 0;index2 = 0;\n\t\tflag1 = 0; flag2 = 0;\n\t\twhile(1)\n\t\t{\n\t\t\tif(index1 == 12)\n\t\t\t\tindex1 = 0;\n\t\t\tif(index2 == 12)\n\t\t\t\tindex2 = 0;\n\t\t\tif(!strcmp(data[index1],Y))\n\t\t\t{\n\t\t\t\top2 = index1;\n\t\t\t\tflag1 = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t\tindex1++;\n\t\t\tif(!strcmp(data[index2],Z))\n\t\t\t{\n\t\t\t\top3 = index2;\n\t\t\t\tflag2 = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t\tindex2++;\n\t\t\tif(flag1 && flag2)\n\t\t\t\tbreak;\n\t\t}\n\t\tflag1 = 0;flag2 = 0;\n\t\tcompare(op1,op2,op3);\n\t\tcompare(op1,op3,op2); \n\t\tcompare(op2,op1,op3);\n\t\tcompare(op2,op3,op1);\n\t\tcompare(op3,op1,op2);\n\t\tcompare(op3,op2,op1);\n\t\tfor(i = 0;i<6;i++)\n\t\t{\n\t\t\tif(len[i][0] == 4 && len[i][1] == 3)\n\t\t\t{\n\t\t\t\tprintf(\"major\\n\");\n\t\t\t\tflag1 =1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor(i = 0;i<6;i++)\n\t\t{\n\t\t\tif(len[i][0] == 3 && len[i][1] == 4)\n\t\t\t{\n\t\t\t\tprintf(\"minor\\n\");\n\t\t\t\tflag2 =1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(flag1 ==0 && flag2 ==0)\n\t\t\tprintf(\"strange\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "23311e3706d1887d457098d0f9647e18", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n/* Written by Nishant Mittal aka nishantwrp */\nint chordtoindex(char *a) {\nif (*a == 'C') {\n a++;\n if (*a == '#') {\n return 2;\n } else {\n return 1;\n }\n}\nif (*a == 'D') {\n a++;\n if (*a == '#') {\n return 4;\n } else {\n return 3;\n }\n}\nif (*a == 'E') {\n return 5;\n}\nif (*a == 'F') {\n a++;\n if (*a == '#') {\n return 7;\n } else {\n return 6;\n }\n}\nif (*a == 'G') {\n a++;\n if (*a == '#') {\n return 9;\n } else {\n return 8;\n }\n}\nif (*a == 'A') {\n return 10;\n}\nif (*a == 'B') {\n return 11;\n}\nif (*a == 'H') {\n return 12;\n}\nreturn 0;\n}\nint distancefind(int a,int b) {\nint count = 0;\nint i = b;\nwhile (i != a) {\n count++;\n if (i == 12) {\n i = 1;\n } else {\n i++;\n }\n}\nreturn count;\n}\nint main()\n{\nchar chord1[3],chord2[3],chord3[3];\nint pos1,pos2,pos3;\nint i=0;\nwhile(i<3) {\nchar tmp;\nscanf(\"%c\",&tmp);\nif (tmp == ' ') {\n break;\n}else {\nchord1[i] = tmp;\n}\ni++;\n}\nint j=0;\nwhile(j<3) {\nchar tmp;\nscanf(\"%c\",&tmp);\nif (tmp == ' ') {\n break;\n}else {\nchord2[j] = tmp;\n}\nj++;\n}\nint k=0;\nwhile(k<3) {\nchar tmp;\nscanf(\"%c\",&tmp);\nif (tmp == '\\n') {\n break;\n}else {\nchord3[k] = tmp;\n}\nk++;\n}\nint ansset = 0;\npos1 = chordtoindex(chord1);\npos2 = chordtoindex(chord2);\npos3 = chordtoindex(chord3);\n//Minor\nif (distancefind(pos2,pos1) == 3 && distancefind(pos3,pos2) == 4) {\n ansset = 1;\nprintf(\"minor\");\n}else if (distancefind(pos2,pos3) == 3 && distancefind(pos1,pos2) == 4) {\n ansset = 1;\nprintf(\"minor\");\n}else if (distancefind(pos1,pos2) == 3 && distancefind(pos3,pos1) == 4) {\n ansset = 1;\nprintf(\"minor\");\n}else if (distancefind(pos1,pos3) == 3 && distancefind(pos2,pos1) == 4) {\n ansset = 1;\nprintf(\"minor\");\n} else if (distancefind(pos3,pos1) == 3 && distancefind(pos2,pos3) == 4) {\n ansset = 1;\nprintf(\"minor\");\n} else if (distancefind(pos3,pos2) == 3 && distancefind(pos1,pos3) == 4) {\n ansset = 1;\nprintf(\"minor\");\n}//Major\nif (distancefind(pos2,pos1) == 4 && distancefind(pos3,pos2) == 3) {\n ansset = 1;\nprintf(\"major\");\n}else if (distancefind(pos2,pos3) == 4 && distancefind(pos1,pos2) == 3) {\n ansset = 1;\nprintf(\"major\");\n}else if (distancefind(pos1,pos2) == 4 && distancefind(pos3,pos1) == 3) {\n ansset = 1;\nprintf(\"major\");\n}else if (distancefind(pos1,pos3) == 4 && distancefind(pos2,pos1) == 3) {\n ansset = 1;\nprintf(\"major\");\n}else if (distancefind(pos3,pos1) == 4 && distancefind(pos2,pos3) == 3) {\n ansset = 1;\nprintf(\"major\");\n}else if (distancefind(pos3,pos2) == 4 && distancefind(pos1,pos3) == 3) {\n ansset = 1;\nprintf(\"major\");\n}\nif (ansset != 1) {\n printf(\"strange\");\n}\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "f373f0806e5cfa9850ea6049cffb484c", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n\t\n\tlong long n;\n\tscanf(\"%lld\", &n);\n\tprintf(\"25\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "9fe35cfbfe88737f1a432cfcabf8dd8f", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n long long n;\n scanf(\"%lld\", &n);\n printf(\"25\\n\");\n}", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "ebfadc16c5977047fe8dda6455c8d8e8", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint co1[30],co2[30];\nint main()\n{\n\tchar s[110],t[110];\n\tint i,j;\n\tscanf(\"%s %s\",s,t);\n\tfor(i=0;istrlen(t))\n\t{\n\t\ti=0;j=0;int flag=0;\n\t\twhile(i\n#include \n\nint main() {\n\tint i, j, ls, lt, good;\n\tstatic char s[101], t[101];\n\tstatic int cnt[26];\n\n\tscanf(\"%s\", s);\n\tscanf(\"%s\", t);\n\tls = strlen(s);\n\tlt = strlen(t);\n\tj = 0;\n\tfor (i = 0; i < ls; i++) {\n\t\tif (s[i] == t[j])\n\t\t\tj++;\n\t\tif (j == lt) {\n\t\t\tprintf(\"automaton\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tfor (i = 0; i < ls; i++)\n\t\tcnt[s[i] - 'a']++;\n\tfor (i = 0; i < lt; i++)\n\t\tcnt[t[i] - 'a']--;\n\tgood = 1;\n\tfor (i = 0; i < lt; i++)\n\t\tif (cnt[t[i] - 'a'] < 0) {\n\t\t\tgood = 0;\n\t\t\tbreak;\n\t\t}\n\tif (!good)\n\t\tprintf(\"need tree\\n\");\n\telse\n\t\tprintf(\"%s\\n\", ls == lt ? \"array\" : \"both\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "8836cf544b90157e4101efc770c55666", "src_uid": "edb9d51e009a59a340d7d589bb335c14", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int a,ta,b,tb,i,x,t=0,h,m;\n scanf(\"%d %d %d %d\",&a,&ta,&b,&tb);\n scanf(\"%d:%d\",&h,&m);\n x=h*60+m;\n for(i=(5*60);i<(24*60);i+=b)\n {\n if(i+tb>x && i\n\nint min(int a, int b) {\n return a <= b ? a : b;\n}\n\nint\nmain() {\n int a, ta, b, tb;\n int time_h, time_m;\n scanf(\"%d %d\", &a, &ta);\n scanf(\"%d %d\", &b, &tb);\n scanf(\"%d:%d\", &time_h, &time_m);\n int m = (time_h - 5) * 60 + time_m;\n int bus_b = 0;\n for(int i = 0; i < (24 - 5) * 60; ++i) {\n if (i >= tb && (i - tb) % b == 0) {\n --bus_b;\n }\n if (i == m) {\n for(int j = i; j < min((24 - 5) * 60, m + ta); ++j) {\n if (j % b == 0) {\n ++bus_b;\n }\n }\n break;\n }\n if (i % b == 0) {\n ++bus_b;\n }\n }\n printf(\"%d\\n\", bus_b);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5f35317b0043502478e104bdf66394d7", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n\tint n, k;\n\tchar s[101];\n\tint p[100][26]={0,};\n\tint i, j, f=0;\t\n\n\tscanf(\"%d %d\", &n, &k);\n\tscanf(\"%s\", s);\n\t\n\n\n\tfor(i=0;i\n#include\nmain()\n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n int c[27]={};\n char s[n+1];\n scanf(\"%s\",s);\n int true=1;\n int i,l=strlen(s);\n for(i=0;ik){\n true=0;\n break;\n }\n}\nif(true==1)\nprintf(\"YES\\n\");\nelse\n printf(\"NO\\n\");\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "20e078f9576dfea8abb19f3e9af49f71", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main(){\n\tint n,t,k,d;\n\tscanf(\"%d %d %d %d\",&n,&t,&k,&d);\n\tif(d<((n-1)/k)*t){\n printf(\"YES\\n\");\n\t}\n\telse{\n printf(\"NO\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "79b8f63a6ae97fcd337a328cdd7ba125", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nint main()\n{\n\tint n, t, k, d;\n\tscanf(\"%d%d%d%d\", &n, &t, &k, &d);\n\tif ((d < (n - 1) / k * t))\n\t{\n\t\tprintf(\"YES\\n\");\n\n\n\t}\n\telse\n\t\tprintf(\"NO\\n\");\n\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "dce5073806731883aa030eb955b0299d", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main() {\n\t\n\tchar s[101];\n\tscanf(\"%s\",s);\n\tint i,count = 0;\n\tint n = strlen(s);\n\tint h = 1;\n\n\tfor(i=0;i\n#include \n#include \n\nint main()\n{\n char s[1000];\n int x,i=0,c=0,k=0;\n scanf(\"%s\",s);\n x=strlen(s);\n while(i\n\nlong f[100006]={0};\nlong s[100006]={0};\nlong hash[200005]={0};\n\nint main()\n{\n long i,n,j,x;\n \n scanf(\"%ld\",&n);\n for(i=1;i<=n;i++)\n {\n for(j=2;j*(j+1)/2<=i;j++)\n if(2*i%j==0&&(2*i/j-j+1)%2==0)\n {\n x=(2*i/j-j+1)/2;\n hash[s[x-1]^s[x+j-1]]=i;\n }\n for(j=0;hash[j]==i;j++);\n f[i]=j;\n s[i]=s[i-1]^f[i];\n }\n \n if(f[n]==0)\n {\n printf(\"-1\\n\");\n return 0;\n }\n \n for(j=2;j*(j+1)/2<=n;j++)\n if(2*n%j==0&&(2*n/j-j+1)%2==0)\n {\n x=(2*n/j-j+1)/2;\n if(!(s[x-1]^s[x+j-1]))\n break;\n }\n \n printf(\"%ld\\n\",j);\n \n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "games"], "code_uid": "b9cd7e196911732a6f3606a33efa57de", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i=0) return grundy[n];\n mini[n] = -1;\n\n rep(i,1000) chk[i]=0;\n\n for(k=2;;k++){\n up = 2*n - k*k + k;\n down = 2*k;\n\n if(up < down) break;\n if(up%down) continue;\n\n m = 0;\n up /= down;\n rep(i,k) m ^= solve(up+i);\n if(m<1000) chk[m] = 1;\n\n if(m==0 && fin==0) fin=1, mini[n] = k;\n }\n\n rep(i,1000) if(chk[i]==0) break;\n return grundy[n] = i;\n}\n\nint main(){\n int i,j,k,l,m,n;\n\n rep(i,100100) grundy[i] = -1;\n\n while(scanf(\"%d\",&n)==1){\n solve(n);\n printf(\"%d\\n\",mini[n]);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "games"], "code_uid": "61dd822eabfb7de422c68db5bafa82ae", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n, x, ans = 0;;\n scanf(\"%d%d\", &n, &x);\n for (int i = 1; i <= n; i++)\n {\n if ((x%i==0) && (x / i) <= n)\n ans++;\n }\n\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "3207cff02c3e4ffa649c9496164c7e39", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(int argc, char const *argv[])\n{\n int n,x;\n scanf(\"%d %d\",&n,&x);\n int i,j,ct1=0,ct2=0;\n int fact[100000];\n int l=(xx)\n break;\n }\n }\n printf(\"%d\\n\",ct2 );\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "65295a9acfea862af52eab1cb10f540d", "src_uid": "c4b139eadca94201596f1305b2f76496", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//a\n#include \nint main()\n{\n\tlong long int n,k;\n\tscanf(\"%lld%lld\",&n,&k);\n\tlong long int x;\n\tx=n/(2*(k+1));\n\tprintf(\"%lld %lld %lld\\n\",x,k*x,n-(k+1)*x );\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "b6c3f48cc186b9a9c287845dedc5df7f", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,k,a,b,c,d;\n scanf(\"%lld%lld\",&n,&k);\n a=n/2;\n b=a/(k+1);\n c=b*k;\n d=n-(b+c);\n printf(\"%lld %lld %lld\\n\",b,c,d);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "3895b03bd2cbec1f45afec0cd6c20f6d", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include\n\nvoid swap(char *p, char *q)\n{\n\tchar tmp = *p;\n\t*p = *q;\n\t*q = tmp;\n}\n\nint main()\n{\n\tchar list[60];\n\tint n, i, j, t;\n\n\twhile (scanf(\"%d %d\", &n, &t) != EOF)\n\t{\n\t\tgetchar();\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tscanf(\"%c\", &list[i]);\n\t\t}\n\t\tlist[i] = '\\0';\n\t\tfor (i = 0; i < t; i++)\n\t\t{\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t{\n\t\t\t\tif (list[j] == 'B' && list[j + 1] == 'G')\n\t\t\t\t{\n\t\t\t\t\tswap(list + j, list + j + 1);\n\t\t\t\t\tj++;\n\t\t\t\t\tif (j >= n)\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tputs(list);\n\t}\n\treturn 0;\n}\n\n\n\n \t \t\t \t \t \t\t\t \t\t \t \t\t", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation", "shortest paths", "graph matchings"], "code_uid": "9dcf5a00165d530b071488f75079208c", "src_uid": "964ed316c6e6715120039b0219cc653a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n\t\tint n,t,i=0,j;\n\t\tscanf(\"%d%d\",&n,&t);\n\t\tchar seq[n+1];\n\t\tscanf(\"%s\",seq);\n\t\t\n\t\t while(t--) \n\t\t{\n\t\t\ti=0;\n\t\t\twhile(i\nint main()\n{\n int n,i,length=0,max_length=0,j=0,word=0,z=0;\n scanf(\"%d\",&n);\n char str[n+1];\n scanf(\" %s\",str);\n\n for(i=0;i='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))&&z==0)\n length++;\n else if(z==0&&str[i]=='_')\n {\n length=0;\n }\n else if(str[i]==')')\n z=0;\n else if(str[i]=='('||z>0)\n {\n length=0;\n z++;\n if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z'))\n {\n if(j==0)\n {\n word++;\n j++;\n }\n }\n else\n {\n j=0;\n }\n }\n if(length>max_length)\n max_length=length;\n }\n\n printf(\"\\n%d %d\\n\",max_length,word);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "f0a65c763247394f4f793c6ca81dff5c", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n, in_par = 0, aux, in = 0, out = 0;\n scanf(\"%d\", &n);\n char word[n+1];\n scanf(\"%s\", word);\n for(int i = 0; i < n; i++){\n if(in_par){\n aux = 0;\n while(word[i] != ')'){\n if(word[i] != '_'){\n while(word[i] != '_' && word[i] != ')')\n i++;\n\n in++;\n }\n else{\n i++;\n }\n }\n in_par = 0;\n }\n else{\n aux = 0;\n while(word[i] != '_' && word[i] != '(' && i < n){\n aux++;\n i++;\n }\n if(word[i] == '(')\n in_par = 1;\n\n if(aux > out)\n out = aux;\n }\n }\n printf(\"%d %d\\n\", out, in);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing", "strings", "implementation"], "code_uid": "20fa1fb930adcd5834c59434581a13a7", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nmain()\n{\n int i,n,s=0,S=0,d,p=1;\n scanf(\"%d\",&n);\n for(i=0;i<10;i++)\n {\n d=n%10;\n n/=10;\n if(d==7)\n s+=p;\n S+=p;\n p*=2;\n if(n==0)\n break;\n }\n printf(\"%d\",S+s);\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "336ef9e05ef8b624d2903a551df6f106", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main() {\n char s[11]; int i,sum=0;\n scanf(\"%s\",s);\n for (i=0;s[i];i++) {\n sum<<=1;\n sum+=s[i]=='4'?1:2;\n }\n printf(\"%d\\n\",sum);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "combinatorics", "bitmasks"], "code_uid": "b28dc17867c3464e9bd22d43fcfb9547", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n\n#ifndef NULL\n #define NULL ((void *) 0)\n#endif\n\nvoid allocate_error(size_t error_line);\nunsigned short readline_hu(FILE * file);\nint compare(const void * a, const void * b);\n\nint main() {\n\n unsigned short n;\n unsigned short index;\n unsigned short index2;\n unsigned short * h;\n unsigned short * g;\n unsigned short counter;\n void * ret;\n\n n = readline_hu(stdin);\n h = malloc(sizeof(unsigned short) * (n * 2));\n g = malloc(sizeof(unsigned short) * (n * 2));\n index = 0;\n index2 = 0;\n counter = 0;\n\n // ----- ERROR -----\n if (h == NULL || g == NULL)\n allocate_error(__LINE__);\n // ----- ERROR -----\n\n for (index = 0; index < n; index++) {\n\n // Save home and guest color\n h [index] = readline_hu(stdin);\n g [index] = readline_hu(stdin);\n }\n\n qsort(h, n, sizeof(unsigned short), compare);\n qsort(g, n, sizeof(unsigned short), compare);\n\n // Look how often the same appears\n \n for (index=0; index\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int h[n],a[n];\n int ch[100],ca[100];\n int i;\n for(i=0;i<100;i++)\n {\n ch[i]=0;\n ca[i]=0;\n }\n for(i=0;i\n\nint main(int argc, char **argv)\n{\n\tint matrix[26][26]={0};\n\tchar s[101];\n\tint n;\n\tscanf(\"%d%*c\",&n);\n\tgets(s);\n\tfor (int i=0;i*pmax)\n\t\t\t{\n\t\t\t\tpmax=&matrix[i][j];\n\t\t\t\timax=i;\n\t\t\t\tjmax=j;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%c%c\",imax+'A',jmax+'A');\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "15b430bd3f8e1bf2e5125fdafe90cf33", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int count;\n int n;\n int max=0;\n int i,j;\n char test[2],ans[2];\n\n scanf(\" %d\", &n);\n char arr[100];\n\n scanf(\" %s\", arr);\n ans[0]=arr[0];\n ans[1]=arr[1];\n\n for(i=0;imax){\n max=count;\n ans[0]=test[0];\n ans[1]=test[1];\n }\n }\n\n printf(\"%c%c\",ans[0],ans[1]);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "c8d88a3d70c1d99ed346cc975a917b38", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nmain()\n{\n int ev,od,count1=0,count2=0,i;\n scanf(\"%d%d\",&ev,&od);\n\n if( ev !=0 || od !=0)\n {\n for(i=1;i<=ev+od;i++)\n {\n if(i%2==0)\n {\n count1=count1+1;\n }\n else\n {\n count2=count2+1;\n }\n }\n\n if((count1==ev && count2==od) || (count2==ev && count1==od))\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n }\n else\n {\n printf(\"NO\");\n }\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "7bed644003b57af899787a608829895d", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint a,b;\n\n\tscanf(\"%d%d\",&a,&b);\n\tif(a==0 && b==0){\n\t\tprintf(\"NO\\n\");return 0;\n\t}\n\tif(a-b>=-1&&a-b<=1)\n\t\tprintf(\"YES\\n\");\n\telse \n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms", "implementation"], "code_uid": "cd29c5b794fd49f0046f58e11dad8723", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* upsolve with Dukkha */\n#include \n\n#define N\t1000000\n#define MD\t1000000007\n\nlong long ff[N], gg[N], pn[N], pm[N];\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\nvoid init(int n, int m) {\n\tlong long f, p;\n\tint i;\n\n\tf = 1;\n\tfor (i = 0; i < N; i++) {\n\t\tff[i] = f;\n\t\tgg[i] = power(f, MD - 2);\n\t\tf = f * (i + 1) % MD;\n\t}\n\tp = 1;\n\tfor (i = 0; i < n; i++) {\n\t\tpn[i] = p;\n\t\tp = p * n % MD;\n\t}\n\tp = 1;\n\tfor (i = 0; i < n; i++) {\n\t\tpm[i] = p;\n\t\tp = p * m % MD;\n\t}\n}\n\nlong long cayley(int n, int k) {\n\treturn k == n ? 1 : k * pn[n - k - 1] % MD;\n}\n\nint main() {\n\tint n, m, a, b, k;\n\tlong long ans;\n\n\tscanf(\"%d%d%d%d\", &n, &m, &a, &b);\n\tinit(n, m);\n\tans = 0;\n\tfor (k = 0; k <= n - 2 && k < m; k++) {\n\t\t/* choose(n - 2, k) * factorial(k) */\n\t\tlong long path = ff[n - 2] * gg[n - 2 - k] % MD;\n\t\t/* choose(m - 1, k) * power(m, n - k - 2) */\n\t\tlong long edges = ff[m - 1] % MD * gg[k] % MD * gg[m - 1 - k] % MD\n\t\t\t* pm[n - k - 2] % MD;\n\n\t\tans = (ans + path * cayley(n, k + 2) % MD * edges) % MD;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "combinatorics", "trees"], "code_uid": "216f8715645f9c68827e70ea3a070c5c", "src_uid": "728fe302b8b18e33f15f6e702e332cde", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long m,n;\n scanf(\"%lld%lld\",&n,&m);\n {\n if(m==1)\n {\n printf(\"%lld\",n-1);\n }\n else if(n==1)\n {\n printf(\"%d\",m-1);\n }\n else\n {\n printf(\"%lld\",(m-1)*n);\n }\n }\n return 0;\n}\n\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": "d5b4eeab708e640e670520766d4ad280", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n long long int m, n, ans;\r\n\r\n scanf(\"%lld %lld\", &n ,&m);\r\n\r\n if(n==1 && m==1)\r\n ans=0;\r\n else if(n==1 && m>1)\r\n ans=m-1;\r\n else if(n>1 && m==1)\r\n ans=n-1;\r\n else if(n>1 && m>1)\r\n ans=(m-1)*n;\r\n printf(\"%lld\\n\", ans);\r\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "c0ec80d863f9de7425a3a421d14362b2", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint k = 998244353;\nint main() {\n int m, n;\n scanf(\"%d%d\", &m, &n);\n int t = m + n, r = 1;\n while (t--) {\n r = (r * 2) % k;\n }\n printf(\"%d\\n\", r);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "combinatorics"], "code_uid": "f775e8753a573ce55d07f3fd3c4f88a2", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n#define MOD(a) ((a)%998244353)\n\nint main(){\n\tint w, h, i, sum=4;\n\tscanf(\"%d %d\", &w, &h);\n\tfor(i=1;i\n\nint isMatch(int m_index, int num) {\n int calendar[13] = {31,28,31,30,31,30,31,31,30,31,30,31};\n int calendar2[13] = {31,29,31,30,31,30,31,31,30,31,30,31};\n m_index %= 12;\n if(num == calendar[m_index] || num == calendar2[m_index]) {\n return 1;\n }\n return 0;\n}\n\n\nint main() {\n int N, flag_2m = 0, re[32] = {0};\n scanf(\"%d\", &N);\n for(int n = 0; n < N; ++n) {\n scanf(\"%d\", &(re[n]));\n if(re[n] == 29) ++flag_2m;\n }\n \n for(int n1 = 0; n1 < 12 && flag_2m < 2; ++n1) {\n int n2 = 0;\n for(n2 = 0; n2 < N && isMatch(n1 + n2, re[n2]); ++n2) {\n \n }\n if(n2 == N) {\n printf(\"Yes\\n\");\n return 0;\n }\n }\n printf(\"No\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a333174bc05dbaa0c3931aeecd6ba066", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n int indexa,indexb,i,j,k,m,n,sign,loop;\n int arr[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};\n int brr[25];\n while(scanf(\"%d\",&n) != EOF){\n sign = 0;\n for(i = 0;i < n;i++)\n scanf(\"%d\",&brr[i]);\n for(i = 1;i <= 12;i++){\n indexb = 0;\n indexa = i;\n k = n;\n loop = 0;\n while(k--){\n if(indexa == 2){\n if(brr[indexb] == 28 || brr[indexb] == 29){\n if(brr[indexb] == 29 && loop == 1){\n sign = 0;\n break;\n }\n if(brr[indexb] == 29 && loop == 0)\n loop = 1;\n indexb++;\n indexa++;\n sign = 1;\n\n continue;\n }\n sign = 0;\n break;\n }\n if(arr[indexa] != brr[indexb]){\n sign = 0;\n break;\n }\n if(arr[indexa] == brr[indexb]){\n indexa++;\n indexb++;\n if(indexa > 12)\n indexa = 1;\n sign = 1;\n }\n }\n if(sign == 1)\n break;\n }\n if(sign == 1)\n printf(\"Yes\\n\");\n if(sign == 0)\n printf(\"No\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "6376d1d7dc84d2c9a74a3935971c0836", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,c,n,x,y,z,r;\n scanf(\"%d %d %d %d\",&a,&b,&c,&n);\n x=a-c;\n y=b-c;\n z=x+y+c;\n r=n-z;\n if(a=c && b>=c && r>=1)\n printf(\"%d\",r);\n else\n printf(\"-1\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "72aafe91ebb6480466280d6324d6f167", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,a,b,c,x;\n scanf(\"%d%d%d%d\",&a,&b,&c,&n);\n x=a+b-c;\n if(n-x>=1&&a>=c&&b>=c)\n printf(\"%d\",n-x);\n else\n printf(\"-1\");\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ab3b8a1675a20f042b54d6a6aaabba33", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint r , g, b , s , min, a[4] ,i ;\n\nint main()\n{\n scanf(\"%d %d %d\" , &r, &g, &b) ;\n\n\n\n a[0] = r ;\n a[1] = g ;\n a[2] = b ;\n min =1000000001 ;\n for( i = 0 ; i < 3 ; i++)\n {\n if ( min > a[i] )\n {\n min = a[i] ;\n }\n}\nr = r - min ;\ng = g - min ;\nb = b - min ;\n//printf(\"%d %d %d %d\\n\", r , g, b , min) ;\ns = r/3 + g/3 + b/3 + min ;\n\nif ( r%3 + g%3 + b%3 == 4 && min != 0 )\n{\n s++ ;\n}\nprintf(\"%d\", s) ;\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "f3342c68571edba52dfefe231a379c49", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint fun(int ,int ,int );\nint min(int ,int );\nint min(int x,int y)\n{\n return (x\nint main()\n{\n int n,i,j=0;\n scanf(\"%d\",&n);\n j=n/100+(n%100)/20+(n%20)/10+(n%10)/5+(n%5)/1;\n printf(\"%d\",j);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "9a8104039bafdd461bcfe7fff34b4341", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nmain()\n{\n int i, money, no_of_change, total= 0;\n scanf(\"%i\", &money);\n\n while(money){\n if(money/100){\n no_of_change= money/100;\n money= money%100;\n total= total+no_of_change;\n }\n else if(money/20){\n no_of_change= money/20;\n money= money%20;\n total= total+no_of_change;\n }\n else if(money/10){\n no_of_change= money/10;\n money= money%10;\n total= total+no_of_change;\n }\n else if(money/5){\n no_of_change= money/5;\n money= money%5;\n total= total+no_of_change;\n }\n else if(money/1){\n no_of_change= money/1;\n money= money%1;\n total= total+no_of_change;\n }\n }\n printf(\"%i\", total);\n}", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "830ef69a433e8750526ba3b2a6c25f90", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\ndouble area(int a)\n{\n return (sqrt(3)*a*a)/4;\n}\n\nint main()\n{\n int a, b,c, d, e, f;\n scanf(\"%d %d %d %d %d %d\", &a, &b, &c, &d, &e, &f);\n\n double n_triangle = area(b+a+c) - area(a) - area(c) - area(e);\n \n printf(\"%.0lf\\n\", n_triangle / area(1));\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "56643979f509b7f3104e66a30d51d298", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n int a, b, c, d, e, f;\n scanf ( \"%d%d%d%d%d%d\", &a, &b, &c, &d, &e, &f );\n int len = e+d+c;\n int ans = len*len;\n ans = ans - c*c - a*a - e*e;\n printf ( \"%d\\n\", ans );\n return 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "61b5aa583d536bbb18a57c9452b78869", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\ndouble square,triangle,d_tri;\n\nint putting_pole(double remain,int count);\n\n\nint main(void){\n int r,h,maxnum,n,count;\n double l;\n scanf(\"%d %d\",&r,&h);\n square=r;\n triangle=sqrt(3)*r/2;\n d_tri=2*triangle;\n l=h-triangle;\n count=3;\n //printf(\"3:%f\\n\",l);\n n=putting_pole(l,count);\n maxnum=n;\n l=h-(double)r/2;\n count=2;\n //printf(\"2:%f\\n\",l);\n n=putting_pole(l,count);\n if(n>maxnum) maxnum=n;\n if(!n) maxnum=1;\n printf(\"%d\\n\",maxnum);\n return 0;\n}\n \nint putting_pole(double remain,int count){\n int x,y,z;\n int max=0,num;\n \n if(remain<0) return 0;\n\n for(x=remain/d_tri;x>=0;x--){\n y=(remain-x*d_tri)/square;\n z=(remain-x*d_tri-y*square>=triangle)?1:0;\n num=3*x+2*y+z;\n if(num>max) max=num;\n } \n return max+count;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "9d35fc2d88165c7a5f43570ceb34c191", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\ntypedef unsigned u;\ntypedef double d;\nint main()\n{\n\td R,h,r,K;\n\tu ans,k;\n\tscanf(\"%lf%lf\",&R,&h);\n\tr=R/2;\n\tK=(h+r)/R;\n\tk=(u)K;\n\tans+=k<<1;\n\tK=h+R-R*k+r;\n\tif(K>=r+r*sqrt(3))ans++;\n\tprintf(\"%u\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "cbe6a74d6a4d9276c412aa833cc222bc", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tlong long l1, r1, l2, r2, k;\n\tscanf(\"%lld %lld %lld %lld %lld\", &l1, &r1, &l2, &r2, &k);\n\n\tlong long strt, end, cnt;\n\tstrt = (l1 > l2) ? l1 : l2;\n\tend = (r1 < r2) ? r1 : r2;\n\n\tif(end < strt) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tcnt = end - strt + 1;\n\tif(k >= strt && k <= end)\n\t\tcnt--;\n\n\tprintf(\"%lld\\n\", cnt);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "998ca5574c37e69575ad409bddf9aa6e", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n\tlong long int l1,r1,l2,r2,k;\n\tscanf(\"%lld %lld %lld %lld %lld\",&l1,&r1,&l2,&r2,&k);\n\tlong long int l,r;\n\t\n\tif(l1>=l2)\n\t\tl=l1;\n\telse\n\t\tl=l2;\n\t\n\tif(r1>=r2)\n\t\tr=r2;\n\telse\n\t\tr=r1;\n // printf(\"l=%lld r=%lld\\n\",l,r);\n\tif(l>r)\n\t{\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tif((k>=l && k<=r)||(k<=l && k>=r))\n\t\t\tprintf(\"%lld\\n\",(r-l));\n\t\telse\n\t\t\tprintf(\"%lld\\n\",(r-l)+1);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c6da0fa04e182b19dba911c798f996ca", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int a1, b1, c1, a2, b2, c2;\n\n scanf(\"%d %d %d\", &a1, &b1, &c1);\n scanf(\"%d %d %d\", &a2, &b2, &c2);\n\n if ((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0)) {\n\t puts(\"0\");\n } else if ((a1 == 0 && b1 == 0) || (a2 == 0 && b2 == 0)) {\n\t puts(\"-1\");\n } else if (a1 * b2 != a2 * b1) {\n\t puts(\"1\");\n } else {\n\t if (a1 == 0) {\n\t if (b1 * c2 == b2 * c1) {\n\t\t puts(\"-1\");\n\t } else {\n\t\t puts(\"0\");\n\t }\n\t } else {\n\t if (a1 * c2 == a2 * c1) {\n\t\t puts(\"-1\");\n\t } else {\n\t\t puts(\"0\");\n\t }\n\t }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "21840c91e95e40ef975ddecfe74375f0", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int a1, b1, c1, a2, b2, c2;\n scanf(\"%d%d%d%d%d%d\", &a1, &b1, &c1, &a2, &b2, &c2);\n if((a1 == 0 && b1 == 0 && c1 != 0) || (a2 == 0 && b2 == 0 && c2 != 0)){\n puts(\"0\");\n }else if(a1 * b2 - a2 * b1 == 0){\n if(a1 * c2 - a2 * c1 == 0 && c1 * b2 - c2 * b1 == 0){\n puts(\"-1\");\n }else{\n puts(\"0\");\n }\n }else{\n puts(\"1\");\n }\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ac64c3b72e2a4a112516789a88c603df", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint a,b,c;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tint d=a,di=b,rem;\n\t/*\twhile(di!=0)\n\t\t{\n\t\trem = d % di;\n\t\td = di;\n\t\tdi = rem;\n\t\t}\n\t*/\n\tint i,j,flag=0;\n\tfor (i=0; i<=c; i++)\n\t{\n\t\tfor (j=0; j<=c; j++)\n\t\t{\n\n\t\t\tif (c == (a*i+b*j))\n\t\t\t\tflag=1;\n\t\t}\n\t}\n\tif (flag)\n\t\tprintf(\"Yes\\n\");\n\telse\n\t\tprintf(\"No\\n\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "cd59f030081a2b14f0996447e37a243e", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint x,y,a,i,j;\n\tscanf(\"%d%d%d\",&x,&y,&a);\n\tfor(i=0;i<=a;i++)\n\t{\n\t\tfor(j=0;j<=a;j++)\n\t\t{\n\t\t\tif(x*i+j*y==a)\n\t\t\t{\n\t\t\t\tprintf(\"YES\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"NO\");\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "b76207f4d2130f2079c608281b4f9c18", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n\tint i,j,y=0,p,k,l,t,m,n;\n\tint a[25];\n\tfor(i=1;i<=24;i++)\n\t\tscanf(\"%d\",&a[i]);\n\tm=a[13];\n\tn=a[17];\n\tif(a[13]==m && a[14]==m && a[15]==m && a[16]==m && a[17]==n && a[18]==n && a[19]==n && a[20]==n)\n\t{\n\n\t\tp=a[1];\n\t\tif(a[1]==p && a[3]==p && a[6]==p && a[8]==p)\n\t\t{\n\t\t\tk=a[5];\n\t\t\tif(a[5]==k && a[7]==k && a[10]==k && a[12]==k)\n\t\t\t{\n\t\t\t\tl=a[9];\n\t\t\t\tif(a[9]==l && a[11]==l && a[21]==l && a[23]==l)\n\t\t\t\t{\n\t\t\t\t\tt=a[2];\n\t\t\t\t\tif(a[2]==t && a[4]==t && a[22]==t && a[24]==t)\n\t\t\t\t\t{\n\t\t\t\t\t\ty=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\tif(a[1]==p && a[3]==p && a[21]==p && a[23]==p)\n\t\t{\n\t\t\tk=a[5];\n\t\t\tif(a[5]==k && a[7]==k && a[2]==k && a[4]==k)\n\t\t\t{\n\t\t\t\tl=a[9];\n\t\t\t\tif(a[9]==l && a[11]==l && a[6]==l && a[8]==l)\n\t\t\t\t{\n\t\t\t\t\tt=a[22];\n\t\t\t\t\tif(a[10]==t && a[12]==t && a[22]==t && a[24]==t)\n\t\t\t\t\t{\n\t\t\t\t\t\ty=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tm=a[1];\n\tn=a[9];\n\tif(a[1]==m && a[2]==m && a[3]==m && a[4]==m && a[9]==n && a[10]==n && a[11]==n && a[12]==n)\n\t{\n\n\t\tp=a[7];\n\t\tif(a[17]==p && a[18]==p && a[7]==p && a[8]==p)\n\t\t{\n\t\t\tk=a[5];\n\t\t\tif(a[5]==k && a[6]==k && a[15]==k && a[16]==k)\n\t\t\t{\n\t\t\t\tl=a[20];\n\t\t\t\tif(a[20]==l && a[19]==l && a[21]==l && a[22]==l)\n\t\t\t\t{\n\t\t\t\t\tt=a[13];\n\t\t\t\t\tif(a[13]==t && a[14]==t && a[23]==t && a[24]==t)\n\t\t\t\t\t{\n\t\t\t\t\t\ty=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\tif(a[7]==p && a[8]==p && a[13]==p && a[14]==p)\n\t\t{\n\t\t\tk=a[5];\n\t\t\tif(a[5]==k && a[6]==k && a[19]==k && a[20]==k)\n\t\t\t{\n\t\t\t\tl=a[17];\n\t\t\t\tif(a[17]==l && a[18]==l && a[23]==l && a[24]==l)\n\t\t\t\t{\n\t\t\t\t\tt=a[22];\n\t\t\t\t\tif(a[15]==t && a[16]==t && a[21]==t && a[22]==t)\n\t\t\t\t\t{\n\t\t\t\t\t\ty=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tm=a[5];\n\tn=a[21];\n\tif(a[5]==m && a[6]==m && a[7]==m && a[8]==m && a[21]==n && a[22]==n && a[23]==n && a[24]==n)\n\t{\n\n\t\tp=a[14];\n\t\tif(a[14]==p && a[16]==p && a[11]==p && a[12]==p)\n\t\t{\n\t\t\tk=a[3];\n\t\t\tif(a[3]==k && a[4]==k && a[13]==k && a[15]==k)\n\t\t\t{\n\t\t\t\tl=a[9];\n\t\t\t\tif(a[9]==l && a[10]==l && a[18]==l && a[20]==l)\n\t\t\t\t{\n\t\t\t\t\tt=a[2];\n\t\t\t\t\tif(a[2]==t && a[1]==t && a[17]==t && a[19]==t)\n\t\t\t\t\t{\n\t\t\t\t\t\ty=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t\tif(a[14]==p && a[16]==p && a[1]==p && a[2]==p)\n\t\t{\n\t\t\tk=a[3];\n\t\t\tif(a[3]==k && a[4]==k && a[18]==k && a[20]==k)\n\t\t\t{\n\t\t\t\tl=a[9];\n\t\t\t\tif(a[9]==l && a[10]==l && a[13]==l && a[15]==l)\n\t\t\t\t{\n\t\t\t\t\tt=a[11];\n\t\t\t\t\tif(a[11]==t && a[12]==t && a[17]==t && a[19]==t)\n\t\t\t\t\t{\n\t\t\t\t\t\ty=1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(y==0)\n\t\tprintf(\"NO\\n\");\n\tif(y==1)\n\t\tprintf(\"YES\\n\");\n\treturn 0;\n}\n\n\n\t\t\t\t\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "e8829e8041a650e2ceb68e652b3b6739", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint judge(int *a)\n{\n\tif (a[1]==a[2]&&a[2]==a[3]&&a[3]==a[4])\n\t\tif (a[5]==a[6]&&a[6]==a[7]&&a[7]==a[8])\n\t\t\tif (a[9]==a[10]&&a[10]==a[11]&&a[11]==a[12])\n\t\t\t\tif (a[13]==a[14]&&a[14]==a[15]&&a[15]==a[16])\n\t\t\t\t\tif (a[17]==a[18]&&a[18]==a[19]&&a[19]==a[20])\n\t\t\t\t\t\tif (a[21]==a[22]&&a[22]==a[23]&&a[23]==a[24]) \n\t\t\t\t\t\t\treturn 1;\n\treturn 0;\n}\nint main()\n{\n\tint a[25],b[25],i,j;\n\tfor (i=1;i<=24;i++)\n\t{\n\t\tscanf(\"%d\",&a[i]);\n\t\tb[i]=a[i];\n\t}\n\t\n\tb[1]=a[5]; b[3]=a[7]; b[5]=a[9]; b[7]=a[11]; b[9]=a[24]; b[11]=a[22]; b[24]=a[1]; b[22]=a[3];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[1]=a[24]; b[3]=a[22]; b[5]=a[1]; b[7]=a[3]; b[9]=a[5]; b[11]=a[7]; b[24]=a[9]; b[22]=a[11];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[2]=a[6]; b[4]=a[8]; b[6]=a[10]; b[8]=a[12]; b[10]=a[23]; b[12]=a[21]; b[23]=a[2]; b[21]=a[4]; \n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[2]=a[23]; b[4]=a[21]; b[6]=a[2]; b[8]=a[4]; b[10]=a[6]; b[12]=a[8]; b[23]=a[10]; b[21]=a[12];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[2]=a[13]; b[1]=a[15]; b[13]=a[11]; b[15]=a[12]; b[11]=a[20]; b[12]=a[18]; b[20]=a[2]; b[18]=a[1];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[1]=a[18]; b[2]=a[20]; b[18]=a[12]; b[20]=a[11]; b[12]=a[15]; b[11]=a[13]; b[15]=a[1]; b[13]=a[2];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[3]=a[16]; b[4]=a[14]; b[17]=a[3]; b[19]=a[4]; b[10]=a[17]; b[9]=a[19]; b[16]=a[10]; b[14]=a[9]; \n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[4]=a[19]; b[3]=a[17]; b[17]=a[10]; b[19]=a[9]; b[10]=a[16]; b[9]=a[14]; b[16]=a[3]; b[14]=a[4];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[13]=a[5]; b[14]=a[6]; b[5]=a[17]; b[6]=a[18]; b[17]=a[21]; b[18]=a[22]; b[21]=a[13]; b[22]=a[14];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\t\n\tfor (i=1;i<=24;i++) b[i]=a[i];\n\tb[14]=a[22]; b[13]=a[21]; b[22]=a[18]; b[21]=a[17]; b[18]=a[6]; b[17]=a[5]; b[6]=a[14]; b[5]=a[13];\n\tif (judge(b))\n\t{\n\t\tprintf(\"YES\\n\"); return 0;\n\t}\n\tprintf(\"NO\\n\");\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "0b6fa6e1c42af93775a0ae46f269aa7c", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(int argc, char const *argv[])\n{\n long i,n;\n long a=0,b=0;\n scanf(\"%ld\",&n);\n long diff = 1<<30;\n for(i=1;i<=n;i++){\n if(n%i==0){\n if(i>n/i){\n break;\n }else{\n if((n/i)-i\n#define lli long long int\n#include\n#include\n\nint main(void)\n{\n\tlli a,b,n,tmp;\n\tscanf(\"%lld\",&n);\n\t\n\tlli mn,mx,mid,ans;\n\n\tmn=0;mx=n;//mid=mn+(mx-mn)/2;\n\twhile(mn<=mx)\n\t{\n\t\tmid=mn+(mx-mn)/2;\n\t\tif(mid*mid>=n)\n\t\t{\n\t\t\tans=mid;\n\t\t\tmx=mid-1;\n\t\t}\n\t\telse\n\t\t\tmn=mid+1;\n//\t\tprintf(\"mx=%lld mn=%lld\\n\",mx,mn);\n\t}\n\n//\tprintf(\"%lld\\n\",ans);\n\n\twhile(n%ans!=0)\n\t{\n\t\tans--;\n\t}\n\n\ta=ans;b=n/ans;\n\n\tif(a>b)\n\t{\n\t\ttmp=a;\n\t\ta=b;\n\t\tb=tmp;\n\t}\n\n\tprintf(\"%lld %lld\\n\",a,b);\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "61e4a05973cc1209549ee7aca947dbea", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main() {\n\tstatic char s[1234567], code[5];\n\tint n, i, kr, kb, ky, kg;\n\n\tscanf(\"%s\", s);\n\tn = strlen(s);\n\tfor (i = 0; i < n; i++)\n\t\tif (s[i] != '!')\n\t\t\tcode[i % 4] = s[i];\n\tkr = kb = ky = kg = 0;\n\tfor (i = 0; i <= n - 4; i++) {\n\t\tint j;\n\n\t\tfor (j = i; j < i + 4; j++)\n\t\t\tif (s[j] == '!') {\n\t\t\t\tint a;\n\n\t\t\t\ta = j % 4;\n\t\t\t\tif (code[a] == 'R')\n\t\t\t\t\tkr++;\n\t\t\t\telse if (code[a] == 'B')\n\t\t\t\t\tkb++;\n\t\t\t\telse if (code[a] == 'Y')\n\t\t\t\t\tky++;\n\t\t\t\telse\n\t\t\t\t\tkg++;\n\t\t}\n\t\ts[i] = code[i % 4];\n\t\ts[i + 1] = code[(i + 1) % 4];\n\t\ts[i + 2] = code[(i + 2) % 4];\n\t\ts[i + 3] = code[(i + 3) % 4];\n\t}\n\tprintf(\"%d %d %d %d\\n\", kr, kb, ky, kg);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "number theory"], "code_uid": "aa02446c3d0fc6ad7da517a789e52bb4", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int i,r,g,b,y,R=0,G=0,B=0,Y=0,x,l=0;\n char s[110];\n scanf(\"%s\",s);\n for(i=0;s[i]!='\\0';i++)\n l++;\n for(i=0;;i++){\n if(s[i]=='R')\n break;\n }\n r=i%4;\n for(i=0;;i++){\n if(s[i]=='G')\n break;\n }\n g=i%4;\n for(i=0;;i++){\n if(s[i]=='B')\n break;\n }\n b=i%4;\n for(i=0;;i++){\n if(s[i]=='Y')\n break;\n }\n y=i%4;\n for(i=0;i\n#include \n\nint main()\n{\n int n,m,a[10],y[10],i,j;\n scanf(\"%d%d\",&n,&m);\n for(i=0; i\n\nint main(void){\n int n,m;\n scanf(\"%d %d\",&n,&m);\n int a[n],b[m];\n for(int i=0;i\n\ntypedef long long int lli;\n\nint main()\n{\n\tlli n,k;\n\tscanf(\"%lld%lld\",&n,&k);\n\tif(n==1)\n\t{\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\tif(k==1)\n\t{\n\t\tprintf(\"%lld\\n\",n);\n\t}\n\telse\n\t{\n\t\tlli tmp=2,i=0;\n\t\twhile(tmp<=n)\n\t\t{\n\t\t\ttmp=tmp*2;\t\n\t\t\ti++;\n\t\t}\n\t\tlli ans;\n\t\tans=tmp-1;\n\n\t\tprintf(\"%lld\\n\",ans);\n\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "0b7a94c259dc5054d4dd7913e30568de", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\ntypedef long long int ll;\nint main()\n{\n\tll n,k;\n\tscanf(\"%lld%lld\",&n,&k);\n\tll ans=n;\n\tll count=1,i;\n/*\tfor(i=n-1;i>=n/2;i--)\n\t{\n\t\tif(count==k) break;\n\t\tll temp=ans^i;\n\t\tif(temp>ans)\n\t\t{\n\t\t\tans=temp;\n\t\t\tcount++;\n\t\t}\n\n//\t\tif(ans==(pow()) break;\n\t}*/\n\tfor(i=n/2;i>0;i/=2)\n\t{\t\n\t//\tif(count==k) break;\n\t\tll temp=ans^i;\n\t\tif(temp>ans)\n\t\t{\n\t\t\tans=temp;\n\t//\t\tcount++;\n\t\t}\n\t}\n\tif(k==1) printf(\"%lld\",n);\n\telse printf(\"%lld\",ans);\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "number theory", "bitmasks"], "code_uid": "e7bc4123f2aec8863deaf4df16828553", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int k,a,b,v,req,nos,box;\n scanf(\"%d %d %d %d\",&k,&a,&b,&v);\n if(a%v==0)\n {\n nos=a/v;\n }\n else\n nos=(a/v)+1;\n for(box=0;(nos>0)&&(k<=(b+1));box++)\n {\n b-=(k-1);\n nos-=k;\n }\n if(nos>0&&b>0)\n {\n nos-=b+1;\n box++;\n }\n if(nos>0)\n box+=nos;\n printf(\"%d\\n\",box);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "40dbc71889e0b7e629215b827d0163d5", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int k,a,b,v,sectionsrequired,boxes,s;\n scanf(\"%d %d %d %d\",&k,&a,&b,&v);\n sectionsrequired=a/v;\n if(a%v != 0)\n sectionsrequired++;\n\n s=sectionsrequired;\n if(s<=b+1)\n {\n boxes=s/k;\n if(s%k !=0)\n boxes=s/k +1;\n }\n else\n boxes=s-b;\n printf(\"%d\",boxes);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "d8ddc44c10998d0b56985c24a9b23210", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint qs(int a[],int n,int m)\n{\n\tint i=n,j=m,k=a[i];\n\tif(n>=m)return 0;\n\twhile(ik)j--;\n\t\tif(i=m)\n\t\t{\n\t\t\tprintf(\"%d\",i);\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(flag==0)\n\tprintf(\"-1\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "c7201251a2bad94d468b9ad1678609a2", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint compare(const void * a, const void * b) {\n return ( *(int*) a - *(int*) b);\n}\n\nint main(void) {\n int i, n, m, k, arr[55], tot = 0, res = 0, pre;\n\n scanf(\"%d%d%d\", &n, &m, &k);\n\n for (i = 0; i < n; i++)\n scanf(\"%d\", &arr[i]);\n\n if(k == m)\n {\n printf(\"0\\n\");\n return 0;\n }\n\n qsort(arr, n, sizeof (int), compare);\n\n tot = k - 1;\n\n if (tot < m) {\n for (i = n - 1; i >= 0; i--) {\n res++;\n tot += arr[i];\n\n if (tot < m) {\n tot--;\n pre = arr[i] - 1;\n if (pre == 0) {\n res = -1;\n break;\n }\n } else break;\n }\n }\n if (tot < m) res = -1;\n printf(\"%d\\n\", res);\n return 0;\n}", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "7d0f24b05fa78389ec30a499f672e11a", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\nint M, N, numero_dominos;\nscanf(\"%d %d\", &M, &N);\nnumero_dominos = (M*N)/2;\nprintf (\"%d\\n\", numero_dominos);\nreturn 0;\n}\n\n/* 1490029633546 */\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "cf1fa34097b33f57285d528096e80aaf", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n\nint M,N,sum=0;\n\nscanf(\"%d %d\",&M,&N);\n\nif(N%2==0&&M!=0&&N!=0){\n sum=M*(N/2);\n}\nelse{\n if(M!=0&&N!=0){\n sum=(M*(N/2))+(M/2);\n }\n}\n\nprintf(\"%d\",sum);\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "9b4242096501d0fcb8242363bb1bef0a", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int ans, i, j, k, m, n, len;\n\n char str[30];\n\n scanf(\"%s\", str);\n\n len = strlen(str);\n\n ans = ( len + 1 ) * 26 - len;\n\n printf(\"%d\", ans);\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "strings"], "code_uid": "eda3369b17cf8f59e2b976d449a24673", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n int len;\n char s[27];\n scanf(\"%s\",s);\n len=strlen(s);\n printf(\"%d\",(len+1)*25+1);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "strings"], "code_uid": "7a4d3fa1fcd698094f409e2c192017d4", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n ============================================================================\n Name : trial.c\n Author : zizo\n Version :\n Copyright : Your copyright notice\n Description : Hello World in C, Ansi-style\n ============================================================================\n */\n\n#include \n#include \n\nint main()\n{\n\tint numofFirst,numofSec,min1,min2,i,j;\n\tscanf(\"%d%d\",&numofFirst,&numofSec);\n\n\tint firsRow[numofFirst],secRow[numofSec];\n\tscanf(\"%d\",&firsRow[0]);\n\tmin1=firsRow[0];\n\tfor(i=1;i\n#include \n#include \n#include \n\nint min(int a,int b)\n{\n\tif(a\ntypedef long int li;\nconst long int MIN = -2147483647;\n#define si(n) scanf(\"%ld\", &n);\n#define pi(n) printf(\"%ld\", n);\nli max(li a, li b){\n\tif(a > b) return a;\n\treturn b;\n}\nli min(li a, li b){\n\tif(a < b) return a;\n\treturn b;\n}\nli gcd(li a, li b){\n\tif(b == 0)\n\t\treturn a;\n\treturn gcd(b, a%b);\n}\nlong int getNumberPFac(long int a){\n\tlong int c = 0;\n\twhile(a % 2 == 0){\n\t\ta/=2; c++;\n\t} \n\twhile(a % 3 == 0){\n\t\ta/=3; c++;\n\t}\n\twhile(a % 5 == 0){\n\t\ta/=5; c++;\n\t}\n\tif(a!=1) return MIN;\n\telse return c;\n}\nint main(){\n// \tfreopen(\"input.txt\", \"r\", stdin);\n\tlong int a, b, c;\n\tsi(a); si(b);\n\t//printf(\"%d\", sizeof(int));\n\t//if(a == b) printf(\"0\"); return \n\tc = gcd(max(a, b), min(a, b)); //pi(c); printf(\"\\n\");\n\ta = getNumberPFac(a/c); b = getNumberPFac(b/c); //pi(a);\n\tif(a<0 || b<0) printf(\"-1\");\n\telse pi(a+b);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "e6961177c79c3da80f5370f8ec9f9768", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.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\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "141f8898f3036ae8c898ec8ac77f4ee6", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//\n// vk.c\n// \n//\n// Created by Vijay Kansal on 16/04/17.\n//\n//\n\n#include \n#include\n\nint calc(char *s) {\n int i, len = strlen(s), result = 0;\n for (i = 0; i + 1 < len; i++) {\n result += s[i] == 'V' && s[i+1] == 'K';\n }\n return result;\n}\n\nint main() {\n char s[101];\n scanf(\"%s\", s);\n int i, val, len = strlen(s), ans = calc(s);\n for (i = 0; i < len; i++) {\n s[i] = s[i] == 'K' ? 'V' : 'K';\n val = calc(s);\n if (val > ans) {\n ans = val;\n }\n s[i] = s[i] == 'K' ? 'V' : 'K';\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "d361b26028f8a836dff9ab0a106a4f59", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char s[101];\n int i,l,c=0;\n gets(s);\nl=strlen(s);\n for(i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n\n#define ll long long\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n#define abs(k) (((k)>0)?(k):(-(k)))\n#define mod(a,b) (((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1))\n#define mset(a) memset(a,0,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n#define inf (1e9)\n#define linf (1e18)\n#define pi 3.14159265358979323846\n\nvoid fileio_in_out()\n{\n freopen(\".in\",\"r\",stdin);\n freopen(\".out\",\"w\",stdout);\n}\n\nvoid fileio_txt()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n}\n\n//==================================================\n\nint n,ans=0;\n\nvoid dfs(int a,int b,long long k)\n{\n int i;\n \n if(k<=n)\n ans++;\n else return;\n \n if(b==-1)\n {\n dfs(a,b,k*10+a);\n for(i=0;i<=9;i++)\n if(i!=a)\n dfs(a,i,k*10+i);\n }\n else\n {\n dfs(a,b,k*10+a);\n dfs(a,b,k*10+b);\n }\n}\n\nint main()\n{\n //fileio_in_out();\n //fileio_txt();\n \n int i,j,k,l,t;\n \n scanf(\"%d\",&n);\n \n for(i=1;i<=9;i++)\n dfs(i,-1,i);\n \n printf(\"%d\\n\",ans);\n \n //system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dfs and similar", "bitmasks"], "code_uid": "78c84b9f0b8f5ae3ab350eb9aab3ea23", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main(int argc, char const *argv[])\n{int c=0,z,n,p=1,l,ans=0,a,i,r,flag,j,y,q,q1,ar[100],h,num,tens=1,f;\n\tscanf(\"%d\",&n);\n\tz=n;\n\tif(n<=100)\n\t{\n\t\tprintf(\"%d\\n\", n);\n\t\treturn 0;\n\t}\n\twhile(z!=0)\n\t{\n\t\tz=z/10;\n\t\tc++;\n\t}\n\tl=c;\n\tc=c-1;\n\tnum=n;\n\tfor (int i = 0; i < c; ++i)\n\t{\n\t\tans=ans+9*(9*(p-1)+1);\n\t\tp=p*2;\n\t\tar[i]=p;\n\t\tnum=num/10;\n\t\ttens=tens*10;\n\t}\na=num*tens;\nans=ans+(num-1)*(9*(p-1)+1);\nfor (int i = a; i <=n ; ++i)\n{h=i;flag=1,f=0;\n\tq=h%10;h=h/10;\n\t\t\t//printf(\"\\ni is %d\\n\",i);\n\n\tfor(j=1;j\n\nint main()\n{\n int n,k,count=0;\n \n scanf(\"%d %d\",&n,&k);\n int a[n],i,j;\n\n for(i=0;i<=n-1;i++)\n {\n scanf(\"%d\",&a[i]);\n }\n for(j=0;j<=n-1;j++)\n {\n if(a[k-1]!=0)\n {\n if(a[j]>=a[k-1])\n {\n count++;\n }\n }\n else if(a[k-1]==0)\n {\n if(a[j]>0)\n {\n count++;\n }\n }\n }\n\n printf(\"%d\",count);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "55a0d3a48866d4bf57d73614c92f28f9", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,j=0,n,k,a[50];\n scanf(\"%d %d\",&n,&k);\n if(k>=0&&k<=n)\n {\n\n for(i=0;i=a[k-1]&&a[i]>0)\n {\n\n j=j+1;\n }\n }\n printf(\"%d\",j);\n return 0;\n }\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "1ea0c1e526e08d05f6158bae928dc549", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint main() {\n\n int i,j,k,n,z,p=0,sum;\n // char pre[30];\n // char suf[30];\n scanf(\"%d\",&n);\n sum=0;\n while(n>0){\n sum=sum+n;\n n=n-2;\n }\n printf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "7059c642d1104891b3c66af47367861b", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n printf(\"%d\\n\", (n % 2)? (n + 1)*(n + 1)/4: n*(n + 2)/4);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "7e2068b7193891ef560d9de0db7022ae", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint n, a[3][6], chk[100];\nint main(){\n scanf(\"%d\", &n);\n\n for (int i=0; i\n#include \n#include \n#include \n#include \n#define MAX 3\nint s[MAX][10];\nint n;\nint sol(){\n int cnt = 0;\n for(int i = 1; i < 10; i++){\n int flag = 0;\n for(int j = 0; j < 3; j++)\n if(s[j][i]){\n flag = 1;\n break;\n }\n if(!flag) return i-1;\n }\n\n for(int i = 1; i < 10; i++){\n for(int k = 0; k < 10; k++){\n int flag = 0, num;\n for(int j = 0; j < 3; j++){\n if(s[j][i]){\n num = j;\n for(int l = 0; l < 3; l++){\n if(l == num) continue;\n if(s[l][k]){\n flag = 1;\n break;\n }\n } \n if(flag) break;\n }\n }\n if(!flag) return i*10+k -1;\n }\n }\n return 99;\n}\n \nint main(void){\n scanf(\"%d\", &n);\n for(int i = 0; i < n; i++)\n for(int j = 0; j < 6; j++){\n int tmp;\n scanf(\"%d\", &tmp);\n s[i][tmp] = 1;\n }\n\n int max = sol();\n printf(\"%d\", max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "f3004334127ddee5a8e3dc64b80fc709", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long int gcd(long long int a, long long int b)\n{\n\tlong long int r = a % b;\n\twhile (r > 0)\n\t{\n\t\ta = b;\n\t\tb = r;\n\t\tr = a % b;\n\t}\n\treturn b;\n}\nint main()\n{\n\tlong long int n;\n\tscanf(\"%lld\", &n);\n\tlong long int g = 0, i;\n\tfor (i = 2; i * i <= n; i++)\n\t\tif (n % i == 0)\n\t\t\tg = gcd(gcd(g, i), n / i);\n\tif (g == 0)\n\t\tg = n;\n\tprintf(\"%lld\\n\", g);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "64d1fe21fbb4f1aeb3ec4f09ca775bbf", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long gcdcal(long long a, long long b)\n{\n if((a%b)==0)\n return b;\n else\n return gcdcal(b, a%b);\n}\nint main()\n{\n long long n, ans, i, j, t, fac[100000], gcd;\n scanf(\"%lld\", &n);\n i=0;\n t=0;\n \n for(j=2; j*j<=n; j++)\n {\n if((n%j)==0)\n {\n fac[i]=j;\n i++;\n if(j*j!=n)\n {\n fac[i]=n/j;\n i++;\n \n }\n t++;\n }\n }\n if(t==0)\n {\n printf(\"%lld\", n);\n return 0;\n }\n gcd=fac[0];\n for(j=1; jfac[j])\n gcd=gcdcal(gcd, fac[j]);\n else\n gcd=gcdcal(fac[j], gcd);\n }\n printf(\"%lld\", gcd);\n \n}", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "230d0a1138e1dd5c90141d39e588c6df", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main()\n{\n\tchar s[13];\n\tint existe=0;\n\tint j=0;\n\tint i;\n\tint conta=0;\n\tgets(s);\n\tchar alfabeto[]=\"zyxwvutsrqponmlkjihgfedcba\";\n\twhile(existe!=1)\n\t{\n\t//\tputs(\"Hola1\");\n\t\tfor(i=0;i\n#include \n\nint main(void){\n char str[11] = {'\\0'};\n scanf(\"%s\", str);\n char max = 'a';\n int count = 0;\n for(int i = 0; i < strlen(str); i++){\n if(str[i] > max) max = str[i], count = 1;\n else if(str[i] == max) count++;\n }\n for(int i = 0; i < count; i++)\n printf(\"%c\", max);\n printf(\"\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search", "bitmasks", "greedy", "strings", "implementation"], "code_uid": "99020ef5b7501d42bac5cb8c3f086064", "src_uid": "9a40e9b122962a1f83b74ddee6246a40", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*\n *Tritonic Iridescence\n *Time complexity O(n)\n */\n\n#include\n#include\n\nint main(){\n\tint len, i, cnt, mulmark;\n\tchar *s, former;\n\n\tscanf(\"%d\", &len);\n\ts = (char*)malloc(len+1);\n\tscanf(\" %s\", s);\n\n\tmulmark = 0;\n\tif(s[0] == '?'){\n\t\tfor(i = 0; s[i] == '?'; i++);\n\t\tformer = s[i];\n\t\ti++;\n\t\tmulmark = 1;\n\t}\n\n\tfor(; i < len; i++){\n\t\tswitch(s[i]){\n\t\t\tcase '?':\n\t\t\t\tfor(cnt = 0; s[i] == '?' && i < len; i++, cnt++);\n\t\t\t\tif(i == len){\n\t\t\t\t\tmulmark = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(cnt > 1 || (cnt == 1 && s[i] == former))\n\t\t\t\t\tmulmark = 1;\n\t\t\t\tformer = s[i];\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif(s[i] == former){\n\t\t\t\t\tprintf(\"No\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tformer = s[i];\n\t\t}\n\t}\n\n\tif(mulmark == 1)\n\t\tprintf(\"Yes\");\n\telse\n\t\tprintf(\"No\");\n\tfree(s);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "dced3a8e44a142bc2d95d28898cc4b08", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n,q=0,w=0;\n scanf(\"%d\",&n);\n char c[n];\n scanf(\"%s\",c);\n int l=0;\n while(c[l]!='\\0')\n l++;\n if(c[0]==c[1]&&c[0]!='?')\n w=1;\n if(c[0]=='?'||c[l-1]=='?')\n q++;\n for(int i=1;c[i+1]!='\\0'&&w<1;i++)\n {\n if(c[i]=='?')\n {\n if(c[i-1]==c[i+1])\n q++;\n\n if(c[i-1]==c[i] || c[i+1]==c[i])\n q++;\n }\n else\n {\n if(c[i+1]==c[i]||c[i-1]==c[i])\n w++;\n }\n }\n if(w==0&&q>0)\n printf(\"Yes\");\n else\n printf(\"No\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ab8ed2779d0385df81d094ffe641e481", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a[3],t=29,i=0;\n scanf(\"%d%d%d\",&a[0],&a[1],&a[2]);\n while(a[0]+a[1]+a[2]>0)\n {\n if(a[i]>=2)\n a[i]-=2;\n else a[i]-=a[i];\n t++;\n if(i==2)\n i=0;\n else i++;\n }\n printf(\"%d\",t);\n return(0);\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "9af2fea62b95a7ddfd15872e7749994d", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n\nint r,g,b,m,ans;\n\nmain()\n{\n scanf(\"%d%d%d\",&r,&g,&b);\n for(ans=0;r>0||g>0||b>0;ans++)\n {\n if(ans%3==0)\n r-=2;\n else if(ans%3==1)\n g-=2;\n else b-=2;\n }\n printf(\"%d\\n\",29+ans);\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "3e7af86e00230b99a0b24112c7bcdaf0", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong long int min(long long int g,long long int h)\n\t { if(g0&&n>=b&&dp[n-b][a1][b1-1]==-1)\n\t\t\tdp[n-b][a1][b1-1]=func(n-b,a1,b1-1);\n\t\tif(b1>0&&dp[x-b][a1][b1-1]==-1)\n\t\t\tdp[x-b][a1][b1-1]=func(x-b,a1,b1-1);\n\t\tif(a1==0)\n\t\t{ if(n>=b)\n\t\t\t\treturn dp[n-b][a1][b1-1]; \n\t\t\telse\n\t\t\treturn\t1+dp[x-b][a1][b1-1]; }\n\t\tif(n>=a&&a1>0&&dp[n-a][a1-1][b1]==-1)\n\t\t\tdp[n-a][a1-1][b1]=func(n-a,a1-1,b1);\n\t\tif(a1>0&&dp[x-a][a1-1][b1]==-1)\n\t\t\tdp[x-a][a1-1][b1]=func(x-a,a1-1,b1);\n\t\tif(b1==0)\n\t\t{ if(n>=a)\n\t\t\treturn dp[n-a][a1-1][b1];\n\t\t\telse\n\t\t\t\treturn 1+dp[x-a][a1-1][b1]; }\n\t\tif(n\n#include\nint main() \n{\n\tint n,a,b;int s=6;\n\tscanf(\"%d%d%d\",&n,&a,&b);\n\tif (n>=4*a+2*b) s=1;\n\telse if (n>=2*a+b) s=2;\n\telse \n\t{\n\t\tif (n>=4*a) if (n>=b+b) {if (2=a+a) if (n>=b+b) {if (3=a+b) if (n>=a+a) {if (3=b+b) if (n>=a+a) {if (3\n#include\n#define max(a,b) (a>b?a:b)\n#define min(a,b) (a>b?b:a)\nint num[105];\nint dp[105];\nint main(void){\n\tmemset(dp,0x3f,sizeof(dp));\n\tint n,m;\n\tscanf(\"%i%i\",&n,&m);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%1d\",&num[i]);\n\t}\n\tdp[1]=0;\n\tfor(int i=2;i<=n;i++)\n\t{\n\t\tif(num[i])\n\t\t{\n\t\t\tfor(int k=i-1;k>i-m-1&&k;k--)\n\t\t\t{\n\t\t\t\tif(num[k])\n\t\t\t\t{\n\t\t\t\t\tdp[i]=min(dp[i],dp[k]+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%i\",dp[n]>1000?-1:dp[n]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "48ee8a3346301734d68715130ea98610", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint m,n;\n\tchar a[101];\n\twhile(scanf(\"%d %d\\n\",&m,&n)!=EOF)\n\t{\n\t\tint i,c,s=0,l=0;\n\t\tfor(i=0;i0;i--)\n\t\t {\n\t\t\t if(a[c+i]=='1')\n\t\t\t {\n\t\t\t\t c+=i;\n\t\t\t\t s++;\n\t\t\t\t break;\n\t\t\t }\n\t\t }\n\t\t if(l==c)\n\t\t\t{\n\t\t\t\tl=-1;\n\t\t\t\tprintf(\"%d\\n\",-1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(l!=-1)\n\t\t{\n\t\t\tprintf(\"%d\\n\",s);\n\t\t}\n\t}\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "dp", "implementation"], "code_uid": "6da639184cf93ce90a03cabc78d68787", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint n, k, a[110] = {0}, d, i, cnt, j;\n\tscanf(\"%d%d\", &n, &k);\n\tfor (j = 0; j < k; j++)\n\t{\n\t\tscanf(\"%d\", &i);\n\t\ta[i]++;\n\t}\n\td = k / n;\n\twhile (d > 0)\n\t{\n\t\tcnt = 0;\n\t\tfor (i = 0; i < 110; i++)\n\t\t\tcnt += a[i] / d;\n\t\tif (cnt >= n)\n\t\t\tbreak;\n\t\td--;\n\t}\n\tprintf(\"%d\", d);\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "48b8deb43c007c470af2de1542d28026", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\t int n,m,d,sum=0,i,flag=0,j,c=1;\n\t scanf(\"%d\",&n);\n\t scanf(\"%d\",&m);\n\t int a[m],b[m],k;\n for(i=0;i=1)\n {\n sum=0;\n for(k=0;ksum)sum=c/d;\n if(sum>=n){printf(\"%d\",d);flag=1;break;}\n else d--;\n\n }\n if(flag==0)printf(\"0\");\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "42b8b256e47de2417764ffbe62b95a0e", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n\n{\nint prob, min,stime,count=0,a=0,i;\n scanf(\"%d %d\", &prob,&min);\n\n stime=240-min;\n for (i=1;i<=prob;i++)\n {\n a=5*i;\n stime=stime-a;\n\n if(stime>=0)\n {\n count++;\n\n }\n else\n break;\n }\n\nprintf(\"%d\", count);\n\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "06e8226a3e8d2a6d1fc9e52f451f2a47", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "a,b,k;main(){\nscanf(\"%d%d\",&a,&b);\nwhile(b<=240)k++,b+=5*k;\na>k-1?a=k-1:0;\nprintf(\"%d\",a);\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "binary search"], "code_uid": "ac61cd9dd68e7939f05b0b26cc81f3b1", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nvoid merge(int arr[], int l, int m, int r)\n{\n int i, j, k;\n int n1 = m - l + 1;\n int n2 = r - m;\n\n /* create temp arrays */\n int 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( int arr[], int l, int r)\n{\n if (l < r)\n {\n // Same as (l+r)/2, but avoids overflow for\n // large l and h\n int 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 int sum=0;\n int i,j,k,c;\n int arr[5];\n for(i=0;i<=4;i++)\n scanf(\"%d\",&arr[i]);\n mergeSort(arr,0,4);\n for(i=0;i<5;i++)\n sum=sum+arr[i];\n int max=arr[4];\n int freq[max+1];\n for(i=0;i<=max;i++)\n freq[i]=0;\n for(i=0;i<=4;i++){\n int x=arr[i];\n freq[x]++;\n\n }\n k=0;\n int arr2[5];\n for(i=0;i<=4;i++)\n arr2[i]=100000;\n\n for(i=0;i<4;i++){\n if(freq[arr[i]]>3)\n {\n arr2[k]=sum-3*arr[i];\n k++;\n }\n else if(freq[arr[i]]<=3&&freq[arr[i]]>1){\n arr2[k]=sum-freq[arr[i]]*arr[i];\n k++;\n }\n\n }\n\n mergeSort(freq,0,max);\n if(freq[max]==1)\n printf(\"%d\",sum);\n else{\n mergeSort(arr2,0,4);\n printf(\"%d\",arr2[0]);\n }\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "5bcf0abc1375e8646c8606eadafb5dfa", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(void)\n{\n\tint a[5],b[5],i,j,k=0,c[5],t[2],m=0;\n\tint max=0;\n\tint man=0;\n\tint sum=0;\n\tint tt=0;\n\tt[0]=1;\n\tt[1]=1;\n\tmemset(c,0,sizeof(c)); \n\tfor(i=0;i<5;i++)\n\t{\n\t scanf(\"%d\",&a[i]);\n\t b[i]=a[i];\n\t}\n\tfor(i=0;i<4;i++)\n\t{\n\t\tif(b[i]!=0)\n\t\t{\n\t\t\tfor(j=i+1;j<5;j++)\n\t\t\t{\n\t\t\t\tif(b[i]==b[j])\n\t\t\t\t{\n\t\t\t\t\tt[m]++;\n\t\t\t\t\tc[k]=b[i];\n\t\t\t\t\tb[j]=0;\n\t\t\t\t}\t\n\t\t\t}\n\t\t\tif(t[m]>1) \n\t\t\t\tm++,k++;\n\t\t}\n\t}\n\tif(t[0]<3&&t[1]<3)\n\t max= c[0]>c[1] ? c[0]:c[1] ;\n if((t[0]==2&&t[1]==3)||(t[0]==3&&t[1]==2))\n\t{\n\t\tfor(i=0;i<2;i++)\n\t {\n\t \tif(t[i]==3)\n\t \t{\n\t\t\t if(c[i]*3>c[1-i]*2)\n\t\t\t\t max=c[i];\n\t\t\t\telse max=c[1-i]; \n\t\t\t}\n\t\t}\n\t}\n\tif(t[0]>=4||t[1]>=4)\n\t{\n\t\tif(c[1]!=0)\n\t\t\tmax=c[1];\n\t\telse max=c[0];\n\t\tman=1;\n\t}\n\tif(t[0]==2||t[0]==3||t[0]==4)\n\t if(t[1]==1)\n\t max=c[0];\n\tfor(i=0;i<5;i++)\n\t{\n\t\tif(a[i]==max&&man==0)\n\t\t\ta[i]=0;\n\t\tif(a[i]==max&&man==1&&tt<3) \n\t\t{\n\t\t\ta[i]=0;\n\t\t\ttt++;\n\t\t}\n\t\tsum+=a[i];\n\t}\n\tprintf(\"%d\",sum);\n\treturn 0;\n} ", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "0ceebdcde3ddbce71e27bb9497aaaf14", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char s[110];\n scanf(\"%s\",s);\n \n int l,ans=1,i,freq[27]={0},sum=0;\n l=strlen(s);\n for(i=0;i='A'&&s[i]<=\"J\"))\n {\n if(s[i]=='?')\n {\n //printf(\"here1\");\n if(i==0)\n ans=ans*9;\n else\n ans=ans*10;\n }\n else if(s[i]>='A'&&s[i]<='J')\n {\n if(i==0)\n {\n //printf(\"here2\");\n ans=ans*9;\n sum++;\n freq[s[i]-'A']=1;\n }\n else if(freq[s[i]-'A']==0)\n {\n //printf(\"here 3\");\n ans=ans*(10-sum);\n sum++;\n freq[s[i]-'A']=1;\n }\n }\n }\n }\n printf(\"%d\\n\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "0d92f410e6e111981a19adc1942d509a", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nchar str[6];\nint found[10]={}; // A~J,?\nint main(){\n gets(str);\n int i, len = strlen(str), solution = 1, letters = 10;\n if( 'A' <= str[0] && str[0] <= 'J' )\n solution = 9, found[str[0] - 'A'] = 1, letters--;\n else if( str[0] == '?' )\n solution = 9; \n for(i = 1; i < len; i++)\n if( 'A' <= str[i] && str[i] <= 'J' ){\n if( found[str[i] - 'A'] == 0)\n solution *= letters, found[str[i] - 'A'] = 1, letters--;\n }else if( str[i] == '?' )\n solution *= 10;\n printf(\"%d\\n\", solution);\n // system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "8a90f68f7f4e4c091aa1f9a85bd72b4f", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\n#define max(a,b) (a>b)?a:b\n\nint main()\n{\t\nint r1,c1,r2,c2,rook,bis,king;\n\nscanf(\"%d %d %d %d\",&r1,&c1,&r2,&c2);\n\nrook=( r1==r2 || c1==c2 ) ? 1:2;\n\nking=max(abs(r2-r1),abs(c2-c1));\n\nif((abs(r1-r2)+abs(c1-c2))%2)\nbis=0;\n\nelse\nbis=(abs(r1-r2)==abs(c1-c2))?1:2;\n\nprintf(\"%d %d %d\\n\",rook,bis,king);\n\nreturn 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "graphs", "shortest paths"], "code_uid": "d47350b174c30afb3c259d2c2c18c6f4", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint king(int r1,int c1,int r2,int c2)\n{\n\tint ct,i,j;\n\tif(r1==r2)\n\t{\n\t\tct=abs(c1-c2);\n\t\treturn ct;\n\t}\n\telse if(c1==c2)\n\t{\n\t\tct=abs(r1-r2);\n\t\treturn ct;\n\t}\n\telse\n\t{\n\t\tif(r1c2)\n\t\t\t{\n\t\t\t\tct=1;\n\t\t\t\tfor(i=r1+1,j=c1-1;i<=8 && j>=1;++i,--j)\n\t\t\t\t{\n\t\t\t\t\tif(i==r2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(c2-j);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\telse if(j==c2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(r2-i);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tct=1;\n\t\t\t\tfor(i=r1+1,j=c1+1;i<=8 && j<=8;++i,++j)\n\t\t\t\t{\n\t\t\t\t\tif(j==c2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(r2-i);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\telse if(i==r2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(c2-j);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(c1>c2)\n\t\t\t{\n\t\t\t\tct=1;\n\t\t\t\tfor(i=r1-1,j=c1-1;i>=1 && j>=1;--i,--j)\n\t\t\t\t{\n\t\t\t\t\tif(j==c2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(r2-i);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\telse if(i==r2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(c2-j);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tct=1;\n\t\t\t\tfor(i=r1-1,j=c1+1;i>=1 && j<=8;--i,++j)\n\t\t\t\t{\n\t\t\t\t\tif(j==c2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(r2-i);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\telse if(i==r2)\n\t\t\t\t\t{\n\t\t\t\t\t\tct+=abs(c2-j);\n\t\t\t\t\t\treturn ct;\n\t\t\t\t\t}\n\t\t\t\t\tct++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\nint full_leftdiag(int temp1,int temp2,int r2,int c2)\n{\n\tint i,j;\n\tfor(i=temp1,j=temp2;i>=1 && j>=1;--i,--j)\n\t\tif(i==r2 && j==c2)\n\t\t\treturn 2;\n\tfor(i=temp1,j=temp2;i<=8 && j<=8;++i,++j)\n\t\tif(i==r2 && j==c2)\n\t\t\treturn 2;\n\treturn 0;\n}\nint full_rightdiag(int temp1,int temp2,int r2,int c2)\n{\n\tint i,j;\n\tfor(i=temp1,j=temp2;i<=8 && j>=1;++i,--j)\n\t\tif(i==r2 && j==c2)\n\t\t\treturn 2;\n\tfor(i=temp1,j=temp2;i>=1 && j<=8;--i,++j)\n\t\tif(i==r2 && j==c2)\n\t\t\treturn 2;\n\treturn 0;\n}\nint right_diag(int r1,int c1,int r2,int c2) //diagonals starting from right\n{\n\tint temp1,temp2,ct;\n\tfor(temp1=r1+1,temp2=c1-1;temp1<=8 && temp2>=1;++temp1,--temp2)\n\t{\n\t\tif(temp1==r2 && temp2==c2)\n\t\t\treturn 1;\n\t\tct=full_leftdiag(temp1,temp2,r2,c2);\n\t\tif(ct!=0)\n\t\t\treturn ct;\n\t}\n\tfor(temp1=r1-1,temp2=c1+1;temp1>=1 && temp2<=8;--temp1,++temp2)\n\t{\n\t\tif(temp1==r2 && temp2==c2)\n\t\t\treturn 1;\n\t\tct=full_leftdiag(temp1,temp2,r2,c2);\n\t\tif(ct!=0)\n\t\t\treturn ct;\n\t}\n\treturn 0;\n}\nint left_diag(int r1,int c1,int r2,int c2) //diagonals starting from left\n{\n\tint temp1,temp2,ct;\n\tfor(temp1=r1+1,temp2=c1+1;temp1<=8 && temp2<=8;++temp1,++temp2)\n\t{\n\t\tif(temp1==r2 && temp2==c2)\n\t\t\treturn 1;\n\t\tct=full_rightdiag(temp1,temp2,r2,c2);\n\t\tif(ct!=0)\n\t\t\treturn ct;\n\t}\n\tfor(temp1=r1-1,temp2=c1-1;temp1>=1 && temp2>=1;--temp1,--temp2)\n\t{\n\t\tif(temp1==r2 && temp2==c2)\n\t\t\treturn 1;\n\t\tct=full_rightdiag(temp1,temp2,r2,c2);\n\t\tif(ct!=0)\n\t\t\treturn ct;\n\t}\n\treturn 0;\n}\nint bishop(int r1,int c1,int r2,int c2)\n{\n\tint ct;\n\tct=left_diag(r1,c1,r2,c2);\n\tif(ct!=0)\n\t\treturn ct;\n\telse\n\t\tct=right_diag(r1,c1,r2,c2);\n\treturn ct;\n}\nint main()\n{\n\tint r1,c1,r2,c2,ct1,ct2,ct3;\n\tscanf(\"%d%d%d%d\",&r1,&c1,&r2,&c2);\n\tif(r1==r2 || c1==c2)\n\t\tct1=1;\n\telse\n\t\tct1=2;\n\tprintf(\"%d \",ct1);\n\tct2=bishop(r1,c1,r2,c2);\n\tprintf(\"%d \",ct2);\n\tct3=king(r1,c1,r2,c2);\n\tprintf(\"%d\\n\",ct3);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "graphs", "shortest paths"], "code_uid": "83b32f45b946232671460f5861d7ba67", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main(){\n int n,k,e=0,s=0,max=0,temp=0;\n scanf(\"%d %d\",&n,&k);\n int str[n];\n for(int i=0;imax) max=temp;\n }\n printf(\"%d\",max);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "49cafc6fb6362c9c1d201de91b3339fc", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int n,k,pcount=0,ncount=0,mag,max=0;\n scanf(\"%d%d\",&n,&k);\n int array[n];\n for(int i=0;i0)\n pcount++;\n }\n ncount=n-pcount;\n for(int i=0;i\n#define sqr(x) ((x)*(x))\nint mod(int x)\n{\n\tif(x>=0) return x;\n\telse return -x;\n}\nint max(int x,int y)\n{\n\tif (x>y) return x;\n\telse return y;\n}\nint res(int a, int b)\n{\n\treturn (a%b+b)%b;\n}\nint main ()\n{\n\tint n, a, b, c, d;\n\tlong long resp;\n\tscanf(\"%d %d %d %d %d\", &n, &a, &b, &c, &d);\n\tresp = max(max(mod(c-b), mod(c-b+d-a)), max(mod(d-a), mod(a+c-d-b)));\n\tif(n-resp>0) printf(\"%lli\\n\", n*(n-resp));\n\telse printf(\"0\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "50d9d422329a764eb4a63c04ea478001", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n int a,b,c,d,e,f;\n scanf(\"%d%d%d%d%d\",&f,&a,&b,&c,&d);\n int flag=0; int i; int cnt=0;\n for(i=1;i<=f;i++){\n int top = i+1+a+b; cnt=0;\n if((top - (1+c+d))<=f && (top-(1+c+d))>0)\n cnt++;\n if((top - (1+b+d))<=f && (top-(1+b+d))>0)\n cnt++;\n if((top - (1+c+a))<=f && (top-(1+c+a))>0)\n cnt++;\n if(cnt == 3){\n flag = 1;\n break;\n }}\n if(!flag){\n printf(\"0\");\n return 0;}\n cnt = i;\n int m=i; cnt=0;\n for(i=m;i<=f;i++){\n int top = i+1+a+b;\n if((top - (c+d+1))<0 || (top - (c+d+1))>f){\n break;\n }\n if((top - (b+d+1))<0 || (top - (b+d+1))>f){\n break;\n }\n if((top - (c+a+1))<0 || (top - (c+a+1))>f){\n break;\n }\n cnt++;\n }\n printf(\"%lld \",(long long int)cnt * f);\n }\n", "lang_cluster": "C", "tags": ["brute force", "math", "constructive algorithms"], "code_uid": "edbe099602b97ecfff835eb77cd5339c", "src_uid": "b732869015baf3dee5094c51a309e32c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,n,k,a[105],x=0,count=0;\n scanf(\"%d\",&n);\n for(i=0; i\nint main()\n{\n int n,i,a,sum,m;\n sum=0;\n scanf(\"%d\",&n);\n for(i=0;i\n#include \n#include \n//#include \n#ifndef LL\n#define LL long long\n#endif\n#ifndef uLL\n#define uLL unsigned long long\n#endif\n#ifndef uL\n#define uL unsigned int\n#endif\n#ifndef iL\n#define iL int\n#endif\n#ifndef iS\n#define iS short\n#endif\n#ifndef uS\n#define uS unsigned short\n#endif\n#ifndef uC\n#define uC unsigned char\n#endif\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n#define abs(a) (((a)<0)?(-(a)):(a))\n#define sgn(a) (((a)<0)?(1):(0))\n#define movs(a,b,l) (memmove((a),(b),sizeof(*(b))*(l)))\n#define stosb(a,b,l) (memset((a),(b),sizeof(*(a))*(l)))\nstatic inline uL bsr(uL a)\n{\n __asm__(\"bsrl %0,%0\":\"+r\"((uL)a));\n return a;\n}\nstatic inline uLL sqrt64(uLL x)\n{\n uLL t,g;\n for (g=(x>>1)+(x&1),t=x;g>1)\n {\n t=g;\n }\n return t;\n}\nstatic inline uLL gcd(uLL a,uLL b)\n{\n while (a>0)\n {\n b=(b%a)^a;\n a=a^b;\n b=a^b;\n }\n return b;\n}\nuLL prime[4000001];\nuLL EulerSieve(uLL n)\n{\n uLL i,j;\n memset(prime,0,sizeof(*prime)*(n+1));\n *prime=0;\n for (i=2;i<=n;i++)\n {\n if (prime[i]==0)\n {\n prime[++(*prime)]=i;\n prime[i]=i;\n }\n for (j=1;j<=*prime;j++)\n {\n if (i*prime[j]>n) {break;}\n prime[i*prime[j]]=prime[j];\n if (prime[i]==prime[j]) {break;}\n }\n }\n return *prime;\n}\nuLL fac[10000];\nuLL times[10000];\nuLL factoring(uLL a,uLL *fac,uLL *times)\n{\n\tuLL k,i,l;\n\tl=sqrt64(a);\n\tfor (k=0,i=1;(i<=prime[0])&&(prime[i]<=l);i++)\n\t{\n\t\tif (a%prime[i]==0)\n\t\t{\n\t\t\tfac[++k]=prime[i];\n\t\t\ttimes[k]=1;\n\t\t\tfor (a=a/prime[i];a%prime[i]==0;a=a/prime[i],times[k]+=1);\n\t\t}\n\t}\n\tif (a>1)\n\t{\n\t\tfac[++k]=a;\n\t\ttimes[k]=1;\n\t}\n\treturn k;\n}\nLL aa,bb,kk,ans1,ans2;\nLL dfs(LL x,LL id)\n{\n\tLL i,j,y;\n\tif (id>*fac)\n\t{\n\t\tkk=x-aa%x;\n\t\tif (x-bb%x==kk)\n\t\t{\n\t\t\t//printf(\"%lld %lld\\n\",x,kk);\n\t\t\tif ((aa+kk)/x*(bb+kk)b) {c=a;a=b;b=c;}\n\tif (b%a==0)\n\t{\n\t\tprintf(\"0\\n\");\n\t}\n\telse\n\t{\n\t\tans1=a/gcd(a,b)*b;ans2=0;\n\t\t*fac=factoring(b-a,fac,times);\n\t\taa=a;bb=b;\n\t\tdfs(1,1);\n\t\tprintf(\"%lld\\n\",ans2);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "42229c6e07a2bbf494717353483f08ae", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define lli long long int\ndouble sqrt(double i){\n\tdouble a = 2.0;\n\tint k = 100;\n\twhile(k-->0){\n\t\ta = (a+i/a)/2.0;\n\t}\n\treturn a;\n}\nint main(void){\n\tlli a,b;\n\tscanf(\"%lld %lld\",&a,&b);\n\tif(a == b){\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tif(a > b){\n\t\tint ch = a;\n\t\ta = b;\n\t\tb = ch;\n\t}\n\tlli q = b - a;\n\tlli j = a/q;\n\tif(q*j < a)\n\t\tj++;\n\tq *=j;\n\tint za = 0;\n\tint rq = sqrt(q);\n\tint me = 1;\n\tint meb = q;\n\twhile((++za) = a)\n\t\t\t\tbreak;\n\t\t\tif((q/za)>=a)\n\t\t\t\tmeb = q/za;\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tif(me < a)\n\t\tza = meb;\n\telse\n\t\tza = me;\n\tlli k = za - a;\n\tprintf(\"%lld\\n\",k);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "ccbcbabf9cd42be4d776024ce5a408a4", "src_uid": "414149fadebe25ab6097fc67663177c3", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,i,count=0;\n scanf(\"%d\",&a);\n int b[a];\n for(i=0;i\nint main()\n{\n int n,i,a[105],sum=0,flag=1;\n scanf(\"%d\",&n);\n for(i=0; i\n#include \n#include \n#include \n\n#define pi 3.1415926\n#define rep(x,ini,end) for(x=(ini);x<(end);x++)\n#define per(x,ini,end) for(x=(end-1);x>=(ini);x--)\n#define max(x,y) ((x)>(y)?(x):(y))\n#define min(x,y) ((x)<(y)?(x):(y))\n\nint main()\n{\n int h1, h2;\n scanf(\"%d %d\", &h1, &h2);\n int a, b;\n scanf(\"%d %d\", &a, &b);\n\n if (h2-h1a*8) && (a<=b))\n {\n printf(\"-1\"); return 0;\n }\n\n int day = 0;\n int dayend,nightend;\n while (1)\n {\n if (day == 0)\n {\n dayend = h1 + a * 8;\n }\n else\n {\n dayend = nightend + a * 12;\n }\n if (dayend>=h2)\n {\n printf(\"%d\",day); return 0;\n }\n nightend = dayend - b * 12;\n// if (nightend<=0)\n// {\n// printf(\"%d\",day+1); return 0;\n// }\n day++;\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "4b9a749145af9a5f6c8ed7b25e64056b", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\tlong long h1,h2,a,b,k,res;\n\tscanf(\"%lld%lld\",&h1,&h2);\n\tscanf(\"%lld%lld\",&a,&b);\n\tif(ab)\n\t{\n\t k=0;res=0;\n\twhile (h1 < h2)\n\t{\n\t if(k == 0)\n\t\t h1 = h1 + a * 8;\n\t\telse\n\t\t h1 = h1 + a * 12;\n\t\tk++;\n\t\tif (h1 > h2 && (k == 1))\n\t\t{\n\t\t\tprintf(\"0\");\n\t\t\treturn 0;\n\t\t}\n\t\tif(h1 >= h2)\n\t\t{\n\t\t printf(\"%lld\",res);\n\t\t return 0;\n\t\t}\n\t\th1 = h1 - 12 * b;\n\t\tres++;\n\t}\n\t\tprintf(\"%lld\",res);\n}\n\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c421d4111eb18ebc48e8975708fea9a6", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint a[4][4],i,j;\n\tfor (i = 0; i < 4; i++)\n\t{\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tscanf(\"%d\",&a[i][j]);\n\t\tif (a[i][3] == 1 && (a[i][0] == 1 || a[i][1] == 1 || a[i][2] == 1))\n\t\t{\n\t\t\tprintf(\"YES\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tfor (i = 0; i < 4;i++)\n\t{\n\t\tif (a[i][3] == 1)\n\t\t\tif (a[(i + 1) % 4][0] || a[(i + 2) % 4][1] || a[(i + 3) % 4][2])\n\t\t\t{\n\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t}\n\tprintf(\"NO\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e4a1db6d2e6774eb8f5f81198dfb8db1", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint check(int *a,int *b,int *c,int *d)\n\n{\n if(a[0]==1&&d[3]==1)\n \n return 1;\n \n\n if(a[1]==1&&c[3]==1)\n \n return 1;\n \nif(a[2]==1&&b[3]==1)\n \n return 1;\n \n if((a[0]==1||a[1]==1||a[2]==1)&&a[3]==1)\n \n return 1;\n \nelse return 0;\n}\n\n\n\n\nint main()\n{\n int i,j,a[4],b[4],c[4],d[4],a1,b1,c1,sum=0;\n \n for(i=0;i<4;i++)\n \n scanf(\"%d\",&a[i]);\n \n for(i=0;i<4;i++)\n \n scanf(\"%d\",&b[i]); \n \n for(i=0;i<4;i++)\n \n scanf(\"%d\",&c[i]); \n \n for(i=0;i<4;i++)\n \n scanf(\"%d\",&d[i]); \n \n\n j=check(a,b,c,d);\n a1=check(b,c,d,a);\n b1=check(c,d,a,b);\n c1=check(d,a,b,c);\n sum=j+a1+b1+c1;\n \nif(sum>0)\n \n printf(\"YES\");\n \n else printf(\"NO\");\n \n \n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "1d1785a3d0ec07e8cbc21ab64de635e7", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(void)\n{\n long long n,i;\n scanf(\"%lld\",&n);\n for(i=2;i*i<=n;i++)\n if(n%(i*i)==0)\n {\n n/=i;\n i=1;\n }\n printf(\"%lld\",n);\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "14b71488cc903bd6fa3f6cb7cb33d7cb", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint func(long long int n)\n{\n long long i;\n for(i=2;i*i<=n;i++)\n {\n if(n%(i*i)==0)\n return 0;\n }\n return 1;\n}\nint main()\n{\n long long int n,i,max=1,tmp;\n scanf(\"%lld\",&n);\n for(i=1;i*i<=n;i++)\n {\n if(n%i==0)\n {\n if(func(n/i))\n {\n max=n/i;\n break;\n }\n else\n if(func(i))\n max=i;\n }\n }\n printf(\"%lld\",max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "91ec44f828d576ef773a5424bb36feef", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c=0,i,j;\n scanf(\"%d%d\",&a,&b);\n\n for(i=1;; i++)\n {\n if(i%2==0)\n b=b-i;\n else\n a=a-i;\n\n if(b<0)\n {\n c=1;\n break;\n }\n else if(a<0)\n {\n break;\n }\n }\n if(c==0)\n printf(\"Vladik\");\n\n else\n printf(\"Valera\");\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "31a835460eb2dc4543adbb11e5ab8c49", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n//#include \"maths.h\"\ndouble zero = 0;\ndouble square_root(double num)\n{\n if(num < 0){\n return 0 / zero;\n }\n double root = 1;\n while(num >= 100){\n num /= 100;\n root *= 10;\n }\n while(num < 1){\n num *= 100;\n root /= 10;\n }\n double d = (1 + num) / 2;\n int i = 0;\n do{\n d = (d + num / d) / 2;\n i++;\n }while(i < 50);\n return d * root;\n}\nint main()\n{\n //while(1){\n int v1, v2, vlad, val;\n scanf(\"%d%d\", &v1, &v2);\n vlad = square_root(v1);\n val = square_root(v2);\n while(val * (val + 1) <= v2)\n val++;\n val--;\n //print loser\n if(vlad <= val)\n printf(\"Vladik\\n\");\n else\n printf(\"Valera\\n\");\n //}\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "0512b13156c3781c6a9f54f3594b5e8e", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long n,m,k,a,min,max;\n\tscanf(\"%lld %lld\",&n,&m);\n\tfor(a=0;a<=m;a++)\n\t{\n\t\tk=a*(a-1);\n\t\tif(k>=(2*m))\n\t\t\tbreak;\n\t}\n\tmax=n-a;\n\tmin=n-2*m;\n\tif(min<0)\n\t\tmin=0;\n\tprintf(\"%lld %lld\\n\",min,max);\n}\n\n", "lang_cluster": "C", "tags": ["constructive algorithms", "graphs"], "code_uid": "8750d657f73a30996b6edb5631d0981a", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tlong long int n,m;\n\tscanf(\"%lld%lld\",&n,&m);\n\tif(m==0)\n\t{\n\t\tprintf(\"%lld %lld\\n\",n,n);\n\t\texit(0);\n\t\t\t}\n\tlong long int k,min,max,n1;\n\tmin=n-(2*m);\n\tif(min<0)\n\tmin=0;\n//\tprintf(\"sd\\n\");\n\tn1=1;\n\n\t\n\twhile(1)\n\t{\tk=(n1*(n1-1))/2;\t\n\t\tif(k=m)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\t\n\t}\n\tmax=n-n1;\n\n\tprintf(\"%lld %lld\\n\",min,max);\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "graphs"], "code_uid": "ef91b1349d480a85b9605b5fa8d22848", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tint i,count,x,temp,j,q,flag=0,c=0,v=0,k=0;\n\tchar n[100],m[100];\n\tscanf(\"%s\",n);\n\tscanf(\"%s\",m);\n\tcount=strlen(n);\n\tx=strlen(m);\n\tif(count!=x)\n\t{\n\t\tprintf(\"WRONG_ANSWER\");\n\t}\n\telse if(n[0]=='0'&& m[0]=='0')\n\t{\n\t\tfor(i=0;in[j+1])\n {\n temp=n[j];\n n[j]=n[j+1];\n n[j+1]=temp;\n }\n\t\t}\n\t}\n\tfor(i=0;i\n#include\n\nint i,j,k =1,x,y,z,a,b,c,min=789;\n\nint main() {\n\n\tchar d[10],g[10],u[40];\n\n\tscanf(\"%s %s\",d,u);\n\t\n\ta = strlen(d);\n\tz = strlen(u);\n\n\tif(a != z){\n\t\tprintf(\"WRONG_ANSWER\");\n\t\treturn 0;\n\t}\n\tfor(i=0 ; i\n#include\nint main()\n{\n int test,i,g,t,k,flag,n,l;\n\n scanf(\"%d %d\",&n,&k);\n char a[n+3];\n scanf(\"%s\",a);\n l=strlen(a);\n g=0;\n t=0;\n for(i=0;it)\n {\n i=g;\n g=t;\n t=i;\n }\n if((t-g)%k==0)\n {\n flag=0;\n for(i=g;i<=t;i+=k)\n {\n if(a[i]=='#')\n flag=1;\n }\n if(flag==1)\n printf(\"NO\");\n else\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "ea6739e8f1391a9419d6b8f8fd329cd6", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n char arr[200];\n int i,j,jp,g,t,cl,jm,a,m,n;\n scanf(\"%d%d\",&cl,&jm);\n\n scanf(\"%c\",&arr[0]);\n\n for(i=1;i<=cl;i++)\n scanf(\"%c\",&arr[i]);\n\n\n for(i=1;i<=cl;i++){\n if(arr[i]=='G'){\n g=i;\n }\n if(arr[i]=='T'){\n t=i;\n }\n }\n\n if(g>t){\n m=t;\n n=g;\n a=g-t;}\n else{\n m=g;\n n=t;\n a=t-g;}\n\n for(i=m; i\nmain()\n{\n int i,j=0,k=0,c,b,l;\n char a[20];\n scanf(\"%s\",a);\n scanf(\"%d\",&b);\n l=strlen(a);\n for(i=l-1;i>=0;i--)\n {\n if(a[i]=='0')\n {\n j++;\n if(j==b)\n {\n k=i;\n break;\n }\n }\n }\n if(k==0)\n printf(\"%d\",l-1);\n else\n {\n k=l-k;\n k=k-b;\n printf(\"%d\",k*1);\n }\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "5c0c2745593e3ac15762f2ac656f88e3", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint n,k,i,a[20]={0},val,x,z,count;\n\t//printf(\"hello\\n\");\n\tscanf(\"%d %d\",&n,&k);\n\t//printf(\"hello\\n\");\n\t//printf(\" hello %d%d\",n,k);\n\ti=-1;\n\tif(n>0)\n\t{\n\t\twhile(n)\n\t\t{\n\t\t\ti++;\t\n\t\t\ta[i]=n%10;\n\t\t\tn=n/10;\n\t\t}\n\t\tx=i;\n\t\tcount=0;\n\t\tfor(i=0;i<=x;i++)\n\t\t{\n\t//\t\tprintf(\"%d\",a[i]);\n\t\t\tif(a[i]==0)\n\t\t\t\tcount++;\n\t\t}\n\t//\tprintf(\"%d\",count);\n\t\tif(count=k)\n\t\t{\n\t\t\t z=k;\n\t\t\t val=0;\n\t\t\tfor(i=0;i<=x;i++)\n\t\t\t{\n\t\t\t\tif(z)\n\t\t\t\t{\n\t\t\t\t\tz--;\n\t\t\t\t\tif(a[i]!=0)\n\t\t\t\t\t{\n\t\t\t\t\t\tz++;\n\t\t\t\t\t\tval++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tprintf(\"%d\\n\",val);\n\t\t}\n\t}\n\telse if(n==0)\n\t\tprintf(\"0\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "06f7a1748051f8fe364e78c7f6ae0ff6", "src_uid": "7a8890417aa48c2b93b559ca118853f9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint a[30];\n\nint MIN(int x, int y){\n\tif (x= i; j--){\n\t\t\tttt = a[j];\n\t\t\ta[j] = a[j + 1];\n\t\t\ta[j + 1] = ttt;\n\t\t}\n\t}\n\n\tfor (i = 1; i <= n; i++){\n\t\tprintf(\"%d\", a[i]);\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "df7a13faf9fedda53872be2abe6cee3c", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tchar tmp, max;\n\tint i, j, imax, l, k;\n\tstatic char a[20];\n\n\tscanf(\"%s\", a);\n\tscanf(\"%d\", &k);\n\tl = strlen(a);\n\tfor (i = 0; i < l; i++) {\n\t\tif (k == 0)\n\t\t\tbreak;\n\t\tmax = 0;\n\t\tfor (j = i + 1; j <= i + k && j < l; j++)\n\t\t\tif (max < a[j]) {\n\t\t\t\timax = j;\n\t\t\t\tmax = a[j];\n\t\t\t}\n\t\tif (a[i] < max)\n\t\t\tfor (j = imax; j >= i + 1; j--) {\n\t\t\t\tif (k == 0)\n\t\t\t\t\tbreak;\n\t\t\t\ttmp = a[j], a[j] = a[j - 1], a[j - 1] = tmp;\n\t\t\t\tk--;\n\t\t\t}\n\t}\n\tprintf(\"%s\\n\", a);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "da4b6576f9e40fbe495cf9f9e7520dfc", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint n;\n\tscanf(\"%d\", &n);\n\tint c = 0;\n\twhile(n > 0) {\n\t\tn /= 2;\n\t\tc++;\n\t}\n\tprintf(\"%d\\n\", c);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "39b8718b862a55bb8e6acb3ee560dde7", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long int n;\n scanf(\"%ld\",&n);\n long int i=1,j=0;;\n for(;i<=n;i=i*2)\n j++;\n printf(\"%ld\\n\",j);\n}", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms"], "code_uid": "11175ce29e3293914055e28c27beb200", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#define max(a, b) (a>b?a:b)\n\n#define LIMIT 30001\n#define WIDTH 500\n\nlong long int powerModulo(long long int a, long long int p, long long int m)\n{ \n if(p==0)\n return 1;\n\n long long int temp = powerModulo(a, p/2, m);\n temp = (temp * temp)%m;\n if(p%2 == 0)\n return temp;\n else\n return (a * temp)%m;\n}\n\nlong long int inverseModulo(long long int a, long long int P)\n{\n return powerModulo(a, P-2, P);\n}\n\nint isGood(int n, int a, int b)\n{\n while(n > 0)\n {\n int last = n%10;\n if(last == a || last == b)\n n = n/10;\n else\n return 0;\n }\n return 1;\n}\n\nint main()\n{\n int a, b, n;\n scanf(\"%d %d %d\", &a, &b, &n);\n\n long long int P = 1000000007;\n int N_MAX = 1000000;\n\n long long int *factorial_inverse;\n factorial_inverse = (long long int*)(malloc(sizeof(long long int) * (N_MAX + 1) ));\n factorial_inverse[0] = 1;\n\n for(int i = 1; i <= N_MAX; i++)\n factorial_inverse[i] = (inverseModulo(i, P) * factorial_inverse[i - 1])%P;\n\n long long int n_factorial = 1;\n for(int i = 2; i <= n; i++)\n {\n n_factorial = (n_factorial * i)%P;\n }\n\n long long int ans = 0;\n for(int num_of_a = 0; num_of_a <= n; num_of_a++)\n {\n int sum_of_digits = num_of_a * a + ( n - num_of_a ) * b;\n if(!isGood(sum_of_digits, a, b))\n continue;\n\n long long int temp = (factorial_inverse[n - num_of_a] * factorial_inverse[num_of_a])%P;\n temp = (n_factorial * temp)%P;\n ans = (ans + temp)%P;\n }\n printf(\"%lld\\n\", ans);\n}\n", "lang_cluster": "C", "tags": ["brute force", "combinatorics"], "code_uid": "b21dbc0ef92b3fb2e2ed8dfaa684d18d", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n long long f[1000001];\n long long find_mmi(long long base,long long n,long long m)\n {\n if(n==0)\n return 1;\n if(n==1)\n return base;\n long long halfn=find_mmi(base,n/2,m);\n if(n%2==0)\n return ((halfn*halfn)%m);\n else\n return ((halfn*halfn)%m*base)%m;\n }\nmain()\n{\n int a,b,n,eat=0,iter;long long div=1000000007;\n scanf(\"%d%d%d\",&a,&b,&n);\n f[0]=1;\n for(iter=1;iter<=n;iter++)\n f[iter]=((f[iter-1]*(n-iter+1))%div*find_mmi(iter,div-2,div))%div;\n long long no=a*n,new_no,k,tot_no=0;\n while(no<=b*n)\n {\n new_no=no;\n while(new_no>0)\n {\n k=new_no%10;\n if(k!=a&&k!=b)\n {\n eat=1;\n break;\n }\n new_no/=10;\n }\n if(eat==0)\n tot_no=(tot_no+f[(no-a*n)/(b-a)])%div;\n no+=b-a;\n eat=0;\n }\n printf(\"%I64d\",tot_no%div);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "combinatorics"], "code_uid": "3374088d271c4dead7b9b94a9b12228b", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n//#include \nint main()\n{\n int x,y,j;\n scanf(\"%d%d\",&x,&y);\n j=1;\n do{\n if(j%2==1)\n {\n if((x*100+y*10)>=220)\n {\n if(x>=2 && y>=2)\n {\n x=x-2;\n y=y-2;\n }\n else if(x>=2 && y<2)\n {\n printf(\"Hanako\");\n break;\n }\n else if(x<2 && y>=2)\n {\n if(y>=(220-x*100)/10)\n {\n x=0;\n y=y-(220-x*100)/10;\n }\n else\n {\n printf(\"Hanako\");\n break;\n }\n }\n\n\n }\n else\n {\n printf(\"Hanako\");\n break;\n }\n }\n else\n {\n if(x*100+y*10>=220)\n {\n if(y>=22)\n y=y-22;\n else\n {\n if(y>=12)\n {\n y=y-12;\n x=x-1;\n }\n else if(y>=2)\n {\n x=x-2;\n y=y-2;\n }\n else\n {\n printf(\"Ciel\");\n break;\n }\n\n }\n }\n else {\n printf(\"Ciel\");\n break;\n }\n }\n j++;\n }while(1);\n\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "e15e88df6c6db4a00f4f8a18373208d2", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n long int x = 0, y = 0;\n long int i=0;\n\n\tscanf( \"%d %d\", &x, &y);\n\twhile(y > 1){\n\t\tif (i%2 == 0) {\n\t\t\tif( x == 0 ){\n\t\t\t\tif(y < 22)\n\t\t\t\t\tbreak;\n\t\t\t\ty -= 22;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\telse if(x == 1){\n\t\t\t\tif(y < 12)\n\t\t\t\t\tbreak;\n\t\t\t\tx -= 1;\n\t\t\t\ty -= 12;\n\t\t\t\ti++;\n\t\t\t}\n\t\t\telse if(x >= 2){\n\t\t\t\tx -= 2;\n\t\t\t\ty -= 2;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else {\n\t\t\tif (y >= 22) {\n\t\t\t\ty -= 22;\n\t\t\t\ti++;\n\t\t\t} else if(y >= 12) {\n\t\t\t\tif (x < 1)\n\t\t\t\t\tbreak;\n\t\t\t\tx -= 1;\n\t\t\t\ty -= 12;\n\t\t\t\ti++;\n\t\t\t} else {\n\t\t\t\tif (x < 2)\n\t\t\t\t\tbreak;\n\t\t\t\tx -= 2;\n\t\t\t\ty -= 2;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t}\n\ti= i%2;\n\tif(i == 0)\n\t{printf(\"Hanako\");\n\t}\n\telse{\n\tprintf(\"Ciel\");\n\t}\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "576f2af65109be2a53fb5803f64e8759", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define ll long long\nint main(){\n ll p,d; \n\tscanf(\"%lld %lld\",&p,&d);\n ll n=++p;\n for(ll k=10;;k*=10){\n if(p%k>d)\n\t\t\tbreak;\n n=p-(p%k);\n }\n\tprintf(\"%lld\",n-1);\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c8920744fdf50b619b52da3d035482f9", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/219/submission/20480662 (Dukkha) */\n#include \n\nint main() {\n\tlong long p, d, x, q_;\n\tint i;\n\n\tscanf(\"%lld%lld\", &p, &d);\n\tq_ = p;\n\tx = 1;\n\tfor (i = 0; i < 18; i++) {\n\t\tlong long q;\n\n\t\tx *= 10;\n\t\tq = p % x == x - 1 ? p : (p / x - 1) * x + x - 1;\n\t\tif (p - q <= d)\n\t\t\tq_ = q;\n\t}\n\tprintf(\"%lld\\n\", q_);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c1af12c643ca0c6a365294ecaeb7b7c4", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nchar greeting[5] = {'A', 'C', 'T', 'G','\\0'};\n\nint substring(char arr[]){\n int i,temp,sum=0,temp1;\n for(i=0;i<4;i++){\n if(greeting[i] != arr[i]){\n if(greeting[i] < arr[i]){\n temp = abs(greeting[i]-arr[i]);\n temp1 = 1 + abs('Z' - arr[i]) + abs('A' - greeting[i]);\n if(temp\nint main()\n{\nint n,i,t=0,m=1000000,r;\nscanf(\"%d\",&n);\nchar s[n];\nscanf(\"%s\",s);\nfor(i=0;i\n#include\nint main()\n{\n int x,y,z,t1,t2,t3,a,b;\n scanf(\"%d %d %d %d %d %d\",&x,&y,&z,&t1,&t2,&t3);\n if(x>y)\n {\n a=t1*(x-y);\n }\n else\n {\n a=t1*(y-x);\n }\n if(x>z)\n {\n b=(x-z)*t2;\n if(x>y)\n {\n b=b+t2*(x-y)+3*t3;\n }\n else\n {\n b=b+t2*(y-x)+3*t3;\n }\n }\n else\n {\n b=(z-x)*t2;\n if(x>y)\n {\n b=b+t2*(x-y)+3*t3;\n }\n else\n {\n b=b+t2*(y-x)+3*t3;\n }\n }\n if(a\n#include \n\nint main()\n{\n\tint x,y,z,t1,t2,t3,time1,time2;\n\tscanf(\"%d%d%d%d%d%d\",&x,&y,&z,&t1,&t2,&t3);\n\ttime1=abs(y-x)*t1;\n\ttime2=abs(x-z)*t2+3*t3+abs(x-y)*t2;\n\tif(time2<=time1)printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f03cd93f4596c5cf35cbf90dc2bbb7e2", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int m,k,q,n=0,t,i;\n scanf(\"%d %d\",&m,&k);\n i=2;\n while (i<9)\n {\n\t t=m*i;\n\t q=t/k;\n\t if ((t%k)!=0)\n\t n=n+q+1;\n\t else \n\t n=n+q;\n\t i=i+3;\n }\n printf (\"%d\",n);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "80b72e1cf9a511b3a2116f774ed0739a", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n\n\t#include \n\nint main(int argc, char **argv)\n{\n\tint n,k,p,a,b,c;\n\tscanf(\"%d%d\",&n,&k);\n\t\n\tif ((n*2)%k!=0)\n\ta=((n*2)/k)+1;\n\telse\n\ta=(n*2)/k;\n\t\n\tif ((n*5)%k!=0)\n\tb=((n*5)/k)+1;\n\telse\n\tb=(n*5)/k;\n\t\n\tif ((n*8)%k!=0)\n\tc=((n*8)/k)+1;\n\telse\n\tc=(n*8)/k;\n\tp=a+b+c;\n\tprintf(\"%d\",p);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "28649f0ee1ff331454ab16d935a731fe", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a[101][101];\n int n,i,j,t;\n long long int sum=0;\n scanf(\"%d\",&n);\n t=n/2;\n for(i=0;i\n\nmain(){\n int n, s = 0;\n scanf(\"%d\", &n);\n int mt[n][n];\n int j = 0, i = 0;\n for(i = 0; i < n; i++){\n for(j = 0; j < n; j++){\n\n scanf(\"%d\", &mt[i][j]);\n if ( i == j)\n s += mt[i][j];\n if ( i + j == n-1)\n s += mt[i][j];\n if (i == (n-1)/2)\n s += mt[i][j];\n if (j == (n-1)/2)\n s += mt[i][j]; \n }\n } \n i = (n - 1) / 2;\n j = i;\n s = s - (3*mt[i][j]);\n printf(\"%d\", s);\n }\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f90c1cc5ef21dea6fb3062faab82e979", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n long long int l,r;\n scanf(\"%lld %lld\",&l,&r);\n\n int len2 = 0, len3 =0;\n\n long long int pow2[100],pow3[100];\n long long ans =0;\n\n long long int x = 1;\n while(x<=r)\n {\n pow2[len2++]=x;\n if(x>=l)\n {\n //printf(\"%lld\\n\",x);\n ans++;\n }\n x*=2;\n }\n\n x = 1;\n while(x<=r)\n {\n pow3[len3++]=x;\n if(x>=l)\n {\n //printf(\"%lld\\n\",x);\n ans++;\n }\n x*=3;\n }\n\n int i,j;\n for(i = 1;i= l && x<=r)\n {\n //printf(\"%lld\\n\",x);\n ans++;\n }\n }\n }\n\n if(l==1)\n ans--;\n\n printf(\"%lld\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "227dea383a4acf8a2d1986467bb9f01e", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint num[326] = {\n 1,\n 2,\n 3,\n 4,\n 6,\n 8,\n 9,\n 12,\n 16,\n 18,\n 24,\n 27,\n 32,\n 36,\n 48,\n 54,\n 64,\n 72,\n 81,\n 96,\n 108,\n 128,\n 144,\n 162,\n 192,\n 216,\n 243,\n 256,\n 288,\n 324,\n 384,\n 432,\n 486,\n 512,\n 576,\n 648,\n 729,\n 768,\n 864,\n 972,\n 1024,\n 1152,\n 1296,\n 1458,\n 1536,\n 1728,\n 1944,\n 2048,\n 2187,\n 2304,\n 2592,\n 2916,\n 3072,\n 3456,\n 3888,\n 4096,\n 4374,\n 4608,\n 5184,\n 5832,\n 6144,\n 6561,\n 6912,\n 7776,\n 8192,\n 8748,\n 9216,\n 10368,\n 11664,\n 12288,\n 13122,\n 13824,\n 15552,\n 16384,\n 17496,\n 18432,\n 19683,\n 20736,\n 23328,\n 24576,\n 26244,\n 27648,\n 31104,\n 32768,\n 34992,\n 36864,\n 39366,\n 41472,\n 46656,\n 49152,\n 52488,\n 55296,\n 59049,\n 62208,\n 65536,\n 69984,\n 73728,\n 78732,\n 82944,\n 93312,\n 98304,\n 104976,\n 110592,\n 118098,\n 124416,\n 131072,\n 139968,\n 147456,\n 157464,\n 165888,\n 177147,\n 186624,\n 196608,\n 209952,\n 221184,\n 236196,\n 248832,\n 262144,\n 279936,\n 294912,\n 314928,\n 331776,\n 354294,\n 373248,\n 393216,\n 419904,\n 442368,\n 472392,\n 497664,\n 524288,\n 531441,\n 559872,\n 589824,\n 629856,\n 663552,\n 708588,\n 746496,\n 786432,\n 839808,\n 884736,\n 944784,\n 995328,\n 1048576,\n 1062882,\n 1119744,\n 1179648,\n 1259712,\n 1327104,\n 1417176,\n 1492992,\n 1572864,\n 1594323,\n 1679616,\n 1769472,\n 1889568,\n 1990656,\n 2097152,\n 2125764,\n 2239488,\n 2359296,\n 2519424,\n 2654208,\n 2834352,\n 2985984,\n 3145728,\n 3188646,\n 3359232,\n 3538944,\n 3779136,\n 3981312,\n 4194304,\n 4251528,\n 4478976,\n 4718592,\n 4782969,\n 5038848,\n 5308416,\n 5668704,\n 5971968,\n 6291456,\n 6377292,\n 6718464,\n 7077888,\n 7558272,\n 7962624,\n 8388608,\n 8503056,\n 8957952,\n 9437184,\n 9565938,\n 10077696,\n 10616832,\n 11337408,\n 11943936,\n 12582912,\n 12754584,\n 13436928,\n 14155776,\n 14348907,\n 15116544,\n 15925248,\n 16777216,\n 17006112,\n 17915904,\n 18874368,\n 19131876,\n 20155392,\n 21233664,\n 22674816,\n 23887872,\n 25165824,\n 25509168,\n 26873856,\n 28311552,\n 28697814,\n 30233088,\n 31850496,\n 33554432,\n 34012224,\n 35831808,\n 37748736,\n 38263752,\n 40310784,\n 42467328,\n 43046721,\n 45349632,\n 47775744,\n 50331648,\n 51018336,\n 53747712,\n 56623104,\n 57395628,\n 60466176,\n 63700992,\n 67108864,\n 68024448,\n 71663616,\n 75497472,\n 76527504,\n 80621568,\n 84934656,\n 86093442,\n 90699264,\n 95551488,\n 100663296,\n 102036672,\n 107495424,\n 113246208,\n 114791256,\n 120932352,\n 127401984,\n 129140163,\n 134217728,\n 136048896,\n 143327232,\n 150994944,\n 153055008,\n 161243136,\n 169869312,\n 172186884,\n 181398528,\n 191102976,\n 201326592,\n 204073344,\n 214990848,\n 226492416,\n 229582512,\n 241864704,\n 254803968,\n 258280326,\n 268435456,\n 272097792,\n 286654464,\n 301989888,\n 306110016,\n 322486272,\n 339738624,\n 344373768,\n 362797056,\n 382205952,\n 387420489,\n 402653184,\n 408146688,\n 429981696,\n 452984832,\n 459165024,\n 483729408,\n 509607936,\n 516560652,\n 536870912,\n 544195584,\n 573308928,\n 603979776,\n 612220032,\n 644972544,\n 679477248,\n 688747536,\n 725594112,\n 764411904,\n 774840978,\n 805306368,\n 816293376,\n 859963392,\n 905969664,\n 918330048,\n 967458816,\n 1019215872,\n 1033121304,\n 1073741824,\n 1088391168,\n 1146617856,\n 1162261467,\n 1207959552,\n 1224440064,\n 1289945088,\n 1358954496,\n 1377495072,\n 1451188224,\n 1528823808,\n 1549681956,\n 1610612736,\n 1632586752,\n 1719926784,\n 1811939328,\n 1836660096,\n 1934917632\n};\nint main() {\n int l, r;\n scanf(\"%d %d\", &l, &r);\n \n int L = -1, R = 326;\n for (int i = 0; i < 326; ++i) {\n if (num[i] < l) {\n L = i;\n }\n }\n for (int i = 325; i >= 0; --i) {\n if (num[i] > r) {\n R = i;\n }\n }\n printf(\"%d\", (R - L - (long long) 1));\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "96cbddd2ccfcc01e32a3384fc40162dc", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n, k;\n scanf(\"%d%d\", &n, &k);\n if(!k || k == n){\n printf(\"0 0\\n\");\n }\n else{\n printf(\"1 %d\\n\", (k <= n/3) ? 2*k : n-k);\n }\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "f5caa26dca1bf5172387b58b63cfb480", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n\t\n\tlong long int n,k, max=0LL;\n\tint min = 1;\n\t\n\tscanf(\"%lli %lld\",&n,&k);\n\t\n\n\tif ( k >= ((n % 3 == 0)? n/3 : n/3+1) )\n\t\tmax = n-k;\n\telse\t\n\t\tmax = 2*k;\n\t\n\tif ( k == 0 || k == n){\n\t\tmax = 0LL;\n\t\tmin = 0;\n\t\t}\n\n\tprintf(\"%i %lld\\n\", min, max);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "af0ae21cca1c7e1563879208f797bf9a", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char a[101];\n int i,j,k,sum=0;\n scanf(\"%s\",a);\n k=strlen(a);\n for(i=0;i')\n sum=sum*16+8;\n else if(a[i]=='<')\n sum=sum*16+9;\n else if(a[i]=='+')\n sum=sum*16+10;\n else if(a[i]=='-')\n sum=sum*16+11;\n else if(a[i]=='.')\n sum=sum*16+12;\n else if(a[i]==',')\n sum=sum*16+13;\n else if(a[i]=='[')\n sum=sum*16+14;\n else if(a[i]==']')\n sum=sum*16+15;\n\n sum=sum%1000003;\n }\n printf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f4c6420f4998438d7fa43b812517dbab", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nconst int p = 1000003;\nint convtoint(char s)\n{\n switch(s)\n {\n case '1': return 1;\n /*case '2': return 2;\n case '3': return 3;\n case '4': return 4;\n case '5': return 5;\n case '6': return 6;\n case '7': return 7;\n case '8': return 8;\n case '9': return 9;*/\n case '0': return 0;\n }\n}\n\nint power(int a, int b)\n{\n int s = 1;\n for(int i = 0; i < b; i++)\n {\n s *= a;\n s %= p;\n }\n return s;\n}\n\nint main(void)\n{\n char ss[101];\n char bin[401];\n unsigned long long int sum = 0;\n int f = 0;\n strcpy(bin, \"\");\n scanf(\"%s\", ss);\n int len = strlen(ss);\n for(int i = 0; i < len; i++)\n {\n switch(ss[i])\n {\n case '>': strcat(bin, \"1000\"); break;\n case '<': strcat(bin, \"1001\"); break;\n case '+': strcat(bin, \"1010\"); break;\n case '-': strcat(bin, \"1011\"); break;\n case '.': strcat(bin, \"1100\"); break;\n case ',': strcat(bin, \"1101\"); break;\n case '[': strcat(bin, \"1110\"); break;\n case ']': strcat(bin, \"1111\");\n }\n }\n for(int i = strlen(bin)-1; i >= 0; i--)\n {\n sum += power(2, f) * convtoint(bin[i]);\n sum %= p;\n f++;\n }\n printf(\"%I64u\", sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "aba64563c1ee4b5f123e3d3deebc84fb", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n\tint x, i, h, f=0, y=0;\n\tchar s[501];\n\t\n\tscanf(\"%s\", s);\n\tx=strlen(s);\n\tint a[x+1];\n\t\n\tfor(h=0; hf)\n\t\t{\n\t\t\tif(a[i]-f==1)\n\t\t\t{\n\t\t\t\tf++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ty=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif(y==1)\n\t{\n\t\tprintf(\"NO\");\n\t}\n\telse\n\t{\n\t\tprintf(\"YES\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy", "strings", "implementation"], "code_uid": "30004a540377002dc725d8639b848f65", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n char s[502];\n scanf(\"%s\",s);\n int ans[502];\n int m=strlen(s);\n for(int i=0;imax+1)\n {\n printf(\"NO\");\n return 0;\n }\n else if(ans[i]==max+1)\n max++;\n }\n printf(\"YES\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "strings", "implementation"], "code_uid": "5527c946f52da9e7d69ba3775d4173b8", "src_uid": "c4551f66a781b174f95865fa254ca972", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\tint arr[5];\nint main()\n{\n\tint arr1[4];\n\tscanf(\"%d %d %d\",&arr1[0],&arr1[1],&arr1[2]);\n\tfor (int i = 0; i < 3; ++i)\n\t{\n\t\tarr[arr1[i]]++;\n\t}\n\tif (arr[1]==1 || arr[2]==2 || arr[3]==3 || arr[1]==2 || arr[1]==3 || arr[2]==3)\n\t{\n\t\tprintf(\"YES\\n\");\n\t}\n\telse if(arr[2]==1 && arr[4]==2)\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms"], "code_uid": "4e4f24399fadd9203acce058f6159630", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main(int argc, char const *argv[])\n{ int n,m,v;\n scanf(\"%d %d %d\",&n,&m,&v);\n if (n==1 || m==1 || v==1) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (n==2 && m==2) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (m==2 && v==2) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (v==2 && n==2) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (m==3 && n==3 && v==3) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (m==4 && n==4 && v==2) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (v==4 && n==4 && m==2) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n if (m==4 && v==4 && n==2) {\n printf(\"YES\\n\");\n return 0;\n /* code */\n }\n printf(\"NO\\n\" );\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms"], "code_uid": "75a0b26f4aea779a6616c24699187e3d", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\nint compare_char(char *a,char *b){\n\treturn strcmp(a,b);\n}\n\nint intsort(const void *a, const void *b){\n\treturn *(int*)b - *(int*)a;\n\t/*qsort(a,a\u306e\u914d\u5217\u6570,sizeof(int),intsort);*/\n}\n\nint longsort(const void *a, const void *b){\n\tlong *A=(long *)a;\n\tlong *B=(long *)b;\n\tif(*A>*B) return -1;\n\tif(*A<*B) return 1;\n\treturn 0;\n}\n\nint main(){\n\tint i,N,j,p,a[4]={0},b[i],cnt=0,min,ans=0,x,y,z,day=0;\n\tfor(i=0;i<3;i++){\n\tscanf(\"%d\",&a[i]);\n\t}\n/*\tif(a[0]%3==0){\n*/\t\n\t\nb[0]=a[0]/3;\nmin=b[0];\n/*\t}else{\n\t\tb[0]=a[0]/3+1;\n\t}\n\tif(a[1]%2==0){\n*/\nb[1]=a[1]/2;\nif(min>b[1])min=b[1];\n/*\t}else{\n\t\tb[1]=a[1]/2+1;\n\t}\n\tif(a[2]%2==0){\n*/\nb[2]=a[2]/2;\nif(min>b[2])min=b[2];\n/*\t}else{\n\t\tb[2]=a[2]/2+1;\n\t}\n*/\n\nans=min*7;\na[0]-=3*min;\na[1]-=2*min;\na[2]-=2*min;\nmin=0;\nx=a[0];\ny=a[1];\nz=a[2];\n\t//sun\n\twhile(1){\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tmin=day;\n\t\n\tday=0;\n\tx=a[0];\t\n\ty=a[1];\n\tz=a[2];\n\t\t\t\t//\u6708\n\twhile(1){\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tif(min0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tif(min0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tif(min0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\t\n\t}else{\t\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tif(min0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tif(min0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(y>0){\n\ty--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(x>0){\n\tx--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\tif(z>0){\n\tz--;\n\tday++;\n\t}else{\n\tbreak;\n\t}\n\t}\n\tif(min\n#include\n\n\nint main(){\n\n long long totald,min,a,b,c,ca,cb,cc;\n scanf(\"%lld%lld%lld\",&a,&b,&c);\n ca=a/3;a=a%3;\n cb=b/2;b=b%2;\n cc=c/2;c=c%2;\n min=camax){\n max=count;\n }\n }\n printf(\"%lld\\n\",totald+max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "35926a9233e79211cddf43c0654a55ad", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint n,k;\nscanf(\"%d %d\",&n,&k);\nprintf(\"%d\\n\",(n/k+1)*k);\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "c0de5e2ad0b59b3468e9872ef75a18e4", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint a,b;\n\tscanf(\"%d %d\",&a,&b);\n\n\tint i,j,calc=0;\n\n\tfor(i=1;;i++) {\n\t\tcalc=b*i;\n\t\tif(calc>a) {\n\t\t\tprintf(\"%d\",calc);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "869ffd00756e566f6d651257103b8736", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,n,a=0;\n scanf(\"%d\",&n);\n int t[n];\n for(i=0;i\n#include \n\nint main()\n{\n int n,i,sum=0,v;\n scanf(\"%d\",&n);\n int a[n];\n\n for(i=0;i=90)\n sum=90;\n printf(\"%d\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f23b7618146756bc8c7e9e37106636aa", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,i,a[12],j,sum=0,tem=0;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i<12;i++){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\tfor(i=0;i<12;i++){\n\t\tfor(j=i+1;j<12;j++){\n\t\t\tif(a[i]\nint main()\n{\n int a,i,j,temp,sum=0,count=0;\n int ara[12];\n\n scanf(\"%d\",&a);\n\n for(i=0;i<12;i++)\n {\n scanf(\"%d\",&ara[i]);\n }\n\n for(i=0;i<11;i++)\n {\n for(j=0;j<11;j++)\n {\n if(ara[j]=a)break;\n\n\n } if(a==0)printf(\"0\");\n else if(sum=a) printf(\"%d\",count);\n\n\n\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation", "greedy"], "code_uid": "d204b3f52c372e7725807d15bbd9a18e", "src_uid": "59dfa7a4988375febc5dccc27aca90a8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,m,a,b,p,q;\n scanf(\"%lld %lld %lld %lld\",&n,&m,&a,&b);\n if(n%m==0)\n {\n printf(\"0\");\n }\n else\n {\n p=n%m;\n q=m-p;\n if((p*b)>=(q*a))\n {\n printf(\"%lld\",(q*a));\n }\n else\n {\n printf(\"%lld\",(p*b));\n }\n }\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "13f2ebe61c17ec78facecfb4675e6464", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n long long n,m;\n int a,b;\n scanf(\"%lld%lld%d%d\",&n,&m,&a,&b);\n long long r=n%m;\n long long answer=0;\n if(r==0){\n answer=0;\n }else{\n if(r*b>(m-r)*a){\n answer=(m-r)*a;\n }else{\n answer=r*b;\n }\n }\n printf(\"%lld\\n\",answer);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ae9c105eb8df3fbfb28ed3debdb9cbb7", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nchar sb[4097]=\"0000000000000000000000000010101111110100000000000000000000000000000000000000000000000010111010101001011111000000000000000000000000000000000000000000111010001000110100001001000000000000000000000000000000000000011110101011111000011110101110100000000000000000000000000000000011000000101000001111000010101011000000000000000000000000000000100110111110111011101001011000100101000000000000000000000000000111001001000000101000111100110110110110000000000000000000000001111110110110111011101110000110010010001110000000000000000000001111111111110000100000100010110011011010011100000000000000000001111111111111111111101111111001111001111111111000000000000000001111111111111111111111111111111111111111111111110000000000000001111111111111111111111111111111111111111111111111100000000000000111111111111111111111111111111111111111111111111110000000000000111111111111111111111111111111111111111111111111111100000000000111111111111111111111111111111111111111111111111111111000000000011111111111111111111111111111111111111111111111111111100000000011111111111111111111111111111111111111111111111111111111000000011111111111111111111111111111111111111111111111111111111110000000011111111111111111111111111111111111111111111111111111111000000000011111111111100010011111111111111000101011111111111110000000110000011111111100100011111111111111101000000011111111000000000011110000011111000110100011111111111111101101100101100000001100011111110000010001110011100111111111110100100011000000000111111001111111110000010010011011000111111111011011111001000011111111100111111111111011011100000111001111111000100100001110111111111110011111111100000100011101110001111111101011111010001001011111111011111111111101110100100100010011111100100100001101110001111111111111111111100010010110111011101111010111011110011100010111111111111111111110111111011110000100101000010100101111000111011111111111111111111000001001001110111000101011011010010001001001111111111111111111110110111101101110001011100000111101011111101111111111111111111110001110010010001110100111011110010111000100011111111111111111111110000011011101101110110000010011011001000101111111111111111111111101101000010100001010010101101000110110111111111111111111111111000011110101010101111011010010111001110001111111111111111111111110100100011100011110001001100001001100011111111111111111111111111111000111000101101101101100101110100100111111111111111111111111111111000101111110000011111110001000111111111111111101111111111111111001000011111010111111111110001001111111111111100111111111111111111111111111111000011111111111111111111111111110011111111111111111111111111101001011111111111111111111111111111001111111111111111111111111010001111111111111111111111111111111100011111111111111111111111100010001111111111111111111111111111100001111111001111111111111111111011111111111111111111111111111110000011111110101111111111111111000111111111111111111111011111110000001111111000100011111111111001011111111111011111010000111111000000111111101010100101000110101100101001011000110000010111111100000001111111100011000001000000011000110000001010011101111111100000000011111110100111101111011100111000011101111101011111111100000000001111111111010010010001011110111011010000010001111111110000000000011111111000011011010000100010100001110100011111111110000000000000111111111011000111110110101000101100011111111111110000000000000011111111100111001010001110001011100100011111111111000000000000000111111111000111100011101101111011110111111111111000000000000000001111111110110000101000000100001011111111111111000000000000000000011111111111101011110110110101100111111111111000000000000000000000111111111111100001111000010000111111111111000000000000000000000000111111111111111111110111111111111111110000000000000000000000000001111111111111111111111111111111111110000000000000000000000000000001111111111111111111111111111111100000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000001111111111111111111111110000000000000000000000000000000000000000001111111111111111111100000000000000000000000000000000000000000000000011111111111100000000000000000000000000\";\nint a,b;\nint main()\n{\nscanf(\"%d%d\",&a,&b);\na=a+1;b=b+1;\nif(sb[a*64+b-65]==48)\n{\n\tprintf(\"OUT\");\n}\nelse{\n\tprintf(\"IN\");\n}\n\nreturn 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "geometry", "implementation"], "code_uid": "c6aee7be69730a34a148a6aa46a7a414", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "char s[33][33];\nint x,y;\nint main()\n{\ns[0][0]='1';\ns[0][1]='1';\ns[0][2]='1';\ns[0][3]='1';\ns[0][4]='1';\ns[0][5]='1';\ns[0][6]='1';\ns[0][7]='0';\ns[0][8]='1';\ns[0][9]='0';\ns[0][10]='1';\ns[0][11]='0';\ns[0][12]='1';\ns[0][13]='0';\ns[0][14]='1';\ns[0][15]='1';\ns[0][16]='1';\ns[0][17]='1';\ns[0][18]='1';\ns[0][19]='0';\ns[0][20]='0';\ns[0][21]='1';\ns[0][22]='0';\ns[0][23]='1';\ns[0][24]='0';\ns[0][25]='0';\ns[0][26]='1';\ns[0][27]='1';\ns[0][28]='1';\ns[0][29]='1';\ns[0][30]='1';\ns[0][31]='1';\ns[0][32]='1';\ns[1][0]='1';\ns[1][1]='0';\ns[1][2]='0';\ns[1][3]='0';\ns[1][4]='0';\ns[1][5]='0';\ns[1][6]='1';\ns[1][7]='0';\ns[1][8]='0';\ns[1][9]='0';\ns[1][10]='0';\ns[1][11]='0';\ns[1][12]='0';\ns[1][13]='0';\ns[1][14]='0';\ns[1][15]='0';\ns[1][16]='0';\ns[1][17]='1';\ns[1][18]='0';\ns[1][19]='1';\ns[1][20]='0';\ns[1][21]='1';\ns[1][22]='1';\ns[1][23]='0';\ns[1][24]='0';\ns[1][25]='0';\ns[1][26]='1';\ns[1][27]='0';\ns[1][28]='0';\ns[1][29]='0';\ns[1][30]='0';\ns[1][31]='0';\ns[1][32]='1';\ns[2][0]='1';\ns[2][1]='0';\ns[2][2]='1';\ns[2][3]='1';\ns[2][4]='1';\ns[2][5]='0';\ns[2][6]='1';\ns[2][7]='0';\ns[2][8]='0';\ns[2][9]='1';\ns[2][10]='1';\ns[2][11]='0';\ns[2][12]='1';\ns[2][13]='1';\ns[2][14]='0';\ns[2][15]='0';\ns[2][16]='0';\ns[2][17]='0';\ns[2][18]='0';\ns[2][19]='1';\ns[2][20]='1';\ns[2][21]='0';\ns[2][22]='1';\ns[2][23]='0';\ns[2][24]='0';\ns[2][25]='0';\ns[2][26]='1';\ns[2][27]='0';\ns[2][28]='1';\ns[2][29]='1';\ns[2][30]='1';\ns[2][31]='0';\ns[2][32]='1';\ns[3][0]='1';\ns[3][1]='0';\ns[3][2]='1';\ns[3][3]='1';\ns[3][4]='1';\ns[3][5]='0';\ns[3][6]='1';\ns[3][7]='0';\ns[3][8]='1';\ns[3][9]='0';\ns[3][10]='1';\ns[3][11]='1';\ns[3][12]='0';\ns[3][13]='0';\ns[3][14]='1';\ns[3][15]='0';\ns[3][16]='0';\ns[3][17]='1';\ns[3][18]='1';\ns[3][19]='1';\ns[3][20]='1';\ns[3][21]='1';\ns[3][22]='0';\ns[3][23]='1';\ns[3][24]='0';\ns[3][25]='0';\ns[3][26]='1';\ns[3][27]='0';\ns[3][28]='1';\ns[3][29]='1';\ns[3][30]='1';\ns[3][31]='0';\ns[3][32]='1';\ns[4][0]='1';\ns[4][1]='0';\ns[4][2]='1';\ns[4][3]='1';\ns[4][4]='1';\ns[4][5]='0';\ns[4][6]='1';\ns[4][7]='0';\ns[4][8]='1';\ns[4][9]='1';\ns[4][10]='0';\ns[4][11]='0';\ns[4][12]='0';\ns[4][13]='1';\ns[4][14]='1';\ns[4][15]='0';\ns[4][16]='0';\ns[4][17]='0';\ns[4][18]='1';\ns[4][19]='1';\ns[4][20]='1';\ns[4][21]='1';\ns[4][22]='0';\ns[4][23]='0';\ns[4][24]='1';\ns[4][25]='0';\ns[4][26]='1';\ns[4][27]='0';\ns[4][28]='1';\ns[4][29]='1';\ns[4][30]='1';\ns[4][31]='0';\ns[4][32]='1';\ns[5][0]='1';\ns[5][1]='0';\ns[5][2]='0';\ns[5][3]='0';\ns[5][4]='0';\ns[5][5]='0';\ns[5][6]='1';\ns[5][7]='0';\ns[5][8]='1';\ns[5][9]='0';\ns[5][10]='1';\ns[5][11]='0';\ns[5][12]='1';\ns[5][13]='0';\ns[5][14]='1';\ns[5][15]='0';\ns[5][16]='1';\ns[5][17]='1';\ns[5][18]='0';\ns[5][19]='1';\ns[5][20]='0';\ns[5][21]='0';\ns[5][22]='0';\ns[5][23]='0';\ns[5][24]='1';\ns[5][25]='0';\ns[5][26]='1';\ns[5][27]='0';\ns[5][28]='0';\ns[5][29]='0';\ns[5][30]='0';\ns[5][31]='0';\ns[5][32]='1';\ns[6][0]='1';\ns[6][1]='1';\ns[6][2]='1';\ns[6][3]='1';\ns[6][4]='1';\ns[6][5]='1';\ns[6][6]='1';\ns[6][7]='0';\ns[6][8]='1';\ns[6][9]='0';\ns[6][10]='1';\ns[6][11]='0';\ns[6][12]='1';\ns[6][13]='0';\ns[6][14]='1';\ns[6][15]='0';\ns[6][16]='1';\ns[6][17]='0';\ns[6][18]='1';\ns[6][19]='0';\ns[6][20]='1';\ns[6][21]='0';\ns[6][22]='1';\ns[6][23]='0';\ns[6][24]='1';\ns[6][25]='0';\ns[6][26]='1';\ns[6][27]='1';\ns[6][28]='1';\ns[6][29]='1';\ns[6][30]='1';\ns[6][31]='1';\ns[6][32]='1';\ns[7][0]='0';\ns[7][1]='0';\ns[7][2]='0';\ns[7][3]='0';\ns[7][4]='0';\ns[7][5]='0';\ns[7][6]='0';\ns[7][7]='0';\ns[7][8]='1';\ns[7][9]='1';\ns[7][10]='1';\ns[7][11]='1';\ns[7][12]='1';\ns[7][13]='0';\ns[7][14]='1';\ns[7][15]='1';\ns[7][16]='1';\ns[7][17]='1';\ns[7][18]='1';\ns[7][19]='0';\ns[7][20]='0';\ns[7][21]='1';\ns[7][22]='1';\ns[7][23]='1';\ns[7][24]='1';\ns[7][25]='0';\ns[7][26]='0';\ns[7][27]='0';\ns[7][28]='0';\ns[7][29]='0';\ns[7][30]='0';\ns[7][31]='0';\ns[7][32]='0';\ns[8][0]='1';\ns[8][1]='0';\ns[8][2]='0';\ns[8][3]='0';\ns[8][4]='1';\ns[8][5]='0';\ns[8][6]='1';\ns[8][7]='1';\ns[8][8]='1';\ns[8][9]='1';\ns[8][10]='0';\ns[8][11]='0';\ns[8][12]='1';\ns[8][13]='0';\ns[8][14]='0';\ns[8][15]='0';\ns[8][16]='0';\ns[8][17]='1';\ns[8][18]='0';\ns[8][19]='1';\ns[8][20]='1';\ns[8][21]='1';\ns[8][22]='1';\ns[8][23]='0';\ns[8][24]='1';\ns[8][25]='1';\ns[8][26]='1';\ns[8][27]='1';\ns[8][28]='1';\ns[8][29]='1';\ns[8][30]='0';\ns[8][31]='0';\ns[8][32]='1';\ns[9][0]='1';\ns[9][1]='1';\ns[9][2]='0';\ns[9][3]='1';\ns[9][4]='1';\ns[9][5]='1';\ns[9][6]='0';\ns[9][7]='0';\ns[9][8]='1';\ns[9][9]='1';\ns[9][10]='1';\ns[9][11]='1';\ns[9][12]='1';\ns[9][13]='1';\ns[9][14]='1';\ns[9][15]='1';\ns[9][16]='0';\ns[9][17]='0';\ns[9][18]='1';\ns[9][19]='0';\ns[9][20]='0';\ns[9][21]='0';\ns[9][22]='0';\ns[9][23]='1';\ns[9][24]='0';\ns[9][25]='0';\ns[9][26]='0';\ns[9][27]='1';\ns[9][28]='0';\ns[9][29]='1';\ns[9][30]='1';\ns[9][31]='0';\ns[9][32]='0';\ns[10][0]='0';\ns[10][1]='1';\ns[10][2]='1';\ns[10][3]='1';\ns[10][4]='0';\ns[10][5]='0';\ns[10][6]='1';\ns[10][7]='1';\ns[10][8]='1';\ns[10][9]='0';\ns[10][10]='1';\ns[10][11]='0';\ns[10][12]='0';\ns[10][13]='0';\ns[10][14]='0';\ns[10][15]='1';\ns[10][16]='0';\ns[10][17]='1';\ns[10][18]='0';\ns[10][19]='0';\ns[10][20]='0';\ns[10][21]='1';\ns[10][22]='1';\ns[10][23]='1';\ns[10][24]='0';\ns[10][25]='1';\ns[10][26]='0';\ns[10][27]='0';\ns[10][28]='0';\ns[10][29]='1';\ns[10][30]='0';\ns[10][31]='1';\ns[10][32]='0';\ns[11][0]='0';\ns[11][1]='1';\ns[11][2]='1';\ns[11][3]='1';\ns[11][4]='1';\ns[11][5]='0';\ns[11][6]='0';\ns[11][7]='0';\ns[11][8]='0';\ns[11][9]='1';\ns[11][10]='1';\ns[11][11]='0';\ns[11][12]='0';\ns[11][13]='0';\ns[11][14]='1';\ns[11][15]='1';\ns[11][16]='1';\ns[11][17]='1';\ns[11][18]='1';\ns[11][19]='1';\ns[11][20]='0';\ns[11][21]='1';\ns[11][22]='0';\ns[11][23]='1';\ns[11][24]='1';\ns[11][25]='0';\ns[11][26]='0';\ns[11][27]='0';\ns[11][28]='0';\ns[11][29]='0';\ns[11][30]='0';\ns[11][31]='1';\ns[11][32]='1';\ns[12][0]='1';\ns[12][1]='1';\ns[12][2]='1';\ns[12][3]='1';\ns[12][4]='1';\ns[12][5]='1';\ns[12][6]='1';\ns[12][7]='1';\ns[12][8]='1';\ns[12][9]='1';\ns[12][10]='1';\ns[12][11]='1';\ns[12][12]='1';\ns[12][13]='1';\ns[12][14]='1';\ns[12][15]='0';\ns[12][16]='0';\ns[12][17]='0';\ns[12][18]='1';\ns[12][19]='1';\ns[12][20]='1';\ns[12][21]='0';\ns[12][22]='0';\ns[12][23]='1';\ns[12][24]='0';\ns[12][25]='0';\ns[12][26]='1';\ns[12][27]='0';\ns[12][28]='1';\ns[12][29]='1';\ns[12][30]='0';\ns[12][31]='0';\ns[12][32]='0';\ns[13][0]='1';\ns[13][1]='1';\ns[13][2]='1';\ns[13][3]='0';\ns[13][4]='0';\ns[13][5]='0';\ns[13][6]='0';\ns[13][7]='1';\ns[13][8]='0';\ns[13][9]='1';\ns[13][10]='1';\ns[13][11]='1';\ns[13][12]='0';\ns[13][13]='1';\ns[13][14]='0';\ns[13][15]='0';\ns[13][16]='1';\ns[13][17]='1';\ns[13][18]='0';\ns[13][19]='1';\ns[13][20]='0';\ns[13][21]='0';\ns[13][22]='1';\ns[13][23]='1';\ns[13][24]='0';\ns[13][25]='1';\ns[13][26]='0';\ns[13][27]='1';\ns[13][28]='0';\ns[13][29]='0';\ns[13][30]='1';\ns[13][31]='0';\ns[13][32]='0';\ns[14][0]='1';\ns[14][1]='0';\ns[14][2]='1';\ns[14][3]='0';\ns[14][4]='1';\ns[14][5]='0';\ns[14][6]='1';\ns[14][7]='0';\ns[14][8]='0';\ns[14][9]='0';\ns[14][10]='1';\ns[14][11]='0';\ns[14][12]='1';\ns[14][13]='1';\ns[14][14]='0';\ns[14][15]='0';\ns[14][16]='1';\ns[14][17]='0';\ns[14][18]='1';\ns[14][19]='1';\ns[14][20]='0';\ns[14][21]='1';\ns[14][22]='0';\ns[14][23]='1';\ns[14][24]='0';\ns[14][25]='1';\ns[14][26]='0';\ns[14][27]='0';\ns[14][28]='0';\ns[14][29]='0';\ns[14][30]='0';\ns[14][31]='1';\ns[14][32]='0';\ns[15][0]='1';\ns[15][1]='0';\ns[15][2]='1';\ns[15][3]='1';\ns[15][4]='0';\ns[15][5]='0';\ns[15][6]='0';\ns[15][7]='0';\ns[15][8]='0';\ns[15][9]='1';\ns[15][10]='0';\ns[15][11]='1';\ns[15][12]='0';\ns[15][13]='1';\ns[15][14]='0';\ns[15][15]='0';\ns[15][16]='0';\ns[15][17]='1';\ns[15][18]='1';\ns[15][19]='1';\ns[15][20]='1';\ns[15][21]='1';\ns[15][22]='0';\ns[15][23]='1';\ns[15][24]='0';\ns[15][25]='0';\ns[15][26]='0';\ns[15][27]='0';\ns[15][28]='0';\ns[15][29]='0';\ns[15][30]='0';\ns[15][31]='0';\ns[15][32]='0';\ns[16][0]='0';\ns[16][1]='0';\ns[16][2]='0';\ns[16][3]='0';\ns[16][4]='1';\ns[16][5]='0';\ns[16][6]='1';\ns[16][7]='0';\ns[16][8]='0';\ns[16][9]='0';\ns[16][10]='1';\ns[16][11]='1';\ns[16][12]='0';\ns[16][13]='0';\ns[16][14]='1';\ns[16][15]='1';\ns[16][16]='0';\ns[16][17]='1';\ns[16][18]='0';\ns[16][19]='0';\ns[16][20]='0';\ns[16][21]='1';\ns[16][22]='1';\ns[16][23]='1';\ns[16][24]='1';\ns[16][25]='0';\ns[16][26]='1';\ns[16][27]='0';\ns[16][28]='1';\ns[16][29]='1';\ns[16][30]='0';\ns[16][31]='1';\ns[16][32]='0';\ns[17][0]='1';\ns[17][1]='0';\ns[17][2]='1';\ns[17][3]='0';\ns[17][4]='0';\ns[17][5]='1';\ns[17][6]='0';\ns[17][7]='0';\ns[17][8]='1';\ns[17][9]='1';\ns[17][10]='1';\ns[17][11]='1';\ns[17][12]='1';\ns[17][13]='0';\ns[17][14]='1';\ns[17][15]='1';\ns[17][16]='1';\ns[17][17]='1';\ns[17][18]='0';\ns[17][19]='0';\ns[17][20]='0';\ns[17][21]='1';\ns[17][22]='0';\ns[17][23]='1';\ns[17][24]='0';\ns[17][25]='1';\ns[17][26]='0';\ns[17][27]='0';\ns[17][28]='0';\ns[17][29]='1';\ns[17][30]='1';\ns[17][31]='1';\ns[17][32]='0';\ns[18][0]='1';\ns[18][1]='0';\ns[18][2]='1';\ns[18][3]='1';\ns[18][4]='0';\ns[18][5]='1';\ns[18][6]='1';\ns[18][7]='1';\ns[18][8]='1';\ns[18][9]='1';\ns[18][10]='1';\ns[18][11]='1';\ns[18][12]='0';\ns[18][13]='0';\ns[18][14]='0';\ns[18][15]='1';\ns[18][16]='0';\ns[18][17]='0';\ns[18][18]='1';\ns[18][19]='0';\ns[18][20]='0';\ns[18][21]='0';\ns[18][22]='0';\ns[18][23]='1';\ns[18][24]='1';\ns[18][25]='1';\ns[18][26]='0';\ns[18][27]='0';\ns[18][28]='0';\ns[18][29]='1';\ns[18][30]='0';\ns[18][31]='0';\ns[18][32]='0';\ns[19][0]='0';\ns[19][1]='0';\ns[19][2]='0';\ns[19][3]='0';\ns[19][4]='1';\ns[19][5]='0';\ns[19][6]='0';\ns[19][7]='1';\ns[19][8]='1';\ns[19][9]='0';\ns[19][10]='0';\ns[19][11]='0';\ns[19][12]='1';\ns[19][13]='0';\ns[19][14]='0';\ns[19][15]='1';\ns[19][16]='1';\ns[19][17]='0';\ns[19][18]='0';\ns[19][19]='0';\ns[19][20]='0';\ns[19][21]='0';\ns[19][22]='1';\ns[19][23]='1';\ns[19][24]='0';\ns[19][25]='1';\ns[19][26]='0';\ns[19][27]='0';\ns[19][28]='0';\ns[19][29]='0';\ns[19][30]='0';\ns[19][31]='1';\ns[19][32]='0';\ns[20][0]='0';\ns[20][1]='0';\ns[20][2]='1';\ns[20][3]='1';\ns[20][4]='0';\ns[20][5]='1';\ns[20][6]='1';\ns[20][7]='0';\ns[20][8]='1';\ns[20][9]='0';\ns[20][10]='0';\ns[20][11]='1';\ns[20][12]='1';\ns[20][13]='0';\ns[20][14]='1';\ns[20][15]='1';\ns[20][16]='1';\ns[20][17]='0';\ns[20][18]='0';\ns[20][19]='1';\ns[20][20]='0';\ns[20][21]='0';\ns[20][22]='1';\ns[20][23]='0';\ns[20][24]='0';\ns[20][25]='1';\ns[20][26]='1';\ns[20][27]='0';\ns[20][28]='1';\ns[20][29]='1';\ns[20][30]='0';\ns[20][31]='0';\ns[20][32]='0';\ns[21][0]='0';\ns[21][1]='1';\ns[21][2]='1';\ns[21][3]='1';\ns[21][4]='0';\ns[21][5]='1';\ns[21][6]='0';\ns[21][7]='1';\ns[21][8]='1';\ns[21][9]='0';\ns[21][10]='1';\ns[21][11]='0';\ns[21][12]='0';\ns[21][13]='0';\ns[21][14]='1';\ns[21][15]='0';\ns[21][16]='0';\ns[21][17]='0';\ns[21][18]='1';\ns[21][19]='1';\ns[21][20]='1';\ns[21][21]='1';\ns[21][22]='0';\ns[21][23]='1';\ns[21][24]='0';\ns[21][25]='1';\ns[21][26]='0';\ns[21][27]='1';\ns[21][28]='0';\ns[21][29]='0';\ns[21][30]='1';\ns[21][31]='1';\ns[21][32]='0';\ns[22][0]='1';\ns[22][1]='1';\ns[22][2]='1';\ns[22][3]='0';\ns[22][4]='1';\ns[22][5]='0';\ns[22][6]='1';\ns[22][7]='0';\ns[22][8]='0';\ns[22][9]='1';\ns[22][10]='1';\ns[22][11]='0';\ns[22][12]='0';\ns[22][13]='1';\ns[22][14]='1';\ns[22][15]='1';\ns[22][16]='0';\ns[22][17]='1';\ns[22][18]='0';\ns[22][19]='0';\ns[22][20]='1';\ns[22][21]='1';\ns[22][22]='0';\ns[22][23]='1';\ns[22][24]='0';\ns[22][25]='0';\ns[22][26]='0';\ns[22][27]='0';\ns[22][28]='0';\ns[22][29]='1';\ns[22][30]='1';\ns[22][31]='1';\ns[22][32]='0';\ns[23][0]='1';\ns[23][1]='1';\ns[23][2]='0';\ns[23][3]='0';\ns[23][4]='0';\ns[23][5]='1';\ns[23][6]='0';\ns[23][7]='1';\ns[23][8]='0';\ns[23][9]='0';\ns[23][10]='1';\ns[23][11]='0';\ns[23][12]='1';\ns[23][13]='0';\ns[23][14]='1';\ns[23][15]='1';\ns[23][16]='1';\ns[23][17]='1';\ns[23][18]='0';\ns[23][19]='0';\ns[23][20]='0';\ns[23][21]='1';\ns[23][22]='0';\ns[23][23]='1';\ns[23][24]='1';\ns[23][25]='1';\ns[23][26]='1';\ns[23][27]='1';\ns[23][28]='1';\ns[23][29]='1';\ns[23][30]='0';\ns[23][31]='0';\ns[23][32]='0';\ns[24][0]='0';\ns[24][1]='0';\ns[24][2]='1';\ns[24][3]='0';\ns[24][4]='0';\ns[24][5]='0';\ns[24][6]='1';\ns[24][7]='1';\ns[24][8]='1';\ns[24][9]='0';\ns[24][10]='1';\ns[24][11]='1';\ns[24][12]='1';\ns[24][13]='0';\ns[24][14]='0';\ns[24][15]='0';\ns[24][16]='0';\ns[24][17]='1';\ns[24][18]='0';\ns[24][19]='1';\ns[24][20]='0';\ns[24][21]='1';\ns[24][22]='1';\ns[24][23]='0';\ns[24][24]='1';\ns[24][25]='1';\ns[24][26]='1';\ns[24][27]='1';\ns[24][28]='1';\ns[24][29]='0';\ns[24][30]='0';\ns[24][31]='0';\ns[24][32]='0';\ns[25][0]='0';\ns[25][1]='0';\ns[25][2]='0';\ns[25][3]='0';\ns[25][4]='0';\ns[25][5]='0';\ns[25][6]='0';\ns[25][7]='0';\ns[25][8]='1';\ns[25][9]='1';\ns[25][10]='1';\ns[25][11]='0';\ns[25][12]='0';\ns[25][13]='1';\ns[25][14]='0';\ns[25][15]='1';\ns[25][16]='1';\ns[25][17]='0';\ns[25][18]='1';\ns[25][19]='0';\ns[25][20]='0';\ns[25][21]='0';\ns[25][22]='1';\ns[25][23]='0';\ns[25][24]='1';\ns[25][25]='0';\ns[25][26]='0';\ns[25][27]='0';\ns[25][28]='1';\ns[25][29]='0';\ns[25][30]='1';\ns[25][31]='1';\ns[25][32]='0';\ns[26][0]='1';\ns[26][1]='1';\ns[26][2]='1';\ns[26][3]='1';\ns[26][4]='1';\ns[26][5]='1';\ns[26][6]='1';\ns[26][7]='0';\ns[26][8]='1';\ns[26][9]='0';\ns[26][10]='0';\ns[26][11]='0';\ns[26][12]='1';\ns[26][13]='0';\ns[26][14]='1';\ns[26][15]='1';\ns[26][16]='1';\ns[26][17]='1';\ns[26][18]='0';\ns[26][19]='0';\ns[26][20]='0';\ns[26][21]='1';\ns[26][22]='1';\ns[26][23]='0';\ns[26][24]='1';\ns[26][25]='0';\ns[26][26]='1';\ns[26][27]='0';\ns[26][28]='1';\ns[26][29]='1';\ns[26][30]='0';\ns[26][31]='1';\ns[26][32]='0';\ns[27][0]='1';\ns[27][1]='0';\ns[27][2]='0';\ns[27][3]='0';\ns[27][4]='0';\ns[27][5]='0';\ns[27][6]='1';\ns[27][7]='0';\ns[27][8]='0';\ns[27][9]='1';\ns[27][10]='1';\ns[27][11]='1';\ns[27][12]='0';\ns[27][13]='1';\ns[27][14]='0';\ns[27][15]='1';\ns[27][16]='0';\ns[27][17]='1';\ns[27][18]='1';\ns[27][19]='1';\ns[27][20]='1';\ns[27][21]='1';\ns[27][22]='0';\ns[27][23]='0';\ns[27][24]='1';\ns[27][25]='0';\ns[27][26]='0';\ns[27][27]='0';\ns[27][28]='1';\ns[27][29]='1';\ns[27][30]='0';\ns[27][31]='1';\ns[27][32]='1';\ns[28][0]='1';\ns[28][1]='0';\ns[28][2]='1';\ns[28][3]='1';\ns[28][4]='1';\ns[28][5]='0';\ns[28][6]='1';\ns[28][7]='0';\ns[28][8]='1';\ns[28][9]='0';\ns[28][10]='0';\ns[28][11]='1';\ns[28][12]='0';\ns[28][13]='1';\ns[28][14]='0';\ns[28][15]='0';\ns[28][16]='0';\ns[28][17]='0';\ns[28][18]='1';\ns[28][19]='0';\ns[28][20]='1';\ns[28][21]='0';\ns[28][22]='0';\ns[28][23]='0';\ns[28][24]='1';\ns[28][25]='1';\ns[28][26]='1';\ns[28][27]='1';\ns[28][28]='1';\ns[28][29]='1';\ns[28][30]='0';\ns[28][31]='0';\ns[28][32]='0';\ns[29][0]='1';\ns[29][1]='0';\ns[29][2]='1';\ns[29][3]='1';\ns[29][4]='1';\ns[29][5]='0';\ns[29][6]='1';\ns[29][7]='0';\ns[29][8]='0';\ns[29][9]='0';\ns[29][10]='1';\ns[29][11]='1';\ns[29][12]='0';\ns[29][13]='1';\ns[29][14]='0';\ns[29][15]='0';\ns[29][16]='1';\ns[29][17]='0';\ns[29][18]='0';\ns[29][19]='1';\ns[29][20]='0';\ns[29][21]='1';\ns[29][22]='1';\ns[29][23]='1';\ns[29][24]='1';\ns[29][25]='1';\ns[29][26]='1';\ns[29][27]='0';\ns[29][28]='1';\ns[29][29]='1';\ns[29][30]='0';\ns[29][31]='1';\ns[29][32]='0';\ns[30][0]='1';\ns[30][1]='0';\ns[30][2]='1';\ns[30][3]='1';\ns[30][4]='1';\ns[30][5]='0';\ns[30][6]='1';\ns[30][7]='0';\ns[30][8]='0';\ns[30][9]='1';\ns[30][10]='0';\ns[30][11]='0';\ns[30][12]='0';\ns[30][13]='1';\ns[30][14]='1';\ns[30][15]='0';\ns[30][16]='1';\ns[30][17]='1';\ns[30][18]='1';\ns[30][19]='1';\ns[30][20]='0';\ns[30][21]='1';\ns[30][22]='1';\ns[30][23]='0';\ns[30][24]='1';\ns[30][25]='0';\ns[30][26]='1';\ns[30][27]='1';\ns[30][28]='1';\ns[30][29]='0';\ns[30][30]='0';\ns[30][31]='0';\ns[30][32]='0';\ns[31][0]='1';\ns[31][1]='0';\ns[31][2]='0';\ns[31][3]='0';\ns[31][4]='0';\ns[31][5]='0';\ns[31][6]='1';\ns[31][7]='0';\ns[31][8]='0';\ns[31][9]='1';\ns[31][10]='1';\ns[31][11]='0';\ns[31][12]='0';\ns[31][13]='1';\ns[31][14]='1';\ns[31][15]='0';\ns[31][16]='0';\ns[31][17]='1';\ns[31][18]='1';\ns[31][19]='1';\ns[31][20]='1';\ns[31][21]='1';\ns[31][22]='0';\ns[31][23]='0';\ns[31][24]='1';\ns[31][25]='1';\ns[31][26]='1';\ns[31][27]='1';\ns[31][28]='0';\ns[31][29]='0';\ns[31][30]='0';\ns[31][31]='0';\ns[31][32]='0';\ns[32][0]='1';\ns[32][1]='1';\ns[32][2]='1';\ns[32][3]='1';\ns[32][4]='1';\ns[32][5]='1';\ns[32][6]='1';\ns[32][7]='0';\ns[32][8]='1';\ns[32][9]='1';\ns[32][10]='0';\ns[32][11]='1';\ns[32][12]='0';\ns[32][13]='0';\ns[32][14]='0';\ns[32][15]='1';\ns[32][16]='0';\ns[32][17]='1';\ns[32][18]='0';\ns[32][19]='0';\ns[32][20]='1';\ns[32][21]='1';\ns[32][22]='0';\ns[32][23]='1';\ns[32][24]='1';\ns[32][25]='1';\ns[32][26]='0';\ns[32][27]='0';\ns[32][28]='1';\ns[32][29]='0';\ns[32][30]='0';\ns[32][31]='0';\ns[32][32]='1';\nscanf(\"%d%d\",&x,&y);\nprintf(\"%c\",s[x][y]);\nreturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "dbe37c42f7643702e7f19b58f85250f0", "src_uid": "879ac20ae5d3e7f1002afe907d9887df", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/******************************************************************************\n\n Online C Compiler.\n Code, Compile, Run and Debug C program online.\nWrite your code in this editor and press \"Run\" button to compile and execute it.\n\n*******************************************************************************/\n\n#include \n\nint main()\n{\n int a,b,c;\n scanf(\"%d\",&a);\n if(a==1)\n {\n printf(\"2\");\n }\n else if(a==2)\n {\n printf(\"3\");\n }\n else\n {\n for(int i=4; ;i++)\n {\n b=i/2;\n c=i-b;\n if(a>(b*c)-b && a<=b*c)\n {\n printf(\"%d\",i);\n break;\n }\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "1b48bd37be2a8675daf2da72155edad2", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n\nint main(void)\n{\n int n;\n int d1, d2;\n scanf(\"%d\", &n);\n if(n==1||n==2)\n printf(\"%d\", n+1);\n else\n {\n for(int m=1; m<=n+1; m++)\n {\n if(m%2==0)\n {\n d1 = m/2;\n d2 = m/2;\n int max = d1*d2;\n if(n<=max)\n {\n printf(\"%d\", m);\n break;\n }\n }\n else\n {\n d1=m/2;\n d2=m/2 + 1;\n int max = d1*d2;\n if(n<=max)\n {\n printf(\"%d\", m);\n break;\n }\n }\n }\n }\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "binary search"], "code_uid": "320e3093891d5c54769391cad439347e", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n int s,v1,v2,t1,t2,x,y;\n scanf(\"%d %d %d %d %d\",&s,&v1,&v2,&t1,&t2);\n x=(s*v1)+(t1*2);\n y=(s*v2)+(t2*2);\n if(xy) printf(\"Second\");\n else printf(\"Friendship\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ecb0fa323da3ce4a6a3394330967e7f2", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int s,v1,v2,t1,t2;\n int p,q;\n scanf(\"%d %d %d %d %d\",&s,&v1,&v2,&t1,&t2);\n p=s*v1+2*t1;\n q=s*v2+2*t2;\n if(p>q)\n printf(\"Second\");\n else if(q>p)\n printf(\"First\");\n else\n printf(\"Friendship\");\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "1ca12c4e45c342eb1354dae928da467d", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n;\n scanf(\"%d\\n\",&n);\n int k[1001],a,m,i=0,b=0;\n while(i\nint main()\n{\n\tint n, a[100000], i, b, c = 0;\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d\", &a[i]);\n\t}\n\t\tb = a[1] - a[0];\n\t\tfor (i = 0; i < n-1; i++)\n\t\t{\n\t\t\tif ((a[i + 1] - a[i]) != b )\n\t\t\t{\n\t\t\t\tc = 1;\n\t\t\t\t\tprintf(\"%d\\n\", a[n - 1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (c == 0)\n\t\t\tprintf(\"%d\\n\", a[n - 1]+b );\n\t\t\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6a6f0b2de533a7347fc5b33b68403b4a", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//BR34k\n#include \nint min(int a, int b)\n{\n if (a < b) {\n return a;\n } else {\n return b;\n }\n}\nint gcd(int a, int b)\n{\n if (a < b)\n return gcd(b, a);\n if (a % b == 0) \n return b;\n return gcd(b, a % b);\n}\n\nint main()\n{\n int a, b, x, y, g;\n scanf(\"%d %d %d %d\", &a, &b, &x, &y);\n g = gcd(x, y);\n x /= g; y /= g;\n a /= x; b /= y;\n printf(\"%d %d\\n\", min(a, b) * x, min(a, b) * y);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["binary search", "number theory"], "code_uid": "961ccd891aee604798e4dba9a2a84f6b", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define max(a,b) (a>=b?a:b)\n#define min(a,b) (a<=b?a:b)\nint gcd (int a , int b)\n{\n if(b==0)\n return a;\n else\n return gcd(b,a%b);\n}/*\nint max(int x,int y)\n{\n return x>=y?x:y;\n}\nint min(int x,int y)\n{\n return x<=y?x:y;\n}*/\nint main()\n{\n int a,b,x,y;\n int deltab=0;\n int comm_ratio,m;\n scanf(\"%d %d %d %d\",&a,&b,&x,&y);\n\n comm_ratio=gcd(max(x,y),min(x,y));\n x/=comm_ratio;\n y/=comm_ratio;\n\n m=min(a/x,b/y);\n\n if ( m==0)\n {\n printf(\"0 0\\n\");\n }\n else\n {\n printf(\"%d %d\\n\",x*m,y*m);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["binary search", "number theory"], "code_uid": "1859e3e84ca59a5fb5532b52c11ecf6e", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int a,b,c=0;\n scanf(\"%d %d\",&a,&b);\n while(a<=b)\n {\n a=a*3;\n b=b*2;\n if(b\n#include \n\nint main()\n{\n int a,b;\n int years = 1;\n scanf(\"%d %d\",&a,&b);\n while(a <= b)\n {\n a = a*3*years;\n b = b*2*years;\n years++;\n }\n years--;\n printf(\"%d\",years);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "711c036a8ad92928f3326c7c11073908", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,i,x;\n int a[10000];\n for(n=1,i=1;n<10,i<10;n++,i++)\n {\n a[i]=n;\n }\n for(n=10,i=10;n<=99,i<190;n++,i+=2)\n {\n a[i]=n/10;\n a[i+1]=n%10;\n }\n for(n=100,i=190;n<=370,i<999;n++,i+=3)\n {\n a[i+2]=n%10;\n a[i+1]=(n/10)%10;\n a[i]=(n/10)/10;\n }\n a[1000]=3;\n scanf(\"%d\",&x);\n printf(\"%d\",a[x]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "982861557ee008bab3aa77327890c393", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include\nint main()\n{\n int n,i,sum=9,x,y,a;\n scanf(\"%d\",&n);\n\n while(1){\n\n if(n<=9){\n printf(\"%d\",n);\n return 0;\n }\n\n for(i=10;i<=1000;i++){\n\n if(i>9 && i<100) a=2;\n if(i>99 && i<999) a=3;\n if(i>999 && i<=1000) a=4;\n\n sum=sum+a;\n\n if(sum==n){\n printf(\"%d\",i%10);\n return 0;\n }\n if(sum>n){\n x=i;\n y=sum;\n while(1){\n x=x/10;\n y--;\n if(y==n){\n printf(\"%d\",x%10);\n return 0;\n }\n }\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "91864369e7a6e54259da8ac7e131ee8b", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint a,b,c;\nint main ()\n{\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tint d=(c-1)/(2*b);\n\tint e=(c-1)%(2*b);\n\tif(c%2==0) printf(\"%d %d R\\n\",d+1,e/2+1);\n\telse printf(\"%d %d L\\n\",d+1,e/2+1);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "76fd278f216764809145e584148e1ede", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n int n,m,p,d,r; //the number of lane r, the number of desk d\n char side; //side of the desk\n\n scanf(\"%d\", &n);\n scanf(\"%d\", &m);\n scanf(\"%d\", &p);\n\n if(p % 2 != 0)\n {\n side = 'L';\n p++;\n }\n else side = 'R';\n\n d = (p/2) % m;\n if (d == 0) d = m;\n\n r = (p-2*d)/(2*m) + 1;\n\n printf(\"%d %d %c\", r,d,side);\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "c8ef0b1306b0fae9cac8e6efc3379b20", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n \nint main()\n{\n int n;\n scanf(\"%d\", &n);\n if(n==20)printf(\"15\");\n else if(n>=11 && n<=21)printf(\"4\");\n else printf(\"0\");\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0568fabe1120591c51b1e9ec04e2dd9e", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n,x;\n scanf(\"%d\",&n);\n\n x=n-10;\n if(x<=0 || x>11)\n printf(\"0\\n\");\n else if(x<10 || x==11)\n printf(\"4\\n\");\n else if(x==10)\n printf(\"15\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "07a86c46a2265efe22f78890c7eeb8f6", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int n,m,a,b,c,count=0,x;\n scanf(\"%d%d\",&n,&m);\n\n for(a=0;a<=1000;a++)\n {\n b = n - a*a;\n if(b>=0)\n {\n x = a +b*b;\n if(x == m)\n count++;\n }\n }\n printf(\"%d\",count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "4b630e96ba7b4c5d23d0af4f2ea23fb6", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main() {\n int n,m,cnt=0;\n scanf(\"%d%d\",&n,&m);\n for (int i=0;i<=31;i++)\n for (int j=0;j<=31;j++)\n if (i*i+j==n&&j*j+i==m) cnt++;\n printf(\"%d\\n\",cnt);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "528ac7a992ca53fa74d1f73dd566b91d", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\tint i,a;\n\tint n,bx,m,by;\n\tlong long int num1=0,num2=0;\n\tscanf(\"%d %d\",&n,&bx);\n\tfor(i=0;i\\n\");\n\t}\n\telse if(check>0){\n\t\tprintf(\"<\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b2e9921c98de0b95ffdffb1e368bb1c3", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(){\n\tint n, m;\n\tint bx, by;\n\tlong long a =0, b = 0;\n\tint i;\n\tint digit;\n\tlong long mul = 1;\n\n\tscanf(\"%d %d\", &n, &bx);\n\tfor(i=0; i b) printf(\">\");\n\tif(a < b) printf(\"<\");\n\tif(a == b) printf(\"=\");\n\n\t\t\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "c5d9b1b61724463795f913a5b1b414d2", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n int l,d,g,r,v,sum,ok=0,a;\n double t,t1,t2,t3;\n scanf(\"%d%d%d%d%d\",&l,&d,&v,&g,&r);\n t=((double)d)/((double)v);\n t1=((double)l)/((double)v);\n sum=g+r;\n t2=t/(double)sum;\n a=(int)t2;\n if(a*sum+g>t){\n printf(\"%lf\\n\",t1);\n }\n else{\n t3=(a+1)*sum+(double)(l-d)/(double)v;\n printf(\"%lf\\n\",t3);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "9c62c696d15d9c1dd0a294129ed3f57c", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint l,d,v,g,r,dr;\n\tscanf(\"%d %d %d %d %d\\n\",&l,&d,&v,&g,&r);\n\tdr=d%((g+r)*v);\n\tif (dr\nint count[1005];\nint main()\n{\n int i,j=0,n,x=0,z=0;\n scanf(\"%d\",&n);\n int a[n],b[n];\n for(i=0;i=0;i--)\n {\n x=b[i];\n if(count[x]==0)\n {\n a[j]=x;\n j++;\n }\n count[x]++;\n }\n printf(\"%d\\n\",j);\n for(i=j-1;i>=0;i--)\n {\n printf(\"%d \",a[i]);\n }\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "74b50acde1a1f29f01a1dcf26adb4de8", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MAX 57\n#define SIZE 1007\n\nint main()\n{\n\tint n, a[MAX], i, x, b[SIZE], c[MAX], j;\n\tscanf(\"%d\", &n);\n\tfor(i=1;i<=n;++i)\n\t{\n\t\tscanf(\"%d\", &a[i]);\n\t}\n\tfor(i=0;i=1;--i)\n\t{\n\t\tif(b[a[i]] == 0)\n\t\t{\n\t\t\tb[a[i]] = 1;\n\t\t\tc[j++] = a[i];\n\t\t}\n\t}\n\tprintf(\"%d\\n\", j);\n\t--j;\n\twhile(j >= 0)\n\t{\n\t\tprintf(\"%d \", c[j]);\n\t\t--j;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "33af13e1859965195abe09cd8133b367", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N 1000001\n\nint main() {\n int b[N];\n for (int i = 0; i < N; i++) {\n b[i] = 1;\n }\n\n for (int i = 2; i < (int)sqrt(N)+1; i++) {\n if (b[i-2]) {\n for (int j = 2*i; j < N; j += i) {\n b[j-2] = 0;\n }\n }\n }\n\n int x2;\n scanf(\"%d\", &x2);\n /*if (x2 == 1000000) {\n printf(\"3\");\n return 0;\n }*/\n\n int p = 1;\n int inter1 = 1;\n while (p*p <= x2) {\n if (x2%p == 0) {\n if (b[x2/p-2]) {\n if (x2/p > inter1) {\n inter1 = x2/p;\n }\n }\n else if (b[p-2]) {\n if (p > inter1) {\n inter1 = p;\n }\n }\n }\n p++;\n }\n\n int ans = x2;\n for (int x1 = x2; x1 > x2-inter1; x1--) {\n int p = 2;\n int inter2 = 1;\n while (p*p <= x1) {\n if (x1%p == 0) {\n if (b[x1/p-2]) {\n if (x1/p > inter2) {\n inter2 = x1/p;\n }\n }\n else if (b[p-2]) {\n if (p > inter2) {\n inter2 = p;\n }\n }\n }\n p++;\n }\n //printf(\"%d\\n\", inter2);\n if (x1-inter2+1 < ans) ans = x1-inter2+1;\n }\n if (ans < 3) {\n printf(\"3\");\n }\n else{\n printf(\"%d\", ans);\n }\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "741ab3abbb1d7fca3a53b68d5bfe4ee3", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nlong v[1000001];\n\nlong min(long a,long b)\n{\n if (a>b)\n return b;\n else\n return a;\n}\n\nint main()\n{\n long n,i,j,result;\n scanf(\"%ld\",&n);\n for (i=1;i<=1000000;i++)\n v[i]=1;\n for (i=2;i<=1000000;i++)\n if (v[i]==1)\n {\n j=i;\n while (j<=1000000)\n {\n v[j]=i;\n j+=i;\n }\n }\n result=1000000000;\n //printf(\"%ld\\n\",n-v[n]+1);\n for (i=n-v[n]+1;i<=n;i++)\n if (i!=v[i])\n result=min(result,i-v[i]+1);\n printf(\"%ld\\n\",result);\n return 0;\n}\n// x0>=3\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "386c9b415efcf69e68940d395fe215d5", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n long long n;\n scanf(\"%lld\",&n);\n printf(\"%lld\",n/2520);\n \n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "c558f274ac5fc65196cdc354eff6f176", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n long long int n,m;\n scanf(\"%lld\",&n);\n printf(\"%lld\\n\",(n/2520));\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "1689d5122a46de7b12ceb2dac46a2e8b", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(int argc, char const *argv[])\n{\n\tlong long int i,j,k,l,n,q,x,y,p,m,a,b,c,d;\n\t// a = c\n\t// b = x0;\n\t// c = x1;\n\t// d = a;\n\t// l = l;\n\tscanf(\"%lld %lld %lld %lld %lld\",&a,&b,&c,&d,&l);\n\tx = 0;\n\ti = 0;\n\tj = 0;\n\tlong long int count = 0;\n\twhile(x= 1)\n\t\t\tx = x-l;\n\t\tif(x < 0)\n\t\t\tx = 0;\n\t\tp = b + count*d;\n\t\tif(p>c)\n\t\t\tp = c;\n\t\tx = x + p;\n\t\t//printf(\"x : %d\\n\",x );\n\t\tcount++;\n\t}\n\n\tprintf(\"%lld\\n\",count );\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5df4b2e3635bddbc7469156bf8227bdf", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": " #include\n int main()\n {\n int c,v,p,a,l,i=0,r=0,b,d;\n scanf(\"%d %d %d %d %d\",&c,&v,&p,&a,&l);\n if(c==v)\n printf(\"1\");\n else{\n for(i=0;i!=-1;i++)\n {\n if(i>0)\n r=r-l;\n d=v+i*a;\n if(d<=p)\n r=r+d;\n else if(d>p)\n r=r+p;\n if(r>=c)\n {\n b=i+1;\n i=-1;\n break;\n }\n }\n printf(\"%d\",b);\n }\n return(0);\n }\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "e68211d7944fea41d23b05f916925021", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int i,j,res=0;\n char day1[15];\n char day2[15];\n\n char test[26][15]={\"tu\",\"tu\",\"th\",\"th\",\"su\",\"su\",\"we\",\"we\",\"sa\",\"sa\",\"mo\",\"mo\",\"th\",\"sa\",\"tu\",\"fr\",\"fr\", \"su\",\"we\",\"fr\",\"su\",\"tu\",\"fr\",\"mo\",\"we\"};\n gets(day1);\n gets(day2);\n day1[2]='\\0';\n day2[2]='\\0';\n for(i=0,j=1;j<27;i++,j++)\n {\n if(!strcmp(day1,test[i]) && !strcmp(day2,test[j]))\n res=1;\n }\n\n if(res)\n printf(\"YES\");\n else\n printf(\"NO\");\n\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b850be6f1984043d109122282c478dce", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n/*#include\n#include\n//char days[][16] ={\"monday\",\"tuesday\",\"wednesday\",\"thursday\",\"friday\",\"saturday\",\"sunday\"};\nchar *s[7] ={\"monday\",\"tuesday\",\"wednesday\",\"thursday\",\"friday\",\"saturday\",\"sunday\"};\nint jiancha(char*x)\n{\n\tint i;\n\tfor(i=0;i<7;i++)\n\tif(strcmp(x,s[i])==0)\n\t break;\n\t\treturn i;\n}\nint main()\n{\n\t//static char s1[10],s2[10];\n\tchar s1[10],s2[10];\n\tint a,b,c;\n\tscanf(\"%s%s\",s1,s2);\n\ta=jiancha(s1);\n\tprintf(\"%d\\n\",a);\n\tb=jiancha(s2);\n\tprintf(\"%d\\n\",b);\n c=a>b?7+b-a:b-a;\n\tif(c==0||c==2||c==3)\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}*/\n#include\n#include\nchar *s[7]={\"monday\",\"tuesday\",\"wednesday\",\"thursday\",\"friday\",\"saturday\",\"sunday\"};\nint jiancha(char*x)\n{\n\tint i;\n\tfor(i=0;i<7;i++)\n\t\tif(strcmp(x,s[i])==0)\n\t\tbreak;\n\t\treturn i;\n}\nint main()\n{\n\tchar s1[10],s2[10];\n\tint a,b,c;\n\tscanf(\"%s%s\",s1,s2);\n\ta=jiancha(s1);\n\n\tb=jiancha(s2);\n c=a>b?7+b-a:b-a;\n\n\tif(c==0||c==2||c==3)\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f27babbeec1fbac0f7c43ac50e2fbe8e", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n long long n,m,k,t,d=1;\n scanf(\"%lld%lld%lld\",&n,&m,&k);\n t=abs(m)+abs(n);\n if(t\nint main()\n{\n\tint a,b,s;\n\tscanf(\"%d%d%d\",&a,&b,&s);\n\tif(a>=0&&b>=0)\n\t{\n\t\tif((s>=(a+b))&& (s-(a+b))%2==0)\n\t\t\tprintf(\"Yes\\n\");\n\t\telse\n\t\t\tprintf(\"No\\n\");\n\t}\n\telse if(a<0 &&b<0)\n\t{\n\t\tif((s>=(-(a+b)))&& (s-(a+b))%2==0)\n\t\t\tprintf(\"Yes\\n\");\n\t\telse\n\t\t\tprintf(\"No\\n\");\n\t}\n\telse if(a<0) \n\t{\n\t\tif(s>=((-a)+b)&&(s-((-a)+b))%2==0)\n\t\t\tprintf(\"Yes\\n\");\n\t\telse\n\t\t\tprintf(\"No\\n\");\n\t}\n\telse\n\t{\n\t\tif(s>=(a+(-b))&&(s-(a+(-b)))%2==0)\n\t\t\tprintf(\"Yes\\n\");\n\t\telse\n\t\t\tprintf(\"No\\n\");\n\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "3a7ececd3b4937d546a6ffd08845a47b", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tstatic int aa[10];\n\tint n, i, j, amax, imax;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tfor (i = 0; i < n; i++) {\n\t\tfor (j = 1; j < n - i; j++)\n\t\t\tif (aa[j] - aa[j - 1] >= 2 || aa[j] - aa[j - 1] <= -2) {\n\t\t\t\tprintf(\"NO\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\tamax = 0;\n\t\tfor (j = 0; j < n - i; j++)\n\t\t\tif (amax < aa[j])\n\t\t\t\tamax = aa[j], imax = j;\n\t\tfor (j = imax; j < n - i - 1; j++)\n\t\t\taa[j] = aa[j + 1];\n\t\taa[n - i - 1] = amax;\n\t}\n\tprintf(\"YES\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d0fbc3f1342c98496bb79e2b521f0ab3", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n// fuck parents\nint main() {\n int n;\n scanf(\"%d\\n\", &n);\n int i, a[100];\n for (i = 0; i < n; ++i) {\n scanf(\"%d\", a + i);\n }\n for (i = 1; i < n; ++i) {\n if (a[i] - a[i-1] >= 2 || a[i-1] - a[i] >= 2) {\n printf(\"NO\\n\");\n return 0;\n }\n }\n printf(\"YES\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "c7f3bea129b9c6878f67e6cee50de0b4", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint n,l,r,x,a[20],ans=0,state=0;\nvoid func(int k,int d,int e,int h,int t)\n{\n\tif(k==n)\n\t{\n\t\tif(h-e>=x && d>=l && d<=r && t>1)\n\t\t{\n\t\t\tans++;\n\t\t\t//\tprintf(\"%d %d %d %d\\n\",t,d,e,h);\n\t\t}\n\t\treturn;\n\t}\n\tif(state==0)\n\t{\n\t\tstate=1;\n\t\tfunc(k+1,d+a[k],a[k],a[k],t+1);\n\t\tstate=0;\n\t\tfunc(k+1,d,e,h,t);\n\t}\n\telse\n\t{\n\t\tif(a[k]h)\n\t\t{\n\t\t\tfunc(k+1,d+a[k],e,a[k],t+1);\n\t\t\tfunc(k+1,d,e,h,t);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfunc(k+1,d+a[k],e,h,t+1);\n\t\t\tfunc(k+1,d,e,h,t);\n\t\t}\n\t}\n\treturn;\n}\nint main()\n{\n\tint i;\n\tscanf(\"%d %d %d %d\",&n,&l,&r,&x);\n\tfor(i=0;i\n#include\n#include\n#include\n//...........................................................\n\n#define pi 3.14159265358979323846 //float type\n#define MAX 100000 //for rmq\n#define SQRTMAX 317 //for rmq\n//#define gc getchar_unlocked\n\n#define FOR(i,a,b) for(i=(a);i<(b);i++)\n\n//only for +ve and single terms\n#define s(x) scanf(\"%d\",&x);\n#define sl(x) scanf(\"%lld\",&x);\n#define p(x) printf(\"%d\\n\",x);\n#define pl(x) printf(\"%lld\\n\",x);\n//..........................................................\n\ntypedef long long int ll;\nconst ll MOD=1000000007;\n\n//returns int and +ve numbers\n\n/*inline int inp(){\n int n=0;\n char c;\n c=gc();\n while(c<'0' || c>'9'){\n c=gc();\n }\n while(c>='0' && c<='9'){\n n=(n<<3)+(n<<1)+c-'0';\n c=gc();\n }\n return n;\n}\n*/\n//...................................\n\n//power with mod........long long int\n ll power(ll a,ll b,ll mod){\n if(b==0)\n return 1;\n ll temp=power(a,b/2,mod);\n temp=(temp*temp)%mod;\n if(b&1)\n temp=(temp*a)%mod;\n return temp;\n}\n\n //power without mod........ int\nll pwr(ll a,ll b){\n if(b==0)\n return 1;\n ll temp=pwr(a,b/2);\n temp=(temp*temp);\n if(b&1)\n temp=(temp*a);\n return temp;\n}\n // .....long long int\nll gcd(ll a,ll b){\n return b==0?a:gcd(b,a%b);\n}\n //......long long int\nll lcm(ll a,ll b){\n return (a/gcd(a,b))*b;\n}\n //......long long int with mod\nll modularInverse(ll a,ll m){\n return power(a,m-2,m);\n}\n\n //only for int\n int min(int a,int b) { return ab? a : b; }\n\n//normal compare func on integers //for qsort(name,size,sizeof(type),compare)\nint compare (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint BinarySearch(int *array, int number_of_elements, int key)\n{\n int low = 0, high = number_of_elements-1, mid;\n while(low <= high)\n {\n mid = (low + high)/2;\n if(array[mid] < key)\n {\n low = mid + 1;\n }\n else if(array[mid] == key)\n {\n return mid;\n }\n else if(array[mid] > key)\n {\n high = mid-1;\n }\n\n }\n return -1;\n}\n//.......................................................\n\n//segment tree\n//not template but how to use ST\n//for minimum element\n/*\nlong long s[400000];\nlong long a[1000000];\nint create(long long b,long long e,long long n)\n{\n if(b==e)\n {\n s[n]=a[b];\n }\n else\n {\n create(b,(b+e)/2,2*n+1);\n create((b+e)/2+1,e,2*n+2);\n s[n]=s[2*n+1]r)\n {\n return 100000001;\n }\n if(b>=l&&e<=r)\n {\n return s[n];\n }\n i=messi(b,(b+e)/2,l,r,2*n+1);\n j=messi((b+e)/2+1,e,l,r,2*n+2);\n return ib[i])\n minimum = b[i];\n if(maximum b[l]){\n minimum = b[l];\n\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n while(j<=j2 && l<=r && j min[j])\n minimum = min[j];\n l = (j+1)*size;\n //printf(\"Checked for %d <--> %d\\n\", j*size, l-1);\n j++;\n }\n while(l<=r){\n if(minimum > b[l]){\n minimum = b[l];\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n return minimum;\n}\n\n//finding max value\nlong findMax(int l, int r){\n int j, j2;\n long maximum = b[l];\n\n j = l/size + 1;\n j2 = r/size - 1;\n\n //printf(\"j= %d and j2 = %d\\n\", j,j2);\n while(l %d\\n\", j*size, l-1);\n j++;\n }\n while(l<=r){\n if(maximum < b[l]){\n maximum = b[l];\n }\n //printf(\"Checked for %d\\n\", l);\n l++;\n }\n return maximum;\n}\n*/\n\n//...........................................END OF TEMPLATE.................................................................\n\nll a[20];\nint main()\n{ ll i,j=20,k=20,t,n,l,r,x,ans=0,xe,tot,sum=0,ju=0,ma,mi;\n sl(n)\n sl(l)\n sl(r)\n sl(x)\n\n FOR(i,0,n)\n sl(a[i])\n\n\n qsort(a,n,sizeof(ll),compare);\n\n FOR(i,0,n)\n {\n if(a[i]>=l)\n {\n j=i;\n break;\n }\n }\n\n for(i=n-1;i>=0;i--)\n {\n if(a[i]<=l)\n {\n k=i;\n break;\n }\n }\n\n if(n<2)\n printf(\"0\\n\");\n\n\n else\n {\n\n FOR(i,3,1<>j)&1)\n {\n\n\n {\n if(a[j]>=ma)\n ma=a[j];\n if(a[j]<=mi)\n mi=a[j];\n sum=sum+a[j];\n }\n\n }\n }\n if(sum>=l&&sum<=r&&ju==0&&(ma-mi>=x))\n ans++;\n\n\n }\n\n pl(ans)\n }\n\n\n\n\n\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "bitmasks"], "code_uid": "631dd229cf98aa04191532cef3e8f570", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n\nint main(int argc, char **argv)\n{\n unsigned long tie, scarf, vest, jacket;\n int suit_cost_jt, suit_cost_jsv, no_suit_jt = 0, no_suit_jsv = 0;\n // zero input protection or validation\n scanf(\"%lu\\n%lu\\n%lu\\n%lu\\n%d\\n%d\", &tie, &scarf, &vest, &jacket, &suit_cost_jt, &suit_cost_jsv);\n\n if ( jacket <= scarf && jacket <= vest ) {\n no_suit_jsv = jacket;\n jacket = 0;\n } else if ( scarf <= jacket && scarf <= vest) {\n no_suit_jsv = scarf;\n jacket -= scarf;\n } else {\n no_suit_jsv = vest;\n jacket -= vest;\n }\n\n if (tie > jacket) {\n no_suit_jt = jacket;\n tie -= jacket;\n } else {\n no_suit_jt = tie;\n tie = 0;\n }\n\n if (suit_cost_jt > suit_cost_jsv) {\n if (tie > no_suit_jsv)\n tie = no_suit_jsv % tie;\n no_suit_jsv -= tie;\n no_suit_jt += tie;\n }\n\n printf(\"%d\\n\", no_suit_jt * suit_cost_jt + no_suit_jsv * suit_cost_jsv);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "brute force"], "code_uid": "74c1b87806143c6b55fee2b6f2f402a4", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\n\tint i, index, index2, suit1Cost, suit2Cost, remainder, total=0;\n\tunsigned int clothes[4];\n\tunsigned int smallest = 100001;\n\n\tscanf(\"%d\", &clothes[0]);\n\tscanf(\"%d\", &clothes[1]);\n\tscanf(\"%d\", &clothes[2]);\n\tscanf(\"%d\", &clothes[3]);\n\tscanf(\"%d\", &suit1Cost);\n\tscanf(\"%d\", &suit2Cost);\n\n\tfor (i = 0; i < 4; i++) {\n\t\tif (clothes[i] < smallest) {\n\t\t\tsmallest = clothes[i];\n\t\t\tindex = i;\n\t\t}\n\t}\n\t\n\tif (suit1Cost <= suit2Cost) {\n\t\tif (index == 0) {\n\t\t\tsmallest = 100001;\n\t\t\tfor (i = 1; i < 4; i++) {\n\t\t\t\tif (clothes[i] < smallest) {\n\t\t\t\t\tsmallest = clothes[i];\n\t\t\t\t\tindex = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (index == 3) {\n\t\t\t\ttotal = clothes[index] * suit2Cost;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tremainder = clothes[3] - smallest;\n\t\t\t\tif (remainder <= clothes[0]) {\n\t\t\t\t\ttotal = ((smallest)*suit2Cost) + (remainder * suit1Cost);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttotal = ((smallest)*suit2Cost) + (clothes[0] * suit1Cost);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (index == 3) {\n\t\t\ttotal = clothes[index] * suit2Cost;\n\t\t}\n\t\telse {\n\t\t\tremainder = clothes[3] - smallest;\n\t\t\tif (remainder > 0) {\n\t\t\t\ttotal = smallest * suit2Cost;\n\t\t\t\tif (remainder <= clothes[0]) {\n\t\t\t\t\ttotal += remainder * suit1Cost;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttotal += clothes[0] * suit1Cost;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotal = clothes[3] * suit2Cost;\n\t\t\t}\n\t\t}\n\t}\n\telse if (suit1Cost > suit2Cost) {\n\t\tremainder = clothes[3] - clothes[0];\n\t\tif (index == 0) {\n\t\t\ttotal = clothes[0] * suit1Cost;\n\t\t\tsmallest = 100001;\n\t\t\tfor (i = 1; i < 4; i++) {\n\t\t\t\tif (clothes[i] < smallest) {\n\t\t\t\t\tsmallest = clothes[i];\n\t\t\t\t\tindex = i;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (remainder <= smallest) {\n\t\t\t\ttotal += remainder * suit2Cost;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotal += smallest * suit2Cost;\n\t\t\t}\n\t\t}\n\t\telse if (index == 3) {\t\n\t\t\ttotal = clothes[3] * suit1Cost;\n\t\t}\n\t\telse {\n\t\t\tif (remainder > 0) {\n\t\t\t\ttotal = clothes[0] * suit1Cost;\n\t\t\t\tif (remainder <= smallest) {\n\t\t\t\t\ttotal += remainder * suit2Cost;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttotal += smallest * suit2Cost;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotal = clothes[3] * suit1Cost;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\", total);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "brute force"], "code_uid": "0294914ff5036c0a82b037f779a9ec32", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n\tint n,m;\n\tint i;\n\tscanf(\"%d%d\",&n,&m);\n\tif(m/n!=2){\n\t\tprintf(\"%d\",0);\n\t}else{\n\t\tprintf(\"%d\",2*n-(m-n));\t\n\t}\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6e08dc6172265141fbc5a64e94a26d37", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,k;\n\tscanf(\"%d %d\",&n,&k);\n\tif(k<3*n)\n\t\tprintf(\"%d\",3*n-k);\n\telse\n\t\tprintf(\"0\");\n\treturn 0;\n}\n\t\t\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "782443172c798692b4b8813bc64b553e", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint re(int n) {\n\tint f=1,r=0;\n\tfor(;n;n/=10) if (n%10!=0) {\n\t\tr+=n%10*f;\n\t\tf*=10;\n\t}\n\treturn r;\n}\n\nint main() {\n\tint a,b;\n\tscanf(\"%d %d\",&a,&b);\n\tif (re(a)+re(b)==re(a+b)) puts(\"YES\"); else puts(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "133afd9e552903990491482d462782d1", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint digits(int num)\n{\n int res=0, sum=1;\n while(num!=0)\n {\n res=res+(num%10)*sum;\n if(num%10!=0)\n sum=sum*10;\n num/=10;\n }\n return res;\n}\nint main()\n{\n int a, b,c;\n scanf(\"%d %d\", &a, &b);\n if(digits(a+b)==digits(a)+digits(b))\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "af5b821e5142e9884f99969b8e048427", "src_uid": "ac6971f4feea0662d82da8e0862031ad", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t1000000\n#define MD\t998244353\n\nint kk[N + 1];\n\nvoid init() {\n\tint i, j;\n\n\tfor (i = 1; i <= N; i++)\n\t\tfor (j = i; j <= N; j += i)\n\t\t\tkk[j]++;\n}\n\nint main() {\n\tint n, i, x, y;\n\n\tinit();\n\tscanf(\"%d\", &n);\n\tx = y = 1;\n\tfor (i = 2; i <= n; i++)\n\t\ty = (y + (x = (y + kk[i]) % MD)) % MD;\n\tprintf(\"%d\\n\", x);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "40395f9b1882c9947f35155b485e2c54", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#define N 1000001\r\nconst int mod=998244353;\r\nint dp[N],s=1;\r\nint main()\r\n{\r\n for(int i=1;i<=1000000;++i)\r\n for(int j=i+i;j<=1000000;j+=i)\r\n ++dp[j];\r\n\r\n for(int i=1;i<=1000000;i++)\r\n {\r\n dp[i]=(s+dp[i])%mod;\r\n s=(dp[i]+s)%mod;\r\n }\r\n\r\n scanf(\"%d\",&s);\r\n printf(\"%d\",dp[s]);\r\n return 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "7215ba233464b3ffd24311d243cc5eae", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main ()\n{\n int i,n,h,m;\n double x,y,ha,ma;\n char ch;\n scanf(\"%d%c%d\",&h,&ch,&m);\n x=((h-1)%12+1);\n if(x==12) {\n x=0;\n }\n x+=(m+0.00)/60;\n ha=x*30;\n ma=m*6;\n printf(\"%0.9lf %0.9lf\\n\",ha,ma);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "fd050a3118fc29667cd601a69dc64e86", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(int argc, char *argv[]) {\n\tint h, m;\n\tscanf(\"%d:%d\", &h, &m);\n\th = h < 12 ? h : h - 12;\n\tif (m % 2 == 0) {\n\t\tprintf(\"%.0f %d\\n\", h * 30.0 + m * 0.5, m * 6);\n\t} else {\n\t\tprintf(\"%.1f %d\\n\", h * 30 + (float)m * 0.5, m * 6);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "3e0e2cb17148362abdeea6ed3c9e77b9", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define Min(a, b) ((a) < (b) ? (a) : (b))\n\nint ans[205], k = 0;\n\nint sum(int x){\n\tint res = 0;\n\twhile(x){\n\t\tres += x % 10;\n\t\tx /= 10;\n\t}\n\treturn res;\n}\n\nint main(){\n\tint n, i;\n\tscanf(\"%d\", &n);\n\tfor(i = n-Min(n, 100); i < n+100; i++){\n\t\tif(i+sum(i) == n){\n\t\t\tans[k++] = i;\n\t\t}\n\t}\n\tprintf(\"%d\\n\", k);\n\tfor(i = 0; i < k; i++){\n\t\tprintf(\"%d \", ans[i]);\n\t}\n}", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "8668702034837d63d3777780906202b1", "src_uid": "ae20ae2a16273a0d379932d6e973f878", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int n,i,a[10010],cnt,temp,sum,j;\n int ans=0;\n scanf(\"%d\",&n);\n cnt=0;\n temp=n;\n memset(a,0,sizeof(a));\n while(temp)\n {\n temp=temp/10;\n cnt++;\n }\n for(i=n-9*cnt;i<=n;i++)\n {\n j=i;\n sum=i;\n while(j)\n {\n sum+=(j%10);\n j/=10;\n }\n if(sum==n) a[ans++]=i;\n }\n\n if(ans==0) printf(\"0\");\n else\n {\n printf(\"%d\\n\",ans);\n for(i=0;i\nint max(int a,int b)\n{\nreturn (a>b?a:b);\n}\nint main()\n{\nint tux,pur,buz,bar,foo,quiz;\nscanf(\"%d\",&tux);\nfoo=bar=buz=0;\nquiz=1;\nwhile(tux--)\n{\nscanf(\"%d\",&pur);\nfoo+=pur;\nbar+=1;\nif(max(foo*quiz,bar*buz)==foo*quiz)\n{\nbuz=foo;\nquiz=bar;\n}\nelse\nbreak;\n\n}\nprintf(\"%.6f\\n\",(float)(buz)/(float)quiz);\n\nreturn 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "21ae101ecd1cbd2b29214c8817432e3f", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint a[50];\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n int i;\n double ans = -1;\n double sum = 0;\n for (i = 1; i <= n; i++)\n {\n int now;\n scanf(\"%d\", &now);\n sum += now;\n if (sum / i > ans)\n ans = sum / i;\n }\n printf(\"%.10f\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "62ae7f4b0fa907db76806c6f7cbec32b", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint max(int a, int b){\n return a > b ? a : b;\n}\n\nint main(void){ // HAI\n int tux; // I HAS A TUX\n scanf(\"%d\", &tux); // GIMMEH TUX\n int foo = 0; // I HAS A FOO ITS 0\n int bar = 0; // I HAS A BAR ITS 0\n int baz = 0; // I HAS A BAZ ITS 0\n int quz = 1; // I HAS A QUZ ITS 1\n while (tux--){ // IM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0\n int pur; // I HAS A PUR\n scanf(\"%d\", &pur); // GIMMEH PUR\n foo += pur; // FOO R SUM OF FOO AN PUR\n bar += 1; // BAR R SUM OF BAR AN 1\n if (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 baz = foo; // BAZ R FOO\n quz = bar; // QUZ R BAR\n }\n }\n printf(\"%lf\\n\", (double)baz / quz); // VISIBLE SMOOSH QUOSHUNT OF BAZ QUZ\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "75c8ce5b37c0f91d29fa72e4cef95060", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "main()\n{\n float ans;\n int n,a,b,c,d,num;\n scanf(\"%d\",&n);\n a = 0;\n b = 0;\n c = 0;\n d = 1;\n while (n--) {\n scanf(\"%d\",&num);\n a = a + num;\n b = b + 1;\n if (a * d >= b * c) {\n c = a;\n d = b;\n }\n }\n ans=(float)c;\n ans=ans/d;\n printf(\"%f\",ans);\n return 0;\n} ", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "b54de2546695366689848624e360fcde", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "main()\n{\n float ans;\n int n,a,b,c,d,num;\n scanf(\"%d\",&n);\n a = 0;\n b = 0;\n c = 0;\n d = 1;\n while (n--) {\n scanf(\"%d\",&num);\n a = a + num;\n b = b + 1;\n if (a * d >= b * c) {\n c = a;\n d = b;\n }\n }\n ans=(float)c;\n ans=ans/d;\n printf(\"%f\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "d22245e6823abf4badaa855be45fe6ac", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n\tint tux=0,pur=0;\n\tscanf(\"%d\",&tux);\n\tdouble foo=0,bar=0,baz=0,quz=1;\n\tfor(int i=1;i<=tux;i++){\n\t\tscanf(\"%d\",&pur);\n\t\tfoo=foo+pur;\n\t\tbar++;\n\t\tif(foo*quz>baz*bar){\n\t\t\tbaz=foo;\n\t\t\tquz=bar;\n\t\t}\n\t}\n\tprintf(\"%.6f\",baz/quz);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "48ea855ec861b2397fa1dc32e5a5edd1", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\t\n\tint TUX;\n\tscanf(\"%d\",&TUX);\n\tint FOO = 0, BAR = 0, BAZ = 0, QUZ = 1;\n\twhile(TUX!=0)\n\t{\n\t\tint PUR;\n\t\tscanf(\"%d\", &PUR);\n\t\tFOO = FOO + PUR;\n\t\tBAR = BAR + 1;\n\t\tif(FOO*QUZ >= BAR*BAZ)\n\t\t{\n\t\t\tBAZ = FOO;\n\t\t\tQUZ = BAR;\n\t\t\t//break;\n\t\t}\n\t\telse\n\t\t\tbreak;\n\t\tTUX--;\n\t}\n\tprintf(\"%f\\n\", (BAZ*1.0)/QUZ);\n\treturn 0;\n\n}", "lang_cluster": "C", "tags": ["implementation", "trees", "graph matchings"], "code_uid": "306e43dd2594dbe26900a95048cd82eb", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\n\r\nint main(){\r\n int n;\r\n scanf(\"%d\", &n);\r\n printf(\"%d\", n ? 1 + (n - 1) % 9 : 0);\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "745d5555802f31c04ce3abaf5eeb1fce", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n\r\nint main()\r\n{\r\n int x,y,z,i,j,k,a,b,c = 0,n,m,t;\r\n scanf(\"%d\",&a);\r\n \r\n loop:\r\n while(a > 0)\r\n {\r\n c += a%10;\r\n a /= 10; \r\n }\r\n \r\n if(c >= 10)\r\n {\r\n a = c;\r\n c = 0;\r\n goto loop;\r\n }\r\n printf(\"%d\\n\",c);\r\n return 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["implementation", "number theory"], "code_uid": "0abc37afe696cc1b35dcb12d68016b8a", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint lucky(long x,int l)\n{\n if(x<0)\n x=-x;\n while(x>0)\n {\n if(x%10 == l)\n return 1;\n else\n x/=10;\n }\n return 0;\n}\nint main()\n{\n long n;\n int l=8;\n scanf(\"%ld\",&n);\n for(int p = 1;p <= 1000; p++)\n {\n if(lucky(n+p,l))\n {\n printf(\"%d\\n\",p);\n return 0;\n }\n }\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "2d5bf785621fcb9cf7858e677dacf9b8", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint islucky(int n){\n \n if(n<0){\n n=-n;\n }\n \n int modfac=10;\n int divfac=1;\n\n while(n/divfac>0){\n int digit=(n%modfac)/divfac;\n if(digit==8){\n return 1;\n }\n modfac*=10;\n divfac*=10;\n }\n \n return 0; //n is not lucky\n}\n\nint main(void){\n\n int a;\n int b=1;\n scanf(\"%d\", &a);\n\n while(islucky(a+b)==0){\n b+=1;\n }\n printf(\"%d\\n\", b);\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "e70dc70854e10808d396aec2e89cddc4", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define oo 2000000000\n#define min(a,b) ((a)<(b)?(a):(b))\n#define max(a,b) ((a)>(b)?(a):(b))\n#define abs(a) ((a)<0?-(a):(a))\n#define eps 1e-8\n\nlong a[5005][5005]={0};\n\nint main()\n{\n long n,m,x;\n long i,j;\n long k;\n long ans=0;\n \n scanf(\"%ld%ld%ld\",&n,&m,&x);\n \n for(i=1,j=1;i<=n-i+1&&j<=m-j+1;i++,j++)\n {\n for(k=j;k<=m-j+1;k++)\n a[i][k]=a[n-i+1][k]=i;\n for(k=i;k<=n-i+1;k++)\n a[k][j]=a[k][m-j+1]=i;\n }\n for(i=1;i<=n;i++)\n for(j=1;j<=m;j++)\n if(((i+j)&1)==0&&a[i][j]==x)\n ans++;\n printf(\"%ld\\n\",ans);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "8c80d55595b54dfe978d5946bcb0efc6", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n long long m,n,i,j,k=0,x;\n scanf(\"%I64d %I64d %I64d\",&m,&n,&x);\n long long arr[100000];\n if(((m==1 || n==1 ) && x!=1)||(m>=n && x>n) ||(n>=m && x>n))\n {\n printf(\"0\");\n return 0;\n }\n else if((m==1 && x==1 && n!=1))\n {\n printf(\"%I64d\",n/2);\n return 0;\n }\n else if(n==1 && x==1 && m!=1)\n {\n printf(\"%I64d\",m/2);\n return 0;\n }\n if(m>=n)\n {\n long long l=m;\n for(i=0;i<((l/2)+1);i++)\n {\n if(m>0 && n>0 &&(m*n)%2==0)\n {\n arr[k]=(m*n)/2;\n m=m-2;\n n=n-2;\n k++;\n }\n else if(m>0 && n>0 && (m*n)%2==1)\n {\n arr[k]=((m*n)+1)/2;\n m=m-2;\n n=n-2;\n k++;\n }\n }\n if(x==1)\n {\n printf(\"%I64d\",arr[0]-arr[1]);\n }\n else\n {\n printf(\"%I64d\",arr[x-1]-arr[x]);\n }\n\n }\n else\n {\nlong long l=n;\n for(i=0;i<(l/2);i++)\n {\n if(m>0 && n>0 &&(m*n)%2==0)\n {\n arr[k]=(m*n)/2;\n m=m-2;\n n=n-2;\n k++;\n }\n else if(m>0 && n>0 && (m*n)%2==1)\n {\n arr[k]=((m*n)+1)/2;\n m=m-2;\n n=n-2;\n k++;\n }\n }\n if(x==1)\n {\n printf(\"%I64d\",arr[0]-arr[1]);\n }\n else\n {\n printf(\"%I64d\",arr[x-1]-arr[x]);\n }\n\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "f22fb5bbdbac69df03bb242c4df9c933", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint p,x,y;\n\tint f=1;\n\tint s;\n\tint temp;\n\tscanf(\"%d %d %d\",&p,&x,&y);\n\tif(y%50==x%50)\n\t\ttemp=y;\n\telse {\n\t\tif(y%50==0)\n\t\t\ty--;\n\t\ttemp=(x%50)+ 50*(y/50+1);\n\t}\n\t//printf(\"%d\",temp);\n\twhile(f)\n\t{\n\t\t\n\t\tint i=(temp/50)%475;\n\t\tint j=0;\n\t\tfor(j=0; j<25 ; j++ )\n\t\t{\n\t\t\ti=((i*96)+42)%475;\n\t\t\tif(p==i+26)\n\t\t\t{\n\t\t\t\tf=0;\n\t\t\t\ts=temp;\n\t\t\t\tbreak;\n\t\t\t}\n//\t\t\tprintf(\"%d\\n\",i);\n\t\t}\n\t\ttemp+=50;\n\t}\n\tif(s<=x)\n\t\tprintf(\"0\");\n\telse if((s-x)%100!=0)\n\t\tprintf(\"%d\",(s-x)/100+1);\n\telse\n\t\tprintf(\"%d\",(s-x)/100);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "6d127d12ec8a2105b0ddaa67013de27d", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define rep(start, n, c) for(((i)=(start));((i)<(n));((i)+=(c)))\n#define MAX 100000\n#define MAX_INT INT_MAX\nint main() {\n int p, x, y;\n scanf(\"%d %d %d\", &p, &x, &y);\n int *arr = (int*)malloc(25 * sizeof(int));\n int i;\n int k = 0, x_temp = x;\n // while(x_temp >= y) {\n // int j = (x_temp / 50) % 475;\n // for(i = 0;i < 25;i++) {\n // //printf(\"%d \", (((j * 96 + 42) % 475) + 26));\n // j = (((j * 96 + 42) % 475) + 26);\n // if(j == p) {\n // printf(\"%d\", k);\n // return 0;\n // }\n // }\n // x_temp -= 100;\n // }\n while(1) {\n x_temp = x + 100 * k;\n while(x_temp >= y) {\n int j = (x_temp / 50) % 475;\n for(i = 0;i < 25;i++) {\n j = ((j * 96 + 42) % 475);\n // printf(\"%d \", j);\n if((j + 26) == p) {\n printf(\"%d\", k);\n return 0;\n }\n }\n x_temp -= 50;\n }\n k++;\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "012a90b6d8dfea226b98cfff5ea8fbd9", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\nint search(int arr[], int n, int x);\nvoid mergeSort(int arr[], int l, int r);\nvoid merge(int arr[], int l, int m, int r);\n\nint main(void){\n\tint a, b, c, x, y, z;\n\tscanf(\"%i %i %i %i %i %i\", &a, &b, &c, &x, &y, &z);\n\tint n1 = x-a, n2 = y-b, n3 = z-c;\n\tint n = ((n1>0)?n1:0) + ((n2>0)?n2:0) + ((n3>0)?n3:0);\n int m = 0;\n\n if(n1<0){\n m += abs(n1)/2;\n }\n if(n2<0){\n m += abs(n2)/2;\n }\n if(n3<0){\n m += abs(n3)/2;\n }\n\n if(m>=n){\n printf(\"YES\\n\");\n }\n else{\n printf(\"NO\\n\");\n }\n}\n\nint search(int arr[], int n, int x)\n{\n int i;\n for (i = 0; i < n; i++)\n if (arr[i] == x)\n return i;\n return -1;\n}\n\nvoid merge(int arr[], int l, int m, int r)\n{\n int i, j, k;\n int n1 = m - l + 1;\n int n2 = r - m;\n\n /* create temp arrays */\n int 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 if (L[i] <= R[j]) {\n arr[k] = L[i];\n i++;\n }\n else {\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 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 arr[k] = R[j];\n j++;\n k++;\n }\n}\n\nvoid mergeSort(int arr[], int l, int r)\n{\n if (l < r) {\n // Same as (l+r)/2, but avoids overflow for\n // large l and h\n int 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}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4f6d7c3b2864891fa2b68c3630d0ace6", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,c,x,y,z,excess,need=0,move=0;\n scanf(\"%d%d%d%d%d%d\",&a,&b,&c,&x,&y,&z);\n if(a>=x) excess=a-x,move+=excess/2;\n else need+=(x-a);\n if(b>=y) excess=b-y,move+=excess/2;\n else need+=(y-b);\n if(c>=z) excess=c-z,move+=excess/2;\n else need+=(z-c);\n if(move>=need) printf(\"Yes\\n\");\n else printf(\"No\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "acddaf91c4d8a089965e5a245eecf89b", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define mod 1000000009u\ntypedef long long unsigned llu;\ntypedef unsigned u;\nu F(u x)\n{\n\tu r=1,e=2;\n\tfor(++x;x;x>>=1)\n\t{\n\t\tif(x&1)r=r*(llu)e%mod;\n\t\te=e*(llu)e%mod;\n\t}\n\treturn r;\n}\nint main()\n{\n\tu n,m,k,x,y,r;\n\tscanf(\"%u%u%u\",&n,&m,&k);\n\ty=n-n/k;x=m-y;\n\tif(m<=y){printf(\"%u\\n\",m);return 0;}\n\tif((r=F(x)+mod-x-2)>=mod)r-=mod;\n\tr=(x+y+r*(llu)k)%mod;\n\tprintf(\"%u\\n\",r);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "3f62773865cf5f3da5bc1398eee927ea", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define modu 1000000009 \n__int64 answ;\nint main()\n{\n\tint n, m, k;\n\t__int64 pa, pb, pg;\n\t__int64 tt, ta;\n\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tpa = n - m;\n\tpg = (pa + 1)*(k - 1);\n\tif (pg >= m)\n\t{\n\t\tansw = m;\n\t\tansw = (answ) % modu;\n\t\tprintf(\"%I64d\\n\", answ);\n\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tpb = m - pg;\n\t\ttt = pb / k;\n\t\tif (pb%k != 0)\n\t\t\ttt = tt + 1;\n\t\tansw = 1;\n\t\tta = 2;\n\t\tm = m - tt*k;\n\t\ttt = tt + 1;\n\t\twhile (tt > 0)\n\t\t{\n\t\t\tif (tt & 1)\n\t\t\t{\n\t\t\t\tansw = answ * ta;\n\t\t\t}\n\t\t\tansw = answ%modu;\n\t\t\tta = ta * ta;\n\t\t\tta = ta%modu;\n\t\t\ttt = tt >> 1;\n\t\t}\n\t\tansw = answ*k - 2 * k;\n\t\tif (answ < 0) answ = answ + modu;\n\t\tansw = answ%modu;\n\t}\n\tansw = (answ + m) % modu;\n\tprintf(\"%I64d\\n\", answ);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "binary search", "number theory", "greedy", "matrices"], "code_uid": "150d93ea43efd0de0548862f57e82a3d", "src_uid": "9cc1aecd70ed54400821c290e2c8018e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint main(){\n int i,n,j,k,sum=0;\n char ch[100],dh,direction[2][2];\n int A[2][2]={0};\n direction[0][0]='0';\n direction[1][0]='0';\n scanf(\"%d\",&n);\n scanf(\"%c\",&dh);\n for(i=0;i\nchar s[101];\nint min(int a,int b){return (a\nint min(int y,int x)\n{\n\tif (y\nint main()\n{\n int n,m;\n scanf(\"%d %d\",&n,&m);\n if(m==0){\n printf(\"1\");\n }\n else if(m<=n/2){\n printf(\"%d\",m);\n }\n else{\n printf(\"%d\",n-m);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "54c502d69902050a71edbb407294ded3", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tlong int a,b;\n\tscanf(\"%ld%ld\",&a,&b);\n\t/*if(a%2!=0 && b%2!=0){\n\t\tif(a>b)\n\t\t\tprintf(\"Masha\\n\");\n\t\telse if(ab)\n\t\t\tprintf(\"Masha\\n\");\n\t\telse if(a\nlong long int GCD(long long int a,long long int b) //recursive\n\n{\n\n if (b==0) return a;\n\n return GCD(b,a%b);\n\n}\nint main()\n{\n long long int a,b,lcm;\n scanf(\"%lld%lld\",&a,&b );\n lcm=(a*b)/GCD(a,b);\n if(alcm/b)\n printf(\"Dasha\\n\");\n else printf(\"Equal\\n\");\n }\n else\n {\n if((lcm/b-1)lcm/a)\n printf(\"Masha\\n\");\n else printf(\"Equal\\n\");\n }\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "ed49a1f61260e7cabb13bd1ed235c5e9", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint x=0,y=0,i,n,flag=0;\n\tchar a[10],b[10];\n\tscanf(\"%s%d\",&a,&n);\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%s\",&b);\n\t\tif(b[1]==a[1]&&b[0]==a[0])\n\t\t{\n\t\t\tprintf(\"YES\");\n\t\t\treturn 0;\n\t\t}\n\t\tif(b[0]==a[1])x=1;\n\t\tif(b[1]==a[0])y=1;\n\t\tif(x&&y)\n\t\t{\n\t\t\tprintf(\"YES\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "b343def4fbacb30ab90a3f5e30369135", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nchar passwd[4], str[4];\nint main(){\n scanf(\"%s\", passwd);\n\n int T, num=0, chk=0;\n scanf(\"%d\", &T);\n while (T--) {\n scanf(\"%s\", str);\n if (str[0]==passwd[0] && str[1] == passwd[1])\n chk=4;\n else if (str[1]==passwd[0] && str[0]==passwd[1])\n chk=4;\n else if (str[0]==passwd[1]){\n if (chk<4){\n if (chk==1) chk=4;\n else chk=2;\n }\n }\n else if (str[1]==passwd[0]){\n if( chk<4) {\n if (chk==2) chk=4;\n else chk=1;\n }\n }\n }\n\n if (chk==4) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "4897a14bae1bf005cb2d56b1a24a4c04", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n char c[90];\n int d=1,i,j,l;\n scanf(\"%d \",&l);\n gets(c);\n for(i=1;i\n#include\nint main()\n{\n int n,num=0,len,c=0,i,j=0,k;\n scanf(\"%d\",&n);\n char str[n+2],number[n+2];\n scanf(\"%s\",str);\n len=strlen(str);\n for(i=0;i\nint main()\n{\n long long n,m,x;\n scanf(\"%lld%lld\",&n,&m);\n while(1)\n {\n if(n==0 || m==0)\n\t\tbreak;\n\t if(n>=2*m)\n\t\t{\n\t\tx=n/(2*m);\n\t\tn=n-x*(2*m);\n\t\t}\n else \n\t {\n\t\tif(m>=2*n)\n\t\t{\n\t\tx=m/(2*n);\n \tm=m-x*(2*n);\n\t\t}\n\t\telse \n\t\tbreak;\n\n }\n }\n printf(\"%lld %lld\",n,m);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "edff734fb6de0bfe8e09bcb14b56e7ec", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main(){\n\tlong long int a,b;\n\tscanf(\"%lld %lld\",&a,&b);\n\tfor(;;){\n\t\tif((a==0)||(b==0))\n\t\t\tbreak;\n\t\tif(a/(2*b)>=1)\n\t\t\ta=a-2*b*(a/(2*b));\n\t\telse if(b/(2*a)>=1)\n\t\t\tb=b-2*a*(b/(2*a));\n\t\telse\n\t\t\tbreak;\n\t}\n\tprintf(\"%lld %lld\",a,b);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "8a3f5e3eb8f0f16c946c7d320258dea7", "src_uid": "1f505e430eb930ea2b495ab531274114", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint x[101]= {0};\n\nint main()\n{\n int i,j,n,a,Ans=0,c=0,d=0,b;\n\n scanf(\"%d %d\",&n,&a);\n for (i=1; i<=n; i++) scanf(\"%d\",&x[i]);\n\n c=a-1;\n d=n-a;\n if(x[a]==1) Ans++;\n if(c=1; i++,j--)\n {\n if(x[i]>0 && x[j]>0) Ans+=2;\n }\n for(i=a+c+1; i<=n; i++)\n {\n if(x[i]>0) Ans++;\n }\n printf(\"%d\\n\",Ans);\n }\n if(c>d)\n {\n for(i=a+1,j=a-1; i<=n,j>=a-d; i++,j--)\n {\n if(x[i]>0 && x[j]>0) Ans+=2;\n }\n for(i=1; i0) Ans++;\n }\n printf(\"%d\\n\",Ans);\n }\n if(c==d)\n {\n for(i=a+1,j=a-1; i<=n,j>=1; i++,j--)\n {\n if(x[i]>0 && x[j]>0) Ans+=2;\n }\n printf(\"%d\\n\",Ans);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "72ace1c24378c27cfb698a0b39e6531f", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nvoid main()\n{\nlong long n,a,i,count=0,k,j=1;\nscanf(\"%lld %lld\",&n,&a);\nlong long t[n],b[n];\nfor(i=0;i(n-a))\nfor(i=0;i(a-1))\nfor(i=a+k;i\nint main()\n{\n long long int a,sum=0,i;\n scanf(\"%lld\",&a);\n sum=a*(a+1)/2;\n if(sum%2==1)\n {\n printf(\"1\");\n }\n else\n {\n printf(\"0\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "f5f53103439022ccad46da9a78566ae3", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n\nint main()\n{\n\n unsigned int i,n,s=0 ;\n scanf(\"%u\",&n);\n s=n*(n+1)/2 ;\n printf(\"%u\",s%2);\n}\n\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "49e9fdffbce8e4b152d39761b9c090b9", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int total,end=0,start1,start2,take,d,start=0,store=0;\n long long int grandtotal=1;\n\n scanf(\"%d\",&total);\n\n for(start1=1;start1<=total;start1++)\n {\n\n scanf(\"%d\",&take);\n\n if(take==1&&start==0)\n {\n start=1;\n continue;\n }\n\n if(start==1&&take==0)\n store++;\n else if(start==1&&take==1)\n {\n if(store!=0)\n grandtotal=grandtotal*(store+1);\n store=0;\n }\n\n }\n if(start==0)\n printf(\"0\\n\");\n else\n printf(\"%lld\\n\",grandtotal);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "08dbc88d186b05cd800e073010e2810f", "src_uid": "58242665476f1c4fa723848ff0ecda98", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong long int i,j,n,sum=0,result=1,flag=0,first_one=-1,last_one=-1;\n\tscanf(\"%lld\",&n);\n\tlong long int a[n];\n\tfor(i=0;i\n int main(void){\n \tint n; scanf(\"%d\", &n);\n \tif(n%2==0) printf(\"%d\", 1<<(n/2));\n \telse printf(\"0\");\n \treturn 0;\n }", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "8b3b76cabcb70ae15edc406a3feff7d6", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint P(int base, int exp)\n{\n int i, r = 1;\n i = 0;\n do{\n r *= base;\n i++;\n }while(i < exp);\n \n return r;\n}\n\nint main()\n{\n int n;\n \n scanf(\"%d\", &n);\n if(n % 2 == 1)\n printf(\"0\");\n else\n printf(\"%d\", P(2, n/2));\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "92e6d960e641c5e31a4c24335e3fd11b", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nunsigned int powten(unsigned int n){\n switch(n){\n case 0:return 1;\n case 1:return 1E1;\n case 2:return 1E2;\n case 3:return 1E3;\n case 4:return 1E4;\n case 5:return 1E5;\n case 6:return 1E6;\n case 7:return 1E7;\n case 8:return 1E8;\n case 9:return 1E9;\n }\n}\n\nint main(void){\n unsigned int a,b,c;\n unsigned int i,k;\n scanf(\"%u%u\",&a,&b);\n c=0;\n for(k=0;k<10;k++) if(b/powten(k)==0) break;\n for(i=0;i\nint main() {\n int a,b,c=0;\n scanf(\"%d%d\",&a,&b);\n while(b) {\n c=c*10+(b%10);\n b/=10;\n }\n printf(\"%d\",a+c);\n return 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms"], "code_uid": "8807529f358ac5ec19477424eb7a75ab", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint main()\r\n{\r\n\r\n int n, m, o, x,t;\r\n scanf(\"%d\",&t);\r\n while(t--)\r\n {\r\n scanf(\"%d%d%d%d\",&x,&n,&m,&o);\r\n if(doors(x,n,m,o))\r\n printf(\"YES\\n\");\r\n else printf(\"NO\\n\");\r\n }\r\n}\r\n\r\n\r\nint doors(int x, int n,int m, int o)\r\n{\r\n char a[4]={x,n,m,o};\r\n int b=x,count=0;\r\n while(a[b]!=0)\r\n {\r\n b=a[b];\r\n count++;\r\n }\r\n if(count==2)\r\n return 1;\r\n else\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "256beb6153c71ba17a0bfcb87de19326", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\nint main(){\r\n int t;\r\n scanf(\"%d\",&t);\r\n while(t--){\r\n int key,arr[3];\r\n scanf(\"%d\",&key);\r\n for(int i=0;i<3;i++){\r\n scanf(\"%d\",&arr[i]);}\r\n if(arr[key-1]!=0){\r\n if(arr[arr[key-1]-1]!=0){\r\n printf(\"YES\\n\");\r\n continue;\r\n }\r\n }printf(\"NO\\n\");\r\n }\r\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation", "math"], "code_uid": "b3aa14060e57e4e65ac40185a48d77ac", "src_uid": "5cd113a30bbbb93d8620a483d4da0349", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int prime;\n scanf(\"%d\",&prime);\n\n long long int i, j, aux, q, count=0;\n\n for(i=1;i\nint main()\n{\n long long int p,val,cnt=0,flag,po,x;\n scanf(\"%lld\",&p);\n for(x=1;x\n\nint main()\n{\n char n[7];\n scanf(\"%s\",n);\n printf(\"%d\",n[6]%2);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "10ccbd071176a03487fbc612b8d32f56", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main(){\n\tchar c;\n\tint d = 0;\n\tscanf(\"%c %d\",&c,&d);\n\tprintf(\"%d \\n\",d&1);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "afc27f7aa56e42adb5682369f6648558", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b;\n scanf(\"%d %d\",&a,&b);\n\n //prime number ber na korte parle ja hoy :)\n\n if(a==2 && b==3)\n {\n printf(\"YES\");\n }\n else if(a==3 && b==5)\n {\n printf(\"YES\");\n }\n else if(a==5 && b==7)\n {\n printf(\"YES\");\n }\n else if(a==7 && b==11)\n {\n printf(\"YES\");\n }\n\n else if(a==11 && b==13)\n {\n printf(\"YES\");\n }\n\n else if(a==13 && b==17)\n {\n printf(\"YES\");\n }\n\n else if(a==17 && b==19)\n {\n printf(\"YES\");\n }\n\n else if(a==19 && b==23)\n {\n printf(\"YES\");\n }\n\n else if(a==23 && b==29)\n {\n printf(\"YES\");\n }\n\n else if(a==29 && b==31)\n {\n printf(\"YES\");\n }\n\n else if(a==31 && b==37)\n {\n printf(\"YES\");\n }\n\n else if(a==37 && b==41)\n {\n printf(\"YES\");\n }\n\n else if(a==41 && b==43)\n {\n printf(\"YES\");\n }\n\n else if(a==43 && b==47)\n {\n printf(\"YES\");\n }\n\n else\n {\n printf(\"NO\");\n }\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "ff24aa9000b066e7fd8a85653f114196", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint prime(int n){\n if(n<2)return 0;\n if(n==2)return 1;\n if(n%2==0)return 0;\n int i=3;\n for(;i*i<=n;i+=2){\n if(n%i==0)return 0;\n }\n return 1;\n}\nint main(void) {\n // your code goes here\n int n,m,i,x1;\n scanf(\"%d %d\",&n,&m);\n for( i=n+1;i<=m;i++){\n x1=prime(i);\n if(x1==1 && i!=m){\n printf(\"NO\");\n exit(0);\n }\n }\n if(x1==1)printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "4fd59da5c5150b795511e054d974f31f", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main()\n{\n int i, a, b, s = 0, t = 0, k = 0, g = 0;\n scanf(\"%d %d\", &a, &b);\n if(a == b){\n printf(\"infinity\");\n return 0;\n }\n else if(a < b) s = 0;\n else{\n k = a - b;\n for(i = 1; i * i <= k; i++)\n {\n if(k % i == 0 && i > b)\n s++;\n if(k % i == 0 && k / i != i && k / i > b)\n s++;\n }\n }\n printf(\"%d\\n\", s);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "ba3188cda0a1510d1dd66a2036a65b85", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(){\n\tlong int a,b;\n\tscanf(\"%ld%ld\",&a,&b);\n\tif(a==b)\n\t\tprintf(\"infinity\\n\");\n\telse if(b>a)\n\t\tprintf(\"0\\n\");\n\telse{\n\t\tlong int count=0;\n\t\tlong int x;\n\t\tint fl=0;\n\t\tfor(x=1; x*x <= (a-b);x++){\n\t\t\tif((a-b)%x==0){\n\t//\t\t\tprintf(\"x = %ld\\n\",x);\n\t\t\t\tif(x>b)\n\t\t\t\t\tcount++;\n\t\t\t\tif((a-b)/x>b && x*x!=(a-b))\n\t\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\tif(fl==1)\n\t\t\tprintf(\"%ld\\n\",count);\n\t\telse\n\t\t\tprintf(\"%ld\\n\",count);\n\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "553a6e0eaa200fca44dc6c19498682f3", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int m,n,c=0,f;\n scanf(\"%d %d\",&n,&m);\n if(m%n!=0)\n {\n printf(\"-1\");\n return 0;\n }\n int q=m/n;\n while(q!=1)\n {\n f=0;\n if(q%2==0)\n {\n f=1;\n q/=2;\n c++;\n }\n if(q%3==0)\n {\n f=1;\n q/=3;\n c++;\n }\n if(f==0)\n {\n c=-1;\n break;\n }\n }\n printf(\"%d\",c);\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e907df07227d1872274ef0358a28449a", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \"stdio.h\"\n\n#define BASE \"%ld\"\n\ntypedef long int Base;\n\nint main()\n{\n\tBase InitialNumber = 0;\n\tBase DesiredNumber = 0;\n\tBase PredictedSteps = 0;\n\tBase ActualSteps = 0; \n\n\tscanf(BASE BASE, &InitialNumber, &DesiredNumber);\n\t\n\tif (DesiredNumber % InitialNumber) {\n\t\tActualSteps = -1;\t\n\t}\n\telse \n\t{\n\t\tPredictedSteps = DesiredNumber / InitialNumber;\t\n\n\t\twhile (PredictedSteps % 3 == 0) \n\t\t{\n\t\t\tActualSteps++;\n\t\t\tPredictedSteps /= 3;\n\t\t}\n\n\t\twhile (PredictedSteps % 2 == 0)\n\t\t{\n\t\t\tActualSteps++;\n\t\t\tPredictedSteps /= 2;\n\t\t}\n\n\t\tif (PredictedSteps != 1) \n\t\t{\n\t\t\tActualSteps = -1;\t\n\t\t}\n\t}\n\n\tprintf(BASE\"\\n\", ActualSteps);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "daa43dfc13e144ede188214cea01d27f", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include\nint main()\n{\nint n,p=0,q=0,x,y;\nscanf(\"%d%d%d\",&n,&x,&y);\ny--;x--;\nif((y==(n/2) || y==((n/2)-1)) && (x==(n/2) || x==((n/2)-1)))\nprintf(\"NO\");\nelse\nprintf(\"YES\");\nreturn(0);\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6c1dc63914a9f0620d6b4c567c22bc41", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main () {\n\tint n, x, y;\n\tscanf(\"%d %d %d\", &n, &x, &y);\n\tif ((x==n/2|x==(n/2+1))&(y==n/2|y==(n/2+1))) {\n\t\tputs(\"NO\");\n\t} else {\n\t\tputs(\"YES\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "0df0257ffbb9d25f9251e28f45f5efa3", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n\t\n\t\tlong long int n;\n\t\tscanf(\"%lld\", &n);\n\t\t\n\t\tlong long int r[n];\n\t\tlong long int b[n];\n\t\tlong long int i;\n\t\t\n\t\tfor ( i = 0; i < n; ++i )\n\t\t{\n\t\t\tscanf(\"%lld\", &r[i]);\n\t\t}\n\n\t\tfor ( i = 0; i < n; ++i )\n\t\t{\n\t\t\tscanf(\"%lld\", &b[i]);\n\t\t}\n\t\t\n\t\tlong long int neg = 0;\n\t\tlong long int pos = 0;\n\t\tfor ( i = 0; i < n; ++i )\n\t\t{\n\t\t\tif ( r[i] == 1 && b[i] == 0 )\n\t\t\t{\n\t\t\t\t++pos;\n\t\t\t}\n\t\t\t\n\t\t\tif ( r[i] == 0 && b[i] == 1 )\n\t\t\t{\n\t\t\t\t++neg;\n\t\t\t}\n\t\t}\n\n\t\tif ( pos == 0 )\n\t\t{\n\t\t\tprintf(\"-1\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tlong long int sol = neg/pos+1;\n\t\t\tprintf(\"%lld\\n\", sol);\n\t\t}\n\n\t//system(\"pause\");\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "b6f7c68fc4d5362dd10be09f21483b83", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int i,m,k,t=0,l=2,n,a,ls=0;\n k=-1;\n int q=3;\n scanf(\"%d\",&m);\n int r[m],b[m];\n for(i=0;is2)\n {\n break;\n }\n\n }\n\n\n }\n\n else\n {\n for(i=1;;i++)\n {\n a=n*s1;\n\n if(a>ls)\n {\n n=n-1;\n a=n*s1;\n if(a\nint main()\n{\n\tlong int a,i;\n\tscanf(\"%ld\",&a);\n\twhile(a>1)\n\t{\n\t printf(\"%ld \",a);\n\t for(i=2;i<=a;i++)\n\t {\n\t \tif(a%i==0)\n\t \t{\n\t \t\ta/=i;\n\t \t\tbreak;\n\t\t\t}\n\t \t\n\t\t}\n\t}\nprintf(\"%ld\",a);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "ec5b0f3c05861a6cf028f43e0e686bf1", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\nint main(){\n\n int n;\n \n scanf(\"%i\" ,&n);\n \n for(int i = n;i>0;i--){\n if(n%i == 0){\n n = i;\n printf(\"%i \",n);\n }\n }\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "59c7aac2a3467f56555730d5715294e7", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nlong long int divn[2009][2009],en[2009],ar[2009][2009];\nint main()\n{\n\tlong long int s=0;\n\tint n,k,i,j,c,g,M=1000000007;\n\tscanf(\"%d%d\",&n,&k);\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tc=0;\n\t\tfor(j=1;j<=i;j++)\n\t\t{\n\t\t\tif(i%j==0)\n\t\t\tdivn[i][c++]=j;\n\t\t\ten[i]=c;\n\t\t}\n\t}\n\tfor(i=0;i<=n;i++)\n\t{\n\t\tfor(j=0;j\n#include \n\n#define DATA_SIZE 2005\n#define MODULE 1000000007\n\nlong long dp[DATA_SIZE][DATA_SIZE];\n\nint main()\n{\n\tint n, k;\n\tscanf(\"%d %d\", &n, &k);\n\tmemset(dp, 0, sizeof(dp));\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tdp[i][1] = 1;\n\t}\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tfor (int kk = 2; kk <= k; ++kk)\n\t\t{\n\t\t\tfor (int j = i; j <= n; j += i)\n\t\t\t{\n\t\t\t\tdp[j][kk] = (dp[j][kk] + dp[i][kk - 1]) % MODULE;\n\t\t\t}\n\t\t}\n\t}\n\n\tlong long res = 0;\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tres += dp[i][k];\n\t}\n\tprintf(\"%I64d\", res % MODULE);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dp", "combinatorics", "number theory"], "code_uid": "aa4e81d707f3310c9e83f56e8e5b0fa6", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n unsigned long long int n,m,k,i,j,x=1,y=1,c=1,l,up=0,r;\n\n scanf(\"%llu %llu %llu\",&n,&m,&k);\n\n if(k<=(n-1)+(m-1))\n {\n if(k<=n-1) printf(\"%llu 1\",1+k);\n else\n {\n c=k-(n-1);\n printf(\"%llu %llu\",n,1+c);\n }\n }\n else\n {\n c=(n-1)+(m-1);\n k-=c;\n x=n;\n y=m;\n up=k/(m-1);\n r=k%(m-1);\n x-=up;\n if(r==0)\n {\n if(up%2==1) y=2;\n if(up%2==0) y=m;\n }\n else if(r>0)\n {\n up++;\n r--;\n x--;\n if(up%2==1) //go left\n {\n y=m;\n for(i=1; i<=r; i++) y--;\n }\n if(up%2==0) //go right\n {\n y=2;\n for(i=1; i<=r; i++) y++;\n }\n }\n printf(\"%llu %llu\",x,y);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "3dc8ae2deab576c48880a5e7b12002f0", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n long long n, m, k, d, fd;\n\n scanf(\"%lld %lld %lld\", &n, &m, &k);\n\n if (k < n) {\n printf(\"%lld 1\", k + 1);\n } else if (k < n + m - 1) {\n printf(\"%lld %lld\", n, 1 + k - (n - 1));\n } else {\n k -= (n - 1) + (m - 1);\n d = k / (m - 1);\n fd = 0;\n if (k % (m - 1) == 0) {\n d--;\n fd = 1;\n }\n\n printf(\"%lld \", n - 1 - d);\n if (d & 1) {\n if (!fd) {\n printf(\"%lld\", 1 + k % (m - 1));\n } else {\n printf(\"%lld\", m);\n }\n } else {\n if (!fd) {\n printf(\"%lld\", m - (k % (m - 1) - 1));\n } else {\n printf(\"%lld\", 2);\n }\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "e3512add85998d2877826194dfb72fee", "src_uid": "e88bb7621c7124c54e75109a00f96301", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint cmp(int *a,int *b);\nint main()\n{\n\tint sl[6];\n\twhile(scanf(\"%d %d %d %d %d %d\",&sl[0],&sl[1],&sl[2],&sl[3],&sl[4],&sl[5])!=EOF){\n\t\tqsort(sl,6,sizeof(int),cmp);\n\t\tif(sl[0]==sl[3]){\n\t\t\tif(sl[4]==sl[5])\n\t\t\t\tprintf(\"Elephant\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"Bear\\n\");\n\t\t}\n\n\t\telse if(sl[1]==sl[4])\n\t\t\tprintf(\"Bear\\n\");\t\t\n\t\telse if(sl[2]==sl[5]){\n\t\t\tif(sl[0]==sl[1])\n\t\t\t\tprintf(\"Elephant\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"Bear\\n\");\n\t\t}\n\t\telse \n\t\t\tprintf(\"Alien\\n\");\n\n\t}\n\treturn 0;\n}\nint cmp(int *a,int *b){\n\treturn *a-*b;\n}\n \t \t \t\t \t \t \t\t \t \t", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "893f3526dca8fc3c6b4734465aca3e1a", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{int a[6],i,j,k,temp,max,min;\t\n\tfor(i=0;i<6;i++){\n\tscanf(\"%d\",&a[i]);}\n\n\tfor(i=0;i<6;i++){\n\tmin=i;\n\t\tfor(j=i+1;j<6;j++)\n\t{\tif(a[j]\n\nint main()\n{\n int a[3001]={0} , n , i , j ;\n scanf(\"%d\",&n);\n for(i=2 ; i<=n ; i++)\n {\n if(!a[i])\n {\n for(j=i ; j<=n ; j+=i)\n {\n a[j]++;\n }\n\n }\n }\n j=0 ;\n for(i=2 ; i<=n ; i++)\n {\n if(a[i]==2)j++;\n }\n printf(\"%d\",j);\n\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "ce8eb0e597f6191dd94ed872e839054c", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n #include\nint main()\n{int x[3005]={0};\nint c=0,h,i,j;\nint n;\nscanf(\"%d\",&n);\n\nfor(i=2;i<=n;i++)\n{\n for(j=2;j\nint main()\n{\n long int i,j,k=0,n,b,c=0,d,e;\n long int g[5][5];\n for(i=0;i<5;i++)\n for(j=0;j<5;j++)\n scanf(\"%ld\",&g[i][j]);\n for(i=0;i<5;i++)\n {\n for(j=0;j<5;j++)\n {\n if(j!=i)\n for(b=0;b<5;b++)\n {\n if(b!=i&&b!=j)\n for(d=0;d<5;d++)\n {\n if(d!=i&&d!=j&&d!=b)\n for(e=0;e<5;e++)\n {\n if(e!=i&&e!=j&&e!=b&&e!=d)\n {\n c=0;\n c+=g[i][j]+g[j][i]+g[b][d]+g[d][b];\n c+=g[j][b]+g[b][j]+g[d][e]+g[e][d];\n c+=g[b][d]+g[d][b];\n c+=g[d][e]+g[e][d];\n if(c>k)\n {\n k=c;\n }\n }\n }\n }\n }\n }\n }\n printf(\"%ld\",k);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "4f12df8549757bdef633f73ef765e0a3", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint Fun(int *A, int Mat[5][5])\n{\n return Mat[A[0]][A[1]] + Mat[A[1]][A[0]] + 2 * (Mat[A[2]][A[3]] + Mat[A[3]][A[2]])\n + Mat[A[1]][A[2]] + Mat[A[2]][A[1]] + 2 * (Mat[A[3]][A[4]] + Mat[A[4]][A[3]]);\n}\n\nint main()\n{\n int i, j, Max, Now;\n int Mat[5][5], A[5];\n for(i=0; i<5; ++i)\n {\n for(j=0; j<5; ++j)\n {\n scanf(\"%d\", &Mat[i][j]);\n }\n }\n Max = 0;\n for(A[0]=0; A[0]<5; ++A[0])\n {\n for(A[1]=0; A[1]<5; ++A[1])\n {\n if(A[1] != A[0])\n {\n for(A[2]=0; A[2]<5; ++A[2])\n {\n if(A[2]!=A[0] && A[2]!=A[1])\n {\n for(A[3]=0; A[3]<5; ++A[3])\n {\n if(A[3]!=A[0] && A[3]!=A[1] && A[3]!=A[2])\n {\n for(A[4]=0; A[4]<5; ++A[4])\n {\n if(A[4]!=A[0] && A[4]!=A[1] && A[4]!=A[2] && A[4]!=A[3])\n {\n Now = Fun(A, Mat);\n if(Now > Max)\n {\n Max = Now;\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n printf(\"%d\\n\", Max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "c2e464902505dab41ae0738f355f4962", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nint count(long long n) {\n\treturn n == 0 ? 0 : count(n & n - 1) + 1;\n}\n\nint main() {\n\tlong long s, x;\n\n\tscanf(\"%lld%lld\", &s, &x);\n\tif (s < x || s - x & 1 || s - x >> 1 & x)\n\t\tprintf(\"0\\n\");\n\telse\n\t\tprintf(\"%lld\\n\", (1LL << count(x)) - (s == x ? 2 : 0));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms", "implementation"], "code_uid": "90cf37f3ccc7d174816e47f316eedea7", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nuint64_t count(uint64_t s, uint64_t x)\n{\n if ((!s && !x))\n return 1;\n if ((s & 1) ^ (x & 1))\n return 0;\n\n if ((s & 1))\n return 2*count(s >> 1, x >> 1);\n return count(s >> 1, x >> 1) + count((s >> 1)-1, x >> 1);\n}\n\n\nint main(int argc, char *argv[])\n{\n uint64_t s, x;\n scanf(\"%\"PRIu64\" %\"PRIu64\"\", &s, &x);\n printf(\"%\"PRIu64\"\\n\", count(s, x) - 2*(s == x));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "a279d9a54f72573a63e62114170188d0", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int x, i;\n long long n = 0;\n\n scanf(\"%d\", &x);\n\n if (x < 0) x *= -1;\n\n for (i = 0; ; i++) {\n\t n += i;\n\n\t if ((n == x) || (n > x && (n - x) % 2 == 0)) {\n\t printf(\"%d\\n\", i);\n\n\t return 0;\n\t }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "0f031b0b0a691b3e87fce33621fde74f", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include \n \nint main()\n{\n long long int n,j,r,x;\n scanf(\"%lld\",&n);\n if(n<0)\n n=-n;\n for(j=0;;j++)\n {\n r=(j*(j+1)/2);\n x=r-n;\n if(x%2==0 && x/2<=r && x/2>=0)\n {\n printf(\"%lld\\n\",j);\n return 0;\n }\n }\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "e6939c5ce5cc1615d873755f2c3faaf4", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main() {\nfloat a,b,c,d,e,f,k,l,j;\nscanf(\"%f %f %f %f %f %f %f %f %f\",&a,&b,&c,&d,&e,&f,&j,&l,&k);\nk = (b / a) * 100;\n\nl = (d / c) * k ;\n\nj = (f / e) * l;\nif(c == 0 && d != 0) {\n printf(\"Ron\");\n}\nelse if(a == 0 && b != 0 && d != 0) {\nprintf(\"Ron\"); }\nelse if(b == 0 || d == 0 || f == 0) {\nprintf(\"Hermione\");}\n\nelse if(a == 0 || c == 0 || e == 0) {\nprintf(\"Ron\");}\n\nelse if(j > 100) {\nprintf(\"Ron\");}\n\nelse\nprintf(\"Hermione\");\n\nreturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "8de36495014cd9fa239861bec6ecf203", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint isZero(double i)\n{\n\tif(fabs(i)<1e-6)\n\t\treturn 1;\n\treturn 0;\n}\n\nint isRon(double a,double b,double c,double d,double e,double f)\n{\n\tdouble result;\n\tif(isZero(d))\n\t\treturn 0;\n\telse\n\t{\n\t\tif(isZero(c))\n\t\t\treturn 1;\n\t\telse\n\t\t{\n\t\t\tif(isZero(b))\n\t\t\t\treturn 0;\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(isZero(a))\n\t\t\t\t\treturn 1;\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(isZero(f))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tif(isZero(e))\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tresult=(b*d*f)/(a*c*e);\n\t\t\t\t\t\t\tif((result<1)||isZero(result-1))\n\t\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\tdouble a,b,c,d,e,f;\n\twhile(scanf(\"%lf %lf %lf %lf %lf %lf\",&a,&b,&c,&d,&e,&f)==6)\n\t{\n\t\tif(isRon(a,b,c,d,e,f))\n\t\t\tprintf(\"Ron\\n\");\n\t\telse\n\t\t\tprintf(\"Hermione\\n\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "20a6360f0623e5603df4d3e8b91d75f1", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nchar F[8][8];\nint D[8];\nint C(int a, int b)\n{\n int i;\n int r = 0;\n for (i = 1; i < 8; i++)\n {\n if (F[a][i] && F[b][i])\n {\n r++;\n }\n }\n return r;\n}\nint main()\n{\n int i, j;\n int t;\n int n, m;\n int a, b;\n int temp;\n int mV;\n scanf(\"%d %d\", &n, &m);\n for (i = 1; i <= n; i++)\n {\n for (j = 1; j <= n; j++)\n {\n F[i][j] = 0;\n }\n }\n for (i = 1; i <= n; i++)\n {\n D[i] = 0;\n }\n for (i = 0; i < m; i++)\n {\n scanf(\"%d %d\", &a, &b);\n F[a][b] = 1;\n D[a]++;\n F[b][a] = 1;\n D[b]++;\n }\n for (t = 1; t <= n; t++)\n {\n if (D[t] == 0)\n {\n break;\n }\n }\n if (t == 8)\n {\n mV = 8;\n if (m)\n {\n for (a = 1; a < 8; a++)\n {\n for (b = a + 1; b < 8; b++)\n {\n temp = C(a, b);\n if (temp < mV)\n {\n mV = temp;\n }\n }\n }\n m -= mV;\n }\n }\n printf(\"%d\", m);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "graphs"], "code_uid": "8360d242040c39716aa9e1651c4fa47a", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int n, m, i, j, k, x, y, a[8][8], c=0, max;\n scanf(\"%d %d\",&n, &m);\n for(i=1; i<=m; i++)\n {\n scanf(\"%d %d\",&x, &y);\n a[x][y] = 1;\n a[y][x] = 1;\n }\n max = 0;\n if(n==7)\n {\n for(i=1; i<=7; i++)\n {\n for(j=i+1; j<=7; j++)\n {\n c=m;\n for(k=1; k<=7; k++)\n {\n if(k!=i && k!=j && a[i][k]==1 && a[j][k]==1)\n {\n c--;\n }\n }\n if(max\n\nint x[8],y[8];\n\nint main() {\n\tint i,j;\n\tfor (i=0;i<8;i++) scanf(\"%d %d\\n\",&x[i],&y[i]);\n\tfor (i=0;i<8;i++) {\n\t\tif (i&1)\n\t\t\tif ((x[i]==x[i-1])==(y[i]==y[i-1]))\n\t\t\t\tbreak;\n\t\tint c=0;\n\t\tint d=0;\n\t\tfor (j=0;j<8;j++)\n\t\t\tif (x[j]==x[i]&&y[j]==y[i]) {\n\t\t\t\tc++;\n\t\t\t\tif (x[i/2*2+!(i%2)]==x[j/2*2+!(j%2)]&&\n\t\t\t\t\ty[i/2*2+!(i%2)]==y[j/2*2+!(j%2)]) d+=1;\n\t\t\t}\n\t\tif (c!=2) break;\n\t\tif (d!=1) break;\n\t\tc=0;\n\t\tfor (j=0;j<8;j++) if (x[j]==x[i]) c++;\n\t\tif (c!=4) break;\n\t}\n\tprintf(\"%s\\n\",i<8?\"NO\":\"YES\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "25c76eca499b5c93ffdb0ac0daa89afb", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct vertex {\n\tstruct coordinate {\n\t\tint x, y;\n\t} c;\n\tchar has_x, has_y;\n} vertices[4];\n\nint compare(const void *a, const void *b) {\n\tstruct vertex pa = *(struct vertex *) a;\n\tstruct vertex pb = *(struct vertex *) b;\n\n\treturn pa.c.x != pb.c.x ? pa.c.x - pb.c.x : pa.c.y - pb.c.y;\n}\n\nstruct vertex *lookup(int x, int y, int vcnt) {\n\tint i;\n\n\tfor (i = 0; i < vcnt; i++)\n\t\tif (vertices[i].c.x == x && vertices[i].c.y == y)\n\t\t\treturn vertices + i;\n\treturn NULL;\n}\n\nint rect1() {\n\tchar good = 1;\n\tint i, x1, y1, x2, y2, vcnt = 0;\n\tstruct vertex *v1, *v2;\n\n\tfor (i = 0; i < 4; i++) {\n\t\tscanf(\"%d%d%d%d\", &x1, &y1, &x2, &y2);\n\t\tif ((x1 != x2 && y1 != y2) || (x1 == x2 && y1 == y2))\n\t\t\tgood = 0;\n\n\t\tif ((v1 = lookup(x1, y1, vcnt)) == NULL)\n\t\t\tif (vcnt == 4)\n\t\t\t\tgood = 0;\n\t\t\telse {\n\t\t\t\tv1 = vertices + vcnt;\n\t\t\t\tvertices[vcnt].c.x = x1, vertices[vcnt].c.y = y1;\n\t\t\t\tvertices[vcnt].has_x = 0, vertices[vcnt].has_y = 0;\n\t\t\t\tvcnt++;\n\t\t\t}\n\t\telse if ((x1 == x2 && v1->has_x) || (y1 == y2 && v1->has_y))\n\t\t\tgood = 0;\n\t\tif ((v2 = lookup(x2, y2, vcnt)) == NULL)\n\t\t\tif (vcnt == 4)\n\t\t\t\tgood = 0;\n\t\t\telse {\n\t\t\t\tv2 = vertices + vcnt;\n\t\t\t\tvertices[vcnt].c.x = x2, vertices[vcnt].c.y = y2;\n\t\t\t\tvertices[vcnt].has_x = 0, vertices[vcnt].has_y = 0;\n\t\t\t\tvcnt++;\n\t\t\t}\n\t\telse if ((x1 == x2 && v2->has_x) || (y1 == y2 && v2->has_y))\n\t\t\tgood = 0;\n\n\t\tif (x1 == x2 && good && !v1->has_x && !v2->has_x) {\n\t\t\tv1->has_x = 1;\n\t\t\tv2->has_x = 1;\n\t\t} else if (y1 == y2 && good && !v1->has_y && !v2->has_y) {\n\t\t\tv1->has_y = 1;\n\t\t\tv2->has_y = 1;\n\t\t}\n\t}\n\tif (vcnt < 4)\n\t\treturn 0;\n\treturn good;\n}\n\nint rect2(struct vertex *v) {\n\tqsort(v, 4, sizeof(struct vertex), compare);\n\treturn v[1].c.x == v[0].c.x && v[1].c.y == v[3].c.y\n\t\t&& v[2].c.x == v[3].c.x && v[2].c.y == v[0].c.y;\n}\n\nint main() {\n\tif (rect1() && rect2(vertices))\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "math", "implementation", "geometry"], "code_uid": "730a034850e7719877a172508f5f04df", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nlong long rec(long long a,long long b)\r\n{\r\n if(b==0)\r\n return 1;\r\n long long res=rec(a,b/2);\r\n if(b&1)\r\n return a*res*res;\r\n else\r\n return res*res;\r\n}\r\nmain()\r\n{\r\n int t;\r\n scanf(\"%d\",&t);\r\n while(t--)\r\n {\r\n long long n;\r\n scanf(\"%lld\",&n);\r\n long long a=2;\r\n printf(\"%lld\\n\",rec(a,n)-1);\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7f986364c75bbf38e5b50e726ea01806", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\r\n#include \r\nlong long int arrey[31];\r\nlong long int num[31] = { 0,2,\r\n4,\r\n8,\r\n16,\r\n32,\r\n64,\r\n128,\r\n256,\r\n512,\r\n1024,\r\n2048,\r\n4096,\r\n8192,\r\n16384,\r\n32768,\r\n65536,\r\n131072,\r\n262144,\r\n524288,\r\n1048576,\r\n2097152,\r\n4194304,\r\n8388608,\r\n16777216,\r\n33554432,\r\n67108864,\r\n134217728,\r\n268435456,\r\n536870912,\r\n1073741824};\r\n\r\nint main()\r\n{\r\n\tlong long int temp;\r\n\tlong long int n;\r\n\t\r\n\tscanf(\"%lld\", &n);\r\n\tfor (int i = 1;i <= n;i++)\r\n\t{\r\n\t\tscanf(\"%d\", &arrey[i]);\r\n\t}\r\n\t\r\n\tfor (int k = 1;k <= n;k++)\r\n\t{\r\n\t\t\r\n\t\ttemp = arrey[k];\r\n\t\t\r\n\t\tif (temp== 1)\r\n\t\t{\r\n\t\t\tprintf(\"1\\n\");\r\n\t\t\t\r\n\t\t}\r\n\t\telse if (temp == 2)\r\n\t\t{\r\n\t\t\tprintf(\"3\\n\");\r\n\t\t\t\r\n\t\t}\r\n\t\telse if (temp == 3)\r\n\t\t{\r\n\t\t\tprintf(\"7\\n\");\r\n\t\t\t\r\n\t\t}\r\n\t\telse if (temp > 3)\r\n\t\t{\r\n\t\t\tprintf(\"%lld\\n\", num[temp] - 1);\r\n\t\t\t\r\n\t\t}\r\n\t}\r\n\r\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0377261a0298ff783797f9600876c48e", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tlong long int i,j,k,l,n,m,ans = 0,a[3];\n\tscanf(\"%lld%lld%lld\",&a[0],&a[1],&a[2]);\n\tfor(i=2;i>0;i--)\n\t\tfor(j=0;j a[j+1]) {\n\t\t\t\tk = a[j];\n\t\t\t\ta[j] = a[j+1];\n\t\t\t\ta[j+1] = k;\n\t\t\t}\n\tif(a[2] > a[1])\n\t\tif(2*a[0] >= a[2]-a[1]) {\n\t\t\tans += (a[2]-a[1])/2;\n\t\t\ta[0] -= (a[2]-a[1])/2;\n\t\t\ta[2] -= 2*((a[2]-a[1])/2);\n\t\t}\n\t\telse {\n\t\t\tans += a[0];\n\t\t\ta[2] -= 2*a[0];\n\t\t\ta[0] = 0;\n\t\t}\n\tif(a[0] > 0) {\n\t\tans += a[0];\n\t\ta[1] -= a[0];\n\t\ta[2] -= a[0];\n\t\ta[0] = 0;\n\t}\n\tif(2*a[1] <= a[2])\n\t\tprintf(\"%lld\\n\",ans+a[1]);\n\telse\n\t\tprintf(\"%lld\\n\",ans+(a[1]+a[2])/3);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "52e9faec54a7211ee08295167d7e0499", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nlong long max(long long a, long long b) { return a > b ? a : b; }\nlong long min(long long a, long long b) { return a < b ? a : b; }\n\nint main() {\n\tint r, g, b, a;\n\tlong long s;\n\n\tscanf(\"%d%d%d\", &r, &g, &b);\n\ta = max(r, max(g, b));\n\ts = (long long) r + g + b;\n\tprintf(\"%lld\\n\", min(s - a, s / 3));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "40fa6b2e3f0be45820343f8d3883caac", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n\nint main()\n{\n int Yes=1;\n int m,n,i,j;\n char map[500][500]={0};\n int flag[25][25]={0};\n int cnt = 0;\n char h[25],v[25];\n int sum;\n scanf(\"%d %d\", &m, &n);\n for(i = 0; i < m; i ++)\n {\n for(j = 0; j < n; j ++)\n {\n flag[i][j] = cnt ++;\n }\n }\n scanf(\"%s\", h);\n scanf(\"%s\", v);\n for(i = 0; i < m; i ++)\n {\n if(h[i] == '>')\n {\n for(j = 0; j < n - 1; j ++)\n {\n map[flag[i][j]][flag[i][j+1]] = 1;\n }\n }\n else\n {\n for(j = 0; j < n - 1; j ++)\n {\n map[flag[i][j+1]][flag[i][j]] = 1;\n }\n }\n }\n for(j = 0; j < n; j ++)\n {\n if(v[j] == 'v')\n {\n for(i = 0; i < m - 1; i ++)\n {\n map[flag[i][j]][flag[i+1][j]] = 1;\n }\n }\n else\n {\n for(i = 0; i < m - 1; i ++)\n {\n map[flag[i+1][j]][flag[i][j]] = 1;\n }\n }\n }\n for(i = 0; i <= flag[m-1][n-1]; i ++)\n {\n sum = 0;\n for(j = 0; j <= flag[m-1][n-1]; j ++)\n {\n sum += map[i][j];\n }\n if(sum == 0) Yes = 0;\n\n }\n puts(Yes==1?\"YES\":\"NO\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "c7e5ad5284bed670e627c4c6589a4683", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define N 20\nint main(){\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tint i;\n\tchar row[N];\n\tchar col[N];\n\tgetchar();//\\n\n\tfor(i=0;i' && col[0]=='v'){\n\t\tok=0;\n\t}else if(row[0]=='<' && col[0]=='^'){\n\t\tok=0;\n\t}\n\t//\u53f3\u4e0a\u89d2\n\tif(row[0]=='>' && col[m-1]=='^'){\n\t\tok=0;\n\t}else if(row[0]=='<' && col[m-1]=='v'){\n\t\tok=0;\n\t}\n\t//\u5de6\u4e0b\u89d2\n\tif(row[n-1]=='<' && col[0]=='v'){\n\t\tok=0;\n\t}else if(row[n-1]=='>' && col[0]=='^'){\n\t\tok=0;\n\t}\n\t//\u53f3\u4e0b\u89d2\n\tif(row[n-1]=='>' && col[m-1]=='v'){\n\t\tok=0;\n\t}else if(row[n-1]=='<' && col[m-1]=='^'){\n\t\tok=0;\n\t}\n\tif(ok){\n\t\tprintf(\"YES\\n\");\n\t}else{\n\t\tprintf(\"NO\\n\");\n\t}\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "implementation", "graphs", "brute force"], "code_uid": "7175e8d2452c12b91375a98364086d0b", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main()\n{\n int n,i,t,k,temp;\n scanf(\"%d\",&n);\n int arr[n];\n for(i=0;i0;i--)\n {\n for(k=0;karr[k+1])\n {\n temp = arr[k];\n arr[k]=arr[k+1];\n arr[k+1]=temp;\n }\n }\n }\n int counter,max=0;\n for(i=0;imax)\n {\n max=counter;\n }\n if(k==n)\n {\n break;\n }\n }\n printf(\"%d\",max+1);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "8b972fe90b4211501f5553cf5a1fdc5e", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint n;\n\tint t[1001] = {0};\n\tint T;\n\tint count[1001] = {0};\n\tint c = 0;\n\tint tmp;\n\tint i, j;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d\", &tmp);\n\t\tt[tmp]++;\n\t}\n\tscanf(\"%d\", &T);\n\n\tfor (i = 1; i <= 1000 - T; i++)\n\t{\t\n\t\tfor (j = i; j <= i + T; j++)\n\t\t\tcount[c] += t[j];\n\t\t//if (c < 8)\n\t\t//\tprintf(\"count[%d] = %d\\n\", c, count[c]);\n\t\tc++;\n\t}\t\t\t\n\n\tint max = 0;\n\tfor (i = 0; i < c; i++)\n\t\tif (count[i] > max)\n\t\t\tmax = count[i];\n\n\tif (T == 1000)\n\t\tmax = n;\n\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "6f25148b0f3cf8d39011a1c5db377f64", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define N 202\nint main(){\n int n;\n scanf(\"%d\",&n);\n char s[N];\n scanf(\"%s\",s);\n //printf(\"%s\\n\",s);\n int count[30];\n int i,j;\n for(j=0;j<30;j++){\n count[j]=0;\n }\n i=0;\n int max_res=0;\n int res=0;\n while(1){\n if(s[i]>='a' && s[i]<='z'){\n count[s[i]-'a']++;\n }else{\n res=0;\n for(j=0;j<30;j++){\n if(count[j]>0){\n res++;\n }\n }\n if(res>max_res)max_res=res;\n for(j=0;j<30;j++){\n count[j]=0;\n }\n }\n if(s[i]=='\\0')break;\n i++;\n }\n printf(\"%d\\n\",max_res);\n //\u6211\u8ba4\u4e3a\u5c31\u662f\u4e0d\u540c\u7684\u5c0f\u5199\u5b57\u6bcd\u7684\u4e2a\u6570\uff01\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "ec254f34e53e3dee6ca90d64a180285c", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint is_big(char a)\n{\n\tif(a>='A'&&a<='Z')\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\nint main()\n{\n\tint n;\n\twhile(scanf(\"%d\",&n)!=EOF)\n\t{\n\t\tgetchar();\n\t\tchar a[220];\n\t\tint max=0,sum=0,abc[27];\n\t\tfor(int i=0;imax)\n\t\t\t\t\tmax = sum;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\",max);\n\t}\n\treturn 0;\n } ", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "b9616673cf7655fd0a4fe8e8f630a9fd", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int num=44720,a;\n\tlong long int A[num+1],i,j;\n\tfor(i=1;i<=num;i++)\n\tA[i]=(i*(i+1))/2;\n\t//for(i=1;i<=22;i++)\n\t//printf(\"%lld\\n\",A[i]);\n\tlong long int n;\n\tscanf(\"%lld\",&n);\n\tfor(i=1;i<=num;i++)\n\t{\n\t\ta=n-A[i];\n\t\tif(a<=0)\n\t\t{\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t\tlong long int first=0;;\n\t\tlong long int last=num;\n\t\tlong long int middle=(first+last)/2;\n\t\twhile(first<=last)\n\t\t{\n\t\t\tif(A[middle]a)\n\t\t\tlast=middle-1;\n\t\t\telse if(A[middle]==a)\n\t\t\t{\n\t\t\t\tprintf(\"YES\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tmiddle=(first+last)/2;\n\t\t}\n\t}\n//\tprintf(\"%lld %lld\",i,j);\n\tprintf(\"NO\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "a10e7a40d3eab677c8f8419b26c756be", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint n,k,l,x,y;\n\tscanf(\"%d\",&n);\n\tx=1;\n\tfor(k=1;x\r\nint main() {\r\n\tint n;\r\n\tscanf(\"%d\", &n);\r\n\tint num[]={1200,1400,1600,1900,2100,2300,2400,2600,3000};\r\n\tint i = 0;\r\n\twhile(num[i] <= n) i++;\r\n\tprintf(\"%d\", num[i]);\r\n}", "lang_cluster": "C", "tags": ["math", "divide and conquer", "implementation"], "code_uid": "9ca3c037c8a2a440b2273bda55dc6e4f", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n\tint n;\r\n\tscanf(\"%d\",&n);\r\n\tif(n<1200)\r\n\t{\r\n\t\tprintf(\"1200\");\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif(n<1400)\r\n\t\t{\r\n\t\t\tprintf(\"1400\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif(n<1600)\r\n\t\t\t{\r\n\t\t\t\tprintf(\"1600\");\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif(n<1900)\r\n\t\t\t\t{\r\n\t\t\t\t\tprintf(\"1900\");\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif(n<2100)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tprintf(\"2100\");\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(n<2300)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tprintf(\"2300\");\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif(n<2400)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tprintf(\"2400\");\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif(n<2600)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tprintf(\"2600\");\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tprintf(\"3000\");\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["math", "divide and conquer", "implementation"], "code_uid": "b2399e790817055e1fc687611cbfe6a6", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint c1, c2, x, y, ans;\nint main()\n{\n scanf(\"%d%d%d%d\", &c1, &c2, &x, &y);\n\n ans = c1+c2;\n while(ans - ans/x < c1)\n {\n ans += c1 - (ans - ans/x);\n }\n while(ans - ans/y < c2)\n {\n ans += c2 - (ans - ans/y);\n }\n while(ans - ans/(x*y) < c1+c2)\n {\n ans += (c1+c2) - (ans - ans/(x*y));\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "778b59c385e51fd9dfee6d7b0be5e592", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n\n#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))\n\ntypedef long long llong;\n\n\nbool enough(llong v, int cx, int cy, int x, int y) {\n\tllong for_neither = v / (x*y);\n\tllong for_x = v / y - for_neither, \n\t\t for_y = v / x - for_neither;\n\n\tllong for_both = v - (for_x + for_y + for_neither);\n\n\treturn for_both - (MAX(cx - for_x, 0) + MAX(cy - for_y, 0)) >= 0L;\n}\n\n\n\nllong solve(int cx, int cy, int x, int y) {\n\n\tllong l = 1;\n\tllong r = MAX(cx, cy);\n\twhile (!enough(r, cx, cy, x, y)) {\n\t\tr *= 2;\n\t}\n\n\twhile (l < r) {\n\t\tllong m = (l + r) / 2;\n\t\tif (enough(m, cx, cy, x, y)) {\n\t\t\tr = m;\n\t\t}\n\t\telse {\n\t\t\tl = m + 1;\n\t\t}\n\t}\n\n\treturn r;\n}\n\n\nint main(int argc, char **argv) {\n\n\tint cx, cy, x, y;\n\twhile (scanf(\"%d %d %d %d\", &cx, &cy, &x, &y) != EOF) {\n\t\tprintf(\"%lld\\n\", solve(cx, cy, x, y));\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "5a8bbf8bb1fe70cd68a2a1dbd328881c", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint fun(int year)\n{\n if((year%4==0&&year%100!=0)||year%400==0)\n return 1;\n return 0;\n}\nint fin(int year,int month,int day)\n{\n int i,sum=0;\n for(i=1;i2)sum+=1;\n return sum;\n}\nvoid swap(int *a,int *b)\n{\n int temp;\n temp=*a;\n *a=*b;\n *b=temp;\n}\nint main()\n{\n int year1,month1,day1,sum,year2,month2,day2,i,j,temp;\n while(~scanf(\"%d:%d:%d\",&year1,&month1,&day1))\n {\n scanf(\"%d:%d:%d\",&year2,&month2,&day2);\n if(year1>year2)\n {\n swap(&year1,&year2),swap(&month1,&month2),swap(&day1,&day2);\n }\n else if(year1==year2)\n {\n if(month1>month2)swap(&month1,&month2),swap(&day1,&day2);\n else if(month1==month2)\n {\n if(day1>day2)swap(&day1,&day2);\n }\n }\n sum=0;\n for(i=year1;i\n#include\n\nint fun(int year)\n{\n if((year%4==0&&year%100!=0)||year%400==0)\n return 1;\n return 0;\n}\nint f1(int year,int month,int day)\n{\n int i,sum=0;\n for(i=1;i2)sum+=1;\n return sum;\n}\nvoid swap(int *a,int *b)\n{\n int temp;\n temp=*a;\n *a=*b;\n *b=temp;\n}\nint main()\n{\n int year1,month1,day1,sum,year2,month2,day2,i,j,temp;\n while(~scanf(\"%d:%d:%d\",&year1,&month1,&day1))\n {\n scanf(\"%d:%d:%d\",&year2,&month2,&day2);\n if(year1>year2)\n {\n swap(&year1,&year2),swap(&month1,&month2),swap(&day1,&day2);\n }\n else if(year1==year2)\n {\n if(month1>month2)swap(&month1,&month2),swap(&day1,&day2);\n else if(month1==month2)\n {\n if(day1>day2)swap(&day1,&day2);\n }\n }\n sum=0;\n for(i=year1;i\n\nint main()\n{\n int a,x,y;\n\n scanf(\"%d%d%d\",&a,&x,&y);\n if(y==0) \n {\n printf(\"-1\\n\");\n return 0;\n }\n if(y0) printf(\"1\\n\");\n else printf(\"1\\n\");\n }\n else if(y>=a)\n {\n int c=y-a;\n if(c%a==0)\n {\n printf(\"-1\\n\");\n return 0;\n }\n else\n {\n int num=0;\n int d=c/a;\n // int rem=c%a;\n if(d%2==0)\n {\n num=1+3*(d/2);\n \n if(2*abs(x)<(a))\n {\n printf(\"%d\\n\",num+1);\n return 0;\n }\n else\n {\n printf(\"-1\\n\");\n return 0;\n }\n }\n else\n {\n if(d>1) num=2+3*(d-1)/2;\n else num = 2;\n if(abs(x)>=a)\n {\n printf(\"-1\\n\");\n return 0;\n }\n else\n {\n if(x==0) printf(\"-1\\n\");\n else if(x<0) printf(\"%d\\n\",num+1);\n else if(x>0) printf(\"%d\\n\",num+2);\n }\n }\n }\n }\n\n\nreturn 0;\n\n}", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "39a20c24bacd1e5a2bf2d65481148da7", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\nint a,x,y,t;\nscanf(\"%d%d%d\",&a,&x,&y);\nif(y%a==0)\nprintf(\"%d\",-1);\nelse if(y<(2*a))\n{\n int p=abs(x);\nif(p<(fabs)((double)a/2))\nprintf(\"%d\",y/a+1);\nelse\nprintf(\"%d\",-1);\n}\nelse if(y>(2*a))\n{\n t=y/a+1;\n if(t%2==0)\n {\n if(abs(x)<(fabs)((double)a/2))\n {\n int g=((t-1)/2)*3+2;\n printf(\"%d\",g);\n\n }\n else\n printf(\"%d\",-1);\n }\n else\n {\n if(x>0 && x-a)\n printf(\"%d\",(t/2)*3);\n else\n printf(\"%d\",-1);\n }\n\n}\nreturn(0);\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "8ed36f0656e0420ea63ecfe5bfc4df78", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint tc;\n\tscanf(\"%d\",&tc);\n\tchar input[105];\n\tscanf(\"%s\",input);\n\tint temp = 0;\n\tfor(int i = 0;i<=tc;i++)\n\t{\n\t\ttemp += i;\n\t\tif(temp >= tc) break;\n\t\tprintf(\"%c\",input[temp]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "2191eef4217397e4287b3deb61c2c7b7", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n,k=0;\n scanf(\"%d\",&n);\n char a[n];\n for(int i=0;i<=n;i++){\n scanf(\"%c\",&a[i]);\n }\n if(n==0)\n printf(\" \");\n for(int i=1;i<=n;){\n printf(\"%c\", a[i]);\n k++;\n i = i + k;\n }\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "dd66236db0f3cb40df84b573313f443d", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint x,y,turn;\nscanf(\"%d %d\",&x,&y);\nif(x==0&&y==0||x==1&&y==0)\n{\n printf(\"0\");\n return 0;\n}\n if(x<0&&y>=x&&y<-x)\n turn=(-4)*x-1;\n if(y<0&&x>y&&x<=-y+1)\n turn=(-4)*y;\n if(x>0&&y>-x+1&&y<=x)\n turn=x*4-3;\n if(y>0&&x=-y)\n turn=4*y-2;\nprintf(\"%d\",turn);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry", "implementation"], "code_uid": "6c6504f38771d0ca129f486818e65631", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint x, y, t;\n\n\tscanf(\"%d%d\", &x, &y);\n\tif (x > 0 && y > -x + 1 && y <= x)\n\t\tt = 1 + 4 * (x - 1);\n\telse if (x < 0 && y < -x && y >= x)\n\t\tt = 3 + 4 * (-x - 1);\n\telse if (y > 0 && x < y && x >= -y)\n\t\tt = 2 + 4 * (y - 1);\n\telse\n\t\tt = 4 + 4 * (-y - 1);\n\tprintf(\"%d\\n\", t);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry", "implementation"], "code_uid": "8ed57c06b3f83998bcf075a4b97ade66", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n#include \n#include \n\n#define in32(x) scanf(\"%d\", &x)\n#define out32(x) printf(\"%d\\n\", (x))\n#define in64(x) scanf(\"%lld\", &x)\n#define out64(x) printf(\"%lld\\n\", (x))\n#define inStr(x) scanf(\"%s\", x)\n#define outStr(x) printf(\"%s\\n\", (x))\n#define fo(a,b,c) for(a=b;a<=c;a++)\n#define of(a,b,c) for(a=b;a>=c;a--)\n\n\n\n\nint main() {\n char w[101], c;\n int ans=0,n,i,j;\n in32(n);\n inStr(w);\n of(c,'z','b') {\n fo(i,0,n-1) {\n if (w[i]==c && \n ((i && w[i-1]==c-1) ||\n (i\nint main()\n{\n\tint i,j,k,n,m;\n\tscanf(\"%d\",&n);\n\tm=n;\n\tchar s[n+1];\n\tint a[n+1],b[n+1];\n\tscanf(\"%s\",&s);\n\tfor(i=0;i1;i--)\n\t{\n\t\tint k1=0;\n\t\twhile(k1<100)\n\t\t{\n\t\tfor(j=0;j\n#include\n#define N 10\n/*interface implementation*/\nint counter,total;\nint c12,question;\nvoid rec(int deep,int value) {\n //printf(\"rec(%d,%d)\\n\",deep,value);\n if(deep==question) {\n //printf(\"value=%d\\n\",value);\n if(c12==value) counter++;\n total++;\n return;\n }\n rec(deep+1,value+1);\n rec(deep+1,value-1);\n}\n/*client*/\nint main() {\n char s1[N+1];\n char s2[N+1];\n scanf(\"%s\",s1);\n scanf(\"%s\",s2);\n int n1=strlen(s1);\n int n2=strlen(s2);\n int c1=0,c2=0;\n int i;\n for(i=0; i\nint q,b,ind,l;\nint r[25];\nint p[11];\nint temp(int lvl);\nint main(){\n int i,o,m;\n char s[11];\n scanf(\"%s\",s);\n for(i=o=0;s[i]!='\\0';i++){\n if(s[i]=='+'){\n o++;\n }else{\n o--;\n }\n }\n scanf(\"%s\",s);\n for(i=m=b=0;s[i]!='\\0';i++){\n if(s[i]=='+'){\n m++;\n }\n if (s[i]=='-'){\n m--;\n }\n if (s[i]=='?'){\n b++;\n }\n }\n temp(0);\n printf(\"%.10lf\",((double)(r[o-m+11]))/((double)(1<\n\nint main()\n{\n int y, day, lpy1, lpy2;\n\n while(scanf(\"%d\", &y) != EOF)\n {\n if(y%400==0 ||(y%100 !=0 && y%4==0)) lpy1 = 1;\n else lpy1 = 0;\n day = 0;\n while(1)\n {\n if(y%400==0 ||(y%100 !=0 && y%4==0))\n {\n day+=2;\n }\n else day++;\n y++;\n if(y%400==0 ||(y%100 !=0 && y%4==0)) lpy2 = 1;\n else lpy2 = 0;\n day = day%7;\n if(day==0 && lpy1==lpy2) break;\n }\n printf(\"%d\\n\", y);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "22dceb5ba07a8e79a1db56525bf4262a", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nint arr[250]={31,29,31,30,31,30,31,31,30,31,30,31};\nint arr1[133];\nint test[133];\nint is_leap(int year){\n if ( year%400 == 0)\n return 1;\n else if ( year%100 == 0)\n return 0;\n else if ( year%4 == 0 )\n return 1;\n else\n return 0;\n \n return 0;\n\t\n}\nint main(){\n\nint start = 1000;\nint week = 1;\nint i;\nint in;\nscanf(\"%d\",&in);\nwhile(start\n#include\nint main(){\nint i,don=3,pun=0,j=0;\nchar direccion[51];\nchar dir[56]={};\nscanf(\"%s\",direccion);\ni=0;\nif(direccion[0] == 'h'){\n don = 4;\n}\nwhile(direccion[i]!='\\0'){\n if(don == 0){\n dir[j]=':';\n j++;\n dir[j]='/';\n j++;\n dir[j]='/';\n j++;\n }\n if(pun==0 && direccion[i] == 'r' && direccion[i+1] == 'u' && don <0){\n dir[j]='.';\n pun++;\n j++;\n }\n dir[j] = direccion[i];\n j++;\n if(pun == 1 && direccion[i]=='u' && direccion[i+1]!='\\0'){\n pun++;\n dir[j]='/';\n j++;\n }\n don=don-1;\n i++;\n }\n dir[j]='\\0';\n printf(\"%s\",dir);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "466a91c14c608af52ff45a84b98f8e38", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nchar s[55];\nint n;\nint main()\n{ int i,j,k,l;\n scanf(\"%s\",s);\n n=strlen(s);\n if(s[0]=='h')\n { printf(\"http://\");\n k=4;\n }\n else if(s[0]=='f')\n { printf(\"ftp://\");\n k=3;\n }\n for(i=k;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 \n#include\n\nint main(int argc, char **argv)\n{\n\tint a,b,c;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tif(b+c<=a)\n\tprintf(\"%d\",a+1-(b+c));\n\telse if(a+c<=b)\n\tprintf(\"%d\",b+1-(a+c));\n\telse if(a+b<=c)\n\tprintf(\"%d\",c+1-(a+b));\n\telse printf(\"0\");\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "e8cb35cf8bca448763c8630a713b27b1", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a,b,c,x,y,z,min;\n scanf(\"%d%d%d\",&a,&b,&c);\n x=a+b;\n y=a+c;\n z=b+c;\n if(x>c && y>b && z>a)\n printf(\"0\");\n else if(x<=c)\n {\n min=c-x+1;\n printf(\"%d\",min);\n }\n else if(y<=b)\n {\n min=b-y+1;\n printf(\"%d\",min);\n }\n else if(z<=a)\n {\n min=a-z+1;\n printf(\"%d\",min);\n }\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "87959dea9c2c760770a5db4373499e81", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\nint main()\n{\n\tlong long int n,a,b,c,cnt;\n\tscanf(\"%lld\",&n);\n\ta=1;\n\tb=1;\n\tc=2;\n\tcnt=1;\n\twhile(c<=n)\n\t{\n\t\ta=b;\n\t\tb=c;\n\t\tc=a+b;\n\t\tcnt++;\n\t}\n\tprintf(\"%lld\\n\",cnt-1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "e3b920bb039edc562f4d86e9fc532993", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \"stdio.h\"\n\nint main(){\n\tlong long n,k,pr1,pr2,pr;\n\t\n\tscanf(\"%lld\",&n);\n\t\n\tpr1=1;\n\tpr2=1;\n\tpr=2;\n\tk=1;\n\twhile (pr<=n){\n\t\tpr2=pr1;\n\t\tpr1=pr;\n\t\tpr=pr1+pr2;\n\t\tk++;\n\t}\n\t\n\tprintf(\"%lld\",k-1);\n\t\n\treturn 0;\n}\n\t\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "78c33cf3d0b70c007edabe65685411bd", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main(int argc, const char * argv[])\n{\n int32_t n, a;\n scanf(\"%d %d\", &n, &a);\n if(a&1) {\n a += 1;\n } else {\n a = n - a + 2;\n }\n printf(\"%d\", a/2);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "139ffed4facb78d3762ed9b144acbad6", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int n,a,b,count=1;\n scanf(\"%d%d\",&n,&b);\n\n if(b%2==0){\n count=count+(n/2)-b/2;\n }\n else if(b%2!=0){\n count=count+b/2;\n }\n\n printf(\"%d\",count);\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "32a65a98cfa63aae7fc02f7033c2f6c2", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t20\n#define MD\t1000000007\n\nint d_, x_, y_;\n\nvoid gcd_(int a, int b) {\n\tif (b == 0)\n\t\td_ = a, x_ = 1, y_ = 0;\n\telse {\n\t\tint 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[N];\n\nvoid init() {\n\tint k;\n\n\tfor (k = 1; k < N; k++) {\n\t\tgcd_(k, MD);\n\t\tif (x_ < 0)\n\t\t\tx_ += MD;\n\t\tinv[k] = x_;\n\t}\n}\n\nlong long ch(long long n, int k) {\n\treturn k == 0 ? 1 : ch(n - 1, k - 1) * (n % MD) % MD * inv[k] % MD;\n}\n\nint main() {\n\tstatic long long ff[N];\n\tint n, b, i, ans;\n\tlong long s;\n\n\tinit();\n\tscanf(\"%d%lld\", &n, &s);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%lld\", &ff[i]);\n\tans = 0;\n\tfor (b = 0; b < 1 << n; b++) {\n\t\tlong long t;\n\t\tint k;\n\n\t\tt = s;\n\t\tk = 0;\n\t\tfor (i = 0; i < n; i++)\n\t\t\tif (b & 1 << i) {\n\t\t\t\tk++;\n\t\t\t\tt -= ff[i] + 1;\n\t\t\t}\n\t\tif (t >= 0) {\n\t\t\tint cnt = ch(t + n - 1, n - 1);\n\n\t\t\tans = (ans + (k % 2 == 0 ? cnt : -cnt)) % MD;\n\t\t}\n\t}\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["combinatorics", "number theory", "bitmasks"], "code_uid": "5761e725af1df7b92d791b0697ace3cd", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n\tchar bessie[4], elsie[4];\n\tint i, a;\n\tint bessietype, elsietype;\n\n\tscanf(\"%c%c%*c%c%c%*c\", &bessie[0], &bessie[1], &bessie[3], &bessie[2]);\n\tbessie[4] = '\\0';\n\tscanf(\"%c%c%*c%c%c\", &elsie[0], &elsie[1], &elsie[3], &elsie[2]);\n\telsie[4] = '\\0';\n\n\tfor(i = 0; i < 4; i++)\n\t{\n\t\tif(bessie[i] == 'A')\n\t\t{\n\t\t\ta = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\twhile(1)\n\t{\n\t\ti = (i + 1) % 4;\n\t\tif(bessie[i] == 'B')\n\t\t{\n\t\t\tbessietype = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif(bessie[i] == 'C')\n\t\t{\n\t\t\tbessietype = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\n\tfor(i = 0; i < 4; i++)\n\t{\n\t\tif(elsie[i] == 'A')\n\t\t{\n\t\t\ta = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\twhile(1)\n\t{\n\t\ti = (i + 1) % 4;\n\t\tif(elsie[i] == 'B')\n\t\t{\n\t\t\telsietype = 1;\n\t\t\tbreak;\n\t\t}\n\t\tif(elsie[i] == 'C')\n\t\t{\n\t\t\telsietype = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif(elsietype == bessietype)\n\t{\n\t\tprintf(\"YES\\n\");\n\t}\n\telse\n\t{\n\t\tprintf(\"NO\\n\");\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "743d7e2d2dd608dda52d40d5fc73b261", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n\tchar a[10], b[10], x;\n\tint i, j = 0;\n\t\n\tfor(i = 0; i < 4; ++i){\n\t\tscanf(\" %c\", &a[i]);\n\t}\n\tfor(i = 0; i < 4; ++i){\n\t\tscanf(\" %c\", &b[i]);\n\t}\n\t\n\tx = a[2]; a[2] = a[3]; a[3] = x; \n\tx = b[2]; b[2] = b[3]; b[3] = x;\n\t\n\tj = 0;\n\tfor(i = 0; i < 4; ++i){\n\t\tif(a[i] != 'X'){\n\t\t\ta[j] = a[i];\n\t\t\tj++;\n\t\t}\n\t}\n\t\n\tj = 0;\n\tfor(i = 0; i < 4; ++i){\n\t\tif(b[i] != 'X'){\n\t\t\tb[j] = b[i];\n\t\t\tj++;\n\t\t}\n\t}\n\ta[3] = '\\0';\n\tb[3] = '\\0';\n\t\n\twhile(a[0] != b[0]){\n\t\tx = b[0];\n\t\tfor(i = 1; i < 3; ++i){\n\t\t\tb[i-1] = b[i];\n\t\t}\n\t\tb[2] = x;\n\t}\t\n\t\n\tif(strcmp(a, b) == 0){\n\t\tprintf(\"YES\");\n\t}else\n\t\tprintf(\"NO\");\n\t\t\nreturn 0;\t\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "implementation"], "code_uid": "1bb2ea4cde0a6b01da48488262c5df87", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int a=0,b=0,c=0,d=0,e=0,f=0,n;\n scanf(\"%d\",&n);\n if(n>=32)\n {\n a=1;\n n-=32;\n }\n if(n>=16)\n {\n b=1;\n n-=16;\n }\n if(n>=8)\n {\n c=1;\n n-=8;\n }\n if(n>=4)\n {\n d=1;\n n-=4;\n }\n if(n>=2)\n {\n e=1;\n n-=2;\n }\n if(n>=1)\n {\n f=1;\n n-=1;\n }\n n=(a*32)+(b*1)+(c*4)+(d*8)+(e*2)+(f*16);\n printf(\"%d\",n);\n return(0);\n }\n ", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "f04dce37f9ef5af8ccf470eb61ddd168", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\nint main(){\n\t//freopen(\"in.txt.txt\",\"r\",stdin);\n\t//freopen(\"out.txt.txt\",\"w\",stdout);\n\tint a,b,c,d,e,f,g;\n\tscanf(\"%d\",&a);\n\tb=a>>5;\n\tc=a>>4&1;\n\td=a>>3&1;\n\te=a>>2&1;\n\tf=a>>1&1;\n\tg=a>>0&1;\n\tprintf(\"%d\\n\",(b<<5) | (g<<4) | (e<<3) | (d<<2) | (f<<1) | (c<<0));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "07d945cd6610a005816b4a158849b0d5", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar Flag[401][401];\n\nint main()\n{\n int N, i, j, Ans = 0;\n char Str[201];\n scanf(\"%d %s\", &N, Str);\n for(i = 0; i < N; ++i) {\n memset(Flag, 0, sizeof(Flag));\n int x = 200, y = 200;\n Flag[x][y] = 1;\n for(j = i; j < N; ++j) {\n if(Str[j] == 'U') {\n --x;\n } else if(Str[j] == 'D') {\n ++x;\n } else if(Str[j] == 'L') {\n --y;\n } else {\n ++y;\n }\n if(Flag[x][y]) {\n ++Ans;\n }\n }\n }\n printf(\"%d\\n\", Ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "0eacb22319dabbe855acba5c9cc7334a", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main(int argc,char** argv){\n\tint numberofcommand;\n\tchar sourcecode[200];\n\tlong long unsigned int result=0;\n\tlong long unsigned int counter=0;\n\t//int skip[120];\n\t//int counterofskip=0;\n\n\t//skip[0]=-1;\n\tscanf(\"%d\",&numberofcommand);\n\tscanf(\"%s\",sourcecode);\n\tfor(int i=0;i\n#include \nmain()\n{\nlong int rust(int x);\nlong int lust(int x);\nint arrb[20]={0};\nlong int a,c,ans=0;\nscanf(\"%ld %ld\",&a,&c);\nint at,ct;\nint k=0,i;\nwhile(a!=0 || c!=0)\n{\nat=a%3;\nct=c%3;\na=a/3;\nc=c/3;\nswitch(ct)\n{\ncase(2):{arrb[k++]=(2-at);\n break;}\n\ncase(0):{if(at==0) arrb[k++]=0;\n else arrb[k++]=(3-at);\n break;}\ncase(1):{if(at==2) arrb[k++]=2;\n else arrb[k++]=(1-at);\n break;}\n}\n}\nk=k-1;\nfor(i=k;i>=0;i--)\n{\nans=ans+lust(i)*arrb[i];\n}\nprintf(\"%ld\",ans);\nreturn 0;\n}\n\nlong int rust(int x)\n {\n int i;\n long int k=1;\n for(i=1;i<=x;i++)\n k=k*10;\n return k;\n }\n\nlong int lust(int x)\n {\n int i;\n long int k=1;\n for(i=1;i<=x;i++)\n k=k*3;\n return k;\n }\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "6c7efb002dc309a2b120906e155d8901", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main ()\n{\n\tlong long int a,b=0,c;\n\tscanf(\"%lld %lld\",&a,&c);\n\tlong long int a3=0,b3=0,c3=0,co=1;\n\twhile (a!=0)\n\t{\n\t\ta3=a%3*co+a3;\n\t\ta/=3;\n\t\tco=co*10;\n\t}\n\tco=1;\n\twhile (c!=0)\n\t{\n\t\tc3=c%3*co+c3;\n\t\tc/=3;\n\t\tco=co*10;\n\t}\n\tco=1;\n\twhile (a3!=0||c3!=0)\n\t{\n\n\t\tif ((c3%10)<(a3%10))\n\t\t{\n\t\t\tif (c3%10==0&&a3%10==2)\n\t\t\t\tb3=co*1+b3;\n\t\t\telse\n\t\t\t\tb3=co*2+b3;\n\t }\n\t\t\telse\n\t\t\tb3=co*(c3%10-a3%10)+b3;\n\t\ta3/=10;\n\t\tc3/=10;\n\t\tco*=10;\n\t}\n\tint x=1;\n\twhile (b3!=0)\n\t{\n\t\tb=b+(b3%10)*x;\n\t\tx*=3;\n\t\tb3/=10;\n\t}\n\tprintf(\"%lld\",b);\n\treturn 0;\n}\n\n\n\n\n\n\n\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "a659793b2b4a9acbf961eaa8b1b71746", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int m,x,y,b,i,rslt=0,j;\n scanf(\"%lld %lld\",&m,&b);\n\n for(i=0;i<=b;i++) {\n x=m*(b-i);\n j=(x+i)*(x+1)*(i+1)/2;\n if(j>rslt) rslt=j;\n }\n printf(\"%lld\\n\",rslt);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "3ef93b42f1ebb3e8c37750bd067e4662", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(void)\n{\n long long int m,b,Count=0,Counter,C;\n long long int Max_Banana=0,Sum;\n scanf(\"%lld%lld\",&m,&b);\n while((m*b-m*Count)>=0)\n {\n Sum=0;\n Counter=m*b-m*Count;\n for(C=0;C<=Count;C++)\n Sum+=((Counter+C)*(Counter+C+1))/2-((C-1)*(C))/2;\n if(Max_Banana\n\nint cor[3][15];\nint main() {\n char c[3];\n int n[3];\n int temp;\n scanf(\"%d%c %d%c %d%c\",&n[0],&c[0],&n[1],&c[1],&n[2],&c[2]);\n for(int i=0;i<3;i++) {\n if(c[i]=='m') c[i]=0;\n else if(c[i]=='p') c[i]=1;\n else if(c[i]=='s') c[i]=2;\n }\n for(int i=0;i<3;i++) {\n cor[c[i]][n[i]]++;\n cor[c[i]][0]++;\n }\n\n for(int i=0;i<3;i++) {\n if(cor[i][0]==3) {\n for(int j=1;j<=9;j++) {\n if(cor[i][j]==3) {\n printf(\"0\");\n return 0;\n }\n else if(cor[i][j] >0 && cor[i][j+1] >0 && cor[i][j+2]>0) {\n printf(\"0\");\n return 0;\n }\n else if(cor[i][j]==2) {\n printf(\"1\");\n return 0;\n }\n else if(cor[i][j] >0 && cor[i][j+1]>0) {\n printf(\"1\");\n return 0;\n }\n else if(cor[i][j] >0 && cor[i][j+2]>0) {\n printf(\"1\");\n return 0;\n }\n }\n }\n else if(cor[i][0]==2) {\n for(int j=1;j<=9;j++) {\n if(cor[i][j]==2) {\n printf(\"1\");\n return 0;\n }\n else if(cor[i][j] >0 && cor[i][j+1]>0) {\n printf(\"1\");\n return 0;\n }\n else if(cor[i][j] >0 && cor[i][j+2]>0) {\n printf(\"1\");\n return 0;\n }\n }\n }\n }\n printf(\"2\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "9521f5ae80da2193fcfee6351c92f017", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint ltr[26], num[10];\nint main()\n{\n int numcnt=0, ltrcnt=0, i, mindiff=100, _1=-1, _2=-1, _3=-1, _a, _b, _c, maxdiff=-1;\n char inp[6];\n scanf(\"%c%c%*c%c%c%*c%c%c\", &inp[0], &inp[1], &inp[2], &inp[3], &inp[4], &inp[5]);\n num[inp[0]-'0']++;\n num[inp[2]-'0']++;\n num[inp[4]-'0']++;\n ltr[inp[1]-'a']++;\n ltr[inp[3]-'a']++;\n ltr[inp[5]-'a']++;\n for (i = 0; i < 26; i++) if(ltr[i]) ltrcnt++;\n for (i = 0; i < 10; i++)\n {\n if(num[i])\n {\n numcnt++;\n if (_1==-1)\n {\n _1=i;\n continue;\n }\n if (_2==-1)\n {\n _2=i;\n continue;\n }\n if (_3==-1) _3=i;\n }\n }\n if (abs(_1-_2)>maxdiff) maxdiff=abs(_1-_2);\n if (abs(_3-_2)>maxdiff) maxdiff=abs(_3-_2);\n if (abs(_1-_3)>maxdiff) maxdiff=abs(_1-_3);\n if (abs(_1-_2)\ndouble pri(double w,double b);\ndouble dra(double w,double b);\ndouble pria[1000][1000]={0};\ndouble draa[1000][1000]={0};\nint main(){\nint w,b;\nscanf(\"%d%d\",&w,&b);\nprintf(\"%.9lf\\n\",pri((double)w,(double)b));\nreturn 0;\n}\n\ndouble pri(double w,double b){\nif(pria[(int)(w-1)][(int)(b-1)]!=0)return pria[(int)(w-1)][(int)(b-1)];\nif(w==0)return 0;\nelse if(b==0)return 1;\npria[(int)(w-1)][(int)(b-1)]=(w/(w+b))+(b/(w+b))*dra(w,b-1);\nreturn pria[(int)(w-1)][(int)(b-1)];\n}\n\ndouble dra(double w,double b){\nif(draa[(int)(w-1)][(int)(b-1)]!=0)return draa[(int)(w-1)][(int)(b-1)];\nif(b==0)return 0;\nelse if(w==1&&b==1)return 0;\nelse if(b==1)return 1/(1+w);\ndraa[(int)(w-1)][(int)(b-1)]=(b/(b+w))*( (w/(b+w-1))*pri(w-1,b-1) + ((b-1)/(b+w-1))*pri(w,b-2) );\nreturn draa[(int)(w-1)][(int)(b-1)];\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "7c92393ff896e508498d0445cc0f2f42", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\ndouble chances_turno_princesa[1001][1001];\ndouble chances_turno_dragao[1001][1001];\n\ndouble calcula_prob_princesa(int w, int b);\ndouble calcula_prob_dragao(int w, int b);\n\n// Prob. da princesa ganhar se turno \u00e9 da princesa com w, b\ndouble calcula_prob_princesa(int w, int b) {\n\tif (w <= 0)\n\t\treturn 0.;\n\t\n\tif (b <= 0)\n\t\treturn 1.;\n\t\n\tif (!chances_turno_princesa[w][b])\n\t\tchances_turno_princesa[w][b] = ((double) w / ((double) w + b)) + ((double) b / ((double) w + b)) * calcula_prob_dragao(w, b - 1);\n\t\n\t//printf(\"Prob. princesa: %d %d %f\\n\", w, b, chances_turno_princesa[w][b]);\n\treturn chances_turno_princesa[w][b];\n}\n\n// Prob. da princesa ganhar se turno \u00e9 do drag\u00e3o com w, b\ndouble calcula_prob_dragao(int w, int b) {\n\tif (w <= 0)\n\t\treturn 0.;\n\t\n\tif (b <= 0.)\n\t\treturn 0.;\n\t\n\tif (!chances_turno_dragao[w][b]) {\n\t\tdouble ans = ((double) b) / ((double) w + b);\t// chance de tirar b\n\t\t\n\t\tans = ans * ((((double) b - 1) / ((double) w + b - 1)) * calcula_prob_princesa(w, b - 2) +\n\t\t\t(((double) w) / ((double) w + b - 1)) * calcula_prob_princesa(w - 1, b - 1));\n\t\t\n\t\tchances_turno_dragao[w][b] = ans;\n\t}\n\t\n\t//printf(\"Prob. drag\u00e3o: %d %d %f\\n\", w, b, chances_turno_dragao[w][b]);\n\treturn chances_turno_dragao[w][b];\n}\n\nint main() {\n\tint w, b;\n\tdouble ans = 0, prob_estado = 1;\n\t\n\tmemset(chances_turno_princesa, 0, sizeof(chances_turno_princesa));\n\tmemset(chances_turno_dragao, 0, sizeof(chances_turno_dragao));\n\t\n\tscanf(\"%d%d\", &w, &b);\n\t\n\tprintf(\"%.9lf\\n\", calcula_prob_princesa(w, b));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities", "games"], "code_uid": "a121c56c91b3a8eb51e1991f453f39c3", "src_uid": "7adb8bf6879925955bf187c3d05fde8c", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main()\n{\n int n,i,e=0;\n scanf(\"%d\",&n);\n char s[n];\n scanf(\"%s\",s);\n for(i=0;s[i]!='\\0';i++)\n {\n if(s[i]=='8')\n e++;\n\n }\n n/=11;\n if(n>=e)\n printf(\"%d\",e);\n else\n printf(\"%d\",n);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "a73040f393ad7218d3475243d9db84f4", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " \n#include\n#include\n\nint main() {\n int n;\n int a[10],i,s=0;\n char st[101];\n scanf(\"%d\",&n);\n scanf(\"%s\",&st);\n for (i=0 ; i<=strlen(st) ;i++)\n if (st[i] == '8') s++;\n if ((n / 11) > s) printf(\"%d\",s);\n else printf(\"%d\",(n / 11));\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "99794131411af7012857b498fee91df1", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n char a[300];\n int i,j,k,len,n,cnt=0,max=0;\n scanf(\"%d\",&n);\n getchar();\n gets(a);\n for(i=0;i='A' && a[i]<='Z') cnt++;\n else if(a[i]==' ')cnt=0;\n if(cnt>max)max=cnt;\n }\n printf(\"%d\\n\",max);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "39a7cb0608ee1aa26f23863c6d096100", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n int i,count=0,max=0,n;\n char str[250];\n scanf(\"%d\\n\",&n);\n scanf(\"%[^\\n]%*c\",str);\nif((n>=1)&&(n<=200))\n\n{\n for(i=0;imax) max=count;\n count=0; }\n if(count>max) max=count;\n }\n}\nprintf(\"%d\",max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5b08cafd4c6c43f0f16944390854670d", "src_uid": "d3929a9acf1633475ab16f5dfbead13c", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long int arr[15], w, ans;\n \nvoid dp(int x, long long int y) \n{\n\tif (x > 8) \n\t{ \n\t\tif (y > ans) \n\t\t{\n\t\t\tans = y;\n\t\t}\n\t\treturn;\n\t}\n\tlong long int k = arr[x];\n\tlong long int temp = (w-y) / x;\n\tif (k > temp) \n\t{\n\t\tk = temp;\n\t}\n\tlong long int i = k - 6;\n\tif (i < 0) \n\t{\n\t\ti = 0;\n\t}\n\twhile(i <= k)\n\t{\n\t\tdp(x + 1, y + i * x);\n\t\ti++;\n\t}\n\t \n}\n \nint main() \n{\n\tscanf(\"%lld\", &w);\n\tans = 0;\n\tfor (int i = 1; i <= 8; i++)\n\t{\n\t\tscanf(\"%lld\", &arr[i]);\n\t}\n\tdp(1, 0);\n\tprintf(\"%lld\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "dp"], "code_uid": "e89f173bf9f5fb6bc835d917ca5b6b55", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nlong long int num[15],w,ans;\nvoid dp(int x, long long int y){\n\tif(x>8){\n\t\tif(y>ans){\n\t\t\tans = y;\n\t\t}\n\t\treturn;\n\t\t\n\t}\n\tlong long int k = num[x];\n\tlong long int temp = (w-y)/x;\n\tif(k>temp){\n\t\tk=temp;\n\t}\n\tlong long int i = k-6;\n\tif(i<0){\n\t\ti=0;\n\t}\n\twhile(i<=k){\n\t\tdp(x+1,y+i*x);\n\t\ti++;\n\t}\t\n}\nint main(){\nscanf(\"%lld\",&w);\nans = 0;\nfor (int i=1;i<=8;i++){\n\tscanf(\"%lld\",&num[i]);\n}\ndp(1,0);\nprintf(\"%lld\",ans);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "dp"], "code_uid": "b55efc2c31916e53c0cc2afb5f57ce24", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n char s[101];\n int a[205][205] = {0};\n int x = 102, y = 102, i;\n\n a[x][y] = 1;\n\n scanf(\"%s\", s);\n\n for (i = 0; i < strlen(s); i++) {\n\t int m;\n\n\t switch(s[i]) {\n\t case 'L' : x--; break;\n\t case 'R' : x++; break;\n\t case 'U' : y++; break;\n\t case 'D' : y--; break;\n\t }\n\n\t if (a[x][y] == 1) {\n\t puts(\"BUG\");\n\n\t return 0;\n\t }\n\n\t m = a[x - 1][y] + a[x + 1][y] + a[x][y - 1] + a[x][y + 1];\n\n\t if (m > 1) {\n\t puts(\"BUG\");\n\n\t return 0;\n\t }\n\n\t a[x][y] = 1;\n }\n\n puts(\"OK\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "0f197eca4e0a2341ebbe31c9b0bfad0c", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define L 100\n#define N 222\n\nconst int DX[4] = {1, 0, -1, 0};\nconst int DY[4] = {0, 1, 0, -1};\n\nchar s[L + 1];\nint a[N][N];\n\nint main()\n{\n scanf(\"%s\", s);\n int n = strlen(s);\n int x = 101;\n int y = 101;\n memset(a, -1, sizeof(a));\n a[x][y] = 0;\n for (int i = 1; i <= n; i++)\n {\n switch (s[i - 1])\n {\n case 'U': x--; break;\n case 'L': y--; break;\n case 'R': y++; break;\n case 'D': x++; break;\n default: assert(0);\n }\n if (~a[x][y]) {\n puts(\"BUG\");\n return 0;\n }\n a[x][y] = i;\n for (int dir = 0; dir < 4; dir++)\n {\n int nx = x + DX[dir];\n int ny = y + DY[dir];\n if (~a[nx][ny] && a[nx][ny] != i - 1)\n {\n puts(\"BUG\");\n return 0;\n } \n }\n }\n puts(\"OK\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation", "graphs"], "code_uid": "ea8533a43c993320dd27677efde375ea", "src_uid": "bb7805cc9d1cc907b64371b209c564b3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(){\n int i, j, k, l, m, n;\n char a[201];\n\n scanf(\"%s\", a);\n scanf(\"%d\", &j);\n\n n = strlen(a);\n for(i = (n + j) / 2; i >= 1; i--){\n l = 0;\n for(k = 0; k < n + j - i; k++){\n if(k + i < n && a[k] != a[k + i]){\n l = -1;\n }\n l++;\n if(l == i){\n break;\n }\n }\n if(l == i){\n break;\n }\n }\n printf(\"%d\\n\", l * 2);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "implementation"], "code_uid": "be55f5018bec8bcf6718e7e45743523a", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.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 char str[2000];\n int i,j,ch,chk,len,k,flag,m;\n scanf(\"%s\",str);\n scanf(\"%d\",&k);\n len=strlen(str);\n if(k>=len)\n {\n if((k+len)%2==0)\n printf(\"%d\",k+len);\n else\n printf(\"%d\",k+len-1);\n }\n else\n {\n //printf(\"%d %d \",len,k);\n ch=k+len;\n for(i=k+len;i>=2*k;i--)\n {\n if((i)%2)\n continue;\n else\n {\n for(j=0;j+i<=len+k;j++)\n {\n flag=1;\n ch=i/2;\n for(m=j;m\n#define MOD 1000000007\nint n,m;\nlong long ans;\nlong long f[200010],g[200010];\nint main()\n{\n int i,j,mn,mx;\n f[0] = 1;\n scanf(\"%d%d\",&n,&m);\n for(i=1;i<=900;i++)\n {\n mn = (1+i)*i/2-m;\n if(mn<0) mn = 0;\n mx = (1+i)*i/2;\n if(mx>n) mx = n;\n if(mn>mx) break;\n for(j=mx;j>=i;j--) f[j] = (f[j]+f[j-i])%MOD;\n for(j=mx;j>=0;j--) g[j] = (g[j+1]+f[j])%MOD;\n if(g[mn]-g[mx+1]) ans = g[mn]-g[mx+1];\n else break;\n }\n printf(\"%I64d\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "284af2a8a2fe6446a250b569734857ef", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n \nint r, g, h, rem;\nint dp[200010];\n \nint main() {\n scanf(\"%d%d\", &r, &g);\n for (h = 1; h*(h+1)/2 <= r+g; h++);\n h--;\n rem = (r+g) - h*(h+1)/2;\n for (int i = 0; i <= rem; i++)\n dp[i] = 1;\n for (int i = 1; i <= h; i++)\n for (int j = r-i; j >= 0; j--)\n dp[j+i] = (dp[j+i]+dp[j])%1000000007;\n printf(\"%d\\n\", dp[r]);\n \n return 0;\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "e1909b4d37e691c6a960da92e103ec72", "src_uid": "34b6286350e3531c1fbda6b0c184addc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tint n;\n\tscanf(\" %d\",&n);\n\n\tif(n%2){\t\tprintf(\"black\\n\"); return 0;\t}\n\telse {\tprintf(\"white\\n1 2\\n\"); return 0;}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "games"], "code_uid": "96d20965e35cf9281dc82af1d1c8dfbc", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main () {\n int n;\n scanf(\"%d\", &n);\n printf(n & 1? \"black\\n\": \"white\\n1 2\\n\");\n}\n\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "games"], "code_uid": "b6137289134d7c9e446f3fd37b1e9983", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n\nint main(void) {\n long long n,l,r,ans, i,bit_set;\n int rem[100], temp;\n scanf(\"%lld %lld %lld\", &n,&l,&r);\n if (n < 2) {\n printf(\"%lld\\n\", n);\n } else {\n temp = 0;\n while (n > 1) {\n rem[temp++] = n % 2;\n n /= 2;\n }\n ans = 0;\n for (i = l; i <= r; i ++) {\n bit_set = 0;\n while (((i >> bit_set) & 1) != 1) {\n bit_set += 1;\n }\n if (bit_set == 0) {\n ans += 1;\n } else {\n ans += rem[temp-bit_set];\n }\n }\n printf(\"%lld\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "38df12878a9ebea3ddf089bfc0711a34", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#ifdef ONLINE_JUDGE\n #define NDEBUG 1\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define long int64_t\n#define fore(i,k,n) for (int _k = (k), _n = (n), i = _k; i <= _n; ++i)\n#define forr(i,n,k) for (int _k = (k), _n = (n), i = _n; i >= _k; --i)\n#define LIST_INIT_CAP 4\n#define HASH_INIT_CAP 64\n#define HASH_SKIP 11\n#define TREE_INIT_CAP 1024\n#define TREE_MAX_HEIGHT 64\n#define DEQUE_INIT_CAP 1024\n#define HEAP_INIT_CAP 1024\n#define TAKEN 1\n#define EMPTY 0\n#define TOMB -1\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n\n#define N 204\n\nlong arr[N];\n\nlong calc(int sz) {\n if (arr[sz] != -1) return arr[sz];\n arr[sz] = 2 * calc(sz-1) + 1;\n return arr[sz];\n}\n\nint getval(long n, int sz, long idx) {\n if (n == 0 || n == 1) return (int)n;\n long t = calc(sz - 1);\n if (idx == t + 1) return (n & 1);\n if (idx <= t) return getval((n >> 1), sz - 1, idx);\n else return getval((n >> 1), sz - 1, idx - t - 1);\n}\n\nint main() {\n\n long n, l, r;\n scanf(\"%I64d %I64d %I64d\", &n, &l, &r);\n fore (i, 1, 100) arr[i] = -1;\n arr[0] = 1; arr[1] = 1;\n long t = n;\n int sz = 0;\n while (t > 0) { t = t >> 1; ++sz; }\n int answer = 0;\n for (long i = l; i <= r; ++i) {\n answer += getval(n, sz, i);\n }\n printf(\"%d\", answer);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "divide and conquer", "constructive algorithms"], "code_uid": "76ef6a8845c94a051e10c31d06a64c22", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/**\n * Created By: Anonyman637\n * Created On: 2/26/2020 8:17:43 AM\n */\n\n/* =============================================================================\n ================================== HEADERS ==================================\n ========================================================================== */\n#include \n#include \n#include \n#include \n\ntypedef char i8;\ntypedef short i16;\ntypedef int i32;\ntypedef long long i64;\n\ntypedef unsigned char ui8;\ntypedef unsigned short ui16;\ntypedef unsigned int ui32;\ntypedef unsigned long long ui64;\n\n/* =============================================================================\n ================================== MACROS ===================================\n ========================================================================== */\n\n#define DEBUG 1\n\n#if DEBUG\n#define debug(format, ...) printf(format, __VA_ARGS__)\n#else\n#define debug(format, ...) \n#endif\n\n/* =============================================================================\n ================================== GLOBALS ==================================\n ========================================================================== */\n\n\n/* =============================================================================\n ================================= FUNCTIONS =================================\n ========================================================================== */\n\n\nint main() {\n\t\n\ti64 i, t;\n\n\ti64 n, k;\n\tscanf(\"%lld %lld\", &n, &k);\n\ti64 laggingZeros = 0;\n\twhile (!((k >> laggingZeros) & 1)) {\n\t\tlaggingZeros++;\n\t}\n\tprintf(\"%lld\", laggingZeros + 1);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "2a8d9bcabb8ce8484d3e713cf1ab4e65", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nlong long int n,k,c=1;\nscanf(\"%lld%lld\",&n,&k);\nif(k%2==1)\nprintf(\"1\");\nelse\n{\nc=1;\nwhile(k!=0 && k%2==0)\n{\nc++;\nk=k/2;\n}\n\nprintf(\"%lld\",c);\n\n}\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "binary search", "implementation", "bitmasks"], "code_uid": "76d68a3491f245739394d46782f449ce", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nchar A[9][9],H[9][9],i;\nvoid f(int x, int y, int s){\n if(x > 8 || !x || y > 8 || !y) return;\n if(H[x][y] > 1 || A[x-s][y] == 'S' || A[x-s+1][y] == 'S') return;\n\n if(A[x][y] == 'A') { printf(\"WIN\"); exit(0); }\n H[x][y]++;\n int j,i=-1;\n for(;i<2;i++)\n for(j=-1;j<2;j++)\n f(x-i,y-j,s+1);\n}\nint main(){\n for(i=1;i<9;i++)\n scanf(\"%s\",A[i]+1);\n f(8,1,0);\n printf(\"LOSE\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar"], "code_uid": "48c1bbb2ab8d592c5147f7cd7f8a7c80", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nchar a[101][101] = {0};\nlong f[21][21][21] = {0};\nlong d[20][20] = {{0, 1}, {0, -1}, {0, 0}, {-1, 1}, {-1, -1}, {-1, 0}, {1, 0}, {1, -1}, {1, 1}};\nlong cango(long x, long y)\n{\n\tif (x >= 0 && x <= 7 && y >= 0 && y <= 7)\n\t\treturn 1;\n\treturn 0;\n}\nlong dfs(long t, long sx, long sy)\n{\n\tlong i, j, vx, vy;\n\tif (f[t][sx][sy] == 1)\n\t\treturn 0;\n\tif (sx == 7 && sy == 7)\n\t\treturn 1;\n\tif (t >= 9)\n\t\treturn 1;\n\tf[t][sx][sy] = 1;\n\tfor (i = 0; i < 9; i++)\n\t{\n\t\tvx = sx + d[i][0];\n\t\tvy = sy + d[i][1];\n\t\tif (cango(vx, vy))\n\t\t\tif (((vx + t + 1) >= 8 || a[vx + t + 1][vy] != 'S') && ((vx + t) >= 8 || a[vx + t][vy] != 'S'))\n\t\t\t\tif (dfs(t + 1, vx, vy))\n\t\t\t\t\treturn 1;\n\t}\n\treturn 0;\n}\nmain()\n{\n\tlong i, j, k, l, m, n;\n\tfor (i = 0; i < 8; i++)\n\t{\n\t\tfor (j = 0; j < 8; j++)\n\t\t{\n\t\t\tscanf(\"%c\", &a[7 - i][j]);\n\t\t}\n\t\tscanf(\"%*c\");\n\t}\n\tif (dfs(0, 0, 0))\n\t{\n\t\tprintf(\"WIN\\n\");\n\t} else\n\t{\n\t\tprintf(\"LOSE\\n\");\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "implementation", "graphs"], "code_uid": "193b87bb8afa3c24d42b4c1c5d809070", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void)\n{\n int s, x1, x2;\n int t1, t2;\n int p, d;\n int tt, x;\n\n scanf(\"%d%d%d\", &s, &x1, &x2);\n scanf(\"%d%d\", &t1, &t2);\n scanf(\"%d%d\", &p, &d);\n x = x2 - x1;\n if (t1 >= t2)\n tt = t2 * fabs(x);\n else\n {\n int t_tr, t_ig;\n if (x >= 0 && d == 1)\n {\n if (p <= x1)\n {\n t_tr = (x2 - p) * t1;\n t_ig = x * t2;\n tt = (t_tr < t_ig) ? t_tr : t_ig;\n }\n else\n {\n t_tr = (2 * s - p + x2) * t1;\n t_ig = x * t2;\n tt = (t_tr < t_ig) ? t_tr : t_ig;\n }\n }\n else if (x <= 0 && d == -1)\n {\n if (p >= x1)\n {\n t_tr = -(x2 - p) * t1;\n t_ig = -x * t2;\n tt = (t_tr < t_ig) ? t_tr : t_ig;\n }\n else\n {\n t_tr = (2 * s + p - x2) * t1;\n t_ig = -x * t2;\n tt = (t_tr < t_ig) ? t_tr : t_ig;\n }\n }\n else if (x > 0 && d == -1)\n {\n t_tr = (p + x2) * t1;\n t_ig = x * t2;\n tt = (t_tr < t_ig) ? t_tr : t_ig;\n }\n else\n {\n t_tr = (2 * s - p - x2) * t1;\n t_ig = -x * t2;\n tt = (t_tr < t_ig) ? t_tr : t_ig;\n }\n }\n printf(\"%d\\n\", tt);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "implementation"], "code_uid": "91e70bc9e31a48b704fce0f18cf556ec", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int a,b,c,d,i,j,k;\n int s,x1,x2,t1,t2,cur,tr;\n int dist;\n scanf(\"%d %d %d\",&s,&x1,&x2);\n scanf(\"%d %d\",&t1,&t2);\n scanf(\"%d %d\",&cur,&d);\n c=(x1>x2)?(x1-x2)*t2:(x2-x1)*t2;\n if(t2<=t1){\n printf(\"%d\",c);\n }\n else\n {\n dist=(x2-x1);\n if(dist>0&&d>0)\n {\n if(cur>x1){\n tr=(s-cur)+x2+s;\n tr=tr*t1;\n }\n else {\n tr=(x2-cur)*t1;\n }\n (c0)\n {\n tr=s-cur+s-x2;\n tr=tr*t1;\n (c0&&d<0)\n {\n tr=(cur+x2)*t1;\n (c\n#include\nmain()\n{\n\tint n,k,i,sum=0;\n\tscanf(\"%d %d\",&n,&k);\n\tif((n-1)<=k)\n\t{\n\t\tprintf(\"%d\",n-1);\n\t}\n\telse\n\t{\n\t\tsum+=k;\n\t\tfor(i=2;i\nint main()\n{\n int n,v,i,s;\n scanf(\"%d %d\",&n,&v);\n if((n-v+1)==0 || (n<=v))\n {\n printf(\"%d\",n-1);\n return 0;\n }\n else\n {\n s=n-v;\n //printf(\"%d\\n\",s);\n for(i=2;i<=s;i++)\n {\n v=v+i;\n }\n printf(\"%d\",v);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "dp"], "code_uid": "5ec9b2ce70e36079e55aa0657500df16", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main( void ) {\n int a, b, w, x, c;\n\n scanf( \"%d %d %d %d %d\", &a, &b, &w, &x, &c );\n\n if ( c <= a )\n puts( \"0\" );\n else {\n int i;\n int start = b, isMinus[ 1000 ], cycle, sumMinus, gap, cnt;\n\n cycle = sumMinus = 0;\n do {\n if ( b >= x ) {\n b -= x;\n isMinus[ cycle++ ] = 0;\n } else {\n b += w - x;\n isMinus[ cycle++ ] = 1;\n sumMinus++;\n }\n } while ( b != start );\n\n cnt = 0;\n for ( gap = ( c - a - 1 ) % ( cycle - sumMinus ) + 1; gap; gap -= !isMinus[ cnt++ ] ) ;\n\n printf( \"%lld\\n\", 1LL * ( c - a - 1 ) / ( cycle - sumMinus ) * cycle + cnt );\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "3817bb779cf9b95be3492c4b30e735f9", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main( void ) {\n int a, b, w, x, c;\n\n scanf( \"%d %d %d %d %d\", &a, &b, &w, &x, &c );\n\n if ( c <= a )\n puts( \"0\" );\n else {\n int bb = b, isMinus[ 1000 ], cycle, sumMinus, gap, cnt;\n\n cycle = sumMinus = 0;\n do {\n if ( bb >= x ) {\n bb -= x;\n isMinus[ cycle++ ] = 0;\n } else {\n bb += w - x;\n isMinus[ cycle++ ] = 1;\n sumMinus++;\n }\n } while ( bb != b );\n\n cnt = 0;\n for ( gap = ( c - a - 1 ) % ( cycle - sumMinus ) + 1; gap; gap -= !isMinus[ cnt++ ] ) ;\n\n printf( \"%lld\\n\", 1LL * ( c - a - 1 ) / ( cycle - sumMinus ) * cycle + cnt );\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "6b3dcb9de82b560b8449d8ec91efdce5", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint k;\n\nint write(int v)\n{\n long long n, p;\n for(n = v, p = k; v / p; p *= k)\n n += v / p;\n return (int) n;\n}\n\nint main(int argc, char *argv[])\n{\n int n, l, u, m;\n\n scanf(\"%d %d\", &n, &k);\n\n l = 1, u = n;\n do\n {\n m = (l + u) / 2;\n if(write(m) >= n && write(m - 1) < n)\n {\n printf(\"%d\\n\", m);\n return 0;\n }\n\n if(write(m) >= n)\n u = m - 1;\n else\n l = m + 1;\n } while(1);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "binary search"], "code_uid": "5b56b3bba100c165c837c3bee2e50c52", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint cal(double v, int k)\n{\n int cnt = 0;\n while ( v >= 1 )\n {\n cnt += (int)v;\n v /= k;\n }\n return cnt;\n}\n\nint binary_search(int l, int r, int n, int k)\n{\n int middle = (l+r)/2;\n if ( cal(middle, k) >= n )\n {\n if ( cal(middle-1, k) < n )\n return middle;\n else\n return binary_search(l, middle, n, k);\n }\n else\n {\n if ( cal(middle+1, k) >= n )\n return middle+1;\n else\n return binary_search(middle, r, n, k);\n }\n}\n\nint main()\n{\n int n, k;\n scanf(\"%d%d\", &n, &k);\n printf(\"%d\\n\", binary_search(1, n, n, k));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "binary search"], "code_uid": "1c8c2928fa8a515968335b5bfcf2d808", "src_uid": "41dfc86d341082dd96e089ac5433dc04", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nint fun(char *);\nint fun(char *s)\n{\n int i,ans=0;\n int a[26];\n for(i=0;i<26;i++)\n {\n a[i]=1;\n }\n for(i=1;s[i]!='\\0';i++)\n {\n if(s[i-1]==s[i])\n {\n a[s[i]-'A']++;\n }\n else\n {\n if(a[s[i-1]-'A']%2==0)\n {\n ans++;\n }\n a[s[i-1]-'A']=1;\n }\n }\n if(a[s[i-1]-'A']%2==0)\n {\n ans++;\n }\n return ans;\n}\nint main()\n{\n char a[101];\n scanf(\"%s\",a);\n printf(\"%d\\n\",fun(a));\n return 0;\n}", "lang_cluster": "C", "tags": ["two pointers", "implementation"], "code_uid": "2caf9b7cc4aead34fc988622202ea416", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\n\nint main(){\n\tint count=0,max=1,i;\n\tchar t,p;\n\tp=getchar();\n\tfor (i=0;(t=getchar())!=10;i++){\n\t\tif (p==t) {\n\t\t\tmax++;\n\t\t}\n\t\telse {\n\t\t\tif (max%2==0) count++;\n\t\t\tmax=1;\n\t\t}\n\t\tp=t;\n\t}\n\tif (max%2==0) count++;\n\tprintf(\"%d\\n\",count);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "implementation"], "code_uid": "59b0bb6193d8f9476a41e867457a67a8", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(void)\n{\n\tint n;\n\tint m;\n\tscanf(\"%d\",&n);\n\tlong long int c=0;\n\tscanf(\"%d\",&m);\n\tlong long int ans[m];\n\n\tfor(int i=0;i\nint main()\n{\n\tint n,m;\n\tlong long int k=0;\n\tscanf(\"%d %d\", &n, &m);\n\tlong long int b[m+1];\n\tfor(int i=0;i<=m;i++)\n\t\tb[i]=0;\n\tfor(int i=1;i<=m;i++)\n\t\tb[i]=n/m;\n\tfor(int i=1;i<=n%m;i++)\n\t\tb[i]++;\n//\tfor(int i=1;i<=m;i++)\n//\t\tprintf(\"b[%d]=%lld\\n\",i,b[i]);\n\tfor(int i=1;i<=m;i++)\n\t{\tfor(int j=1;j<=m;j++)\n\t\t{\tif(((i*i)+(j*j))%m==0)\n\t\t\t{\tk=k+b[i]*b[j];\n\t\t\t//\tprintf(\"%lld * %lld =%lld\",b[i],b[j],b[i]*b[j]);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%lld\\n\",k);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "f6c92b1b5768282d8707d3e3539d0031", "src_uid": "2ec9e7cddc634d7830575e14363a4657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint power(int i) {\n int s;\n\tint k;\n s = 1;\n for (k = 0;k < i;k++,s*=10);\n\treturn(s);\n}\n \n\nint main() {\n int n;\n scanf(\"%d\",&n);\n\tint x = 0, k = 1, t;\n\tint i = 0;\n\twhile (x <= n) {\n\t k = i;\n\t\tt = 0;\n\t\tx = 0;\n\t while (k != 0) {\n\t\t x += (k%2)*power(t);\n if (k > 1) k = k/2;\n\t\t\telse k = 0;\n\t\t\tt++;\n }\n\t\ti++;\n }\n\tprintf(\"%d\",i-2);\n\treturn(0);\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "d2561f5798d4529b1881245c3f1ae039", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int n, i, k, p = 1, ans = 0;\n scanf(\"%d\", &n);\n for(k = 0; n >= p; k++, p *= 10);\n for(i = k-1; i >= 0; i--) {\n p /= 10;\n if(n/p > 1) {\n ans += (1<<(i+1)) - 1;\n break;\n } else {\n ans += (1<\nmain()\n{int n,inch,feet;\nscanf(\"%d\",&n);\nfeet=n/3;\nif(n%3==2)\nfeet++;\nprintf(\"%d %d \",feet/12,feet%12);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "24c2074286a9781e14e3b981575435d3", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n int x;\n if(n%3 == 0 || n%3 == 1)\n x=n/3;\n else\n x=n/3+1;\n printf(\"%d %d\", x/12, x%12);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "8efe99be25b8a74ce21d87da24663380", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int m, i, j, k;\n int a[5][5] = {0};\n\n scanf(\"%d\", &m);\n\n for (i = 0; i < m; i++) {\n\t int x, y;\n\n\t scanf(\"%d %d\", &x, &y);\n\n\t a[x - 1][y - 1]++;\n\t a[y - 1][x - 1]++;\n }\n\n for (i = 0; i < 5; i++) {\n\t for (j = i + 1; j < 5; j++) {\n\t for (k = j + 1; k < 5; k++) {\n\t\t if (a[i][j] == 1 && a[j][k] == 1 && a[k][i] == 1) {\n\t\t\t puts(\"WIN\");\n\n\t\t\t return 0;\n\t\t }\n\t\t if (a[i][j] == 0 && a[j][k] == 0 && a[k][i] == 0) {\n\t\t\t puts(\"WIN\");\n\n\t\t\t return 0;\n\t\t }\n\t }\n\t }\n }\n\n puts(\"FAIL\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "graphs"], "code_uid": "b2b827934e10c5d50b4cbc298c71af91", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nint\t\tmain()\n{\n\tint n_cone, i = 0, cont[6];\n\tscanf(\"%d\", &n_cone);\n\tint l, r;\n\tint cnt = 0;\n\tint\ttab[6];\n\tchar *res = \"FAIL\";\n\tmemset(tab, 0, sizeof(tab));\n\twhile (n_cone > i)\n\t{\n\t\tscanf(\"%d%d\", &l, &r);\n\t\ttab[l] = tab[l] + 1;\n\t\ttab[r] = tab[r] + 1;\n\t\ti++;\n\t}\n\ti = 1;\n\twhile (i <= 5)\n\t{\n\t\tif (tab[i] != 2)\n\t\t\tres = \"WIN\";\n\t\ti++;\n\t}\n\tprintf(\"%s\", res);\n\texit(0);\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "graphs"], "code_uid": "8caa0e7bfd071c2d4b4087b3d7b79c9e", "src_uid": "2bc18799c85ecaba87564a86a94e0322", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define max(a,b) \\\n ({ __typeof__ (a) _a = (a); \\\n __typeof__ (b) _b = (b); \\\n _a > _b ? _a : _b; })\nint main(){\nint t,n,a;\nscanf(\"%d\",&t);\nwhile(t--){\n a=1;\nscanf(\"%d\",&n);\nif(n%2==0)\n printf(\"%d %d\\n\",n/2,n/2);\nelse{\nfor(int i=3;i*i<=n;i+=2){\n if(n%i==0){\n if(max(i,n/i)>a)\n a=max(i,n/i);\n }\n}\nprintf(\"%d %d\\n\",a,n-a);\n}\n}\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "9e606bf7330a1fd38249466693de9141", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint solve(int n)\n{\n\tint i;\n\tfor (i = 2; i * i <= n; i++)\n\t\tif (n % i == 0)\n\t\t\treturn n / i;\n\treturn 1;\n}\nint main()\n{\n\tint t;\n\tscanf(\"%d\", &t);\n\tint n, m;\n\tfor (; t > 0; t--)\n\t{\n\t\tscanf(\"%d\", &n);\n\t\tif (n % 2 == 0)\n\t\t\tprintf(\"%d %d\\n\", n / 2, n / 2);\n\t\telse\n\t\t{\n\t\t\tm = solve(n);\n\t\t\tprintf(\"%d %d\\n\", m, (n / m - 1) * m);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "58a3654ca2130c4ac74e53379488b5a1", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char a[100];\n int i,n;\n scanf(\"%d\",&n);\n for(i=0; i\nint main()\n{\n int i,n,x,z=0;\n char a[102];\n scanf(\"%d\",&n);\n for(i=0;i<=n;i++)\n {\n scanf(\"%c\",&a[i]);\n }\n for(i=1;i0)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b86f50665dd75ae355f86dd8f0374b9b", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n\n\nlong long int insaneMod(long long int a, long long int mods[19]){\n long long int temp;\n long long int result = 1ll;\n int ct;\n int counter = 0;\n while(a > 0){\n ct = a % 10;\n temp = 1ll;\n for(int ct2 = 1 ; ct2 <= ct ; ct2++){\n temp = temp * mods[counter];\n temp %= 1000000007;\n }\n result *= temp;\n result %= 1000000007;\n a = a / 10;\n counter++;\n }\n return result;\n}\n\nlong long int modToPower(long long int a , long long int b){\n long long int temp , result;\n int remainders[19];\n remainders[1] = a;\n int ct;\n for(ct = 2 ; ct <= 18 ; ct++){\n long long int temp = remainders[ct - 1];\n int ct2;\n for(ct2 = 1; ct2 <= 9 ; ct2++){\n temp *= remainders[ct - 1];\n temp = temp % (1000000007);\n }\n remainders[ct] = temp;\n }\n\n\n\n\n}\n\nint main(){\n\n long long int mods[19];\n mods[0]= 2;\n mods[1] = 1024;\n int ct;\n for(ct = 2 ; ct <= 18 ; ct++){\n long long int temp = mods[ct - 1];\n int ct2;\n for(ct2 = 1; ct2 <= 9 ; ct2++){\n temp *= mods[ct - 1];\n temp = temp % (1000000007);\n }\n mods[ct] = temp;\n }\n\n long long int n, m;\n int k;\n scanf(\"%lld%lld%d\", &n, &m, &k);\n if(k == -1 && n % 2 != m % 2){\n printf(\"0\");\n return 0;\n }else{\n long long int result;\n result = insaneMod(n-1 , mods);\n long long int remainders[19];\n remainders[0] = result;\n int cts;\n for(cts = 1 ; cts <= 18 ; cts++){\n long long int temp = remainders[cts - 1];\n int ct2;\n for(ct2 = 1; ct2 <= 9 ; ct2++){\n temp *= remainders[cts - 1];\n temp = temp % (1000000007);\n }\n remainders[cts] = temp;\n }\n\n\n result = insaneMod(m - 1, remainders);\n printf(\"%lld\", result);\n return 0;\n }\n}\n\n\n\n\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "7692d44ca765fb163358c645e8608824", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define __STDC_FORMAT_MACROS\n#include \n\n#define MOD 1000000007ULL\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\n// lets consider line of len M. To have product to be 1 we need even count of -1, and for -1 odd count of -1\n// if we consider first M-1 numbers, disregarding how we pick them we can always \"fix\" it with the last one\n// so count(M) = 2^(M-1)\n// similarly for N > 1 rows we can pick N-1 however we want and \"fix it\" with the last one\n// but this is only possible if N,M have same parity\n// 2 ^ [(N-1)*(M-1)] = [([2^(N-1)] mod M) ^ (M-1)] mod M\n\nint main() {\n uint64_t N,M; int K; scanf(\"%\"PRIu64 \"%\"PRIu64 \"%d\\n\", &N,&M,&K);\n if(N % 2 != M % 2 && K == -1) { printf(\"0\\n\"); return 0; }\n printf(\"%\"PRIu64 \"\\n\", pow_mod(pow_mod(2,M-1,MOD), N-1,MOD));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "combinatorics", "number theory"], "code_uid": "e8a4afb3572bd4b0c59042455099b9c5", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint l[26]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101},prime[2000001];\nchar hash[20000001];\nint k,a,b,ans=0;\n\nvoid dfs(int now,int s,int f)\n{\n if (l[now]==k)\n ans+=f*(b/s-(a-1)/s);\n else\n {\n dfs(now+1,s,f);\n if ((long long)s*l[now]<=b)\n dfs(now+1,s*l[now],-f);\n }\n}\n\nint main()\n{\n int i,j,o=0;\n scanf(\"%d%d%d\",&a,&b,&k);\n b/=k;\n a=(long long)(a+k-1)/k;\n for (i=2;i*i<=k&&k%i;i++);\n if (i*i>k)\n if (k<=100)\n dfs(0,1,1);\n else\n {\n ans+=(a==1&&b>=1);\n for (i=2;i<=b;i++)\n {\n if (!hash[i])\n {\n ans+=(i>=k&&a<=i);\n prime[++o]=i;\n }\n for (j=1;prime[j]*i<=b;j++)\n {\n hash[prime[j]*i]=1;\n ans+=(prime[j]>=k&&a<=prime[j]*i);\n if (i%prime[j]==0)\n break;\n }\n }\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "number theory"], "code_uid": "8c901bf3586756b6bd7e2ba66a6f0372", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define K\t22\n#define N\t25000000\n\nint pp[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n\t31, 37, 41, 43, 47, 53, 59, 61, 67, 71,\n\t73, 79 };\n\nchar bad[N + 1];\n\nint solve1(int n, int p) {\n\tint a, b, cnt;\n\n\tif (n < p)\n\t\treturn n == 0 ? 0 : 1;\n\tmemset(bad, 0, (n + 1) * sizeof *bad);\n\tcnt = n;\n\tfor (a = 2; a < p; a++) {\n\t\tif (bad[a])\n\t\t\tcontinue;\n\t\tfor (b = a; b <= n; b += a)\n\t\t\tif (!bad[b]) {\n\t\t\t\tbad[b] = 1;\n\t\t\t\tcnt--;\n\t\t\t}\n\t}\n\treturn cnt;\n}\n\nint solve2(int n, int k) {\n\tlong long ans;\n\tint b, i;\n\n\tans = 0;\n\tfor (b = 0; b < 1 << k; b++) {\n\t\tint m = n, parity = 0;\n\n\t\tfor (i = 0; i < k; i++)\n\t\t\tif ((b & 1 << i) != 0) {\n\t\t\t\tint p = pp[i];\n\n\t\t\t\tm /= p;\n\t\t\t\tparity ^= 1;\n\t\t\t}\n\t\tans += parity == 0 ? m : -m;\n\t}\n\treturn ans;\n}\n\nint prime(int p) {\n\tint a;\n\n\tfor (a = 2; a <= p / a; a++)\n\t\tif (p % a == 0)\n\t\t\treturn 0;\n\treturn 1;\n}\n\nint main() {\n\tint a, b, p, ans, i;\n\n\tscanf(\"%d%d%d\", &a, &b, &p);\n\tif (!prime(p)) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\ti = 0;\n\twhile (i < K && pp[i] < p)\n\t\ti++;\n\tif (i == K)\n\t\tans = solve1(b / p, p) - solve1((a - 1) / p, p);\n\telse\n\t\tans = solve2(b / p, i) - solve2((a - 1) / p, i);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "number theory"], "code_uid": "b42628567650520d217da8908462e02b", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint midd;\nint mid(int num1,int num2,int num3)\n{\n if(num2>num3&&num2num1)\n {\n midd=num2;\n return ;\n }\n else\n mid(num3,num1,num2);\n}\nint main()\n{\n int x1,y1;\n scanf(\"%d%d\",&x1,&y1);\n int x2,y2;\n scanf(\"%d%d\",&x2,&y2);\n int x3,y3;\n scanf(\"%d%d\",&x3,&y3);\n if((x1==x2&&x1==x3)||(y1==y2&&y1==y3))\n {\n printf(\"1\\n\");\n return 0;\n }\n if(x1!=x2&&x1!=x3&&x2!=x3&&y1!=y2&&y1!=y3&&y2!=y3)\n {\n printf(\"3\\n\");\n return 0;\n }\n if(x1!=x2&&x1!=x3&&x2!=x3)\n {\n mid(x1,x2,x3);\n if(midd==x1&&y1!=y2&&y1!=y3)\n {\n printf(\"3\\n\");\n return 0;\n }\n if(midd==x2&&y2!=y1&&y2!=y3)\n {\n printf(\"3\\n\");\n return 0;\n }\n if(midd==x3&&y3!=y2&&y3!=y1)\n {\n printf(\"3\\n\");\n return 0;\n }\n }\n if(y1!=y2&&y1!=y3&&y2!=y3)\n {\n mid(y1,y2,y3);\n if(midd==y1&&x1!=x2&&x1!=x3)\n {\n printf(\"3\\n\");\n return 0;\n }\n if(midd==y2&&x2!=x1&&x2!=x3)\n {\n printf(\"3\\n\");\n return 0;\n }\n if(midd==y3&&x3!=x2&&x3!=x1)\n {\n printf(\"3\\n\");\n return 0;\n }\n }\n printf(\"2\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "e290ceec92f27b237c35eb7bcab04ed6", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong int i,j,k,n;\n\tlong int x1,x2,x3,y1,y2,y3;\n\tscanf(\"%ld %ld\",&x1,&y1);\n\tscanf(\"%ld %ld\",&x2,&y2);\n\tscanf(\"%ld %ld\",&x3,&y3);\n\n\tif((x1==x2 && x2==x3) || (y1==y2 && y2==y3))\n\t{\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\n\tif((x1==x2))\n\t{\n\t\tif((y1>=y3 && y2>=y3) || (y1<=y3 && y2<=y3))\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif((y1==y2))\n\t{\n\t\tif((x1>=x3 && x2>=x3) ||(x1<=x3 && x2<=x3))\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif((x1==x3))\n\t{\n\t\tif((y1>=y2 && y3>=y2) || (y1<=y2 && y3<=y2))\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif((y1==y3))\n\t{\n\t\tif((x1>=x2 && x3>=x2) || (x1<=x2 && x3<=x2))\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tif((x2==x3))\n\t{\n\t\tif((y2>=y1 && y3>=y1) || (y2<=y1 && y3<=y1))\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif((y2==y3))\n\t{\n\t\tif((x2>=x1 && x3>=x1) || (x2<=x1 && x3<=x1))\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"3\\n\");\n\treturn 0;\n\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "9ba4551dc9f04d9d6d9fec807e2d78f0", "src_uid": "36fe960550e59b046202b5811343590d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define MAX 1000000007\n\nint main()\n{\n\tlong long int a27[100]={0},a7[100]={0},n,b[100]={0},p,i,c,d;\n\ta27[1]=27,a7[1]=7;\n\tscanf(\"%lld\",&n);\n\ti=1;\n\twhile(n!=0)\n\t{\n\t\tb[i++]=n%2;\n\t\tn=n/2;\n\t}\n\tp=i;\n\ti=2;\n\twhile(i<=p)\n\t{\n\t\ta27[i]=a27[i-1]*a27[i-1]%MAX;\n\t\ta7[i]=a7[i-1]*a7[i-1]%MAX;\n\t\ti++;\n\t}\n\tfor(i=1,c=1,d=1;i\nint main()\n{\n long long int a,b,n,i,ans, mod=1000000007;\n a=b=1;\n scanf(\"%lld\",&n);\n \n for(i=0;i\n#include \n\n#define N\t100\n#define A\t(1 << 10)\n\nint count(int n) {\n\treturn n == 0 ? 0 : count(n & n - 1) + 1;\n}\n\nint main() {\n\tstatic int aa[N];\n\tstatic char used[A];\n\tint n, i, k, l, a, b, c, ans;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) {\n\t\tstatic char s[2];\n\t\tchar c, d;\n\n\t\tscanf(\"%s\", s);\n\t\tc = s[0];\n\t\td = s[1];\n\t\ta = 0;\n\t\tif (c == 'R')\n\t\t\ta |= 1 << 0;\n\t\telse if (c == 'G')\n\t\t\ta |= 1 << 1;\n\t\telse if (c == 'B')\n\t\t\ta |= 1 << 2;\n\t\telse if (c == 'Y')\n\t\t\ta |= 1 << 3;\n\t\telse\n\t\t\ta |= 1 << 4;\n\t\ta |= 1 << 5 + d - '1';\n\t\taa[i] = a;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tused[aa[i]] = 1;\n\tk = 0;\n\tfor (a = 0; a < A; a++)\n\t\tif (used[a])\n\t\t\tk++;\n\tans = 10;\n\tfor (b = 0; b < A; b++) {\n\t\tc = count(b);\n\t\tif (ans > c) {\n\t\t\tmemset(used, 0, sizeof used);\n\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\ta = aa[i] & b;\n\t\t\t\tused[a] = 1;\n\t\t\t}\n\t\t\tl = 0;\n\t\t\tfor (a = 0; a < A; a++)\n\t\t\t\tif (used[a])\n\t\t\t\t\tl++;\n\t\t\tif (k == l)\n\t\t\t\tans = c;\n\t\t}\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "debcdaa23ceab78f5f1501c919b97869", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint B[5][5];\nint H[10];\nint A=10, N;\n\nint find(int at, int t)\n{\n\tif(at < 10)\n\t{\n\t\tH[at] = 0;\n\t\tfind(at+1, t);\n\t\tH[at] = 1;\n\t\tfind(at+1, t+1);\n\t\tH[at] = 0;\n\t\treturn 0;\n\t}\n\t\n\tint i, j, k;\n\tint z=0;\n\tint b[5][5];\n\t\n\tfor(i=0; i<5; i++)\n\t{\n\t\tfor(j=0; j<5; j++)\n\t\t{\n\t\t\tb[i][j] = 0;\n\t\t\tif(B[i][j] == 0)\n\t\t\t\tcontinue;\n\t\t\tif(H[i] == 1 && H[j+5] == 1)\n\t\t\t\tcontinue;\n\t\t\tb[i][j] = B[i][j];\n\t\t}\n\t}\n\t\n\tfor(i=0; i<5; i++)\n\t{\n\t\tfor(j=0; j<5; j++)\n\t\t{\n\t\t\tif(b[i][j] == 0)\n\t\t\t\tcontinue;\n\t\t\tif(H[i] == 1)\n\t\t\t{\n\t\t\t\tfor(k=0; k<5; k++)\n\t\t\t\t{\n\t\t\t\t\tif(b[i][k] > 0 && k != j)\n\t\t\t\t\t\tz++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(H[j+5] == 1)\n\t\t\t{\n\t\t\t\tfor(k=0; k<5; k++)\n\t\t\t\t{\n\t\t\t\t\tif(b[k][j] > 0 && k != i)\n\t\t\t\t\t\tz++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(H[i] == 0 && H[j+5] == 0)\n\t\t\t\tz++;\n\t\t}\n\t}\n\t\n\tif(z <= 1)\n\t{\n\t\tif(t < A)\n\t\t\tA = t;\n\t}\n\t\n\treturn 0;\n}\n\nint main()\n{\n\tint i, j;\n\tchar c, d;\n\t//FILE *input, *output;\n\t\n\t//input = fopen(\"hanabi.in\", \"r\");\n\t\n\tscanf(\"%d\\n\", &N);\n\t\n\tfor(i=0; i\n#include \n#include \n\nstruct exam{\n\tint a;\n\tint b;\n\tint c;\n};\n\nstruct exam x[100];\nint s[100],day[100]={0};\n\nint compare(const void *a,const void *b){\n\treturn x[*(int *)a].b-x[*(int *)b].b;\n}\n\nint main(void){\n\tint n,m,i,j;\n\n\tscanf(\"%d %d\",&n,&m);\n\tfor(i=0;i0){\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tday[i]=m+1;\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tfor(j=0;j=x[s[j]].a&&x[s[j]].c>0){\n\t\t\t\t\tx[s[j]].c--;\n\t\t\t\t\tday[i]=s[j]+1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor(i=0;i \n#include \nstruct ex {int s; int d; int c; int n;};\nint cm (const void *A, const void *B){\n\treturn\t((struct ex *)A)->d - ((struct ex *)B)->d;\n\t}\nint main (){\nint i, j, n, m;\nint const MAX = 100;\nint ans[100] = {0};\nstruct ex a[MAX];\n\nscanf(\"%d %d\",&n, &m);\nfor (i=0;i < m;i++){\n\tscanf(\"%d %d %d\", &a[i].s, &a[i].d, &a[i].c);\n\ta[i].n = i + 1;\n\tans[a[i].d - 1] = m + 1;\n\t}\n\nqsort(a,m,sizeof a[0], cm);\nj = 0;\nfor (i=0;i 0 ){\n\t\t\tans[i] = a[k].n;\n\t\t\ta[k].c--;\n\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\n\t}\n//check\nj = 0;\nfor (i=0;i 0)\n//if(0)\n\tprintf(\"-1\");\nelse\n\tfor (i = 0; i\nint main(){\nint t,x;\nscanf(\"%d\",&t);\nwhile(t--){\nscanf(\"%d\",&x);\nint a=x%10-1,r=0,p=1;\nwhile(x){\nx=x/10;\nr=r+p;\np++;\n}\nprintf(\"%d\\n\",a*10+r);\n}\nreturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "fda87e81c5d0236e6d7a60cf54b4b444", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include \n\n\nint main(){\n\tint t,n;\n\tchar s[100];\n\tscanf(\"%d\",&t);\n\t\n\twhile(t--){\n\t\tscanf(\"%s\",&s);\n\t\tint a = s[0]-'0';\n\t\tint count = strlen(s);\n\t\tprintf(\"%d\\n\",(a-1)*10+count*(count+1)/2);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "24c7ea16ba41d023b48c0bd82923b0f3", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint main()\r\n{\r\n int n,k,i,j,test;\r\n long long int c;\r\n scanf(\"%d\",&test);\r\n for(i=1;i<=test;i++)\r\n {\r\n c=1;\r\n scanf(\"%d\",&n);\r\n scanf(\"%d\",&k);\r\n for(j=1;j<=k;j++)\r\n {\r\n c=(c*n)%(1000000000+7);\r\n }\r\n printf(\"%lld\\n\",c);\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "43cd46a78ea7cdab13a87cc4ec1db469", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nlong long K = 1000000000+7;\r\n\r\nint main() {\r\n long long t, n, k, i, sol, j;\r\n scanf(\"%lld\", &t);\r\n\r\n for( i = 0; i < t; i++ ){\r\n scanf(\"%lld\", &n);\r\n scanf(\"%lld\", &k);\r\n sol = 1;\r\n for( j = 0; j < k; j++ )\r\n sol = (sol*n)%K;\r\n printf(\"%lld\\n\", sol);\r\n }\r\n}", "lang_cluster": "C", "tags": ["math", "combinatorics", "bitmasks"], "code_uid": "8fcb6e44c27452f966da63b00ca3def5", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint num_len(long long n)\n{\t\n\tint len = 0;\n\twhile (n && ++len && (n /= 10));\n \treturn len;\t\n}\n\nint sum_digits(long long n)\n{\t\n\tint sum = 0;\n\n\twhile (n) {\n\t\tsum += n % 10;\n\t\tn /= 10;\t\n\t}\n\n\treturn sum;\n}\n\nint main() {\n\tlong long n, a = 0, b = 0;\n\tlong long lenN, sumA, sumB;\n\n\tscanf(\"%lld\", &n);\n\n\tlenN = num_len(n);\n\t\n\tfor (int i = 0; i < lenN - 1; i++) {\n\t\ta = a * 10 + 9; \n\t}\n\n\tsumA = 9 * (lenN - 1);\n\tb = n - a;\n\tsumB = sum_digits(b);\n\n\tprintf(\"%lld\", sumA + sumB);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "b0041b18250ef3bc801e8b5cb20515e1", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main() {\n long long n,m,ten,b;\n\tint k;\n\tten = 1;\n scanf(\"%lld\", &n);\n m = n;\n int i;\n for (i = 0; (m /= 10) != 0; i++)\n continue;\n \n \n \n for (k = 0; k < i; k++)\n ten *= 10;\n \n b = n - ten + 1;\n int sum = 9 * i;\n while (b != 0)\n\t{\n sum += b % 10;\n b /= 10;\n }\n printf(\"%d\\n\", sum);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "2b83b482ef40dc59ce820825bb040f30", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\tchar str[10];\n\tint x;\n\tint y=8;\n\tint flag=0;\n\tchar cl;\n\t\n\twhile(y--)\n\t{\n\t\tscanf(\"%s\",str);\n\t\tcl=str[0];\n\t\tfor(x=1;x<8;x++)\n\t\t{\n\t\t\tif(cl==str[x])\n\t\t\t\tflag=1;\n\t\t\tcl=str[x];\n\t\t}\n\t}\n\tif(flag==1)\n\tprintf(\"NO\");\n\telse\n\tprintf(\"YES\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "strings"], "code_uid": "c5c0a62474ecc6309147be7e85bd2158", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,j,k,l,c;\n char arra[8][8];\n c=0;\n for(i=0;i<8;i++){\n scanf(\"%s\",&arra[i]);\n }\n\n\n for(i=0;i<8;i++){\n for(j=0;j<7;j++){\n if(arra[i][j]==arra[i][j+1]){\n c=1;\n break;\n }\n\n }\n if(c==1)break;\n }\n\n\n if(c==1)printf(\"NO\");\n else printf(\"YES\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings"], "code_uid": "7f1a4a45f9f29b4077a7047defd4fc1d", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n\tint a,b;\n\tscanf(\"%d%d\",&a,&b);\n\tint i,sum=0;\n\tfor(i=a;i<=b;i++){\n\t\tint d=i;\n\t\twhile(d!=0){\n\t\t\tint t=d%10;\n\t\t\tif(t==0)\n\t\t\t\tsum=sum+6;\n\t\t\tif(t==1)\n\t\t\t\tsum=sum+2;\n\t\t\tif(t==2||t==3||t==5)\n\t\t\t\tsum=sum+5;\n\t\t\tif(t==4)\n\t\t\tsum=sum+4;\n\t\t\tif(t==6)\n\t\t\tsum=sum+6;\n\t\t\tif(t==7)\n\t\t\t\tsum=sum+3;\n\t\t\tif(t==8)\n\t\t\tsum+=7;\n\t\t\tif(t==9)\n\t\t\tsum+=6;\n\t\t\td=d/10;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",sum);\t\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4797a98c3f60e9ce9713992daade5a91", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n#include \n\nint main()\n{\n long long int test,n,i,j,sum1,k,m,a,flag=0,count=0,b,c[10]={6,2,5,5,4,5,6,3,7,6},a1,b2;\n scanf(\"%lld%lld\",&a,&b);\n count=0;\n for(i=a;i<=b;i++){\n k=i;\n while(k>0){\n count+=c[k%10];\n k/=10;\n }\n }\n printf(\"%lld\",count);\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "f121dc58635f5f2d977c68f1ad909979", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define ifdot(a) (str[a]=='d' && str[a+1]=='o' && str[a+2]=='t')\n#define ifat(a) \t(str[a]=='a' && str[a+1]=='t')\n#define endl puts(\"\");\nchar str[200];\nint main ()\n{\n\tscanf(\"%s\",str);\n\tint i,len=strlen(str),b=0;\n\tprintf(\"%c\",str[0]);\n\tfor(i=1; i\n#include\n#define p printf\n\tchar a[1444],u,at;\n\tint i,j;\nint main(){\n\tscanf(\"%s\",a);\n\tu=strlen(a);\n\tif(a[1]=='a' && a[2]=='t'){\n\t\tp(\"%c@\",a[0]);\n\t\tj=3;at++;\n\t}\n\telse if(a[0]=='d' && a[1]=='o' && a[2]=='t'){\n\t\tp(\"dot\");\n\t\tj=3;\n\t}\n\tif(a[0]=='a' && a[1]=='t'){\n\t\tp(\"at\");\n\t\tj=2;\n\t}\n\tfor(i=j;i\n#include \n#include \n\n#define MAX 2000010\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nshort len[MAX];\nchar mu[MAX], flag[MAX];\nint prime[MAX], dp[MAX], sum[MAX], power[MAX], L[MAX], *divisors[MAX];\n\nint expo(int a, int b){\n int res = 1;\n\n while (b){\n if (b & 1) res = (long long)res * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return res;\n}\n\nvoid mobius(){\n mu[1] = 1;\n int i, j, k, p = 0;\n\n for (i = 2; i < MAX; i++){\n if (!flag[i]) mu[i] = -1, prime[p++] = i;\n for (j = 0; j < p && (k = i * prime[j]) < MAX; j++){\n\n flag[k] = true;\n if (!(i % prime[j])){\n mu[k] = 0;\n break;\n }\n else mu[k] -= mu[i];\n }\n }\n for (i = 1; i < MAX; i++) sum[i] = sum[i - 1] + mu[i];\n}\n\nvoid generate(){\n mobius();\n int i, j, k, c, d, x;\n\n len[0] = len[1] = L[0] = L[1] = 1;\n for (i = 4; i < MAX; i++, i++) len[i] = 2;\n\n for (i = 3; (i * i) < MAX; i += 2){\n if (!len[i]){\n for (j = (i * i), d = i << 1; j < MAX; j += d){\n if (!len[j]) len[j] = i;\n }\n }\n }\n\n for (i = 2; i < MAX; i++){\n if (!len[i]) L[i] = i;\n else{\n L[i] = len[i];\n x = L[i /len[i]];\n if (x > L[i]) L[i] = x;\n }\n }\n\n divisors[1] = (int *) malloc(sizeof(int));\n divisors[1][0] = 1, len[1] = 1;\n\n for (i = 2; i < MAX; i++){\n c = 0, k = i;\n while (k > 1 && L[k] == L[i]){\n c++;\n k /= L[k];\n }\n\n len[i] = (c + 1) * len[k];\n divisors[i] = (int *) malloc(sizeof(int) * len[i]);\n\n for (x = 1, j = 0, len[i] = 0; j <= c; j++, x *= L[i]){\n for (d = 0; d < len[k]; d++){\n divisors[i][len[i]++] = divisors[k][d] * x;\n }\n }\n }\n}\n\nint count(int n, int m){\n int z, y, x = m;\n long long v, res = 0;\n\n while (x >= 1){\n y = m / x, z = m / (y + 1);\n v = (long long)power[y] * (sum[x] - sum[z]);\n x = z, res += v;\n }\n\n res = (res % MOD + MOD) % MOD;\n return res;\n}\n\nint solve(int n, int k){\n long long res = 0;\n int i, j, v, m, x, y, z;\n for (i = 0; i < MAX; i++) power[i] = expo(i, n);\n\n dp[1] = count(n, 1);\n for (m = 2; m <= k; m++){\n res = dp[m - 1];\n for (j = 0; j < len[m]; j++){\n x = 0, y = 0, z = 0;\n x = divisors[m][j], v = m / x;\n y = power[v] * mu[x];\n z = power[v - 1] * mu[x];\n res = res + y - z;\n }\n dp[m] = ((res % MOD) + MOD) % MOD;\n }\n\n for (m = 1, res = 0; m <= k; m++) res += (m ^ dp[m]);\n return res % MOD;\n}\n\nint main(){\n generate();\n int n, k, res;\n\n while (scanf(\"%d %d\", &n, &k) != EOF){\n printf(\"%d\\n\", solve(n, k));\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "324e626625ab45bfd9a294ecf6600572", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MAX 2000010\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nshort len[MAX];\nchar mu[MAX], flag[MAX];\nint prime[MAX], dp[MAX], sum[MAX], power[MAX], L[MAX], *divisors[MAX];\n\nint expo(int a, int b){\n int res = 1;\n\n while (b){\n if (b & 1) res = (long long)res * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return res;\n}\n\nvoid mobius(){\n mu[1] = 1;\n int i, j, k, p = 0;\n\n for (i = 2; i < MAX; i++){\n if (!flag[i]) mu[i] = -1, prime[p++] = i;\n for (j = 0; j < p && (k = i * prime[j]) < MAX; j++){\n\n flag[k] = true;\n if (!(i % prime[j])){\n mu[k] = 0;\n break;\n }\n else mu[k] -= mu[i];\n }\n }\n for (i = 1; i < MAX; i++) sum[i] = sum[i - 1] + mu[i];\n}\n\nvoid generate(){\n mobius();\n int i, j, k, c, d, x;\n\n len[0] = len[1] = L[0] = L[1] = 1;\n for (i = 4; i < MAX; i++, i++) len[i] = 2;\n\n for (i = 3; (i * i) < MAX; i += 2){\n if (!len[i]){\n for (j = (i * i), d = i << 1; j < MAX; j += d){\n if (!len[j]) len[j] = i;\n }\n }\n }\n\n for (i = 2; i < MAX; i++){\n if (!len[i]) L[i] = i;\n else{\n L[i] = len[i];\n x = L[i /len[i]];\n if (x > L[i]) L[i] = x;\n }\n }\n\n divisors[1] = (int *) malloc(sizeof(int));\n divisors[1][0] = 1, len[1] = 1;\n\n for (i = 2; i < MAX; i++){\n c = 0, k = i;\n while (k > 1 && L[k] == L[i]){\n c++;\n k /= L[k];\n }\n\n len[i] = (c + 1) * len[k];\n divisors[i] = (int *) malloc(sizeof(int) * len[i]);\n\n for (x = 1, j = 0, len[i] = 0; j <= c; j++, x *= L[i]){\n for (d = 0; d < len[k]; d++){\n divisors[i][len[i]++] = divisors[k][d] * x;\n }\n }\n }\n}\n\nint count(int n, int m){\n int z, y, x = m;\n long long v, res = 0;\n\n while (x >= 1){\n y = m / x, z = m / (y + 1);\n v = (long long)power[y] * (sum[x] - sum[z]);\n x = z, res += v;\n }\n\n res = (res % MOD + MOD) % MOD;\n return res;\n}\n\nint solve(int n, int k){\n long long res = 0;\n int i, j, v, m, x, y, z;\n for (i = 0; i < MAX; i++) power[i] = expo(i, n);\n\n dp[1] = count(n, 1);\n for (m = 2; m <= k; m++){\n res = dp[m - 1];\n for (j = 0; j < len[m]; j++){\n x = 0, y = 0, z = 0;\n x = divisors[m][j], v = m / x;\n y = power[v] * mu[x];\n z = power[v - 1] * mu[x];\n res = res + y - z;\n }\n dp[m] = ((res % MOD) + MOD) % MOD;\n }\n\n for (m = 1, res = 0; m <= k; m++) res += (m ^ dp[m]);\n return res % MOD;\n}\n\nint main(){\n generate();\n int n, k, res;\n\n while (scanf(\"%d %d\", &n, &k) != EOF){\n printf(\"%d\\n\", solve(n, k));\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "d8d17ab58f5114449aac9ebc78dd8c14", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main() \n{\n\tchar s[11];\n\tunsigned k, m;\n\tscanf(\"%s\\n\", s);\n\tscanf(\"%u\\n\", &k);\n\n\tswitch (s[0]) \n\t{\n\t\tcase 'J': \n\t\t\tif (s[1] == 'a') \n\t\t\t\tm = 1; \n\t\t\telse\n\t\t\t{\n\t\t\t\tif (s[2] == 'n')\n\t\t\t\t\tm = 6;\n\t\t\t\telse\n\t\t\t\t\tm = 7;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'F':\n\t\t\tm = 2;\n\t\t\tbreak;\n\t\tcase 'M':\n\t\t\tif (s[2] == 'r')\n\t\t\t\tm = 3;\n\t\t\telse\n\t\t\t\tm = 5;\n\t\t\tbreak;\n\t\tcase 'A':\n\t\t\tif (s[1] == 'p')\n\t\t\t\tm = 4;\n\t\t\telse\n\t\t\t\tm = 8;\n\t\t\tbreak;\n\t\tcase 'S':\n\t\t\tm = 9;\n\t\t\tbreak;\n\t\tcase 'O':\n\t\t\tm = 10;\n\t\t\tbreak;\n\t\tcase 'N':\n\t\t\tm = 11;\n\t\t\tbreak;\n\t\tcase 'D':\n\t\t\tm = 12;\n\t\t\tbreak;\n\t}\n\t\n\tm = (k+m)%12;\n\n\n\tif (k == 0)\n\t\tprintf(\"%s\\n\", s);\n\telse\n\t{\n\tswitch (m)\n\t{\n\t\tcase 1: printf(\"January\\n\"); break;\n\t\tcase 2: printf(\"February\\n\"); break;\n\t\tcase 3: printf(\"March\\n\"); break;\n\t\tcase 4: printf(\"April\\n\"); break;\n\t\tcase 5: printf(\"May\\n\"); break;\n\t\tcase 6: printf(\"June\\n\"); break;\n\t\tcase 7: printf(\"July\\n\"); break;\n\t\tcase 8: printf(\"August\\n\"); break;\n\t\tcase 9: printf(\"September\\n\"); break;\n\t\tcase 10: printf(\"October\\n\"); break;\n\t\tcase 11: printf(\"November\\n\"); break;\n\t\tcase 0: printf(\"December\\n\"); break;\n\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "7684c597b0ad4ece75cbd4fee49170c1", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{\n int k,i;\n char s[10];\n char c[12][10]={\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\n scanf(\"%s %d\",s,&k);\n for(i=0; i<12;i++) \n {\n if(strcmp(s,c[i])==0) break;\n }\n i=(i+k) % 12;\n printf(\"%s\\n\", c[i]);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a6d3ba9828c8785897930db69286e5a1", "src_uid": "a307b402b20554ce177a73db07170691", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define MAXN 53\n#define MAXW 500003\nint dp[MAXW]={1};\nint n,d,c[MAXN];\nint ans,day;\n\nint main()\n{\n\tint i,j,k,sum=0;\n\n\tscanf(\"%d%d\",&n,&d);\n\tfor(i=0;i=c[i];j--,k--)\n\t\t\tif(dp[j]==0 && dp[k]==1)dp[j]=1;\n\t}\n\n\tans=day=0;\n\twhile(1)\n\t{\n\t\ti=ans+d;\n\t\tif(i>sum)i=sum;\n\t\tfor(;i>ans;i--)\n\t\t{\n\t\t\t//printf(\"now i %d %d\\n\",ans,i);\n\t\t\tif(dp[i]==1)break;\n\t\t}\n\t\tif(i==ans)break;\n\t\tans=i;\n\t\t++day;\n\t}\n\tprintf(\"%d %d\\n\",ans,day);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "e996d0dffba9b923834a2833eab07b14", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint a[60];\nint dp[500100];\nint ans[500100];\nint main(void)\n{\n\tint n ,d;\n\tint i ,j;\n\tint sum;\n\tint aa;\n\tint p ,pans;\n\tint k;\n\t\n\twhile (scanf(\"%d %d\" ,&n ,&d)!=EOF)\n\t{\n\t\tsum=0;\n\t\tfor (i=1 ; i<=n ; i++)\t\n\t\t{\n\t\t\tscanf(\"%d\" ,&a[i]);\n\t\t\tsum+=a[i];\n\t\t}\n\t\tfor (j=1 ; j<=sum ; j++)\n\t\t{\n\t\t\tdp[j]=0;\t\n\t\t\tans[j]=0;\n\t\t}\n\t\tdp[0]=1;\n\t\tfor (i=1 ; i<=n ; i++)\n\t\t{\n\t\t\taa=a[i];\n\t\t\tfor (j=sum-aa ; j>=0 ; j--)\n\t\t\t{\n\t\t\t\tif (dp[j])\n\t\t\t\t{\n\t\t\t\t\tdp[j+aa]=1;\n\t\t\t\t}\t\n\t\t\t}\n\t\t}\t\t\n\t\tans[0]=1;\n\t\tp=0;\n\t\tpans=2;\n\t\tfor (i=1 ; i<=sum ; i++)\n\t\t{\n\t\t\tif (dp[i])\n\t\t\t{\n\t\t\t\tk=i-d;\n\t\t\t\tif (k<=p)\n\t\t\t\t{\n\t\t\t\t\tans[i]=pans;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tfor (j=k ; j\n\nint main(void)\n{\n long long arr[14];\n int i,j;\n for(i=0; i<14; ++i){\n scanf(\"%lld\", &arr[i]);\n }\n long long brr[14];\n long long k=0;\n long long r;\n long long q;\n long long rem,div;\n for(i=0; i<14; ++i){\n if(arr[i]!=0){\n for(j=0; j<14; ++j){\n brr[j]=arr[j];\n }\n q=brr[i];\n brr[i]=0;\n j=i+1;\n while(q>0 && j<14){\n ++brr[j];\n --q;\n ++j;\n }\n div=q/14;\n rem=q%14;\n if(div!=0){\n for(j=0; j<14; ++j){\n brr[j]+=div;\n }\n }\n for(j=0; jk){\n k=r;\n }\n }\n }\n printf(\"%lld\", k);\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "d05b6fb7d600d69e470e0389580141fd", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{ \n int A[20],B[20],i,j,count,m,n,k;\n long long int max=-1,sum;\n for(i=1;i<=14;i++)\n {\n scanf(\"%d\",&A[i]);\n B[i] = A[i];\n }\n \n for(i=1;i<=14;i++)\n {\n count=1; sum=0;\n if(A[i]>0)\n {\n m = A[i]/14;\n n = A[i]%14;\n B[i] =0;\n for(j=1;j<=14;j++)\n {\n B[j]= B[j]+ m ;\n }\n k=i;\n while(count<=n)\n {\n if(k+1 ==14)\n B[14]++;\n else\n B[(k+1)%14]++;\n k++;\n count++;\n }\n for(j=1;j<=14;j++)\n {\n if(B[j]%2==0)\n {\n sum = sum + B[j];\n }\n }\n \n if(sum>=max)\n max = sum;\n for(j=1;j<=14;j++)\n {\n B[j]=A[j];\n }\n \n }\n }\n printf(\"%lld\",max);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "939be4015ee71e4098c68b831b78bc5d", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define\tLLD\t\"%lld\"\nlong long n;\nint l;\nint x[10];\nint w[10];\nlong long dp[10][21];\nlong long c[21][21];\nvoid init(){\n\tint i,j;\n\tfor(i=1;i<=20;i++){\n\t\tc[i][0]=1;\n\t\tc[i][i]=1;\n\t}\n\tfor(i=2;i<=20;i++){\n\t\tfor(j=1;j0;n/=10){\n\t\t\tx[n%10]++;\n\t\t}\n\t\tl=0;\n\t\tfor(i=1;i<10;i++){\n\t\t\tif(x[i]>0){\n\t\t\t\tw[l++]=x[i];\n\t\t\t}\n\t\t}\n\t\tfor(i=0;i<10;i++){\n\t\t\tfor(j=0;j<=20;j++){\n\t\t\t\tdp[i][j]=0;\n\t\t\t}\n\t\t}\n\t\tfor(i=1;i<=w[0];i++){\n\t\t\tdp[0][i]=1;\n\t\t}\n\t\tfor(i=1;i=i;k++){\n\t\t\t\t\tdp[i][j]+=dp[i-1][j-k]*c[j-k+k][j-k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(x[0]>0){\n\t\t\tl++;\n\t\t\tfor(j=i+1;j<=20;j++){\n\t\t\t\tfor(k=1;k<=x[0]&&j-k>=i;k++){\n\t\t\t\t\tdp[i][j]+=dp[i-1][j-k]*c[j-1-k+k][j-1-k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tr=0;\n\t\tfor(i=0;i<=20;i++){\n\t\t\tr+=dp[l-1][i];\n\t\t}\n\t\tprintf(LLD\"\\n\",r);\n\t}\n}\nmain(){\n#ifndef\tONLINE_JUDGE\n\tfreopen(\"4912e_min.in\",\"rb\",stdin);\n\tfreopen(\"4912e_.out\",\"wb\",stdout);\n#endif\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "combinatorics"], "code_uid": "b65690d7f2b5be03e4c49c82b549f143", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nint i,d[25],f[25],l;\nlong long a[25],ans;\nchar s[25];\n\nvoid dfs(int x)\n{\n\tint i,sum;\n\tlong long res;\n\t\n\tif (x>=10)\n\t{\n\t\tfor (i=0,sum=0;i<=9;i++) sum+=d[i];\n\t\tres=(long long) a[sum-1]*(sum-d[0]);\n\t\tfor (i=0;i<=9;i++) res/=a[d[i]];\n\t\tans+=res;\n\t\treturn;\n\t}\n\tif (!f[x]) dfs(x+1);\n\telse\n\t{\n\t\tfor (i=1;i<=f[x];i++) \n\t\t{\n\t\t\td[x]=i;\n\t\t\tdfs(x+1);\n\t\t}\n\t}\n}\n\nint main()\n{\n\tmemset(f,0,sizeof(f));\n\tmemset(d,0,sizeof(d));\n\tscanf(\"%s\",s);\n\tl=strlen(s);\n\tfor (i=ans=0;i\nint main()\n{\n\tint i,a,b,c,k,size;\n\tscanf(\"%d %d %d\",&a,&b,&c);\n\tsize=a*c/b;\n\tk=0;\n\tfor(i=1;i<=size;i++)\n\t{\n\t\tk=a*c-b*i;\n\t\tif((b*c)>=k)\n\t\tbreak;\n\t}\n\tprintf(\"%d\",i);\n\treturn 0;\n}\n\t\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "5c16cb39aecc5d2544d16f8e75409b3c", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\"stdio.h\"\nint main()\n{\n int a,b,c,ans;\n while(scanf(\"%d%d%d\",&a,&b,&c)!=EOF)\n {\n ans=(int)((a*c-b*c)*1.0/(b*1.0)+0.5);\n if(ans*b+c*b>=a*c) ;\n else ans++;\n printf(\"%d\\n\",ans);\n }\n return 0;\n}\n \n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "e3853e73d24750231e4850c01eaae954", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n int a,b,c,d, count=0;\n scanf(\"%d %d %d %d\", &a,&b,&c,&d);\n count = 2*(abs(a-c)+abs(b-d)+2);\n if((a==c)||(b==d))\n {\n printf(\"%d\",count+2);\n return 0;\n }\n printf(\"%d\",count);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "a201712f80937f8fe0a5ffe9ab8d854f", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint ab(int a,int b)\n{\n\tif(a>b)return a-b;\n\telse return b-a;\n}\n\nint main()\n{\n\tint sx,sy,fx,fy;\n\tscanf(\"%d %d %d %d\",&sx,&sy,&fx,&fy);\n\n\tif(sx!=fx && sy!=fy)printf(\"%d\\n\",4+2*(ab(sx,fx)+ab(sy,fy)));\n\telse printf(\"%d\\n\",6+2*(ab(sx,fx)+ab(sy,fy)));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "c59f2e88b997b036950adb943c6a6a46", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint32_t max(int32_t a, int32_t b);\n\nint main() {\n int32_t h, w;\n int32_t u1, d1;\n int32_t u2, d2;\n\n scanf(\"%d%d\", &w, &h);\n scanf(\"%d%d\", &u1, &d1);\n scanf(\"%d%d\", &u2, &d2);\n\n for (int32_t i = h; i > 0; i--) {\n w += i;\n if (i == d1) {\n w = max(0, w - u1);\n } else if (i == d2) {\n w = max(0, w - u2);\n }\n }\n\n printf(\"%d\\n\", w);\n\n return 0;\n}\n\n\nint32_t max(int32_t a, int32_t b) {\n return a > b ? a : b;\n}\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3be3bc9d16ac517342e0dd34f2a05658", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n int w,h,w1,w2,h1,h2;\n scanf(\"%d %d\", &w, &h);\n scanf(\"%d %d\", &w1, &h1);\n scanf(\"%d %d\", &w2, &h2);\n for(int i = h; i > 0; i--)\n {\n if(i == h1) w -= w1;\n else if(i == h2) w -= w2;\n w += i;\n if(w < 0) w = 0;\n }\n printf(\"%d\\n\",w);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "35e3a5d0d12c3b0d24e329fc7280ee6d", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long n,k,min;\n scanf(\"%lld %lld\",&n,&k);\n min=n*k+1;\n for(long long i=1,temp;i\n#include \n\n\n\nint main(){\n\tint i = 0, k, n, x;\n\t\n\tscanf(\"%d %d\", &n, &k);\n\t\n\twhile(1){\n\t\t\tfor(x = 0; x < k; x++){\n\t\t\t\tif(n == x*i) {printf(\"%d\", x + i*k); return 0;}\n\t\t\t\t//printf(\"%d\\n\", div(i,k).quot * div(i,k).rem);\n\t\t\t}\n\t\ti++;\n\t}\n\t\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "40724dbca8a1228e80be76cd40b171c0", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint comp(const void *a, const void *b)\n{\n int *x = (int*)a;\n int *y = (int*)b;\n return *x-*y;\n}\n\nint main()\n{\n int n,a[105],i,sum=0,cnt=0,l=0;\n float avg;\n scanf(\"%d\",&n);\n for(i=0;i\n#include\n#include\n//int c=0;\n/*void display(int *a,float sum,int n)\n{\n\t\tif(sum/(float)n>=4.5)\nprintf(\"%d\",c);\n\telse \n\t{c++;return display(sum,n);\n\t}\n}*/\nint cmp(int *a,int *b)\n{\n\treturn *a-*b;\n}\nint main(void) {\n\t// your code goes here\n\tint n,val1,i,c=0;\n\tfloat sum=0;\n\tscanf(\"%d\",&n);\n\tval1=(n*5)-2;\nint *a=(int *)malloc(sizeof(int)*n);\n\tfor( i=0;i\n#define MAX(x,y) (((x)>(y))?(x):(y))\n#define ABS(x) (((x)<0)?(-(x)):(x))\n\nint getagroup(int x,int y,int num);\nint getbgroup(int x,int y,int num);\n\nint main(void){\n int a,b,x1,x2,y1,y2;\n int ga1,ga2,gb1,gb2;\n int difa,difb,ans;\n scanf(\"%d %d %d %d %d %d\",&a,&b,&x1,&y1,&x2,&y2);\n ga1=getagroup(x1,y1,a);\n ga2=getagroup(x2,y2,a);\n gb1=getbgroup(x1,y1,b);\n gb2=getbgroup(x2,y2,b);\n difa=ABS(ga1-ga2);\n difb=ABS(gb1-gb2);\n ans=MAX(difa,difb);\n printf(\"%d\\n\",MAX(difa,difb));\n return 0;\n}\n\nint getagroup(int x,int y,int num){\n int n;\n n=x+y;\n if(n>=0) n/=(2*num);\n else{\n n/=(2*num);\n n--;\n }\n return n;\n}\n\nint getbgroup(int x,int y,int num){\n int n;\n n=x-y;\n if(n>=0) n/=(2*num);\n else{\n n/=(2*num);\n n--;\n }\n return n;\n}\n \n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "number theory"], "code_uid": "fb487d0d9b8e848ba7991e6e4f520159", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nchar g[64][64];\nint h[64][64];\n\ntypedef long long ll;\n\nvoid conv(ll x,ll y,ll a,ll b,ll *dx,ll *dy) {\n ll k,l;\n k=x-y+b*2000000000LL;\n l=x+y+a*2000000000LL;\n *dx=k/(2*b)-1000000000LL;\n *dy=l/(2*a)-1000000000LL;\n}\n\nvoid solve(int x1,int y1,int x2,int y2,int a,int b) {\n ll c,d,e,f,g,h,i;\n conv(x1,y1,a,b,&c,&d);\n conv(x2,y2,a,b,&e,&f);\n/* printf(\"%I64d %I64d\\n\",c,d);\n printf(\"%I64d %I64d\\n\",e,f);*/\n g=c-e; if(g<0) g=-g;\n h=d-f; if(h<0) h=-h;\n i=g>h?g:h;\n printf(\"%d\\n\",i);\n}\n\nint main() {\n int i,j,u,v;\n int a,b,x1,y1,x2,y2;\n ll A,B;\n ll k,l;\n memset(g,0,sizeof(g));\n scanf(\"%d %d %d %d %d %d\",&a,&b,&x1,&y1,&x2,&y2);\n/* for(i=0;i<64;i++) for(j=0;j<64;j++) {\n u=i;\n v=j;\n if(abs(u+v)%(2*a)==0) g[i][j]=1;\n if(abs(u-v)%(2*b)==0) g[i][j]=1;\n if(!g[i][j]) {\n k=i-j;\n l=j+i;\n A=k+b*100000000000LL;\n B=l+a*100000000000LL;\n A/=2*b;\n B/=2*a;\n h[i][j]='a'+B%26;\n }\n }\n for(j=0;j<64;j++) {for(i=0;i<64;i++) printf(\"%c\",g[i][j]?'*':h[i][j]);printf(\"\\n\");}\n*/\n solve(x1,y1,x2,y2,a,b);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ef115502907adfc3dae7b95ea475b817", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define ull unsigned long long\n\null w, m;\nbool solve(void){\n\tull cur;\n\tfor (cur=1; cur <= m; cur *= w){\n\t\tull k = m % (cur * w) / cur;\n\t\tif (k == 1)\n\t\t\tm = m - cur;\n\t\telse if (k == w-1)\n\t\t\tm = m + cur;\n\t\telse if (k != 0)\n\t\t\treturn false;\n\t}\n\treturn true;\n}\n\nint main(void){\n\tscanf(\"%llu %llu\", &w, &m);\n\tif (solve())\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "e0c62546b6fbfdfb18e1747c878a449e", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int w,m,i,k,j,flag=0;\n\tscanf(\"%I64d%I64d\",&w,&m);\n\tint a[101];\n\tk=m;\n\tfor(i=0;i<101;i++)\n\t{\n\t\ta[i]=k%w;\n\t\tk=k/w;\n\t}\n\tfor(i=0;i<101;i++)\n\t{\n\t\tif(a[i]!=1&&a[i]!=0)\n\t\t{\n\t\t\tif(a[i]<(w-1))\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ta[i+1]++;\n\t\t\t}\n\t\t}\n\t}\n\tif(flag==1)\n\t{\n\t\tprintf(\"NO\");\n\t}\n\telse\n\t{\n\t\tprintf(\"YES\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "meet-in-the-middle", "greedy", "number theory"], "code_uid": "9342c6b52d16a7299a4fb2f63300a45e", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.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\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 rightmostColumn = min(x, n);\n ll rightmostFullColumn = min(x, x/m);\n result += rightmostFullColumn * min(x, m);\n for (ll column = rightmostFullColumn + 1; column <= rightmostColumn; column++)\n result += min(x / column, m);\n //printf(\"%d %d %d %d\\n\", n, m, x, result);\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, 100) == 100);\n assert(findKthInList(10, 10, 99) == 90);\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": "564a8bb7decf58130b00bd148378d4b0", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long c,r,target,t2;\nlong long cnt(long long n)\n{\n long long i,j,num=0;\n for(i=1;i<=c;i++)\n {\n if(n%i==0 && n/i<=r) num++;\n }\n\n\n\n return num;\n}\nlong long table(long long n)\n{\n long long count=0,i,j;\n for(i=1;i<=c;i++)\n {\n\n if(i*r<=n) count+=r;\n else\n count+=n/i;\n }\n \n return count;\n}\n\n\n\nint main()\n{\n\n long long low,high,mid,t1,t2,r1;\n scanf(\"%lld %lld %lld\",&r,&c,&target);\n if(target==1) printf(\"1\\n\");\n else{\n low=0,high=r*c+1;\n while(low<=high)\n {\n mid=low+(high-low)/2;\n \n t1=table(mid);\n t2=table(mid-1);\n r1=cnt(mid);\n \n if(t2=target)) { printf(\"%lld\\n\",mid); break; }\n else if(t1>=target) {high=mid; }\n else low=mid;\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search"], "code_uid": "25fb3dc2a8655343aa2e4a2c99c35be3", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MD\t1000000007\n\nint power(int n, int k) {\n\tint p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(n, k / 2);\n\tp = (long long) p * p % MD;\n\tif (k % 2 == 1)\n\t\tp = (long long) p * n % MD;\n\treturn p;\n}\n\nint main() {\n\tint n, m, k, sum, x;\n\n\tscanf(\"%d%d\", &n, &m);\n\tsum = 0;\n\tfor (k = 0; k < n; k++) {\n\t\tx = power(m + m - 1, k); /* Binomial theorem */\n\t\tsum = (sum + (long long) x * m % MD * power(m, n - 1 - k)) % MD;\n\t}\n\tprintf(\"%d\\n\", (sum + power(m, n)) % MD);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "a5314f279c9099adc838bce495003ff2", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\nint n,m,i,j,a,b;\nscanf(\"%d %d %d %d %d %d\",&n,&m,&i,&j,&a,&b);\nint x,y,h;\nint ma[4];\nfor(h=0;h<4;h++)\n{ma[h]=999999;\n}\nif(((i==n)&&(j==m))||((i==1)&&(j==m))||((i==1)&&(j==1))||((i==n)&&(j==1)))\n{\n printf(\"0\\n\");\n return 0;\n}\nif((b>=m)||(a>=n))\n{\nprintf(\"Poor Inna and pony!\\n\");\nreturn 0;\n}\nif((((i-1)%a)==0)&&(((j-1)%b)==0))\n{\n if(((i-1)/a+(j-1)/b)%2==0)\nma[0]=((i-1)/(a)>(j-1)/(b)?(i-1)/(a):(j-1)/(b));\n //printf(\"here %d\\n\",ma[0]);\n\n}\nif((((i-1)%a)==0)&&(((m-j)%b)==0))\n{\n if(((i-1)/a+(m-j)/b)%2==0)\nma[1]=((i-1)/(a)>(m-j)/(b)?(i-1)/(a):(m-j)/(b));\n //printf(\"hrtyr %d\\n\",ma[1]);\n}\nif((((n-i)%a)==0)&&(((j-1)%b)==0))\n{\n if(((n-i)/a+(j-1)/b)%2==0)\nma[2]=((n-i)/(a)>(j-1)/(b)?(n-i)/(a):(j-1)/(b));\n\n //printf(\"hrtyr3 %d\\n\",ma[2]);\n}\nif((((n-i)%a)==0)&&(((m-j)%b)==0))\n{\n if(((n-i)/a+(m-j)/b)%2==0)\nma[3]=((n-i)/(a)>(m-j)/(b)?(n-i)/(a):(m-j)/(b));\n\n\n // printf(\"hrtyr4 %d\\n\",ma[3]);\n}\n\n\n/*if(((n-i)%(2*a)==0)&&((m-j)==0))\n{ma[4]=(n-i)/a;\n //printf(\"hrtyr4 %d\\n\",ma[4]);\n}\nelse if(((m-j)%(2*b)==0)&&((n-i)==0))\n{\nma[4]=(m-j)/b;\n //printf(\"hrtyr4 %d\\n\",ma[4]);\n\n}\nif(((i-1)%(2*a)==0)&&(j-1==0))\n{\nma[5]=(i-1)/a;\n // printf(\"here %d\\n\",ma[0]);\n\n}\nelse if(((j-1)%(2*b)==0)&&(i-1==0))\n{\nma[5]=(j-1)/b;\n //printf(\"here %d\\n\",ma[0]);\n\n}\n\n\n\nif(((i-1)%(2*a)==0)&&(j-m==0))\n{\nma[6]=(i-1)/a;\n //printf(\"here %d\\n\",ma[6]);\n\n}\nelse if(((j-1)%(2*b)==0)&&(i-n==0))\n{\n ma[6]=(j-1)/b;\n //printf(\"here %d\\n\",ma[6]);\n\n}\n\n\nif(((n-i)%(2*a)==0)&&(j-1==0))\n{\nma[7]=(n-i)/a;\n //printf(\"here %d\\n\",ma[7]);\n\n}\nelse if(((m-j)%(2*b)==0)&&(i-1==0))\n{\n ma[7]=(m-j)/b;\n //printf(\"here %d\\n\",ma[7]);\n\n}\n\n\n\n\n*/\n\n\n\nint temp=ma[0];\nfor(h=0;h<4;h++)\n{\n if(temp>ma[h])\n temp=ma[h];\n}\nif(temp==999999)\nprintf(\"Poor Inna and pony!\\n\");\nelse\nprintf(\"%d\\n\",temp);\n return 0;\n\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "6adc9df9d9c88b8313ccd2d68214e95f", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint calc_moves(int, int, int, int, int, int);\nint min(int, int);\n\nint main(){\n \n int i, j, x, y, n, m, a, b;\n scanf(\"%d %d %d %d %d %d\", &n, &m, &x, &y, &a, &b);\n\n int sol1 = calc_moves(x, y, 1, 1, a, b);\n int sol2 = calc_moves(x, y, 1, m, a, b);\n int sol3 = calc_moves(x, y, n, 1, a, b);\n int sol4 = calc_moves(x, y, n, m, a, b);\n\n if (sol1 == -1 && sol2 == -1 && sol3 == -1 && sol4 == -1) {\n printf(\"Poor Inna and pony!\\n\");\n }\n else {\n int sol = min(sol1, min(sol2, min(sol3, sol4)));\n if (sol > 0 && ((x - a < 1 && x + a > n) || (y - b < 1 && y + b > m))) {\n printf(\"Poor Inna and pony!\\n\");\n }\n else {\n printf(\"%d\\n\", sol);\n }\n }\n\n#ifdef _AT_HOME_\n system(\"pause\");\n#endif\n\n return 0;\n}\n\nint calc_moves(int start_x, int start_y, int finish_x, int finish_y, int step_x, int step_y) {\n\n int dx = abs(start_x - finish_x);\n int dy = abs(start_y - finish_y);\n\n if (dx % step_x != 0 || dy % step_y != 0) {\n return -1;\n }\n\n int sx = dx / step_x;\n int sy = dy / step_y;\n\n if (abs(sx - sy) & 1) {\n return -1;\n }\n else {\n return (sx > sy)?sx:sy;\n }\n\n}\n\nint min(int a, int b) {\n if (a == -1 || b == -1) {\n return -a*b;\n }\n else{\n return (a > b)?b:a;\n }\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "3690db51a6022b54a0cdc4c757ce5df2", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\ntypedef long long ll;\n\nint main(int argc, char ** argv){\n\t\n\tll MAX = 823543;\n\tll n,m;\n\tscanf(\"%lld%lld\",&n,&m);\n\tif(n>MAX || m>MAX){\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tll num_dg_hr = 1;\n\tll num_dg_min = 1;\n\tll x1 = 7*num_dg_hr;\n\tll x2 = 7*num_dg_min;\n\twhile((n-1)/x1!=0){\n\t\tnum_dg_hr++;\n\t\tx1*=7;\n\t}\n\twhile((m-1)/x2!=0){\n\t\tnum_dg_min++;\n\t\tx2*=7;\n\t}\n\tif(num_dg_min+num_dg_hr>7){\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tll i,j;\n\tll ans = 0;\n\tfor(i=0; i1){\n\t\t\t\tflag = false;\n\t\t\t}\n\t\t}\n\t\tif(flag){\n\t\t\tans++;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\",ans);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "combinatorics"], "code_uid": "4605c361f44a3eb8c6d383c405da10b9", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n\nint check(int a, int b, int c)\n{\n\tint oc[7]={0}, sum=0,flag=0,i=0;\n\t\n\twhile(a)\n\t{\n\t\tif(oc[a%7]) {flag=1;break;}\n\t\telse oc[a%7]++;\n\t\ta/=7;\n\t\tsum++;\n\t}\n\t\n\twhile(b&&!flag)\n\t{\n\t\tif(oc[b%7]) {flag=1;break;}\n\t\toc[b%7]++;\n\t\tb/=7;\n\t\tsum++;\n\t}\n\t\n\tif(c-sum>1) flag=1;\n\t\n\tif(c-sum>0 && oc[0]==1) flag=1;\n\t\n\tif(flag==1) return 0;\n\t\n\telse return 1;\n}\n\nint main(void) {\n\tint n,m,i=0,a,d=0,ans=0;\n\t\n\tscanf(\"%d %d\",&n,&m);\n\n\ta=n-1;\n\twhile(1)\n\t{\n\t\td++;\n\t\ta/=7;\n\t\tif(a==0) break;\n\t}\n\t\n\ta=m-1;\n\twhile(1)\n\t{\n\t\td++;\n\t\ta/=7;\n\t\tif(a==0) break;\n\t}\n\t\n\tif(d>7) printf(\"0\");\n\t\n\telse\n\t{\n\t\ti=0;\n\t\twhile(i\n\nint main(){\n int z,k;\n scanf(\"%i\",&z);\n for(k=0;k\nint main()\n{\n\tint t;\n\tscanf(\"%d\", &t);\n\tint n, k, d;\n\tint a[200005];\n\tint c[1000006];\n\tint count, ans;\n\tint i, j;\n\tfor (j = 0; j < t; j++)\n\t{\n\t\tscanf(\"%d %d %d\", &n, &k, &d);\n\t\tfor (i = 0; i < n; i++)\n\t\t\tscanf(\"%d\", &a[i]);\n\t\tfor (i = 0; i <= k; i++)\n\t\t\tc[i] = 0;\n\t\tcount = 0;\n\t\tfor (i = 0; i < d; i++)\n\t\t{\n\t\t\tif (c[a[i]] == 0)\n\t\t\t\tcount++;\n\t\t\tc[a[i]]++;\n\t\t}\n\t\tans = count;\n\t\tfor (i = 1; i + d - 1 < n; i++)\n\t\t{\n\t\t\tif (c[a[i + d - 1]] == 0)\n\t\t\t\tcount++;\n\t\t\tc[a[i + d - 1]]++;\n\t\t\tif (c[a[i - 1]] == 1)\n\t\t\t\tcount--;\n\t\t\tc[a[i - 1]]--;\n\t\t\tif (ans > count)\n\t\t\t\tans = count;\n\t\t}\n\t\tprintf(\"%d\\n\", ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fdec11e448c6a05df99375e2f70362d0", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nchar Flag[1000000];\nint A[1000000];\n\nint ModExp(int n, int m, int p)\n{\n int k = 1;\n n %= p;\n while(m != 1) {\n if(m & 1) {\n k = ((long long)k * n) % p;\n }\n n = ((long long)n * n) % p;\n m >>= 1;\n }\n return ((long long)n * k) % p;\n}\n\nint main()\n{\n int p, k, i, exp = 0;\n scanf(\"%d %d\", &p, &k);\n if(k == 0) {\n printf(\"%d\\n\", ModExp(p, p - 1, 1000000007));\n return 0;\n } else if(k == 1) {\n printf(\"%d\\n\", ModExp(p, p, 1000000007));\n return 0;\n }\n for(i = 1; i < p; ++i) {\n A[((long long)i * k) % p] = i;\n }\n for(i = 1; i < p; ++i) {\n if(!Flag[i]) {\n ++exp;\n }\n int j = i;\n while(!Flag[j]) {\n Flag[j] = 1;\n j = A[j];\n }\n }\n printf(\"%d\\n\", ModExp(p, exp, 1000000007));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "math", "combinatorics", "number theory"], "code_uid": "20a29ed53903ebc7c210f4d1727cd5e9", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nint p, k;\nbool visited[1000010];\n\nint expo(int a, int b){\n long long res = 1;\n\n while (b){\n if (b & 1) res = res * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return res;\n}\n\nint main(){\n long long i, j, res, counter;\n\n while (scanf(\"%lld %lld\", &p, &k) != EOF){\n counter = 0;\n clr(visited);\n for (i = 0; i < p; i++){\n if (!visited[i]){\n counter++;\n visited[i] = true;\n j = (i * k) % p;\n while (!visited[j]){\n visited[j] = true;\n j = (j * k) % p;\n }\n }\n }\n\n if (k == 1) res = expo(p, p);\n else res = expo(p, --counter);\n printf(\"%lld\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "combinatorics", "dsu", "number theory"], "code_uid": "c7be5e5036106db83e50b73bc3efcd4e", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MOD 1000000007\n\nint dp[5001][5001];\n\nint main(void) {\n\tint i, j;\n\tint n, a, b, k;\n\tint ans;\n\n\tscanf(\"%d %d %d %d\", &n, &a, &b, &k);\n\n\tdp[0][a] = 1;\n\tfor (i = 1; i <= k; i++) {\n\t\tint sum[5001];\n\n\t\tsum[0] = 0;\n\t\tfor (j = 1; j <= n; j++) {\n\t\t\tsum[j] = sum[j - 1] + dp[i - 1][j];\n\t\t\tif (sum[j] >= MOD)\n\t\t\t\tsum[j] -= MOD;\n\t\t}\n\n\t\tfor (j = 1; j <= n; j++)\n\t\t\tif (j < b) {\n\t\t\t\tdp[i][j] = sum[(j + b - 1) / 2] - dp[i - 1][j] + MOD;\n\t\t\t\tif (dp[i][j] >= MOD)\n\t\t\t\t \tdp[i][j] -= MOD;\n\t\t\t} else if (j > b) {\n\t\t\t\tdp[i][j] = sum[n] - sum[(j + b) / 2] + MOD;\n\t\t\t\tif (dp[i][j] >= MOD)\n\t\t\t\t\tdp[i][j] -= MOD;\n\t\t\t\tdp[i][j] += -dp[i - 1][j] + MOD;\n\t\t\t\tif (dp[i][j] >= MOD)\n\t\t\t\t\tdp[i][j] -= MOD;\n\t\t\t}\n\t}\n\n\tans = 0;\n\tfor (j = 1; j <= n; j++)\n\t\tans = (ans + dp[k][j]) % MOD;\n\n\tprintf(\"%d\\n\", ans);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "implementation", "combinatorics"], "code_uid": "c4bd29eb8f894820d6f2dc77ad0020ba", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long d[5005][5005];\nlong long bef[5005], aft[5005];\n\nint main(){\n\tint n, a, b, k;\n\tscanf(\"%d %d %d %d\", &n, &a, &b, &k);\n\n\td[0][a] = 1;\n\n\tint t, i;\n\tlong long sum = 0;\n\n\tif (a < b) {\n\t\tfor (t = 1; t <= k; t++){\n\t\t\tfor (i = 1; i < b; i++){\n\t\t\t\tbef[i] = bef[i - 1] + d[t - 1][i - 1];\n\t\t\t\tbef[i] %= 1000000007;\n\t\t\t}\n\t\t\tfor (i = b - 1; i >= 1; i--){\n\t\t\t\taft[i] = aft[i + 1] + d[t - 1][i + 1] - ((b - i) % 2 ? 0 : d[t - 1][(i + b) / 2]);\n\t\t\t\taft[i] = (aft[i] + 1000000007) % 1000000007;\n\t\t\t}\n\t\t\tfor (i = 1; i < b; i++){\n\t\t\t\td[t][i] = bef[i] + aft[i];\n\t\t\t\td[t][i] %= 1000000007;\n\t\t\t}\n\t\t}\n\t\tfor (i = 1; i < b; i++){\n\t\t\tsum += d[k][i];\n\t\t\tsum %= 1000000007;\n\t\t}\n\t}\n\telse {\n\t\tfor (t = 1; t <= k; t++){\n\t\t\tfor (i = n; i > b; i--){\n\t\t\t\tbef[i] = bef[i + 1] + d[t - 1][i + 1];\n\t\t\t\tbef[i] %= 1000000007;\n\t\t\t}\n\t\t\tfor (i = b + 1; i <= n; i++){\n\t\t\t\taft[i] = aft[i - 1] + d[t - 1][i - 1] - ((i - b) % 2 ? 0 : d[t - 1][(b + i) / 2]);\n\t\t\t\taft[i] = (aft[i] + 1000000007) % 1000000007;\n\t\t\t}\n\t\t\tfor (i = n; i > b; i--){\n\t\t\t\td[t][i] = bef[i] + aft[i];\n\t\t\t\td[t][i] %= 1000000007;\n\t\t\t}\n\t\t}\n\t\tfor (i = n; i > b; i--){\n\t\t\tsum += d[k][i];\n\t\t\tsum %= 1000000007;\n\t\t}\n\t}\n\tprintf(\"%lld\", sum);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "1dfaba34f406c47a4a201b9677d40b15", "src_uid": "142b06ed43b3473513995de995e19fc3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\ntypedef struct GG\n{\n int x1,y1,x2,y2;\n};\n\nint main()\n{\n struct GG gg1,gg2,gg3;\n scanf(\"%d%d%d%d\",&gg1.x1,&gg1.y1,&gg1.x2,&gg1.y2);\n scanf(\"%d%d%d%d\",&gg2.x1,&gg2.y1,&gg2.x2,&gg2.y2);\n scanf(\"%d%d%d%d\",&gg3.x1,&gg3.y1,&gg3.x2,&gg3.y2);\n \n getchar();\n \n if(gg2.x1 <= gg1.x1 && gg2.y1 <= gg1.y1 && gg2.x2 >= gg1.x2 && gg2.y2 >= gg1.y2)\n {\n printf(\"NO\");\n }//b\u5168\u8986\u76d6a\n \n else if(gg3.x1 <= gg1.x1 && gg3.y1 <= gg1.y1 && gg3.x2 >= gg1.x2 && gg3.y2 >= gg1.y2)\n {\n printf(\"NO\");\n }//c\u5168\u8986\u76d6a\n \n else if(gg2.y1 <= gg1.y1 && gg2.y2 >= gg1.y2 && gg3.y1 <= gg1.y1 && gg3.y2 >= gg1.y2 && gg2.x1 <= gg1.x1 && gg3.x1 <= gg2.x2 && gg3.x2 >= gg1.x2)\n {\n printf(\"NO\");\n }//b,c\u5de6\u53f3\u8986\u76d6\n \n else if(gg3.y1 <= gg1.y1 && gg3.y2 >= gg1.y2 && gg2.y1 <= gg1.y1 && gg2.y2 >= gg1.y2 && gg3.x1 <= gg1.x1 && gg2.x1 <= gg3.x2 && gg2.x2 >= gg1.x2)\n {\n printf(\"NO\");\n }//c,b\u5de6\u53f3\u8986\u76d6\n \n else if(gg3.x1 <= gg1.x1 && gg3.x2 >= gg1.x2 && gg2.x1 <= gg1.x1 && gg2.x2 >= gg1.x2 && gg3.y1 <= gg1.y1 && gg2.y2 >=gg1.y2 && gg3.y2 >= gg2.y1)\n {\n printf(\"NO\");\n }\n \n else if(gg2.x1 <= gg1 .x1 && gg2.x2 >= gg1.x2 && gg3.x1 <= gg1.x1 && gg3.x2 >= gg1.x2 && gg2.y1 <= gg1.y1 && gg3.y2 >= gg1.y2 && gg2.y2 >=gg3.y1)\n {\n printf(\"NO\");\n }\n \n else{\n printf(\"YES\");\n }\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "d400b9c1c51dcc031c9d8634fe4a2b6d", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main(){\n\tint x[3][2], y[3][2], i;\n\tfor(i=0;i<6;++i) scanf(\"%d %d\", x[0]+i, y[0]+i);\n\tif((x[0][0]>=x[1][0] && y[0][0]>=y[1][0] && x[0][1]<=x[1][1] && y[0][1]<=y[1][1]) ||\n\t\t\t(x[0][0]>=x[2][0] && y[0][0]>=y[2][0] && x[0][1]<=x[2][1] && y[0][1]<=y[2][1])){\n\t\tputs(\"NO\");\n\t\treturn 0;\n\t}\n\tif(x[1][0]<=x[0][0] && x[0][1]<=x[1][1] && x[2][0]<=x[0][0] && x[0][1]<=x[2][1] &&\n\t\t\t((y[1][0]<=y[0][0] && y[1][1]>=y[2][0] && y[0][1]<=y[2][1]) ||\n\t\t\t (y[2][0]<=y[0][0] && y[2][1]>=y[1][0] && y[0][1]<=y[1][1]))){\n\t\tputs(\"NO\");\n\t\treturn 0;\n\t}\n\tif(y[1][0]<=y[0][0] && y[0][1]<=y[1][1] && y[2][0]<=y[0][0] && y[0][1]<=y[2][1] &&\n\t\t\t((x[1][0]<=x[0][0] && x[1][1]>=x[2][0] && x[0][1]<=x[2][1]) ||\n\t\t\t (x[2][0]<=x[0][0] && x[2][1]>=x[1][0] && x[0][1]<=x[1][1]))){\n\t\tputs(\"NO\");\n\t\treturn 0;\n\t}\n\tputs(\"YES\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "dd9fe711fa0b025cfb13970b8ec3f6df", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main(int argc,char** argv){\n int a,b,c,d;\n int delta;\n float q;\n scanf(\"%d %d %d %d\",&a,&b,&c,&d);\n delta = b -a;\n if( (c-b) == delta && (d - c) == delta)\n {\n printf(\"%d\\n\",d+delta);\n }\n else\n {\n q = b/(float)a;\n if(q!= 0 && q!=1 && c/(float)b == q && d/(float)c == q){\n a = (int)((float)d*q*10) ;\n b = ((int)(d *q)) *10;\n if(a == b)\n printf(\"%d\\n\",(int)((float)d*q));\n else\n printf(\"42\\n\");\n }else{\n printf(\"42\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "226178505bfd5eefc114d4832f7adc08", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\nint n,i,k;\nfloat j;\nfloat arr[4];\n\nfor(i=0 ; i<4 ; i++)\n\tscanf(\"%f\" , &arr[i]);\n\t\n\nif(arr[1]-arr[0]==arr[2]-arr[1] && arr[2]-arr[1]==arr[3]-arr[2])\n{\n\tj =arr[3]+arr[1]-arr[0];\n\tk=j;\n\tif(j==k)\n\tprintf(\"%d\",k);\n\telse\n\tprintf(\"42\");\n}\n\nelse if(arr[1]/arr[0]==arr[2]/arr[1] && arr[2]/arr[1]==arr[3]/arr[2])\n{\n\tj = arr[3]*(arr[1]/arr[0]);\n\tk =j;\n\tif(j == k)\n\tprintf(\"%d\" , k);\n\telse\n\tprintf(\"42\");\n}\nelse\n\tprintf(\"42\");\n\n\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "04ecde7453218bc1650d72ad895f6c40", "src_uid": "68a9508d49fec672f9c61766d6051047", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define MAX_SIZE(X) ((unsigned short)(X))\nvoid MSA(short, short, unsigned short*);\nvoid Merge(short, short, short, unsigned short*);\nint main()\n{\n unsigned short Seq[MAX_SIZE(1e2)], Cut[MAX_SIZE(1e2)], n, b, i, j = 0, Odd = 0, Even = 0, max = 0, Sum = 0;\n scanf(\"%hu%hu\", &n, &b);\n for(i = 0; i < n; i++){ scanf(\"%hu\", Seq + i); }\n for(i = 0; i < n - 2; i++){\n if(Seq[i] % 2 == 0){ Even++; }\n else{ Odd++; }\n if(Odd == Even){ Cut[j++] = Seq[i] > Seq[1 + i] ? Seq[i] - Seq[1 + i] : Seq[1 + i] - Seq[i]; }\n }\n MSA(0, j - 1, Cut);\n for(i = 0; i < j; i++){\n Sum += Cut[i];\n if(Sum > b){ break; }\n max++;\n }\n printf(\"%hu\", max);\n\n return 0;\n}\nvoid MSA(short l, short r, unsigned short* A){\n if(l < r){\n unsigned short m = (l + r) / 2;\n MSA(l, m, A);\n MSA(1 + m, r, A);\n Merge(l, m, r, A);\n }\n}\nvoid Merge(short l, short m, short r, unsigned short* A){\n unsigned short s1 = m - l + 1, s2 = r - m, i, j;\n unsigned short A1[s1], A2[s2];\n for(i = 0; i < s1; i++){ A1[i] = A[i + l]; }\n for(j = 0; j < s2; j++){ A2[j] = A[j + m + 1]; }\n i = 0, j = 0;\n while(i < s1 && j < s2){ A[l++] = A1[i] < A2[j] ? A1[i++] : A2[j++]; }\n while(i < s1){ A[l++] = A1[i++]; }\n while(j < s2){ A[l++] = A2[j++]; }\n\n}\n", "lang_cluster": "C", "tags": ["sortings", "dp", "greedy"], "code_uid": "16390b5733f49caa8babf38d259d4ed5", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint memo[101][101][101];\nint max(int a,int b){\n if(a>b)\n return a;\n return b;\n}\nint fun(int i,int p,int b,int n,int a[],int O[],int E[]){\n if(memo[i][p][b]!=-1)\n return memo[i][p][b];\n if(i==n){\n if(O[i]-O[p]==E[i]-E[p]){\n memo[i][p][b] = 0;\n return 0;\n }\n memo[i][p][b] = -10000;\n return -10000;\n }\n if(O[i]-O[p]==E[i]-E[p]){\n int aa,bb;\n aa = 0; \n bb = 0;\n if(abs(a[i]-a[i+1])<=b){\n aa = 1 + fun(i+1,i,b-abs(a[i]-a[i+1]),n,a,O,E);\n// printf(\"%d\\n\",aa);\n }\n bb = fun(i+1,p,b,n,a,O,E);\n memo[i][p][b] = max(aa,bb);\n return memo[i][p][b];\n }\n memo[i][p][b]= fun(i+1,p,b,n,a,O,E);\n return memo[i][p][b];\n}\n\nint main(){\n\n int n,i,j,k,b;\n scanf(\"%d%d\",&n,&b);\n int a[n+1],O[n+1],E[n+1];\n O[0] = E[0] = 0;\n for(i=1;i<=n;i++){\n scanf(\"%d\",&a[i]);\n if(a[i]%2==0){\n E[i] = E[i-1]+1;\n O[i] = O[i-1];\n }else{\n O[i] = O[i-1] + 1;\n E[i] = E[i-1] ;\n }\n }\n for(i=0;i<=n;i++){\n for(j=0;j<=n;j++){\n for(k=0;k<=b;k++){\n memo[i][j][k] = -1;\n }\n }\n }\n printf(\"%d\",fun(1,0,b,n,a,O,E));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "dp", "greedy"], "code_uid": "3c525995746fc5844d6ffd682daee325", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define INF ~0ULL\n#define ULL unsigned long long\nULL p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};\nULL n, ans;\nvoid dfs(ULL depth, ULL temp, ULL num, ULL up)\n{\n if (num == n && temp < ans) ans = temp;\n if (num >= n || depth == 16) return;\n for (int i = 1; i <= up; ++i)\n {\n if (temp * p[depth] >= ans) return;\n else dfs(depth + 1, temp = temp * p[depth], num * (i + 1), i);\n }\n}\nint main()\n{\n while (scanf(\"%llu\", &n) != EOF)\n {\n ans = INF;\n dfs(0, 1, 1, 64);\n printf(\"%llu\\n\", ans);\n }\n}", "lang_cluster": "C", "tags": ["brute force", "dp", "number theory"], "code_uid": "df40398051f0afd01728c7ed6feb6873", "src_uid": "62db589bad3b7023418107de05b7a8ee", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\ntypedef long long LL;\n#define debug(i) printf(\"->%d\\n\",i)\n\nLL min(LL a,LL b){\n if(a>b)return b;\n else return a;\n}\n\nLL pri[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};\n //\u4e3a\u4ec0\u4e48\u5c31\u7b97\u662f1e18\u4e5f\u53ea\u9700\u8981\u8fd9\u4e9b\u6570\u5c31\u591f\u4e86\u5462? \u56e0\u4e3a\u8d8a\u5f80\u540e,\u524d\u9762\u7684\u6b21\u65b9\u5c31\u8d8a\u591a\nLL ans,n;\nvoid dfs(LL Y,LL dep,LL num){\n //\u56e0\u5b50\u6570 \u6df1\u5ea6 \u5f53\u524d\u7684\u6570\n if(dep==16)return;\n if(Y==n)ans=min(ans,num);\n if(Y>=n)return;\n for(int i=1;i<=63;i++){\n if(ans/pri[dep]\nint zuida(int a)\n{\n int t11;\n for(t11=a-1;t11>=1;t11--)\n {\n if(a%t11==0)\n break;\n }\n return t11;\n}\nint main()\n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n int zhong1;\n int zhong2;\n int t1;\n int out[20],ppp=1;\n zhong2=n;\n for(t1=0;;t1++)\n {\n zhong1=zuida(zhong2);\n //printf(\"%d:%d \",t1,zhong1);\n if(zhong1==1)\n break;\n else\n zhong2=zhong1;\n }\n //printf(\"%d\\n\",t1+1);\n if(t1+1>=k)\n {\n zhong2=n;\n for(t1=0;t1\n\nint main(int argc, const char * argv[]) {\n \n int k = 0, n = 0, i = 1, arr[20], temp = 0;\n \n scanf(\"%d%d\", &n, &k);\n \n temp = k;\n \nline:\n \n if(n%2 == 0) {\n \n if(k == 1){\n \n while(temp > 1){\n printf(\"%d \", arr[temp]);\n \n temp--;\n }\n \n printf(\"%d\", n);\n return 0;\n }\n \n n/=2 ;\n arr[k] = 2;\n --k;\n \n goto line;\n }else{\n \n for(i = 3; i <= n; i += 2){\n \n if(n%i == 0){\n \n arr[k] = i;\n k--;\n \n if(k == 0) break;\n n/=i;\n i-=2;\n\n }\n \n }\n \n }\n if(k == 0){\n \n while(temp > 1){\n printf(\"%d \", arr[temp]);\n \n temp--;\n }\n \n printf(\"%d\", n);\n \n }else{\n printf(\"-1\");\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "9b85e9a5de94685b2e98d29c73a43e30", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tint t, s, q, count = 0;\n\tscanf(\"%d%d%d\",&t, &s, &q);\n\twhile(s < t)\n\t{\n\t\tcount++;\n\t\ts *= q;\n\t}\n\tprintf(\"%d\\n\", count);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "72931802f8e723f4b1518d313ce3ab1d", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong duration, downloaded, q, counter = 0;\n\tscanf(\"%ld %ld %ld\", &duration, &downloaded, &q);\n\twhile (downloaded < duration)\n\t{\n\t\tcounter++;\n\t\tdownloaded += (q-1)*downloaded;\n\t}\n\tprintf(\"%ld\\n\", counter);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "043a907818825535f6c623ee625a4f9b", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long a, b, c, n;\n\t\n\tscanf(\"%lld%lld\",&a,&b);\n\n//\tif(a==0&&b!=0)\n//\t{\n//\t\tprintf(\"%d\",b%10);\n//\t\treturn 0;\n//\t}\n\n\tif(a==0&&b==0||a==b)\n\t{\n\t\tprintf(\"1\");\n\t}\n\telse if (b-a >= 10)\n\t{\n\t\tprintf(\"0\");\n\t}\n\telse\n\t{\n\t\tc=1;\n\t\tfor(long long i=b;i>a;i--){\n\t\t\tc=c*i;\n\t\t\tc=c%10;\n\t\t}\n\t\t\t\n\t\t\n\t\t//n=c%10;\n\t\tprintf(\"%lld\",c);\n\t}\t\n\t\n\treturn 0;\n\t\n}\n\n\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "f82ebad40d2e5470c541162a5cbd84e4", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint fact(unsigned long long x,unsigned long long y){\n\tint z = 1;\n\tunsigned long long i = x+1;\n\twhile(i <= y && z != 0){\n\t\tz = (z*i)%10;\n\t\ti++;\n\t}\n\treturn z;\n}\nint main(){\n\tunsigned long long x, y; scanf(\"%llu%llu\", &x, &y);\n\t//if(x == 0) printf(\"%d\", y%10);\n printf(\"%d\", fact(x, y));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "31e6f3af0ce2878120e50325300b90a6", "src_uid": "2ed5a7a6176ed9b0bda1de21aad13d60", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\n#define ll long long\n\nconst ll M = 1000000007;\n\nll inv(ll a, ll M)\n{\n if (a < 0)\n a = (a + (1+(0-a)/M)*M)%M;\n ll M_o = M;\n ll ac0 = 1;\n ll ac1 = 0;\n ll bc0 = 0;\n ll bc1 = 1;\n ll q;\n ll r;\n ll temp;\n while (M > 0)\n {\n q = a/M;\n r = a%M;\n a = M;\n M = r;\n\n temp = ac0;\n ac0 = bc0;\n bc0 = temp - q*bc0;\n\n temp = ac1;\n ac1 = bc1;\n bc1 = temp - q*bc1;\n }\n M = M_o;\n if (ac0 > 0)\n return ac0%M;\n else\n return (ac0 + M*(1+(0-ac0)/M))%M;\n}\n\nll expmod(ll a, ll x, ll m)\n{\n ll ans = 1;\n while (x > 0)\n {\n if (x%2 == 1)\n ans = ans*a%m;\n a = a*a%m;\n x /= 2;\n }\n if (ans > 0)\n return ans%M;\n else\n return (ans + M*(1 + (0-ans)/M))%M;\n}\n\nint main()\n{\n int n, m;\n int ai, bi;\n int ki;\n\n fscanf(stdin, \"%d %d\\n\", &n, &m);\n fscanf(stdin, \"%d %d\\n\", &ai, &bi);\n fscanf(stdin, \"%d\", &ki);\n\n ll a = (ll) ai;\n ll b = (ll) bi;\n ll k = (ll) ki;\n\n ll p = a*inv(b, M)%M;\n\n ll* kchoose = malloc((m+1)*sizeof(ll));\n kchoose[0] = 1;\n for (int l = 1; l < m+1; l++)\n kchoose[l] = (kchoose[l-1]*(k-l+1)%M)*inv(l,M)%M;\n\n ll* expmodp = malloc((m+1)*sizeof(ll));\n ll* expmod1pkminus = malloc((m+1)*sizeof(ll));\n expmodp[0] = 1;\n expmod1pkminus[0] = expmod(1-p, k, M);\n ll inv1p = p!=1? inv(1-p, M):1;\n\n for (int x = 1; x < m+1; x++)\n {\n expmodp[x] = p*expmodp[x-1]%M;\n if (p != 1)\n expmod1pkminus[x] = inv1p*expmod1pkminus[x-1]%M;\n else\n expmod1pkminus[x] = x k)\n p_left[l] = 0;\n else\n p_left[l] = (((kchoose[l]*expmodp[l])%M)*expmod1pkminus[l])%M;\n }\n\n ll* egs1 = malloc((m+1)*sizeof(ll));\n ll* egs2 = malloc((m+1)*sizeof(ll));\n ll* sle1 = malloc((m+1)*sizeof(ll));\n ll* sle2 = malloc((m+1)*sizeof(ll));\n\n ll* R = malloc(m*sizeof(ll));\n ll* T = malloc((m+1)*sizeof(ll));\n T[m] = 1;\n for (int i = 0; i < m; i++)\n {\n R[i] = 1;\n T[i] = 0;\n }\n\n ll* Tp_left = malloc(m*sizeof(ll));\n ll* Rp_left = malloc(m*sizeof(ll));\n\n for (int ni = 0; ni < n; ni++)\n {\n egs1[m] = 0;\n egs2[m] = 0;\n\n for (int i = 0; i < m; i++)\n Rp_left[i] = R[i]*p_left[m-(i+1)]%M;\n\n for (int s = m-1; s >= 0; s--)\n {\n egs1[s] = (egs1[s+1] + Rp_left[s])%M;\n egs2[s] = (egs2[s+1] + p_left[m-(s+1)])%M;\n }\n\n sle1[0] = 0;\n sle2[0] = 0;\n\n for (int i = 0; i < m; i++)\n Tp_left[i] = T[i]*p_left[i]%M;\n\n for (int e = 1; e < m+1; e++)\n {\n sle1[e] = (sle1[e-1] + p_left[e-1])%M;\n sle2[e] = (sle2[e-1] + Tp_left[e-1])%M;\n }\n\n R[0] = (p_left[0]*egs1[0]%M - Tp_left[0]*egs2[0]%M + M)%M;\n for (int s = 1; s < m; s++)\n R[s] = (R[s-1] + p_left[s]*egs1[s]%M - Tp_left[s]*egs2[s]%M + M) % M;\n\n T[0] = 0;\n for (int e = 1; e < m+1; e++)\n T[e] = (T[e-1] + Rp_left[e-1]*sle1[e]%M - p_left[m-e]*sle2[e]%M + M)%M;\n }\n\n printf(\"%lld\\n\", T[m]);\n}\n", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "3d00db271dfd0cb7df86896665fa53fd", "src_uid": "33b6b0d3a6af273f22b703491bd17289", "difficulty": 3100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n\ni64 gcd (i64 a, i64 b) {\n i64 r = a % b;\n while (r > 0) {\n a = b;\n b = r;\n r = a % b;\n }\n return b;\n}\n\nvoid run (void) {\n const i32 n = read_int();\n const i32 k = read_int();\n const i32 a = read_int();\n const i32 b = read_int();\n const i64 m = (i64) n * k;\n i64 min = (i64) n * k;\n i64 max = 1;\n for (i32 i = 0; i < 4; ++i) {\n const i32 s = i >= 2 ? a : (k - a) % k;\n for (i32 j = 0; j < 4; ++j) {\n i32 t = (j & 1) ? (k - b) % k : b;\n if (t <= s) {\n\ti64 d = m - (s - t);\n\ti64 v = m / gcd (d, m);\n\tmin = MIN(min, v);\n\tmax = MAX(max, v);\n\tt += k;\n }\n for (i64 l = t; l < m; l += k) {\n\ti64 d = l - s;\n\ti64 v = m / gcd (d, m);\n\tmin = MIN(min, v);\n\tmax = MAX(max, v);\n }\n }\n }\n print_int (min);\n putchar(' ');\n print_int (max);\n puts(\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "69bc5181114c7fb8044bc79712e34fdf", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\nint64_t gcd(int64_t a, int64_t b){\n\treturn b==0? a: gcd(b, a%b);\n}\n\nint main(){\n\tint n, k, a, b, i, stp[4];\n\tint64_t min_t, max_t, dis, t, l;\n\n\tmin_t = INT64_MAX, max_t = INT64_MIN;\n\n\tscanf(\"%d%d%d%d\", &n, &k, &a, &b);\n\tdis = (int64_t)n * k;\n\tstp[0] = a-b, stp[1] = b-a, stp[2] = a+b, stp[3] = k-a-b;\n\n\tfor(i = 0; i < 4; i++){\n\t\tfor(l = stp[i]; l <= dis; l += k){\n\t\t\tif(l <= 0)\n\t\t\t\tcontinue;\n\t\t\tt = dis / gcd(dis, l);\n\t\t\tmin_t = min_tt? max_t: t;\n\t\t}\n\t}\n\n\tprintf(\"%\" PRIi64 \" %\" PRIi64 \"\\n\", min_t, max_t);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "5b5d0ff2ecaee5973c3e7bc7379b5e3a", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tint k1, k2, k3, k4;\n\n\tscanf(\"%d%d%d%d\", &k1, &k2, &k3, &k4);\n\tprintf(\"%d\\n\", k1 == k4 && (k1 > 0 || k3 == 0));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "b488173d550ecc93382dc56c01dfe015", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n\tint q,w,e,r;\n\tscanf(\"%d%d%d%d\",&q,&w,&e,&r);\n\tif(q!=r) printf(\"0\");\n\telse if (q==0&&e!=0) printf(\"0\");\n\telse printf(\"1\");\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "13da59e8004f4fce0d7d0668b7ed6d51", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\n\nll MAX = 100000000000; // 1e11\nll MIN = -100000000000; // -1e11\nll MOD = 1000000007;\n\nll longlongmax = __LONG_LONG_MAX__;\n\nll maxormin(ll a, ll b, ll flag)\n{\n return flag == 1 ? (a > b ? a : b) : (a < b ? a : b);\n}\n\nll overflowcheck(ll a)\n{\n if (a == 1)\n {\n return 0;\n }\n else\n {\n ll temp = a;\n ll power = 1;\n while (longlongmax / temp > a)\n {\n temp *= a;\n power++;\n }\n return power + 1; // Overflow occurs at this power.\n }\n}\n\nll merge(ll A[], ll B[], ll left, ll mid, ll right)\n{\n ll count = 0;\n ll n1 = mid - left + 1;\n ll n2 = right - mid;\n\n ll LA[n1], LB[n1], RA[n1], RB[n2];\n\n for (ll n = 0; n < n1; n++)\n {\n LA[n] = A[n + left];\n LB[n] = B[n + left];\n }\n for (ll n = 0; n < n2; n++)\n {\n RA[n] = A[n + mid + 1];\n RB[n] = B[n + mid + 1];\n }\n\n ll i = 0, j = 0, k = left;\n\n while (i < n1 && j < n2)\n {\n if (LA[i] < RA[j])\n {\n A[k] = LA[i];\n B[k] = LB[i];\n i++;\n }\n else\n {\n A[k] = RA[j];\n B[k] = RB[j];\n count += n1 - i;\n j++;\n }\n k++;\n }\n while (i < n1)\n {\n A[k] = LA[i];\n B[k] = LB[i];\n i++;\n k++;\n }\n\n while (j < n2)\n {\n A[k] = RA[j];\n B[k] = RB[j];\n j++;\n k++;\n }\n return count;\n}\n\nll mergesort(ll A[], ll B[], ll left, ll right)\n{\n ll total = 0;\n if (left < right)\n {\n ll mid = (right - left) / 2 + left;\n total += mergesort(A, B, left, mid);\n total += mergesort(A, B, mid + 1, right);\n total += merge(A, B, left, mid, right);\n }\n return total;\n}\n\nll primemarked[3000000];\nll primearray[3000000];\nll primeind;\n\nvoid setupprimes()\n{\n for (ll i = 2; i < 3000000; i++)\n {\n for (ll j = 2 * i; j < 3000000; j += i)\n {\n primemarked[j] = 1;\n }\n }\n for (ll i = 2; i < 3000000; i++)\n {\n if (!primemarked[i])\n {\n primearray[primeind++] = i;\n }\n }\n}\n\nll power(ll x, ll y, ll p)\n{\n ll res = 1; // Initialize result\n\n x = x % p; // Update x if it is more than or\n // equal to p\n\n while (y > 0)\n {\n // If y is odd, multiply x with result\n if (y & 1)\n res = (res * x) % p;\n\n // y must be even now\n y = y >> 1; // y = y/2\n x = (x * x) % p;\n }\n return res;\n}\n\nll factorsX[3000000];\nll ind = 0;\n\nint main(int argc, char const *argv[])\n{\n ll T = 1;\n // scanf(\"%lld\",&T);\n setupprimes();\n \n \n for (ll t = 0; t < T; t++)\n {\n ll x, N;\n scanf(\"%lld %lld\", &x, &N);\n for (ll j = 0; j < primeind; j++)\n {\n if ((x % primearray[j]) == 0)\n {\n factorsX[ind++] = primearray[j];\n while((x % primearray[j])==0)\n {\n x /= primearray[j];\n }\n }\n }\n if (x!=1)\n {\n // a prime itself\n factorsX[ind++] = x;\n }\n \n ll total = 1;\n // printf(\"%lldpopop\\n\",longlongmax/947);\n for (ll o = 0; o < ind; o++)\n {\n // for each prime factor calculate\n ll count[300];\n ll cind = 0;\n ll fac = factorsX[o];\n ll p = 1;\n ll gh = 1;\n while (p <= N && gh)\n {\n // printf(\"%lld\\n\",p);\n count[cind++] = N / p;\n if( p >= longlongmax/fac)\n {\n gh = 0;\n }\n p *= fac;\n }\n \n for (ll m = 0; m < cind; m++)\n {\n ll num = 1;\n ll prod ;\n\n if(m!=(cind-1))\n {\n num = (m*(count[m]-count[m+1]))%(MOD-1);\n }\n else\n {\n num = (m*count[m])%(MOD-1);\n }\n // printf(\"%lld\\n\",num);\n prod = power(factorsX[o],num,MOD);\n total = (total*prod)%MOD;\n total %= MOD;\n }\n }\n printf(\"%lld\\n\",total%MOD);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "5b1d6d6bf5ba9a9c05bca860d1bde5ba", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define lint long long\n\nconst int P = 1e9 + 7;\n\nlint f(lint n, lint k) {\n\tlint ret = 1;\n\twhile (k) {\n\t\tif (k & 1) ret = ret * n % P;\n\t\tn = n * n % P;\n\t\tk >>= 1;\n\t}\n\treturn ret;\n}\n\nint main()\n{\n\tlint x, n, i, k, cnt, ans = 1;\n\tscanf(\"%lld%lld\", &x, &n);\n\n\tfor (i = 2; i*i <= x; ++i) {\n\t\tif (x % i) continue;\n\t\tcnt = 0, k = i;\n\t\twhile (1) {\n\t\t\tcnt += n / k;\n\t\t\tif (k > n/i) break;\n\t\t\tk *= i;\n\t\t}\n\t\tans = ans * f(i, cnt) % P;\n\t\twhile (!(x % i)) x /= i;\n\t}\n\n\tif (x - 1) {\n\t\tcnt = 0, k = x;\n\t\twhile (1) {\n\t\t\tcnt += n / k;\n\t\t\tif (k > n/x) break;\n\t\t\tk *= x;\n\t\t}\n\t\tans = ans * f(x, cnt) % P;\n\t}\n\n\tprintf(\"%d\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "310a01881b9f062d6cb7e7b8da8ce589", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define ll long long \n\nchar ss[123];\n\nll max( ll a , ll b ){\n\tif( a > b ){\n\t\treturn a;\n\t}\n\telse{\n\t\treturn b;\n\t}\n}\n\nlong long BS(ll l, ll h, ll b, ll s, ll c, ll nb, ll ns, ll nc, ll pb, ll ps, ll pc, ll r, ll ans){\n\t\n\tif(l <= h){\n\n\t\tll m = l + (h - l) / 2;\n\t\tll p = max( 0 , b*m - nb ) * pb + max( 0 , c*m - nc ) * pc + max( 0 , s*m - ns ) * ps;\n\n\t\tif(p == r){\n\t\t\treturn m;\n\t\t}\n\t\telse if(p < r){\n\t\t\tans = max( ans , m );\n\t\t\treturn BS(m + 1, h, b, s, c, nb, ns, nc, pb, ps, pc, r, ans);\n\t\t}\n\t\telse{\n\t\t\treturn BS(l, m - 1, b, s, c, nb, ns, nc, pb, ps, pc, r, ans);\n\t\t}\n\t}\n\t\n\treturn ans;\n}\n\nint main(){\n\n\tscanf(\"%s\" , ss);\n\tint len = strlen(ss);\n\n\n\tll c = 0, b = 0, s = 0;\n\tfor(int i = 0; i < len ; i++){\n\t\tif(ss[i] == 'B') b++;\n\t\telse if(ss[i] == 'C') c++;\n\t\telse s++;\n\t}\n\n\tll nb, ns, nc, pb, ps, pc, r , ans = 0;\n\tscanf(\"%lld%lld%lld%lld%lld%lld%lld\", &nb, &ns, &nc, &pb, &ps, &pc, &r);\n\n\tans = BS(0 , r*max(nb , max(ns , nc)) + r*max(nb , max(ns , nc)) , b , s , c , nb , ns , nc , pb , ps , pc , r , ans);\n\n\tprintf(\"%lld\\n\", ans);\n\t\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search"], "code_uid": "00b87dedf22ecaef3a59f7ba1bcf2ddc", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*************************************************************************\n > File Name: 371C.c\n > Author: Stomach_ache\n > Mail: 1179998621@qq.com \n > Created Time: 2013\u5e7412\u670810\u65e5 \u661f\u671f\u4e8c 18\u65f645\u520651\u79d2\n ************************************************************************/\n\n#include\n#include\n#include\n\n#define max(x,y) ((x)>(y)?(x):(y))\n\ntypedef long long ll;\nint nb, ns, nc, pb, ps, pc, cb, cs, cc;\nll r;\nchar str[105];\n\nint ok(ll x) {\n\tll tmp = x * cb - nb, rr = r;\n\tif (tmp * pb > rr || rr < 0)\n\t\treturn 0;\n\tif (tmp > 0)\n\t\trr -= tmp * pb;\n\n\ttmp = x * cs - ns;\n\tif (tmp * ps > rr || rr < 0)\n\t\treturn 0;\n\tif (tmp > 0)\n\t\trr -= tmp * ps;\n\n\ttmp = x * cc - nc;\n\tif (tmp * pc > rr || rr < 0)\n\t\treturn 0;\n\tif (tmp > 0)\n\t\trr -= tmp * ps;\n\t\n\treturn 1;\n}\n\nint main(void) {\n\twhile (~scanf(\"%s\", str)) {\n\t\tscanf(\"%d %d %d\", &nb, &ns, &nc);\n\t\tscanf(\"%d %d %d\", &pb, &ps, &pc);\n\t\tscanf(\"%lld\", &r);\n\t\tint i;\n\t\tcb = cs = cc = 0;\n\t\tfor (i = 0; i < strlen(str); i++) {\n\t\t\tif (str[i] == 'B')\n\t\t\t\tcb++;\n\t\t\telse if (str[i] == 'S')\n\t\t\t\tcs++;\n\t\t\telse\n\t\t\t\tcc++;\n\t\t}\n\t\tll lf = 0, rg = 100*r+cb+cs+cc, ans = 0;\n\t\twhile (lf <= rg) {\n\t\t\tll mid = (lf + rg) >> 1;\n\t\t\tif (ok(mid)) {\n\t\t\t\tans = mid;\n\t\t\t\tlf = mid + 1;\n\t\t\t}\n\t\t\telse\n\t\t\t\trg = mid - 1;\n\t\t}\n\t\tprintf(\"%lld\\n\", ans);\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search"], "code_uid": "08129e70b2c3884f232b60d5db92d8b7", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n//n==0 MAY be a special case to be considered\nint main()\n{\n\tint n, groups[5], i, j, temp;\n\t\n\tscanf(\"%d\", &n);\n\t\n\tfor(i=0; igroups[j])\n\t\t\t{\n\t\t\t\ttemp=groups[i];\n\t\t\t\tgroups[i]=groups[j];\n\t\t\t\tgroups[j]=temp;\n\t\t\t}\n\t\t}\n\n\tprintf(\"%d\", groups[(n-1)/2]);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation"], "code_uid": "136d5c4dae21543c292e1e119cfb4207", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n int n = 0,\n i = 0,\n max = 2009,\n min = 2101,\n mid = 0,\n cur = 0;\n scanf(\"%d\",&n);\n for ( ; i < n; i++ ){\n scanf( \"%d\", &cur);\n if ( cur > max )\n max = cur;\n if ( cur < min )\n min = cur;\n }\n mid = ( max + min ) / 2;\n printf(\"%d\",mid);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["sortings", "implementation"], "code_uid": "c22568218879baa5cf89933f3a209e41", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main(void) {\n char s1[11], s2[11], s3[21],temp[21];\n\tint i,j,k,l1,t,l2;\n\tscanf(\"%s %s\",s1,s2);\n\tl1=strlen(s1);\n\tl2=strlen(s2);\n\tprintf(\"%c\",s1[0]);\n\tfor(i=1;i\n#define MAX 17\n\nint main()\n{\n\tchar f[MAX], s[MAX];\n\tint len, i;\n\tscanf(\"%s %s\", f, s);\n\t//printf(\"%s %s\\n\", f, s);\n\tlen = strlen(f);\n\tprintf(\"%c\", f[0]);\n\tfor(i=1;i\n\nconst int MOD=998244353;\nint pa[2001][2001];\nint po[2001];\n\nlong long fp(int ba,int e){\n\tif(e==0)return 1;\n\tlong long res=fp(ba,e/2);\n\tres=(res*res)%MOD;\n\tif(e%2)res=(res*ba)%MOD;\n\treturn res;\n}\nint main(){\n\t\n\tint i,j;\n\tpa[0][0]=1;\n\tfor(i=1;i<=2000;i++){\n\t\tpa[i][0]=pa[i][i]=1;\n\t\tfor(j=1;j\n#include \nint main() {\n int i,j,k,m,mp,n;\n long long *a, *b, *c;\n scanf(\"%d%d%d\", &n, &m, &k);\n a = malloc(sizeof(long long)*(k+1));\n b = malloc(sizeof(long long)*(k+1));\n mp = m - 1;\n a[0] = m;\n for (j = 1; j <= k; j++) { a[j] = 0; }\n for (i = 1; i < n; i++) {\n b[0] = m;\n for (j = 1; j <= k; j++) {\n b[j] = (a[j] + mp*a[j-1]) % 998244353;\n }\n c = a;\n a = b;\n b = c;\n }\n printf(\"%ld\\n\", (long) a[k]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "ebf7c511306f3d356c78c64de27ba142", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(int argc, const char *argv[])\n{\n unsigned long long a,b;\n unsigned long long res = 0;\n unsigned long long r;\n unsigned long long sum;\n scanf( \"%lld %lld\", &a, &b );\n\n sum = ( a * ( a + 1LL ) / 2LL ) % 1000000007;\n for( r = 1LL; r < b; r++ )\n {\n unsigned long long tmp;\n tmp = ( sum * r ) % 1000000007;\n tmp = ( tmp * b ) % 1000000007;\n res = ( res + tmp + a * r ) % 1000000007;\n }\n\n printf( \"%lld\\n\", res );\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "d3ff75df19ed37dbed6cba0d35623f6d", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n long long int a,b,sum=0,i,c,e,m=1000000007,f;\n scanf(\"%lld%lld\",&a,&b);\n f=((b)*(b-1))/2;\n for(i=1;i<=a;i++){\n c=i*b+1;\n e=((c%m)*(f%m))%m;\n sum+=e;\n }\n printf(\"%lld\",sum%m);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "ef1a0bfd82bfd2852126c03aeea8abe0", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main()\n{\n int x, y, z, vx, vy, vz, f1, f2, f3, f4, f5, f6;\n scanf(\"%d %d %d\", &x, &y, &z);\n scanf(\"%d %d %d\", &vx, &vy, &vz);\n scanf(\"%d %d %d %d %d %d\", &f1, &f2, &f3, &f4, &f5, &f6);\n\n int sum=0;\n\n\n if(z<0){\n sum+=f3;\n if(x>0 && y>0){\n sum+=f2+f6;\n if(x<=vx)\n sum-=f6;\n if(y<=vy)\n sum-=f2;\n }\n else if(x<0 && y<0)\n sum+=f1+f5;\n else if(x<0){\n if(y>vy)\n sum+=f2+f5;\n else\n sum+=f5;\n }\n else if(y<0){\n if(x>vx)\n sum+=f1+f6;\n else\n sum+=f1;\n }\n else if(x==0){\n if(y>vy)\n sum+=f2;\n else if(y<0)\n sum+=f1;\n }\n else if(y==0){\n if(x>vx)\n sum+=f6;\n else if(x<0)\n sum+=f5;\n }\n }\n else if(z<=vz){\n if(x>0 && y>0){\n sum+=f2+f6;\n if(x<=vx)\n sum-=f6;\n if(y<=vy)\n sum-=f2;\n }\n else if(x<0 && y<0)\n sum+=f1+f5;\n else if(x<0){\n if(y>vy)\n sum+=f2+f5;\n else\n sum+=f5;\n }\n else if(y<0){\n if(x>vx)\n sum+=f1+f6;\n else\n sum+=f1;\n }\n else if(x==0){\n if(y>vy)\n sum+=f2;\n else if(y<0)\n sum+=f1;\n }\n else if(y==0){\n if(x>vx)\n sum+=f6;\n else if(x<0)\n sum+=f5;\n }\n }\n else{\n sum+=f4;\n if(x>0 && y>0){\n sum+=f2+f6;\n if(x<=vx)\n sum-=f6;\n if(y<=vy)\n sum-=f2;\n }\n else if(x<0 && y<0)\n sum+=f1+f5;\n else if(x<0){\n if(y>vy)\n sum+=f2+f5;\n else\n sum+=f5;\n }\n else if(y<0){\n if(x>vx)\n sum+=f1+f6;\n else\n sum+=f1;\n }\n else if(x==0){\n if(y>vy)\n sum+=f2;\n else if(y<0)\n sum+=f1;\n }\n else if(y==0){\n if(x>vx)\n sum+=f6;\n else if(x<0)\n sum+=f5;\n }\n }\n\n printf(\"%d\\n\", sum);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "efb928ed4ffd314d8aa61208db8e767a", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint main()\n{\n int x,y,z,x1,y1,z1,sum=0;\n scanf(\"%d%d%d\",&x,&y,&z);\n scanf(\"%d%d%d\",&x1,&y1,&z1);\n int ara[6],i;\n for(i=0;i<6;i++)\n {\n scanf(\"%d\",&ara[i]);\n }\n if(y>y1)\n sum+=ara[1];\n else if(y<0)\n sum+=ara[0];\n if(x>x1)\n sum+=ara[5];\n else if(x<0)\n sum+=ara[4];\n if(z>z1)\n sum+=ara[3];\n else if(z<0)\n sum+=ara[2];\n printf(\"%d\\n\",sum);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "geometry"], "code_uid": "b82ffca483e77fe3988d7e639b2c1afe", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nchar a[20],a_[20];\nint l;\nint x[10];\nvoid swap(char *p,char *q){\n\tchar t=*p;\n\t*p=*q;\n\t*q=t;\n}\nint cat00(){\n\tint i,j,r;\n\tif(!(x[0]>=2)){\n\t\treturn -1;\n\t}\n\tr=0;\n\tfor(i=l-1;i>=0;i--){\n\t\tif(a_[i]==0){\n\t\t\tr=l-i-1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=0;i--){\n\t\tif(a_[i]==0){\n\t\t\tr+=l-i-2;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=1&&x[5]>=1)){\n\t\treturn -1;\n\t}\n\tif(x[0]>0&&x[0]==l-2){\n\t\t/*205*/\n\t\treturn -1;\n\t}\n\tr=0;\n\tfor(i=l-1;i>=0;i--){\n\t\tif(a_[i]==5){\n\t\t\tr=l-i-1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=0;i--){\n\t\tif(a_[i]==2){\n\t\t\tr+=l-i-2;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=1&&x[0]>=1)){\n\t\treturn -1;\n\t}\n\tif(x[0]>1&&x[0]==l-1){\n\t\t/*500*/\n\t\treturn -1;\n\t}\n\tr=0;\n\tfor(i=l-1;i>=0;i--){\n\t\tif(a_[i]==0){\n\t\t\tr=l-i-1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=0;i--){\n\t\tif(a_[i]==5){\n\t\t\tr+=l-i-2;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=1&&x[5]>=1)){\n\t\treturn -1;\n\t}\n\tif(x[0]>0&&x[0]==l-2){\n\t\t/*705*/\n\t\treturn -1;\n\t}\n\tr=0;\n\tfor(i=l-1;i>=0;i--){\n\t\tif(a_[i]==5){\n\t\t\tr=l-i-1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;j=0;i--){\n\t\tif(a_[i]==7){\n\t\t\tr+=l-i-2;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(j=i;jj)){\n\t\t\tr=j;\n\t\t}\n\t\tfor(i=0;ij)){\n\t\t\tr=j;\n\t\t}\n\t\tfor(i=0;ij)){\n\t\t\tr=j;\n\t\t}\n\t\tfor(i=0;ij)){\n\t\t\tr=j;\n\t\t}\n\t\tprintf(\"%d\\n\",r);\n\t}\n}\nmain(){\n#ifndef\tONLINE_JUDGE\n\tfreopen(\"4863e_min.in\",\"rb\",stdin);\n\tfreopen(\"4863e_.out\",\"wb\",stdout);\n#endif\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "275c71d49262c3eb3ef1e291177f1edb", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint requires_substitute(char string[], int index1, int index2) {\n if (index1 != 0 && index2 != 0) return 0;\n if (index1 == 1 || index2 == 1) {\n if (string[2] == '0') return 1;\n } if (string[1] == '0') return 1;\n}\nint requires_substitute_fifty(char string[], int index1, int index2) {\n if (index1 == 0 && index2 != 1 && string[1] == '0') return 1;\n else return 0;\n}\nint substitute(char string[], int index1, int index2, int size) {\n int res = -1;\n for (int i = 0; i < size; i++) {\n if (i != index1 && i != index2 && string[i] != '0') {\n res = i;\n break;\n }\n }\n return res;\n}\n\nint main() {\n char string[20];\n scanf(\"%s\", string);\n int nums[5];\n for (int i = 0; i < 5; i++) {\n nums[i] = -1;\n }\n int switchZero = 1;\n int size = strlen(string);\n for (int i = 0; i < size; i++) {\n if (string[i] == '2') {\n nums[0] = i;\n } else if (string[i] == '5') {\n nums[1] = i;\n } else if (string[i] == '7') {\n nums[2] = i;\n } else if (string [i] == '0') {\n if (switchZero) {\n nums[3] = i;\n switchZero = 0;\n } else {\n nums[4] = i;\n switchZero = 1;\n }\n }\n }\n\n if (nums[3] > nums[4] || nums[4] == -1) {\n int tmp = nums[3];\n nums[3] = nums[4];\n nums[4] = tmp;\n }\n int steps[4];\n for (int i = 0; i < 4; i++) \n steps[i] = -1;\n if (nums[1] != -1) {\n if (nums[0] != -1) {\n int step_count = 0;\n if (size > 2 && requires_substitute(string, nums[1], nums[0])) {\n int sub = substitute(string, nums[1], nums[0], size);\n if (sub != -1) {\n step_count += sub;\n if (sub > nums[0])\n step_count --;\n if (sub > nums[1]) \n step_count --;\n }\n }\n if (nums[1] < nums[0]) {\n step_count ++;\n }\n step_count += size - nums[1] - 1;\n step_count += size - nums[0] - 2;\n steps[0] = step_count;\n } if (nums[2] != -1) {\n int step_count = 0;\n if (size > 2 && requires_substitute(string, nums[1], nums[2])) {\n int sub = substitute(string, nums[1], nums[2], size);\n if (sub != -1) {\n step_count += sub;\n if (sub > nums[2])\n step_count --;\n if (sub > nums[1]) \n step_count --;\n }\n }\n if (nums[1] < nums[2]) {\n step_count ++;\n }\n step_count += size - nums[1] - 1;\n step_count += size - nums[2] - 2;\n steps[1] = step_count;\n } if (nums[4] != -1) {\n int step_count = 0;\n if (size > 2 && requires_substitute_fifty(string, nums[1], nums[4])) {\n int sub = substitute(string, nums[1], nums[4], size);\n if (sub != -1) {\n step_count += sub;\n }\n }\n if (nums[1] > nums[4]) {\n step_count ++;\n }\n step_count += size - nums[1] - 1;\n step_count += size - nums[4] - 2;\n steps[2] = step_count;\n }\n } if (nums[3] != -1 && nums[4] != -1) {\n int step_count = 0;\n step_count += size - nums[3] - 1;\n step_count += size - nums[4] - 2;\n steps[3] = step_count;\n }\n int min = -1;\n for (int i = 0; i < 4; i ++) {\n \n if (steps[i] != -1) {\n if (min == -1 || steps[i] < min) {\n min = steps[i];\n }\n }\n }\n printf(\"%d\", min);\n}", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "6519d2eee3064f9fd259599c64d2fb05", "src_uid": "ea1c737956f88be94107f2565ca8bbfd", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#define ll long long\nll digitsum(ll num) \n{\n ll div = 1;\n ll sum = 0;\n\n while (num / div != 0)\n {\n sum += ((num) % (div * 10)) / div;\n div *= 10;\n }\n\n return sum;\n}\n\nint main(void)\n{\n ll n, s;\n scanf(\"%lli %lli\", &n, &s);\n \n ll left = 0, right = n; \n while(right != left)\n {\n ll mid = (right + left) / 2;\n ll check = mid - digitsum(mid);\n\n if (check >= s)\n right = mid;\n else\n left = mid;\n\n if (right - left == 1)\n left++;\n }\n\n if (n - digitsum(n) >= s) \n printf(\"%lli\\n\", n - right + 1);\n else\n printf(\"0\\n\");\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "binary search"], "code_uid": "2462539303f90353aeb1f0a302c47961", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n/* http://codeforces.com/contest/817/submission/27799686 (Dukkha) */\n\nlong long count(long long x) {\n\treturn x < 10 ? x : count(x / 10) + x % 10;\n}\n\nint check(long long x, long long s) {\n\treturn x - count(x) >= s;\n}\n\nint main() {\n\tlong long n, m, s, cnt, x;\n\tint d;\n\n\tscanf(\"%lld%lld\", &n, &s);\n\td = 9 * 18;\n\tcnt = n - s - d > 0 ? n - s - d : 0;\n\tm = s + d < n ? s + d : n;\n\tfor (x = s; x <= m; x++)\n\t\tif (check(x, s))\n\t\t\tcnt++;\n\tprintf(\"%lld\\n\", cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "binary search"], "code_uid": "54f04ece8d9f9499487bbc5a47b26ec3", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n char q[6];\n long long a,b=5,c=1;\n scanf(\" %s\",q);\n a=(q[0]-48)*10000+(q[2]-48)*1000+(q[4]-48)*100+(q[3]-48)*10+(q[1]-48);\n while (b--)\n c=(c*a)%100000;\n b=5;\n while (--b>=0)\n q[b]=c%10+48,c/=10;\n puts(q);\n return 0;\n}/*2016-02-21 21:42:41.772*/", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "a59ff4235b093b0e2d57c9f2e7f48c3f", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n\t// your code goes here\n\t\nlong long\tint n,q,w,e,r,t,a,b,c,d,i,j,k;\n\tscanf(\"%I64d \",&n);\n\tint act;\n\t\n\te=n%10;\n\tn=n/10;\n\td=n%10;\n\tn=n/10;\n\tc=n%10;\n\tn=n/10;\n\tb=n%10;\n\tn=n/10;\n\ta=n;\n\t\n\tn=a*10000 + c*1000 +e*100+d*10+b;\n\tact=n;\n\tint arr[5];\n\tfor(i=0;i<4;i++)\n\t{n=n*act;\n\t \te=n%10;\n\tn=n/10;\n\td=n%10;\n\tn=n/10;\n\tc=n%10;\n\tn=n/10;\n\tb=n%10;\n\tn=n/10;\n\ta=n%10; \n\t arr[0]=a;\n\t arr[1]=b;\n\t arr[2]=c;\n\t arr[3]=d;\n arr[4]=e;\n\t n=a*10000 + b*1000 +c*100+d*10+e;\n\t \n\t \n\t} \n\tfor(i=0;i<5;i++)printf(\"%d\",arr[i]);\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "2c601f30843a3e67eafcc5822df8e914", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nconst long long aa = (long long)3e16;\n\nlong long arr[100][2];\n\nlong long max(long long x,long long y)\n{\n if(x>y) return x;\n else return y;\n}\nint main()\n{\n long long x0,y0,ax,ay,bx,by,i,j,tim,xs,ys,cnt=0;\n int ndcollect=0;\n \n scanf(\"%lld %lld %lld %lld %lld %lld\\n\",&x0,&y0,&ax,&ay,&bx,&by);\n \n scanf(\"%lld %lld %lld\",&xs,&ys,&tim);\n \n arr[0][0]=x0;\n arr[0][1]=y0;\n\n \n while(arr[cnt][0]< aa && arr[cnt][1]< aa)\n {\n cnt++;\n\n arr[cnt][0]=ax*arr[cnt-1][0]+bx;\n arr[cnt][1]=ay*arr[cnt-1][1]+by;\n\n }\n \n for(i=0;i\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": "9dfe205df5b85bb663e9ecdff60069e2", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nchar a[105];\nint main()\n{\n int max,i,j,k,w,l,flag;\n while(~scanf(\"%s\",a))\n {\n l=strlen(a);\n max=0;\n for(i=1; i\n#include\nint main(void)\n{\n\tchar s[110];\n\tint i,len,j,k,flag=1;\n\tscanf(\"%s\",s);\n\tlen=strlen(s);\n\tfor(i=len;i>=1;i--)\n\t{\n\t\tfor(j=0;j\n\nint n, m, highest = 0, highest_temp = 0, p[8+1], i, k, m_note, n_count, min;\nvoid permutate(int, int);\nvoid swap(int *x, int *y);\n\nint main()\n{\n while(scanf(\"%d\", &n)!=EOF)\n {\n highest = 0;\n highest_temp = 0;\n min = 9;\n scanf(\"%d\", &m);\n for(i = 1; i<=8; i++)\n {\n p[i] = 0;\n }\n for(i = 1; i<=n; i++)\n {\n p[i] = i;\n }\n for(i = 1; i<=n; i++)\n {\n highest += i * (n+1-i);\n }\n \n m_note = 0;\n permutate(1, n);\n \n }\n return 0;\n}\n\nvoid permutate(int start, int end)\n{\n if(start == end)\n {\n \n for(k=1; k<=n; k++)\n {\n n_count = n;\n for(n_count; n_count>0; --n_count)\n {\n min = 9;\n for(i=k; i<=n_count; ++i)\n {\n \n if(p[i]= highest)\n {\n ++m_note;\n if(m_note==m)\n {\n for(i=1; i<=n; i++)\n {\n printf(\"%d \", p[i]);\n }\n printf(\"\\n\");\n }\n else{}\n }\n else{}\n }\n else\n {\n int j;\n for(j = start; j <= end; ++j)\n {\n \n swap((p+start), (p+j));\n permutate(start+1, end);\n highest_temp = 0;\n swap((p+start), (p+j));\n }\n }\n}\n\nvoid swap(int *x, int *y)\n{\n int temp; \n temp = *x;\n *x = *y; \n *y = temp;\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "a590c67736d08db5793901d8bbfcad9a", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,j,n,a[64],v,mr;\n long long int b,m,sh,pow[64];\n pow[0]=1;\n for(i=1;i<53;i++)\n pow[i]=pow[i-1]*2;\n scanf(\"%d %I64d\",&n,&m);\n i=0;j=n-1;\n b=pow[j-1];\n m--;\n v=1;\n while(b>0)\n {\n if((b&m)==0)\n {\n a[i]=v;\n i++;\n mr=0;\n }\n else\n {\n a[j]=v;\n j--;\n mr=1;\n }\n v++;\n b>>=1;\n }\n if(mr==0)\n a[i]=v;\n else\n a[j]=v;\n for(i=0;i\n#include \n\n#define N\t52\n#define K\t(N * 9)\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nvoid carry(int *aa, int n) {\n\tint i;\n\n\tfor (i = 0; i < n; i++)\n\t\tif (aa[i] >= 10)\n\t\t\taa[i + 1] += aa[i] / 10, aa[i] %= 10;\n\t\telse if (aa[i] < 0)\n\t\t\taa[i + 1] -= (-aa[i] + 9) / 10, aa[i] = (aa[i] % 10 + 10) % 10;\n}\n\nint main() {\n\tstatic char aa[N + 1];\n\tstatic int bb[N + 1], dp[K * 2 + 1], dq[K * 2 + 1], dp_[K * 2 + 1], dq_[K * 2 + 1];\n\tint n, i, j, k, ans;\n\tchar tmp;\n\n\tscanf(\"%s\", aa), n = strlen(aa);\n\tfor (i = 0; i < n; i++)\n\t\taa[i] -= '0';\n\tfor (i = 0, j = n - 1; i < j; i++, j--)\n\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\tn += 2;\n\tmemset(dp, 0x3f, (K * 2 + 1) * sizeof *dp), memset(dq, 0x3f, (K * 2 + 1) * sizeof *dq); \n\tdp[K] = 0;\n\tfor (i = n - 2; i >= 0; i--) {\n\t\tmemset(dp_, 0x3f, (K * 2 + 1) * sizeof *dp_), memset(dq_, 0x3f, (K * 2 + 1) * sizeof *dq_); \n\t\tfor (k = 0; k <= K * 2; k++) {\n\t\t\tint x;\n\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = aa[j] + k - K;\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dp[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdp_[k - d] = min(dp_[k - d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdq_[k - d] = min(dq_[k - d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = -bb[j];\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dq[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tbb[0]--;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdq_[k + d] = min(dq_[k + d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdp_[k + d] = min(dp_[k + d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmemcpy(dp, dp_, (K * 2 + 1) * sizeof *dp_), memcpy(dq, dq_, (K * 2 + 1) * sizeof *dq_); \n\t}\n\tans = INF;\n\tfor (k = 0; k <= K * 2; k++)\n\t\tif ((aa[0] + k - K) % 10 == 0)\n\t\t\tans = min(ans, dp[k]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "shortest paths"], "code_uid": "329a1f3070b438031cf448d0242672bc", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t52\n#define K\t(N * 6)\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nvoid carry(int *aa, int n) {\n\tint i;\n\n\tfor (i = 0; i < n; i++)\n\t\tif (aa[i] >= 10)\n\t\t\taa[i + 1] += aa[i] / 10, aa[i] %= 10;\n\t\telse if (aa[i] < 0)\n\t\t\taa[i + 1] -= (-aa[i] + 9) / 10, aa[i] = (aa[i] % 10 + 10) % 10;\n}\n\nint main() {\n\tstatic char aa[N + 1];\n\tstatic int bb[N + 1], dp[K * 2 + 1], dq[K * 2 + 1], dp_[K * 2 + 1], dq_[K * 2 + 1];\n\tint n, i, j, k, ans;\n\tchar tmp;\n\n\tscanf(\"%s\", aa), n = strlen(aa);\n\tfor (i = 0; i < n; i++)\n\t\taa[i] -= '0';\n\tfor (i = 0, j = n - 1; i < j; i++, j--)\n\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\tn += 2;\n\tmemset(dp, 0x3f, (K * 2 + 1) * sizeof *dp), memset(dq, 0x3f, (K * 2 + 1) * sizeof *dq); \n\tdp[K] = 0;\n\tfor (i = n - 2; i >= 0; i--) {\n\t\tmemset(dp_, 0x3f, (K * 2 + 1) * sizeof *dp_), memset(dq_, 0x3f, (K * 2 + 1) * sizeof *dq_); \n\t\tfor (k = 0; k <= K * 2; k++) {\n\t\t\tint x;\n\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = aa[j] + k - K;\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dp[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdp_[k - d] = min(dp_[k - d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdq_[k - d] = min(dq_[k - d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = -bb[j];\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dq[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tbb[0]--;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdq_[k + d] = min(dq_[k + d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdp_[k + d] = min(dp_[k + d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmemcpy(dp, dp_, (K * 2 + 1) * sizeof *dp_), memcpy(dq, dq_, (K * 2 + 1) * sizeof *dq_); \n\t}\n\tans = INF;\n\tfor (k = 0; k <= K * 2; k++)\n\t\tif ((aa[0] + k - K) % 10 == 0)\n\t\t\tans = min(ans, dp[k]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "shortest paths"], "code_uid": "08b51319539f0f4916739076ccc29a98", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#define size 100\nint max(int a,int b)\n{\n\tif(a>b)\n\t return a;\n\telse\n\t return b;\n}\nint partition(int a[],int l,int u)\n{\n\tint v,i,j,temp;\n\tv=a[l];\n\ti=l;\n\tj=u+1;\n\t\n\tdo\n\t{\n\t\tdo\n\t\t\ti++;\n\t\t\t\n\t\twhile(a[i]=m)\n\t{\n\t\tprintf(\"%d\",i);\n\t\texit(0);\n\t}\n}\nprintf(\"-1\");\n}", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "a4c65d3e79800f2095dbbb408c72f384", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint a[100];\nvoid qs(int first, int last)\n \n{\n if (first < last)\n {\n int left = first, right = last, middle = a[(left + right) / 2];\n do\n {\n while (a[left] < middle) left++;\n while (a[right] > middle) right--;\n if (left <= right)\n {\n int tmp = a[left];\n a[left] = a[right];\n a[right] = tmp;\n left++;\n right--;\n }\n } while (left <= right);\n qs( first, right);\n qs( left, last);\n }\n}\n \n \nint main() {\n int n,l,r,sum,t,middle,in,i,j;\n long long int m;\n scanf(\"%i %I64d\",&n,&m);\n for (int i=1;i<=n;++i) scanf(\"%i\",&a[i]);\n qs(1,n);\n \n l=1;\n r=n;\n \n while(l<=r){\n sum=0;\n t=n;\n middle=(l+r)/2;\n (n % middle==0)?(in= n / middle):(in=( n / middle)+1);\n for(i=0;i=1;j++){\n if (a[t] - i > 0)\n sum = sum + a[t] - i;\n t--;\n }\n }\n if(sum==m){\n l=middle;\n r=middle;\n break;\n }\n else if(sum= 0)){\n if((l+r)%2!=0)\n printf(\"%d\",(l+r)/2+1);\n else\n printf(\"%d\",(l+r)/2);\n }\n else printf(\"-1\");\n}\n ", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "2247f7328860a2cf995e4e7f5c4e0618", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#define For(i,n) for(i=0;iy?x:y\n#define MAXN 111\n\nint mov[MAXN][2];\n\nmain()\n{\n int i, j, flag = 1;\n int k, a, b;\n int x, y, sx = 0, sy = 0;\n char s[111];\n scanf(\"%d%d%s\",&x,&y,s);\n mov[0][0] = mov[0][1] = 0;\n for(i = 0; s[i]; i++)\n {\n mov[i+1][0] = (s[i]=='U'||s[i]=='D')?0:s[i]=='R'?1:-1;\n mov[i+1][1] = (s[i]=='R'||s[i]=='L')?0:s[i]=='U'?1:-1;\n sx += mov[i+1][0];\n sy += mov[i+1][1];\n }\n For(i,strlen(s)){\n x -= mov[i][0];\n y -= mov[i][1];\n //printf(\"%d %d\\n\",x,y);\n if(sx==0&&sy==0) k = 1;\n else if(sx!=0) k = x/sx;\n else k = y/sy;\n if(sx*k==x&&sy*k==y&&k>=0)\n {\n printf(\"Yes\\n\");\n flag = 0; break;\n }\n }\n if(flag) printf(\"No\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "2447c7b43e6036e1d5c4805cc78d5021", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint a, b;\nint dx, dy;\nchar str[110];\n\nint abs(int a){\n\treturn a >= 0 ? a : -a;\n}\n\nint sign(int x){\n\tif (x > 0)\n\t\treturn 1;\n\telse if (x == 0)\n\t\treturn 0;\n\telse\n\t\treturn -1;\n}\n\nbool check(int x, int y){\n\tint xdiff = a - x;\n\tint ydiff = b - y;\n\n\tif (x == a && y == b)\n\t\treturn true;\n\n\tif (a != x && dx == 0)\n\t\treturn false;\n\tif (b != y && dy == 0)\n\t\treturn false;\n\n\tif (sign(xdiff) * sign(dx) < 0 || sign(ydiff) * sign(dy) < 0)\n\t\treturn false;\n\n\tif (dx == 0)\n\t\treturn abs(ydiff) % abs(dy) == 0;\n\telse if (dy == 0)\n\t\treturn abs(xdiff) % abs(dx) == 0;\n\telse\n\t\treturn \n\t\t\tabs(ydiff) % abs(dy) == 0 &&\n\t\t\tabs(xdiff) % abs(dx) == 0 &&\n\t\t\t((long long int)xdiff) * dy == ((long long int)ydiff) * dx;\n}\n\nint main(void){\n\tint i, j;\n\n\tscanf(\"%d %d\", &a, &b);\n\tscanf(\"%s\", str);\n\n\tfor (i = 0; str[i]; i++){\n\t\tif (str[i] == 'U')\n\t\t\tdy++;\n\t\telse if (str[i] == 'D')\n\t\t\tdy--;\n\t\telse if (str[i] == 'R')\n\t\t\tdx++;\n\t\telse if (str[i] == 'L')\n\t\t\tdx--;\n\t}\n\n\tint x = 0, y = 0;\n\tbool works = check(0,0);\n\n\tfor (i = 0; !works && str[i]; i++){\n\t\tif (str[i] == 'U')\n\t\t\ty++;\n\t\telse if (str[i] == 'D')\n\t\t\ty--;\n\t\telse if (str[i] == 'R')\n\t\t\tx++;\n\t\telse if (str[i] == 'L')\n\t\t\tx--;\n\t\tworks = check(x,y);\n\t}\n\n\tprintf(\"%s\\n\", works ? \"Yes\" : \"No\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "d8b76b78e697b85351e146291fc8d508", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \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"], "code_uid": "cc68aff62221a57f743c1a8cd59ae4e5", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define max2(a,b) (a= L[n]; i--)\n for (a = 0; a <= count[0]; a++)\n for (b = 0; b <= count[1]; b++)\n for (c = 0; c <= count[2]; c++) {\n int pos = 0;\n if (G[n] == 0)\n pos |= !!add2i(P[i][a+1][b][c], P[i-L[n]][a][b][c]);\n if (G[n] == 1)\n pos |= !!add2i(P[i][a][b+1][c], P[i-L[n]][a][b][c]);\n if (G[n] == 2)\n pos |= !!add2i(P[i][a][b][c+1], P[i-L[n]][a][b][c]);\n\n if (pos && i > max_d)\n max_d = i;\n }\n count[G[n]] = min2(count[G[n]] + 1, N/2+1);\n }\n\n u64 r = 0;\n for (a = 0; a <= count[0]; a++)\n for (b = 0; b <= count[1]; b++)\n for (c = 0; c <= count[2]; c++)\n if (P[T][a][b][c])\n for (int g = 0; g < 3; g++)\n add2i(r, mul3(fact3(a,b,c), perm[a][b][c][g], P[T][a][b][c]));\n return r;\n}\n\nint main() {\n int i, j, k, n;\n\n scanf(\"%d %d\", &N, &T);\n for (i = 0; i < N; i++) {\n scanf(\"%d %d\", &L[i], &G[i]);\n G[i]--;\n }\n\n perm[1][0][0][0] = perm[0][1][0][1] = perm[0][0][1][2] = 1;\n for (n = 2; n <= N; n++)\n for (i = 0; i <= n/2+1; i++)\n for (j = 0; j <= min2(n - i, n/2+1); j++) {\n k = n - i - j;\n if (k > n/2+1) continue;\n\n if (i) perm[i][j][k][0] = add2(perm[i-1][j][k][1], perm[i-1][j][k][2]);\n if (j) perm[i][j][k][1] = add2(perm[i][j-1][k][2], perm[i][j-1][k][0]);\n if (k) perm[i][j][k][2] = add2(perm[i][j][k-1][0], perm[i][j][k-1][1]);\n }\n\n printf(\"%llu\\n\", walk());\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "56f556fe1c22ff7932e6222b0d9096ec", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long int min(long long int n,long long int k)\n{\n\tif(n=n)\n\t\t{\n\t\t\tans=k;\n\t\t\tr=k-1;\n\t\t}\n\t\telse\n\t\t\tl=k+1;\n\t}\n\tprintf(\"%lld\\n\",ans);\n}\n", "lang_cluster": "C", "tags": ["implementation", "binary search"], "code_uid": "ba48f9df50f90dc00ebd5c24d33d8562", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong long n,k,r,total;\n\tlong long ok,nk,rc;\n\n\tscanf(\"%lld\",&n);\n\n\tif (n%2==0) rc = n/2;\n\telse rc = n/2+1;\n\n\tok = rc;\n\tnk = 0;\n\n\twhile(ok-nk>1)\n\t{\n\t\tk = (ok+nk)/2;\n\t\n\t\tr = n;\t\n\t\ttotal = 0;\n\n\t\twhile (r>0)\n\t\t{\n\t\t\tlong long p;\n\t\t\tif (k>=r) p = 0;\n\t\t\telse\n\t\t\t\tp=(r-k)/10;\n\t\t\tif (k=rc)\n\t\t ok = k;\n\t\telse\t\n\t\t nk = k;\n\t}\n\tprintf(\"%lld\\n\",ok);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation", "binary search"], "code_uid": "e13500bd939d7d21e2556116508f69fe", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.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 // printf(\"%d\\n\",j);\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#define __STDC_FORMAT_MACROS\n#include \n#include \n#include \n#include \n\nstatic int64_t _factorial[20] = {};\n\n// generates permutation of [0, .., n-1]\nstatic void generate_kth_permutation(int n, int64_t k, int v[static n]) {\n bool taken[n]; for(int i = 0 ; i < n ; ++i) taken[i] = false;\n for(int i = 0 ; i < n ; ++i) {\n const int64_t f = _factorial[n-i-1];\n int64_t q,r; if(k < f) {\n r = k, q = 0;\n } else {\n r = k % f; if(r == 0) r = f; // 0 < r <= m!\n q = (k - r) / f;\n }\n int qi = 0; for(int j = 0, ti = 0, tn = q+1 ; ti < tn ; ++j)\n if(!taken[j]) qi = j, ++ti;\n\n v[i] = qi; taken[qi] = true; k = r;\n }\n}\n\n// sort digits of in increasing order, and generate permutations\n// use binary search to find needed permutation\n\nstatic int compare_digit(const void* a, const void* b) { return *(const int*)a - *(const int*)b; }\n\nstatic inline int64_t number_from_digits_perm(int n, int perm[static n], int d[static n]) { int64_t ret = 0;\n if(d[perm[0]] == 0) return 0;\n for(int i = 0 ; i < n ; ++i)\n ret = 10*ret + d[perm[i]];\n return ret;\n}\n\nstatic inline bool perm_gt(int n, int64_t pn, int d[static n], int64_t V) {\n int perm[n]; generate_kth_permutation(n, pn, perm);\n const int64_t a = number_from_digits_perm(n, perm, d);\n return a > V;\n}\n\nstatic inline bool perm_lt(int n, int64_t pn, int d[static n], int64_t V) {\n int perm[n]; generate_kth_permutation(n, pn, perm);\n const int64_t a = number_from_digits_perm(n, perm, d);\n return a <= V;\n}\n\nstatic inline int64_t solve(int64_t a, int64_t b) {\n int adcount = 0; int ad[20]; while(a) {\n ad[adcount++] = a % 10; a /= 10;\n }\n qsort(ad, adcount, sizeof(int), compare_digit);\n\n int64_t low = 0, high = _factorial[adcount]+1; /* start with whole array */\n while(high - low > 1) { /* more than one candidate */\n const int64_t mid = low + (high - low) / 2; /* pick middle */\n if(perm_gt(adcount, mid, ad, b)) high = mid; /* higher than b: no need to consider it */\n else low = mid;\n }\n\n int aperm[adcount]; generate_kth_permutation(adcount, low, aperm);\n return number_from_digits_perm(adcount, aperm, ad);\n}\n\nint main() {\n _factorial[0] = 1; for(int i = 1 ; i < 20 ; ++i) _factorial[i] = i*_factorial[i-1];\n int64_t a, b; scanf(\"%\"PRId64 \" %\"PRId64 \"\\n\", &a, &b);\n printf(\"%\" PRId64 \"\\n\", solve(a,b));\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "01eafca3ed8b8d4a49190a1a2d227c7b", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#define __USE_MINGW_ANSI_STDIO 0\r\n#include \r\n#include \r\n#include \r\n\r\n#define maxN 65\r\n\r\nchar str[maxN];\r\nchar tmpstr[maxN];\r\nchar tgt[maxN];\r\n\r\nint zeroCnt(char *str) {\r\n int ctr = 0;\r\n for (int i = strlen(str) - 1; i >= 0; --i) {\r\n if (str[i] == '0') ++ctr;\r\n }\r\n return ctr;\r\n}\r\n\r\nvoid trim(char *str) {\r\n for (int i = strlen(str) - 1; i >= 0; --i) {\r\n if (str[i] == '1') break;\r\n else str[i] = '\\0';\r\n }\r\n}\r\n\r\nstatic inline void cswap(char *a, char *b) {\r\n char tmp = *a;\r\n *a = *b;\r\n *b = tmp;\r\n return;\r\n}\r\n\r\nvoid reverse(char *str) {\r\n int p = 0, q = strlen(str) - 1;\r\n for (; p < q; ++p, --q) {\r\n cswap(&str[p], &str[q]);\r\n }\r\n}\r\n\r\n// bin\r\n#define lltoa(a, b) _lltoa(a, b)\r\nvoid _lltoa(long long num, char *dest) {\r\n int len = 0;\r\n while (num) {\r\n if (num % 2 == 0) dest[len++] = '0';\r\n else dest[len++] = '1';\r\n num /= 2;\r\n }\r\n dest[len] = '\\0';\r\n reverse(dest);\r\n}\r\n\r\nvoid testcase() {\r\n long long a, b;\r\n scanf(\"%lld%lld\", &a, &b);\r\n lltoa(a, str);\r\n lltoa(b, tgt);\r\n // Orig string: Either equal, or at least a 1 on the right, and any amount of 1s on the left and right after.\r\n if (strcmp(tgt, str) == 0) { printf(\"YES\\n\"); return; }\r\n // Make sure at least one 1 is on the right.\r\n strcpy(tmpstr, str);\r\n int len = strlen(tmpstr);\r\n if (tmpstr[len - 1] == '0') {\r\n tmpstr[len++] = '1';\r\n tmpstr[len] = '\\0';\r\n }\r\n if (strstr(tgt, tmpstr) && zeroCnt(tgt) == zeroCnt(tmpstr)) { printf(\"YES\\n\"); return; }\r\n // This flipped +1 string must also be used to match.\r\n reverse(tmpstr);\r\n if (strstr(tgt, tmpstr) && zeroCnt(tgt) == zeroCnt(tmpstr)) { printf(\"YES\\n\"); return; }\r\n\r\n // 2 flips performed: Completely trimmed. Add any amount of 1s to the left or right.\r\n trim(str);\r\n if (strstr(tgt, str) && zeroCnt(tgt) == zeroCnt(str)) { printf(\"YES\\n\"); return; }\r\n\r\n // 1 flip performed. Both sides start and end with a 1. Add any amounts of 1 left and right.\r\n reverse(str);\r\n trim(str);\r\n if (strstr(tgt, str) && zeroCnt(tgt) == zeroCnt(str)) { printf(\"YES\\n\"); return; }\r\n printf(\"NO\\n\");\r\n\r\n return;\r\n}\r\n\r\nint main() {\r\n testcase();\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "950e7278b7c0644e56938ab88be16183", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t62\n\nlong long rev(long long x) {\n\tlong long y = 0;\n\n\twhile (x) {\n\t\ty = y << 1 | (x & 1);\n\t\tx >>= 1;\n\t}\n\treturn y;\n}\n\nlong long padded(long long a, long long b) {\n\treturn a % b == 0 && ((a / b) & (a / b - 1)) == 0;\n}\n\nint main() {\n\tstatic int yy[N];\n\tlong long x, y, z;\n\tint n, l, r, i;\n\n\tscanf(\"%lld%lld\", &x, &y);\n\tif (x == y) {\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif ((y & 1) == 0) {\n\t\tprintf(\"NO\\n\");\n\t\treturn 0;\n\t}\n\tn = 0;\n\twhile (y)\n\t\tyy[n++] = y & 1, y >>= 1;\n\tfor (l = 0; l < n; l++) {\n\t\tfor (r = n - 1; r >= l; r--) {\n\t\t\tif (yy[l] == 0 && yy[r] == 0)\n\t\t\t\tbreak;\n\t\t\telse if (yy[l] == 0) {\n\t\t\t\tz = 0;\n\t\t\t\tfor (i = r; i >= l; i--)\n\t\t\t\t\tz = z << 1 | yy[i];\n\t\t\t\tif (x == z) {\n\t\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t} else if (yy[r] == 0) {\n\t\t\t\tz = 0;\n\t\t\t\tfor (i = l; i <= r; i++)\n\t\t\t\t\tz = z << 1 | yy[i];\n\t\t\t\tif (x == z) {\n\t\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tz = 0;\n\t\t\t\tfor (i = l; i <= r; i++)\n\t\t\t\t\tz = z << 1 | yy[i];\n\t\t\t\tif (padded(x, z) || padded(x, rev(z))) {\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\tif (yy[l] == 0)\n\t\t\tbreak;\n\t}\n\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "constructive algorithms", "math", "bitmasks", "strings", "implementation"], "code_uid": "10ef8761c54fb80a26f5938c8ed486b3", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define LL \"%I64d\"\n\nlong long d[2][48][7][8][9][2][2];\nint digits[26], dgCount;\n\nint nx7[10][10], nx8[10][10], nx9[10][10];\nint nxmask[48][10];\nint bad5[48][10], bad7[48][10], bad8[48][10], bad9[48][10];\nint buf[10 * 25];\n\nvoid swap(int *x, int *y) {\n int t = *x;\n *x = *y;\n *y = t;\n}\n\nint max(int a, int b) { return (a > b ? a : b); }\n\nlong long solve(long long n, int useN) {\n int i, mask, j, high, r7, r8, r9, last, next;\n memset(d[0], 0, sizeof(d[0]));\n\n if(useN) {\n dgCount = 0;\n while(n) {\n digits[dgCount++] = n % 10;\n n /= 10;\n }\n } else {\n for(i = 0; i < dgCount / 2; i++)\n swap(&digits[i], &digits[dgCount - i - 1]); \n }\n\n d[0][0][0][0][0][0][0] = 1;\n for(i = 0; i < dgCount; i++) {\n memset(d[(i & 1) ^ 1], 0, sizeof(d[(i & 1) ^ 1]));\n for(mask = 0; mask < 48; mask++) {\n for(r7 = 0; r7 < 7; r7++) {\n for(r8 = 0; r8 < 8; r8++) {\n for(r9 = 0; r9 < 9; r9++) {\n for(high = 0; high < 2; high++) {\n for(last = 0; last < 2; last++) {\n if(d[i & 1][mask][r7][r8][r9][high][last] == 0)\n continue;\n int limit = 9;\n if(high == 0)\n limit = digits[dgCount - i - 1];\n for(next = 0; next <= limit; next++) {\n int nr7 = nx7[r7][next];\n int nr8 = nx8[r8][next];\n int nr9 = nx9[r9][next];\n int nmask = nxmask[mask][next];\n int nhigh = (high ? 1 : (next == limit ? 0 : 1));\n int nlast = (next == 0 || next == 5 ? 1 : 0);\n d[(i & 1) ^ 1][nmask][nr7][nr8][nr9][nhigh][nlast] += \n d[i & 1][mask][r7][r8][r9][high][last];\n }\n }\n }\n }\n }\n }\n }\n }\n\n long long ans = 0;\n for(mask = 0; mask < 48; mask++) {\n for(r7 = 0; r7 < 7; r7++) {\n if(bad7[mask][r7]) {\n break;\n }\n for(r8 = 0; r8 < 8; r8++) {\n if(bad8[mask][r8]) {\n continue;\n }\n for(r9 = 0; r9 < 9; r9++) {\n if(bad9[mask][r9]) {\n continue;\n }\n for(high = 0; high < 2; high++)\n for(last = 0; last < 2; last++) {\n if(bad5[mask][last])\n continue;\n ans += d[dgCount & 1][mask][r7][r8][r9][high][last];\n if(0 && d[dgCount & 1][mask][r7][r8][r9][high][last] > 0)\n printf(\"mask=%d r7=%d r8=%d r9=%d high=%d last=%d val=\"LL\"\\n\"\n , mask, r7, r8, r9, high, last, \n d[dgCount & 1][mask][r7][r8][r9][high][last]);\n \n }\n }\n }\n }\n }\n //printf(\"HERE \"LL\"\\n\", d[1][24][0][7][7][0][0]); \n return ans;\n}\n\nint stupid(int n) {\n int i, j, tmp;\n int ans = 0;\n for(i = 0; i <= n; i++) {\n int isValid = 1;\n tmp = i;\n while(tmp) {\n int cur = tmp % 10;\n tmp /= 10;\n if(cur >= 2 && i % cur)\n isValid = 0;\n }\n ans += isValid;\n }\n return ans;\n}\n\nvoid test() {\n int n;\n for(n = 0; n <= 200; n++) {\n int answer = stupid(n);\n int cand = solve(n, 1);\n if(answer != cand) {\n puts(\"WA\");\n printf(\"n = %d, answer is %d, you think it's %d\\n\", n, answer, cand);\n break;\n }\n }\n}\n\nvoid init() {\n int i, j;\n for(i = 0; i < 10; i++)\n for(j = 0; j < 10; j++) {\n nx7[i][j] = (10 * i + j) % 7; \n nx8[i][j] = (10 * i + j) % 8;\n nx9[i][j] = (10 * i + j) % 9;\n }\n for(i = 0; i < 48; i++)\n for(j = 0; j < 10; j++) {\n if(j < 2)\n nxmask[i][j] = i;\n else { \n int tmp = i;\n int p7 = tmp / 24;\n tmp %= 24;\n int p5 = tmp / 12;\n tmp %= 12;\n int p3 = tmp / 4;\n tmp %= 4;\n int p2 = tmp;\n \n tmp = j;\n int p[10], k;\n memset(p, 0, sizeof(p));\n for(k = 2; k <= 7; k++)\n while(tmp % k == 0) {\n tmp /= k;\n p[k]++;\n }\n \n p2 = max(p2, p[2]);\n p3 = max(p3, p[3]);\n p5 = max(p5, p[5]);\n p7 = max(p7, p[7]);\n nxmask[i][j] = 24 * p7 + 12 * p5 + 4 * p3 + p2;\n }\n }\n for(i = 0; i < 48; i++) {\n for(j = 0; j < 10; j++) {\n int tmp = i;\n int p7 = tmp / 24;\n tmp %= 24;\n int p5 = tmp / 12;\n tmp %= 12;\n int p3 = tmp / 4;\n tmp %= 4;\n int p2 = tmp;\n \n if(j == 0 && p5 == 1)\n bad5[i][j] = 1;\n\n if(j != 0 && p7 == 1)\n bad7[i][j] = 1;\n\n if(j != 0 && p2 == 3)\n bad8[i][j] = 1;\n if(j != 4 && j != 0 && p2 == 2)\n bad8[i][j] = 1;\n if(j != 6 && j != 4 && j != 2 && j != 0 && p2 == 1)\n bad8[i][j] = 1;\n \n if(j != 0 && p3 == 2)\n bad9[i][j] = 1;\n if(j != 6 && j != 3 && j != 0 && p3 == 1)\n bad9[i][j] = 1;\n }\n }\n}\n\nint getInt() {\n int ret = 0;\n char c;\n while((c = getchar()) != '\\n')\n ret = ret * 10 + c - '0';\n return ret;\n}\n\nvoid getLong() {\n dgCount = 0;\n char c;\n while((c = getchar()) != '\\n') {\n digits[dgCount++] = c - '0';\n }\n}\n\nint main() {\n int t, i;\n init();\n t = getInt();\n for(i = 0; i < t; i++) {\n long long from;\n scanf(LL\" \", &from);\n long long val = -solve(from - 1, 1);\n getLong();\n val += solve(0, 0);\n printf(LL\"\\n\", val);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "number theory"], "code_uid": "c524ae1fe4cf3c114aabd3893335623e", "src_uid": "37feadce373f728ba2a560b198ca4bc9", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i=0;now--){\n rep(i,M) nx1[i]=nx2[i]=0;\n\n rep(i,M) if(dp2[i]) rep(k,us) nx2[nex[i][k]] += dp2[i];\n \n rep(i,M) if(dp1[i]) rep(k,us){\n if(go[now]==use[k]) nx1[nex[i][k]] += dp1[i];\n if(go[now]> use[k]) nx2[nex[i][k]] += dp1[i];\n }\n\n swap=dp1, dp1=nx1, nx1=swap;\n swap=dp2, dp2=nx2, nx2=swap;\n }\n\n rep(i,M) dp[mask][i] = dp1[i] + dp2[i];\n }\n\n res = 0;\n rep(mask,1<<8){\n g=1;\n rep(i,8) if(mask&1<\nint main()\n{\n int i,j,k,s1=0,s2=0,n,m,c1=0,c2=0,tem,d;\n scanf(\"%d%d\",&n,&m);\n int t[n];\n for(i=0;i=d)break;\n else c2++;\n }\n printf(\"%d \",++c2);\n }\n }\n}", "lang_cluster": "C", "tags": ["sortings", "greedy"], "code_uid": "1ee306c85340f2cf7c7016705813d67e", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint compare(const void* p, const void* q){\n\tint a = *(const int*)p;\n\tint b = *(const int*)q;\n\treturn a-b;\n}\n\nint fit(int a[], int size, int val_left){\n\tint i;\n\tint count = 0;\n\tfor(i=0; i < size && val_left >= 0; i++){\n\t\tval_left -= a[i];\n\t\tif(val_left >= 0)\n\t\t\tcount++;\n\t}\n\treturn size - count;\n}\n\nvoid print(int a[], int size){\n\tprintf(\"ARRAY: \\n\");\n\tfor(int i=0; i < size; i++)\n\t\tprintf(\"%d \", a[i]);\n\tprintf(\"\\n\");\n}\n\nint main() {\n\tint N, M;\n\tscanf(\"%d %d\", &N, &M);\n\tint t[N];\n\tint i;\n\tfor(i=0; i\n#define ll long long int\n#define loop(a,b) for(int i = a; i < b; ++i)\n#define loop2(a,b) for(int j = a; j < b; ++j)\n\nconst int mod=1e+9+7;\nlong long dp[100][2];\n\nvoid solve(){\n int n,k,d;\n scanf(\"%d %d %d\",&n,&k,&d);\n loop(1,n+1){\n dp[i][0] = dp[i][1] = 0;\n loop2(1,k+1){\n if (i-j < 0) break;\n if (j < d){\n dp[i][0] = (dp[i][0] + dp[i-j][0])%mod;\n dp[i][1] = (dp[i][1] + dp[i-j][1])%mod;\n }\n else{\n dp[i][1] = (dp[i][1] + dp[i-j][0] + dp[i-j][1])%mod;\n }\n }\n }\n ll ans = dp[n][1]%mod;\n printf(\"%lld\\n\",ans);\n}\n\nint main(){\n dp[0][0] = 1;\n dp[0][1] = 0;\n \n int t=1;\n // cin>>t;\n while(t--) solve();\n return 0;\n}", "lang_cluster": "C", "tags": ["dp", "implementation", "trees"], "code_uid": "361791ab1f6b681df8229a31f035c715", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define mo 1000000007\nlong dp[105][2]={{0}},n,k,d;\nint main()\n{\n\tlong i,j;\n\tscanf(\"%ld %ld %ld\",&n,&k,&d);\n\tdp[0][0]=1;\n\tfor (i=0;i=d) dp[i+j][1]=(dp[i+j][1]+dp[i][0])%mo;\n\t\telse dp[i+j][0]=(dp[i+j][0]+dp[i][0])%mo;\n\t\tdp[i+j][1]=(dp[i+j][1]+dp[i][1])%mo;\n\t}\n\tprintf(\"%ld\",dp[n][1]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "implementation", "trees"], "code_uid": "75cd3d5869dd23471a307ad9d6b45a8c", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint mask(int c) {\n char s_c[7];\n int i = 0;\n int ans = 0;\n\n sprintf(s_c, \"%d\", c);\n while (s_c[i] != '\\0') {\n if (s_c[i] == '4') ans = ans*10 + 4;\n else if (s_c[i] == '7') ans = ans*10 + 7;\n i++;\n }\n return ans;\n}\n\nint main() {\n int a, b, c;\n\n scanf(\"%d%d\", &a, &b);\n c = a + 1;\n \n while (c < 1000000) {\n if (mask(c) == b) {\n printf(\"%d\", c);\n break;\n }\n c++;\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "eaaa9afa3eee58baa3cfaafa2d7eac77", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n\tint a, b;\n\tchar ar[20], br[20];\n\tscanf (\"%d%d\", &a, &b);\n\tint ans = a+1;\n\tint i;\n\tint temp;\n\tar[19] = '\\0';\n\twhile (1){\n\t\ttemp = ans;\n\t\ti=18;\n\t\twhile (temp > 0){\n\t\t\tif ( temp%10 == 7 || temp%10 == 4 )\n\t\t\t\tar[i--] = temp%10 + 48;\n\t\t\ttemp = temp/10;\n\t\t}\n\t\tif ( atoi(&ar[i+1]) == b ){\n\t\t\tprintf (\"%d\\n\", ans);\n\t\t\tbreak;\n\t\t}\n\t\telse\n\t\t\tans++;\n\t\t\n\t}\n\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "6f8b394714bb87eb28803be9f8857663", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define my_abs(x) ((x) < 0 ? -(x) : (x))\n#define chk(x) (x != p[0] && x != p[1] && x != p[2])\n#define min(x, y) ((x) < (y) ? (x) : (y))\n#define max(x, y) ((x) > (y) ? (x) : (y))\n#define true 1\ntypedef int bool; \nbool vis[55][55][55][9][9]; \nint p[5], m[5], t[5], ans; \nvoid dfs(int *p, int x, int y)\n{\n\tif (vis[p[0]][p[1]][p[2]][x][y])\n\t\treturn; \n\tvis[p[0]][p[1]][p[2]][x][y] = true; \n\tint far = 0, near = 50; \n\tfor (int i = 0; i < 3; i++)\n\t{\n\t\tif (p[i] < 45)\n\t\t\tfar = max(far, p[i]); \n\t\tnear = min(near, p[i]);\n\t}\n\tans = max(ans, far); \n\tfor (int j = 0; j < 3; j++)\n\t{\n\t\tint arr[] = {p[0], p[1], p[2]}, z = 1 << j; \n\t\tif (p[j] >= 45)\n\t\t{\n\t\t\tint pos = p[j] - 45; \n\t\t\tif (p[pos] >= 45)\n\t\t\t\tcontinue;\n\t\t\tfor (int i = p[pos] + t[pos]; i >= p[pos] - t[pos] && i > near - 2 && i; i--)\n\t\t\t{\n\t\t\t\tif (chk(i))\n\t\t\t\t{\n\t\t\t\t\tarr[j] = i; \n\t\t\t\t\tdfs(arr, x, y); \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if (chk(j + 45))\n\t\t{\n\t\t\tif (y & z)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < 3; i++)\n\t\t\t\t{\n\t\t\t\t\tif (my_abs(p[i] - p[j]) != 1)\n\t\t\t\t\t\tcontinue; \n\t\t\t\t\tarr[i] = 45 + j; \n\t\t\t\t\tdfs(arr, x, y ^ z); \n\t\t\t\t\tarr[i] = p[i]; \n\t\t\t\t}\n\t\t\t}\n\t\t\tif (x & z)\n\t\t\t{\n\t\t\t\tfor (int i = p[j] + m[j]; i >= p[j] - m[j] && i > near - 2 && i; i--)\n\t\t\t\t{\n\t\t\t\t\tif (!chk(i))\n\t\t\t\t\t\tcontinue; \n\t\t\t\t\tarr[j] = i; \n\t\t\t\t\tdfs(arr, x ^ z, y); \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\nint main()\n{\n\t// freopen(\"105E.in\", \"r\", stdin); \n\tfor (int i = 0; i < 3; i++)\n\t\tscanf(\"%d%d%d\", p + i, m + i, t + i); \n\tdfs(p, 7, 7); \n\tprintf(\"%d\\n\", ans);\n\treturn 0; \n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "5c877ea2795e2d2f6dc652083be71cff", "src_uid": "a14739b86d1fd62a030226263cdc1afc", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint max=0;\nint a[10];\nint p[100];\ntypedef struct\n{\n\tint val;\n\tint mvrg;\n\tint thrg;\n}Ch;\ntypedef Ch CA[4];\nint movethrow(CA,int);\nint search(int pe)\n{\n\tint i,t;\n\tfor (i=1;i<45;i++)\t\n\t{\n\t\tif (p[i]>0)\n\t\t{\n\t\t\tt=p[i];\n\t\t\twhile (t)\n\t\t\t{\n\t\t\t\tif ((t%10)==pe)\n\t\t\t\t\treturn i;\n\t\t\t\tt=t/10;\n\t\t\t}\n\t\t}\n\t}\n}\nint change(int pe,int pos)\n{\n\tint t;\n\tt=search(pe);\n\tp[t]=0;\n\tp[pos]=pe;\n\t\n}\nint tr(CA C,int pe)\n{\n\tint i,j;\n\tint f,m,r,t[4];\n\tint temp;\n\tt[1]=search(1);\n\tt[2]=search(2);\n\tt[3]=search(3);\n\tm=t[pe];\n\ttemp=p[m];\n\tf=m-C[pe].thrg;\n\tr=m+C[pe].thrg;\n\tif (r>max)\n\t\tmax=r;\n\tif (f<=0)\n\t\tf=1;\n\tfor (i=f;i<=r;i++)\n\t{\n\t\tif (i!=m&&p[i]==0&&\n\t\t\t(abs(i-t[1])==1||abs(i-t[2]==1)||abs(i-t[3])==1||i==r))\n\t\t{\n\t\t\t\n\t\t\tp[i]=temp/10;\n\t\t\tp[m]=temp%10;\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp[i]=0;\n\t\t\tp[m]=temp;\n\t\t}\n\t}\n\treturn 0;\n}\nint mv(CA C,int pe)\n{\n\tint i,j;\n\tint f,m,r,t[4];\n\tt[1]=search(1);\n\tt[2]=search(2);\n\tt[3]=search(3);\n\tint temp;\n\ttemp=t[pe];\n\tm=t[pe];\n\tt[pe]=t[3];\n\tt[3]=temp;\n\tf=m-C[pe].mvrg;\n\tr=m+C[pe].mvrg;\n\tif (r>max)\n\t\tmax=r;\n\tif (f<=0)\n\t\tf=1;\n\tfor (i=f;i<=r;i++)\n\t{\n\t\tif (i!=m&&p[i]==0&&\n\t\t\t(abs(i-t[1])<=2||abs(i-t[2]<=2)||abs(i-t[3])<=1||i==r))\n\t\t{\n\t\t\tchange(pe,i);\n\t\t\t\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tchange(pe,m);\n\treturn 0;\n}\n\nint movethrow(CA C,int fr)\n{\n\tint i,j;\n\tint rt;\n\tif (fr%3==1)\n\t{\n\t\trt=fr/3+1;\n\t\tif (a[fr+1]==1&&a[fr+2]==0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse if (p[search(rt)]>10)\n\t\t{\n\t\t\treturn 0;\n\t \t}\n\t\telse\n\t\t{\n\t\t\tmv(C,rt);\n\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t}\n\tif (fr%3==2)\n\t{\n\t\tint px;\n\t\trt=fr/3+1;\n\t\tpx=search(rt);\n\t\tif (p[px]>10)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse if (p[px-1]>0)\n\t\t{\n\t\t\tint temp;\n\t\t\tp[px]+=p[px-1]*10;\n\t\t\ttemp=p[px-1];\n\t\t\tp[px-1]=0;\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp[px]=rt;\n\t\t\tp[px-1]=temp;\n\t\t}\n\t\telse if (p[px+1]>0)\n\t\t{\n\t\t\tint temp;\n\t\t\tp[px]+=p[px+1]*10;\n\t\t\ttemp=p[px+1];\n\t\t\tp[px+1]=0;\n\t\t\tfor (j=1;j<=9;j++)\n\t\t\t{\n\t\t\t\tif (a[j]==0)\n\t\t\t\t{\n\t\t\t\t\ta[j]=1;a[0]++;\n\t\t\t\t\tmovethrow(C,j);\n\t\t\t\t\ta[j]=0;a[0]--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tp[px]=rt;\n\t\t\tp[px+1]=temp;\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif (fr%3==0)\n\t{\n\t\trt=fr/3;\n\t\tint px;\n\t\tpx=search(rt);\n\t\tif (a[fr-1]==0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse if (p[px]%10!=rt)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse \n\t\t{\n\t\t\ttr(C,rt);\n\t\t\treturn 0;\n\t\t}\n\t}\n}\nint main()\n{\n\tCA C;\n\tint i,j;\n\tfor (i=1;i<100;i++)\n\t{\n\t\tp[i]=0;\n\t}\n\tfor (i=1;i<=3;i++)\n\t{\n\t\tscanf(\"%d %d %d\",&C[i].val,&C[i].mvrg,&C[i].thrg);\n\t\tp[C[i].val]=i;\n\t}\n\tfor (i=0;i<=9;i++)\n\t{\n\t\ta[i]=0;\n\t}\n\tfor (i=1;i<=9;i++)\n\t{\n\t\ta[i]=1;a[0]++;\n\t\tmovethrow(C,i);\n\t\ta[i]=0;a[0]--;\n\t}\n\t\n\tprintf(\"%d\",max);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "464f4d82be7fa4388d6e7a6c1c14a185", "src_uid": "a14739b86d1fd62a030226263cdc1afc", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n \r\ntypedef unsigned long long ll;\r\ntypedef unsigned int uint;\r\n \r\nint mod = 998244353;\r\n \r\nll qPow(ll a, ll b) {\r\n\tll ret = 1;\r\n\twhile(b) {\r\n\t\tif(b&1)\r\n\t\t\tret = ret * a % mod;\r\n\t\ta = a * a % mod;\r\n\t\tb >>= 1;\r\n\t}\r\n\treturn ret;\r\n}\r\n\r\nuint C[501][501];\r\nuint inited = 0;\r\nvoid init() {\r\n\tif (inited) return;\r\n\tinited = 1;\r\n\tmemset(C,0,sizeof(C));\r\n\tfor(uint i=0;i<=500;i++){\r\n\t\tfor(uint j=0;j<=i;j++) {\r\n\t\t\tif(!j)\r\n\t\t\t\tC[i][j] = 1;\r\n\t\t\telse\r\n\t\t\t\tC[i][j] = C[i-1][j] + C[i-1][j-1];\r\n\t\t\tif(C[i][j] >= mod)\r\n\t\t\t\tC[i][j] -= mod;\r\n\r\n\t\t}\r\n\t}\r\n}\r\nll f[501][501];\r\nint main() {\r\n uint n, x;\r\n scanf(\"%u %u\", &n, &x);\r\n\tinit();\r\n\t\r\n\tmemset(f,0,sizeof(f));\r\n\tfor(uint i=2;i<=n;i++){\r\n\t\tfor(uint j=1;j<=x;j++) {\r\n\t\t\tif(j\r\n#include \r\n \r\ntypedef long long ll;\r\n \r\nint mod = 998244353;\r\n \r\nll qPow(ll a, ll b) {\r\n\tll ret = 1;\r\n\twhile(b) {\r\n\t\tif(b&1)\r\n\t\t\tret = ret * a % mod;\r\n\t\ta = a * a % mod;\r\n\t\tb >>= 1;\r\n\t}\r\n\treturn ret;\r\n}\r\n \r\n \r\nint main() {\r\n int n, x;\r\n scanf(\"%d %d\", &n, &x);\r\n\tll C[n+1][n+1];\r\n\tmemset(C,0,sizeof(C));\r\n\tfor(int i=0;i<=n;i++){\r\n\t\tfor(int j=0;j<=i;j++) {\r\n\t\t\tif(!j)\r\n\t\t\t\tC[i][j] = 1;\r\n\t\t\telse\r\n\t\t\t\tC[i][j] = C[i-1][j] + C[i-1][j-1];\r\n\t\t\t\tif(C[i][j] >= mod)\r\n\t\t\t\t C[i][j] -= mod;\r\n\t\t\t\t \r\n\t\t}\r\n\t}\r\n\tll f[n+1][x+1];\r\n\tmemset(f,0,sizeof(f));\r\n\tfor(int i=2;i<=n;i++){\r\n\t\tfor(int j=1;j<=x;j++) {\r\n\t\t\tif(j \n \nint main() \n{ \n\tint x1,x2,y1,y2;\n\tint x,y;\n\tint n,m;\n\tscanf(\"%d%d%d%d\",&x1,&y1,&x2,&y2);\n\tscanf(\"%d%d\",&x,&y);\n\n\tif(((y2-y1)%y)==0)\n\t{\n\t\tn=(y2-y1)/y;\n\t\tif(((x2-x1)%x)==0)\n\t\t{\n\t\t\tm=(x2-x1)/x;\n\t\t\tif((m-n)%2==0)\n\t\t\t\tprintf(\"YES\");\n\t\t\telse\n\t\t\t\tprintf(\"NO\");\n\t\t}\n\t\telse\n\t\t\tprintf(\"NO\");\n\t}\n\telse\n\t\tprintf(\"NO\");\n return 0; \n} ", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "abd5ffab7ad802a713fa91ba84c4075f", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int x1,x2,y1,y2,x,y,a,b;\n scanf(\"%d %d %d %d\",&x1,&y1,&x2,&y2);\n scanf(\"%d %d\",&x,&y);\n\n a=abs(x2-x1);\n b=abs(y2-y1);\n\n if(a%x!=0||b%y!=0)\n {\n printf(\"NO\\n\");\n }\n\n else if((a/x)%2==(b/y)%2)\n {\n printf(\"YES\\n\");\n }\n else{\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "number theory"], "code_uid": "4a700ff3b051df2568e0a719a9fe6520", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nvoid swap(int a[],int b[])\n{\n int t;\n t=a[0];\n a[0]=b[0];\n b[0]=t;\n t=a[1];\n a[1]=b[1];\n b[1]=t;\n}\nint main()\n{\n int a[2][2],b[2][2];\n scanf(\"%d%d\",&a[0][0],&a[0][1]);\n scanf(\"%d%d\",&a[1][0],&a[1][1]);\n scanf(\"%d%d\",&b[0][0],&b[0][1]);\n scanf(\"%d%d\",&b[1][0],&b[1][1]);\n\n if(((a[0][0]>b[1][1]&&a[1][1]>b[0][0])&&(a[0][0]>b[0][1]&&a[1][1]>b[1][0]))||(((a[1][0]>b[0][1]&&a[0][1]>b[1][0]))&&(a[1][0]>b[1][1]&&a[0][1]>b[0][0])))\n {\n printf(\"Team 1\\n\");\n }\n else if(((a[0][0]\n\n#define WIN(x, y, z, w) a[x] > b[y] && b[z] > a[w]\n\nint main(void) {\n int i;\n int a[4], b[4];\n\n for (i = 0; i < 4; i++)\n scanf(\"%d %d\", a + i, b + i);\n\n puts(WIN(0, 2, 1, 3) && WIN(0, 3, 1, 2) || WIN(1, 2, 0, 3) && WIN(1, 3, 0, 2) ? \"Team 1\" : (WIN(2, 0, 3, 1) || WIN(3, 0, 2, 1)) && (WIN(2, 1, 3, 0) || WIN(3, 1, 2, 0)) ? \"Team 2\" : \"Draw\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "d29be1a0b9f06070d791f5c8f8f4aeb3", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n#include \n\n#define N\t50\n#define A\t26\n#define N_\t(1 + N + A + 1)\n#define M_\t(N + N * A + A)\n#define INF\t0x3f3f3f3f\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 oo[1 + M_ * 2], oh[1 + M_ * 2];\n\nint link(int o, int h) {\n\tstatic int _ = 1;\n\n\too[_] = o, oh[_] = h;\n\treturn _++;\n}\n\nint ii[M_], jj[M_], cc[M_ * 2], cost[M_], cost_[M_], m_;\nint ae[N_], pi[N_], dd[N_], ff[N_], n_;\nint pq[1 + N_], iq[N_], cnt;\n\nvoid link_(int i, int j, int c, int co) {\n\tint h = m_++;\n\n\tii[h] = i, jj[h] = j, cc[h << 1] = c;\n\tcost[h] = co;\n\tae[i] = link(ae[i], h << 1);\n\tae[j] = link(ae[j], h << 1 | 1);\n}\n\nint less(int u, int v) {\n\treturn pi[u] < pi[v] || pi[u] == pi[v] && dd[u] < dd[v];\n}\n\nint i2(int i) {\n\treturn (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;\n}\n\nvoid pq_up(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_dn(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_add_last(int u) {\n\tpq[iq[u] = ++cnt] = u;\n}\n\nint pq_remove_first() {\n\tint u = pq[1], v = pq[cnt--];\n\n\tif (v != u)\n\t\tiq[v] = 1, pq_dn(v);\n\tiq[u] = 0;\n\treturn u;\n}\n\nint dijkstra(int s, int t) {\n\tmemset(pi, 0x3f, n_ * sizeof *pi);\n\tpi[s] = 0, pq_add_last(s);\n\twhile (cnt) {\n\t\tint i, d, o;\n\n\t\ti = pq_remove_first();\n\t\td = dd[i] + 1;\n\t\tfor (o = ae[i]; o; o = oo[o]) {\n\t\t\tint h_ = oh[o];\n\n\t\t\tif (cc[h_] > 0) {\n\t\t\t\tint h = h_ >> 1, j = i ^ ii[h] ^ jj[h];\n\t\t\t\tint p = pi[i] + ((h_ & 1) == 0 ? cost_[h] : -cost_[h]);\n\n\t\t\t\tif (pi[j] > p || pi[j] == p && dd[j] > d) {\n\t\t\t\t\tif (pi[j] == INF)\n\t\t\t\t\t\tpq_add_last(j);\n\t\t\t\t\tpi[j] = p, dd[j] = d, ff[j] = h_;\n\t\t\t\t\tpq_up(j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn pi[t] != INF;\n}\n\nint trace(int s, int t) {\n\twhile (t != s) {\n\t\tint h_ = ff[t], h = h_ >> 1;\n\n\t\tcc[h_]--, cc[h_ ^ 1]++;\n\t\tt ^= ii[h] ^ jj[h];\n\t}\n\treturn 1;\n}\n\nint edmonds_karp(int s, int t) {\n\tint h, f, ans;\n\n\tfor (h = 0; h < m_; h++) {\n\t\tint i = ii[h], j = jj[h];\n\n\t\tpi[j] = min(pi[j], pi[i] + cost[h]);\n\t}\n\tfor (h = 0; h < m_; h++) {\n\t\tint i = ii[h], j = jj[h];\n\n\t\tcost_[h] = cost[h] + pi[i] - pi[j];\n\t}\n\tf = 0;\n\twhile (dijkstra(s, t)) {\n\t\tf += trace(s, t);\n\t\tfor (h = 0; h < m_; h++) {\n\t\t\tint i = ii[h], j = jj[h];\n\n\t\t\tif (pi[i] != INF && pi[j] != INF) {\n\t\t\t\t/* pi[j] <= pi[i] + cost_[h] */\n\t\t\t\t/* cost_[h] + pi[i] - pi[j] >= 0 */\n\t\t\t\tcost_[h] += pi[i] - pi[j];\n\t\t\t}\n\t\t}\n\t}\n\tans = 0;\n\tfor (h = 0; h < m_; h++)\n\t\tans += cc[h << 1 | 1] * cost[h];\n\treturn ans;\n}\n\nint main() {\n\tstatic char cc[N * 2 + 1];\n\tstatic int bb[N * 2], kk[A];\n\tint n, i, a;\n\n\tscanf(\"%d%s\", &n, cc), n /= 2;\n\tn_ = 1 + n + A + 1;\n\tfor (i = 0; i < n * 2; i++)\n\t\tscanf(\"%d\", &bb[i]);\n\tfor (i = 0; i < n; i++)\n\t\tlink_(0, 1 + i, 2, 0);\n\tfor (i = 0; i < n; i++) {\n\t\tint j = n * 2 - 1 - i;\n\t\tint ai = cc[i] - 'a';\n\t\tint aj = cc[j] - 'a';\n\n\t\tfor (a = 0; a < A; a++) {\n\t\t\tint b;\n\n\t\t\tif (a == ai && a == aj)\n\t\t\t\tb = max(bb[i], bb[j]);\n\t\t\telse if (a == ai)\n\t\t\t\tb = bb[i];\n\t\t\telse if (a == aj)\n\t\t\t\tb = bb[j];\n\t\t\telse\n\t\t\t\tb = 0;\n\t\t\tlink_(1 + i, 1 + n + a, 1, -b);\n\t\t}\n\t}\n\tfor (i = 0; i < n * 2; i++) {\n\t\ta = cc[i] - 'a';\n\t\tkk[a]++;\n\t}\n\tfor (a = 0; a < A; a++)\n\t\tlink_(1 + n + a, n_ - 1, kk[a], 0);\n\tprintf(\"%d\\n\", -edmonds_karp(0, n_ - 1));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "flows", "graphs"], "code_uid": "8107059f00c48075738a9f764424682c", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n#include \n\n#define N\t50\n#define A\t26\n#define N_\t(1 + N + A + 1)\n#define M_\t(N + N * A + A)\n#define INF\t0x3f3f3f3f\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 oo[1 + M_ * 2], oh[1 + M_ * 2];\n\nint link(int o, int h) {\n\tstatic int _ = 1;\n\n\too[_] = o, oh[_] = h;\n\treturn _++;\n}\n\nint ii[M_], jj[M_], cc[M_ * 2], ww[M_], ww_[M_], m_;\nint ae[N_], dd[N_], kk[N_], ff[N_], n_;\nint pq[1 + N_], iq[N_], cnt;\n\nvoid link_(int i, int j, int c, int w) {\n\tint h = m_++;\n\n\tii[h] = i, jj[h] = j, cc[h << 1] = c;\n\tww[h] = w;\n\tae[i] = link(ae[i], h << 1);\n\tae[j] = link(ae[j], h << 1 | 1);\n}\n\nint less(int u, int v) {\n\treturn dd[u] < dd[v] || dd[u] == dd[v] && kk[u] < kk[v];\n}\n\nint i2(int i) {\n\treturn (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;\n}\n\nvoid pq_up(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_dn(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_add_last(int u) {\n\tpq[iq[u] = ++cnt] = u;\n}\n\nint pq_remove_first() {\n\tint u = pq[1], v = pq[cnt--];\n\n\tif (v != u)\n\t\tiq[v] = 1, pq_dn(v);\n\tiq[u] = 0;\n\treturn u;\n}\n\nint dijkstra(int s, int t) {\n\tmemset(dd, 0x3f, n_ * sizeof *dd);\n\tdd[s] = 0, pq_add_last(s);\n\twhile (cnt) {\n\t\tint i, k, o;\n\n\t\ti = pq_remove_first();\n\t\tk = kk[i] + 1;\n\t\tfor (o = ae[i]; o; o = oo[o]) {\n\t\t\tint h_ = oh[o];\n\n\t\t\tif (cc[h_] > 0) {\n\t\t\t\tint h = h_ >> 1, j = i ^ ii[h] ^ jj[h];\n\t\t\t\tint d = dd[i] + ((h_ & 1) == 0 ? ww_[h] : -ww_[h]);\n\n\t\t\t\tif (dd[j] > d || dd[j] == d && kk[j] > k) {\n\t\t\t\t\tif (dd[j] == INF)\n\t\t\t\t\t\tpq_add_last(j);\n\t\t\t\t\tdd[j] = d, kk[j] = k, ff[j] = h_;\n\t\t\t\t\tpq_up(j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn dd[t] != INF;\n}\n\nint trace(int s, int t) {\n\twhile (t != s) {\n\t\tint h_ = ff[t], h = h_ >> 1;\n\n\t\tcc[h_]--, cc[h_ ^ 1]++;\n\t\tt ^= ii[h] ^ jj[h];\n\t}\n\treturn 1;\n}\n\nint edmonds_karp(int s, int t) {\n\tint h, f, cost;\n\n\tfor (h = 0; h < m_; h++) {\n\t\tint i = ii[h], j = jj[h];\n\n\t\tdd[j] = min(dd[j], dd[i] + ww[h]);\n\t}\n\tfor (h = 0; h < m_; h++) {\n\t\tint i = ii[h], j = jj[h];\n\n\t\tww_[h] = ww[h] + dd[i] - dd[j];\n\t}\n\tf = 0;\n\twhile (dijkstra(s, t)) {\n\t\tf += trace(s, t);\n\t\tfor (h = 0; h < m_; h++) {\n\t\t\tint i = ii[h], j = jj[h];\n\n\t\t\tif (dd[i] != INF && dd[j] != INF) {\n\t\t\t\t/* dd[j] <= dd[i] + ww_[h] */\n\t\t\t\t/* ww_[h] + dd[i] - dd[j] >= 0 */\n\t\t\t\tww_[h] += dd[i] - dd[j];\n\t\t\t}\n\t\t}\n\t}\n\tcost = 0;\n\tfor (h = 0; h < m_; h++)\n\t\tcost += ww[h] * cc[h << 1 | 1];\n\treturn cost;\n}\n\nint main() {\n\tstatic char cc[N * 2 + 1];\n\tstatic int bb[N * 2], kk[A];\n\tint n, i, a;\n\n\tscanf(\"%d%s\", &n, cc), n /= 2;\n\tn_ = 1 + n + A + 1;\n\tfor (i = 0; i < n * 2; i++)\n\t\tscanf(\"%d\", &bb[i]);\n\tfor (i = 0; i < n; i++)\n\t\tlink_(0, 1 + i, 2, 0);\n\tfor (i = 0; i < n; i++) {\n\t\tint j = n * 2 - 1 - i;\n\t\tint ai = cc[i] - 'a';\n\t\tint aj = cc[j] - 'a';\n\n\t\tfor (a = 0; a < A; a++) {\n\t\t\tint b;\n\n\t\t\tif (a == ai && a == aj)\n\t\t\t\tb = max(bb[i], bb[j]);\n\t\t\telse if (a == ai)\n\t\t\t\tb = bb[i];\n\t\t\telse if (a == aj)\n\t\t\t\tb = bb[j];\n\t\t\telse\n\t\t\t\tb = 0;\n\t\t\tlink_(1 + i, 1 + n + a, 1, -b);\n\t\t}\n\t}\n\tfor (i = 0; i < n * 2; i++) {\n\t\ta = cc[i] - 'a';\n\t\tkk[a]++;\n\t}\n\tfor (a = 0; a < A; a++)\n\t\tlink_(1 + n + a, n_ - 1, kk[a], 0);\n\tprintf(\"%d\\n\", -edmonds_karp(0, n_ - 1));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "flows", "graphs"], "code_uid": "72ac0fe2aecb5036ec131a6e62c6b738", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long power_mod (long long a, long long b, long long mod_num) {\n long long ans = 1LL;\n \n if (b > 0LL) {\n ans = power_mod(a, b/2LL, mod_num);\n ans = (ans * ans) % mod_num;\n if (b%2LL == 1LL) {\n ans = (ans * a) % mod_num;\n }\n }\n \n return ans;\n}\n\nint main () {\n int n = 0;\n int k = 0;\n \n int res = 0;\n \n long long ans = 0LL;\n long long mod_num = 1000000007LL;\n \n long long fact[100001] = {};\n long long invf[100001] = {};\n \n res = scanf(\"%d\", &n);\n res = scanf(\"%d\", &k);\n \n if (n <= k) {\n printf(\"%lld\\n\", power_mod(2LL, (long long)n, mod_num));\n return 0;\n }\n \n fact[0] = 1LL;\n for (int i = 0; i < n; i++) {\n fact[i+1] = fact[i];\n fact[i+1] *= (long long) (i+1);\n fact[i+1] %= mod_num;\n }\n \n invf[n] = power_mod(fact[n], mod_num-2LL, mod_num);\n for (int i = n; i > 0; i--) {\n invf[i-1] = invf[i];\n invf[i-1] *= (long long)i;\n invf[i-1] %= mod_num;\n }\n \n for (int i = 0; i <= k; i++) {\n long long tmp = invf[i];\n tmp = (tmp*invf[n-i])%mod_num;\n ans = (ans+tmp)%mod_num;\n }\n \n ans = (ans*fact[n])%mod_num;\n printf(\"%lld\\n\", ans);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "constructive algorithms", "combinatorics"], "code_uid": "88ce92f7467aad898b0880ff77eb3a31", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define maxN 1000001\n\nbool isP[maxN];\nint ps[maxN];\n\nbool isPrime( int n ) {\n\tint i;\n\n\tfor( i = 2; (long long) i * i <= n; i++ )\n\t\tif( n % i == 0 ) return false;\n\t\n\treturn true;\n}\n\nint main( void ) {\n\tint i, j, c;\n\n\tisP[2] = isP[3] = isP[5] = 1;\n\n\tfor( i = 7; i < maxN; i += 2 )\n\t\tif( isPrime(i) ) isP[i] = 1;\n\t\n\tps[0] = 0;\n\tfor( i = 1; i < maxN; i++ )\n\t\tps[i] = ps[i-1] + isP[i];\n\t\n\tint a, b, k;\n\tscanf(\"%i %i %i\", &a, &b, &k);\n\t\n\tint lo = 0, hi = b-a+1, ans = -1, mid;\n\twhile( lo <= hi ) {\n\t\tmid = (lo + hi) / 2;\n\n\t\tint cnt = ps[a+mid-1] - ps[a-1];\n\t\t\n\t\tbool ok = 1;\n\t\tif( cnt < k ) ok = 0;\n\n\t\tfor( i = a+1; i <= b-mid+1; i++ )\n\t\t\tif( ps[i+mid-1] - ps[i-1] < k ) ok = 0;\n\n\t\tif( ok ) {\n\t\t\tans = mid;\n\t\t\thi = mid - 1;\n\t\t} else lo = mid + 1;\n\n\t}\n\n\tprintf(\"%i\\n\", ans);\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "binary search", "number theory"], "code_uid": "fb49b982373e98b08e8e9450b527bc22", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint check(int w,int p[],int a,int b,int k) {\n\tint i;\n\tfor(i=a; i<=b-w+1; i++) {\n\t\tif(p[i+w-1]-p[i-1]\n#include \n\n#define MAXN 1010000\nbool isc[MAXN];\n\nint rev(int x)\n{\n\tint ans=0;\n\twhile(x)\n\t{\n\t\tans*=10;\n\t\tans+=x%10;\n\t\tx/=10;\n\t}\n\treturn ans;\n}\n\nint main()\n{\n\tint i,j;\n\tisc[0]=isc[1]=true;\n\tfor(i=2;i\n#define N 1000000\n\nchar is[N] = {0};\n\nint main() {\n long long i, j;\n int n;\n\n is[2] = 0;\n for (i = 2; i < N; i++) {\n if (!is[i]) {\n for (j = i * i; j < N; j += i) {\n is[j] = 1;\n }\n }\n }\n scanf(\"%d\", &n);\n int count = 0;\n for (i = 2; i < N; i++) {\n if (!is[i]) {\n int rev = 0, t = i;\n while (t > 0) {\n rev = rev * 10 + t % 10;\n t = t / 10;\n }\n if (!is[rev] && rev != i) {\n if (++count == n) {\n printf(\"%d\\n\", i);\n break;\n }\n }\n }\n }\n\n return 0;\n};\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "number theory"], "code_uid": "f8718fa859e2cba30847d5849b00e236", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nchar a[301][301][301];\nchar b[301][301];\n\nint main()\n{\n int n, x, y, z, f, i, j, k;\n \n scanf(\"%d\", &n);\n \n if (n == 1) {\n scanf(\"%d\", &x);\n \n if (x == 0) {\n f = 1;\n } else {\n f = 0;\n }\n } else if (n == 2) {\n scanf(\"%d %d\", &x, &y);\n \n for (i = 0; i <= 300; i++) {\n for (j = 0; j <= 300; j++) {\n int f = 0;\n \n for (k = 0; k < i; k++) {\n if (b[k][j] == 0) f = 1;\n }\n \n for (k = 0; k < j; k++) {\n if (b[i][k] == 0) f = 1;\n }\n \n for (k = 1; k <= i && k <= j; k++) {\n if (b[i - k][j - k] == 0) f = 1;\n }\n \n b[i][j] = f;\n }\n }\n \n f = 1 - b[x][y];\n } else {\n scanf(\"%d %d %d\", &x, &y, &z);\n \n for (i = 0; i <= 300; i++) a[0][i][i] = b[i][i] = 1;\n \n for (i = 1; i <= 300; i++) {\n int c[301] = {0};\n \n for (j = 1; j + i >= j * 2; j *= 2) ;\n \n for (; j <= 300; j++) {\n if (c[j] == 1) continue;\n \n for (k = j + 1; k <= 300; k++) {\n if (b[j][k] == 0 && c[k] == 0) {\n a[i][j][k] = b[j][k] = c[k] = 1;\n \n break;\n }\n }\n }\n }\n \n if (x > y) {\n int tmp = x;\n x = y;\n y = tmp;\n }\n \n if (y > z) {\n int tmp = y;\n y = z;\n z = tmp;\n }\n \n if (x > y) {\n int tmp = x;\n x = y;\n y = tmp;\n }\n \n f = a[x][y][z];\n }\n \n if (f == 0) {\n puts(\"BitLGM\");\n } else {\n puts(\"BitAryo\");\n }\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "c7c9953cfd2cd276f63b239e81599fb8", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint n;\nint a[3];\nchar dp[300*300*300];\nlong long step = 0;\n\nvoid calculate_result(int index, long long index1){\n if(index >= n){\n if(index1 == 0){\n dp[0] = 0;\n return;\n }\n int i, min = 300,j;\n long long index2 = index1;\n for(i=0;i (index2 % 300) ) ? (index2 % 300) : min;\n index2 /= 300;\n }\n int win = 0;\n for(i=1;i<=min;i++){\n if(dp[index1 - i*step] == 0){\n win = 1;\n break;\n }\n }\n index2 = index1;\n long long pos = 1;\n if(win == 0){\n for(i=0;i\nint c=0;\nvoid F(int l,int r,int a,int b)\n{\n\tif(a<=(r+l-1)/2&&b>(r+l-1)/2)\n\t{\n\t\t//printf(\"*\\n\");\n\t\treturn;\n\t}\n\telse if(b<=(r+l-1)/2)\n\t{\n\t\tc++;\n\t\t//printf(\"**\\n\");\n\t\tF(l,(r+l-1)/2,a,b);\n\t\treturn;\n\t}\n\telse if(a>(r+l-1)/2)\n\t{\n\t\tc++;\n\t\t//printf(\"***\\n\");\n\t\tF((r+l-1)/2+1,r,a,b);\n\t\treturn;\n\t}\n}\nint main()\n{\n\tint n,a,b;\n\tscanf(\"%d%d%d\",&n,&a,&b);\n\tint count=-1;\n\tint m=n;\n\tdo{\n\t\tn=n/2;\n\t\tcount++;\n\t}while(n);\n\t//printf(\"%d\\n\",count);\n\tif(a>b)\n\t{\n\t\t//printf(\"##\\n\");\n\t\tF(1,m,b,a);\n\t}\t\n\telse\n {\n\t\t//printf(\"##\\n\");\n\t\tF(1,m,a,b);\n\t}\n if(c==0)\n {\n \tprintf(\"Final!\\n\");\n\t}\n\telse \n\t{\n\t\tprintf(\"%d\\n\",count-c);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "1ca835fbbb2ef6b9b7ef9c79810be057", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//codeforces_931B\n#include \n#include \n\nint main(){\n\tint n, a, b;\n\tscanf(\" %d %d %d\", &n,&a,&b);\n\ta--;b--;\n\tint level = 1;\n\twhile (a/2!=b/2){\n\t\tlevel++;\n\t\ta/=2;b/=2;\n\t}\n\tint final = 0;\n\twhile (n/2){ n/=2; final++; }\n\tif (level == final){ printf(\"Final!\\n\"); } else\n\tprintf(\"%d\\n\", level);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "implementation"], "code_uid": "2bc02458db36c7fd84f64a1e72ec04a5", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct Team {\n char name[25];\n int point;\n int score;\n int miss;\n}team[4], tmp_team[4];\n\nvoid swap(int *lhs, int *rhs) {\n int tmp = *lhs;\n *lhs = *rhs;\n *rhs = tmp;\n}\n\nvoid cpy_team() {\n int i;\n for (i = 0; i < 4; ++i) {\n tmp_team[i].point = team[i].point;\n tmp_team[i].score = team[i].score;\n tmp_team[i].miss = team[i].miss;\n strcpy(tmp_team[i].name, team[i].name);\n }\n}\n\nchar hash_s[4][25];\nint hash_idx = 0;\nint hash(const char* str) {\n int i;\n for (i = 0; i < hash_idx; ++i) {\n if (!strcmp(str, hash_s[i])) {\n return i;\n }\n }\n strcpy(hash_s[hash_idx++], str);\n return hash_idx - 1;\n}\n\nint comp(const void *lhs, const void *rhs) {\n struct Team *sa = (struct Team *)lhs;\n struct Team *sb = (struct Team *)rhs;\n if (sa->point != sb->point) {\n return sa->point < sb->point;\n }\n if (sa->score - sa->miss != sb->score - sb->miss) {\n return sa->score - sa->miss < sb->score - sb->miss;\n }\n if (sa->score != sb->score) {\n return sa->score < sb->score;\n }\n return strcmp(sa->name, sb->name) > 0;\n}\n\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n int i, j, ia, ib, na, nb, b_id, opp_id, x, y, min = 10000, cnt[4];\n char sa[25], sb[25];\n\n memset(cnt, 0, sizeof(cnt));\n for (i = 0; i < 5; ++i) {\n scanf(\"%s %s %d:%d\", sa, sb, &na, &nb);\n ia = hash(sa);\n ib = hash(sb);\n strcpy(team[ia].name, sa);\n strcpy(team[ib].name, sb);\n ++cnt[ia];\n ++cnt[ib];\n /*printf(\"%d %d %d %d\\n\", na, nb, ia, ib);*/\n if (nb > na) {\n swap(&na, &nb);\n swap(&ia, &ib);\n }\n /*printf(\"%d %d\\n\", na, nb);*/\n if (na > nb) {\n team[ia].point += 3;\n } else if (na == nb) {\n team[ia].point += 1;\n team[ib].point += 1;\n }\n team[ia].score += na;\n team[ia].miss += nb;\n team[ib].score += nb;\n team[ib].miss += na;\n }\n /*for (i = 0; i < 4; ++i) {*/\n /*printf(\"%d %d %d\\n\", team[i].point, team[i].score, team[i].miss);*/\n /*}*/\n /*return 0;*/\n for (i = 0; i < 4; ++i) {\n if (!strcmp(team[i].name, \"BERLAND\")) {\n b_id = i;\n } else if (cnt[i] != 3) {\n opp_id = i;\n }\n }\n\n cpy_team();\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n /*for (i = 0; i < 4; ++i) {*/\n /*printf(\"%s\\n\", tmp_team[i].name);*/\n /*}*/\n /*printf(\"opp_id = %d, b_id = %d\\n\", opp_id, b_id);*/\n /*for (i = 0; i < hash_idx; ++i) {*/\n /*printf(\"%s\\n\", hash_s[i]);*/\n /*}*/\n for (i = 1; i < 100; ++i) {\n for (j = i - 1; j >= 0; --j) {\n cpy_team();\n tmp_team[b_id].point += 3;\n tmp_team[b_id].score += i;\n tmp_team[opp_id].miss += i;\n\n tmp_team[b_id].miss += j;\n tmp_team[opp_id].score += j;\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n if (!strcmp(tmp_team[0].name, \"BERLAND\") || !strcmp(tmp_team[1].name, \"BERLAND\")) {\n if (i - j < min) {\n min = i - j;\n x = i;\n y = j;\n }\n }\n }\n }\n if (min != 10000) {\n printf(\"%d:%d\\n\", x, y);\n } else {\n puts(\"IMPOSSIBLE\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b0e2abc7989f570376dd872d2ce66317", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nstruct Team {\n char name[25];\n int point;\n int score;\n int miss;\n}team[4], tmp_team[4];\n\nvoid swap(int *lhs, int *rhs) {\n int tmp = *lhs;\n *lhs = *rhs;\n *rhs = tmp;\n}\n\nvoid cpy_team() {\n int i;\n for (i = 0; i < 4; ++i) {\n tmp_team[i].point = team[i].point;\n tmp_team[i].score = team[i].score;\n tmp_team[i].miss = team[i].miss;\n strcpy(tmp_team[i].name, team[i].name);\n }\n}\n\nchar hash_s[4][25];\nint hash_idx = 0;\nint hash(const char* str) {\n int i;\n for (i = 0; i < hash_idx; ++i) {\n if (!strcmp(str, hash_s[i])) {\n return i;\n }\n }\n strcpy(hash_s[hash_idx++], str);\n return hash_idx - 1;\n}\n\nint comp(const void *lhs, const void *rhs) {\n struct Team *sa = (struct Team *)lhs;\n struct Team *sb = (struct Team *)rhs;\n if (sa->point != sb->point) {\n return sa->point < sb->point;\n }\n if (sa->score - sa->miss != sb->score - sb->miss) {\n return sa->score - sa->miss < sb->score - sb->miss;\n }\n if (sa->score != sb->score) {\n return sa->score < sb->score;\n }\n return strcmp(sa->name, sb->name) > 0;\n}\n\nint main() {\n // freopen(\"in.txt\", \"r\", stdin);\n int i, j, ia, ib, na, nb, b_id, opp_id, x, y, min = 10000, cnt[4];\n char sa[25], sb[25];\n\n memset(cnt, 0, sizeof(cnt));\n for (i = 0; i < 5; ++i) {\n scanf(\"%s %s %d:%d\", sa, sb, &na, &nb);\n ia = hash(sa);\n ib = hash(sb);\n strcpy(team[ia].name, sa);\n strcpy(team[ib].name, sb);\n ++cnt[ia];\n ++cnt[ib];\n /*printf(\"%d %d %d %d\\n\", na, nb, ia, ib);*/\n if (nb > na) {\n swap(&na, &nb);\n swap(&ia, &ib);\n }\n /*printf(\"%d %d\\n\", na, nb);*/\n if (na > nb) {\n team[ia].point += 3;\n } else if (na == nb) {\n team[ia].point += 1;\n team[ib].point += 1;\n }\n team[ia].score += na;\n team[ia].miss += nb;\n team[ib].score += nb;\n team[ib].miss += na;\n }\n /*for (i = 0; i < 4; ++i) {*/\n /*printf(\"%d %d %d\\n\", team[i].point, team[i].score, team[i].miss);*/\n /*}*/\n /*return 0;*/\n for (i = 0; i < 4; ++i) {\n if (!strcmp(team[i].name, \"BERLAND\")) {\n b_id = i;\n } else if (cnt[i] != 3) {\n opp_id = i;\n }\n }\n\n cpy_team();\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n /*for (i = 0; i < 4; ++i) {*/\n /*printf(\"%s\\n\", tmp_team[i].name);*/\n /*}*/\n /*printf(\"opp_id = %d, b_id = %d\\n\", opp_id, b_id);*/\n /*for (i = 0; i < hash_idx; ++i) {*/\n /*printf(\"%s\\n\", hash_s[i]);*/\n /*}*/\n for (i = 1; i < 100; ++i) {\n cpy_team();\n tmp_team[b_id].point += 3;\n tmp_team[b_id].score += i;\n tmp_team[opp_id].miss += i;\n /*for (j = 0; j < 4; ++j) {*/\n /*printf(\"%d %d %d\\n\", tmp_team[j].point, tmp_team[j].score, tmp_team[j].miss);*/\n /*}*/\n /*putchar('\\n');*/\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n if (!strcmp(tmp_team[0].name, \"BERLAND\") || !strcmp(tmp_team[1].name, \"BERLAND\")) {\n for (j = i - 1; j >= 0; --j) {\n cpy_team();\n tmp_team[b_id].point += 3;\n tmp_team[b_id].score += i;\n tmp_team[opp_id].miss += i;\n\n tmp_team[b_id].miss += j;\n tmp_team[opp_id].score += j;\n qsort(tmp_team, 4, sizeof(struct Team), comp);\n if (!strcmp(tmp_team[0].name, \"BERLAND\") || !strcmp(tmp_team[1].name, \"BERLAND\")) {\n if (i - j < min) {\n min = i - j;\n x = i;\n y = j;\n }\n }\n }\n }\n }\n if (min != 10000) {\n printf(\"%d:%d\\n\", x, y);\n } else {\n puts(\"IMPOSSIBLE\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "befc544732059f8fe81feac2ad65ddea", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,i,count=0,ara[5000];\n scanf(\"%lld\",&n);\n for(i=1;i*i<=n;i++)\n {\n if(n%i==0)\n {\n ara[count]=i;\n count++;\n }\n }\n if(ara[count-1]*ara[count-1]==n)\n printf(\"%lld\\n\",2*count-1);\n else\n printf(\"%lld\\n\",2*count);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "ae71209d37ff57cdbb219199e75cb112", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define int long long int \nsigned main(){\n\tint n,z=0;\n\tscanf(\"%lld\",&n);\n\tfor(int i=1;i*i<=n;i++){\n\t\tif(n%i==0){\n\t\t\tif(n/i==i)\n\t\t\t\tz++;\n\t\t\telse \n\t\t\t\tz=z+2;\n\t\t}\n\t}\n\tprintf(\"%lld\",z);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "80d8c81ee6f9e96f44abfa8c738d24fd", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define __STDC_FORMAT_MACROS\n#include \n#include \n#include \n\n#define SIEVE_MAX_PRIME 999983\n#define SIEVE_PRIME_COUNT 78498\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 inline bool is_prime(int64_t n) {\n if(n <= SIEVE_MAX_PRIME) {\n if(n == 2) return true;\n else if(n % 2 == 0) return false;\n else return !_sieve_is_composite[(n-1)/2];\n } else {\n for(int pi = 0 ; ; ++pi) { const int64_t p = _sieve_prime[pi];\n if(p*p > n) return true;\n if(n % p == 0) return false;\n }\n }\n}\n\nstatic inline bool is_divisible_by_primes_le(int64_t n, int64_t pm) {\n for(int pi = 0 ; ; ++pi) { const int64_t p = _sieve_prime[pi];\n if(p > pm) return false;\n if(p*p > n) return false;\n if(n % p == 0) return true;\n }\n return true;\n}\n\nint main() {\n generate_primes();\n int64_t p,y; scanf(\"%\" PRId64 \" %\" PRId64 \"\\n\", &p,&y);\n\n // we need to find largest x such that it is not divisible by primes <= pmax\n // if pmax is larger than sqrt(y) than we need biggest prime less than y\n // otherwise search for not divisible by primes smaller than pmax\n if(p*p > y) {\n for(int i = y ; i > p ; --i) if(is_prime(i)) {\n printf(\"%d\\n\", i); return 0;\n }\n } else {\n for(int i = y ; i > p ; --i) if(!is_divisible_by_primes_le(i,p)) {\n printf(\"%d\\n\", i); return 0;\n }\n }\n\n printf(\"-1\\n\"); return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "6edddb02e9930afc4524aeaf8345f43d", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint check(int x, int p) {\n\tint a;\n\n\tfor (a = 2; a <= p && a * a <= x; a++)\n\t\tif (x % a == 0)\n\t\t\treturn 0;\n\treturn 1;\n}\n\nint main() {\n\tint p, y, x;\n\n\tscanf(\"%d%d\", &p, &y);\n\tfor (x = y; x > p; x--)\n\t\tif (check(x, p)) {\n\t\t\tprintf(\"%d\\n\", x);\n\t\t\treturn 0;\n\t\t}\n\tprintf(\"-1\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "fef28ff6fe0bf9c63ada0fe525cbcce3", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint a[50],b[50];\nint main(){\n\tint n,l,flag=0;\n\tscanf(\"%d%d\",&n,&l);\n\tint i,j=0,k=0,p,q=0,temp;\n\tfor(i=0;i\n#include\nint ke[101],sa[101];\nint cha1[101],cha2[101];\n\nint main(void)\n{\n\tint n,L;\n\tint i,j,x,flag,num;\n\twhile(~scanf(\"%d %d\",&n,&L))\n\t{\n\t\tif(n==1) \n\t\t{\n\t\t\tflag=0;\n\t\t\tscanf(\"%d %d\",&ke[0],&sa[0]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tscanf(\"%d\",&ke[0]);\n\t\t\tfor(i=1; i=n) x=0;\n//\t\t\t\t\tprintf(\"!!!x=%d j=%d %d %d\\n\",x,j,cha1[x],cha2[j]);\n\t\t\t\t\tif(cha1[x]!=cha2[j])\n\t\t\t\t\t{\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\tif(num==n) flag=0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(flag==0) break;\n\t\t\t}\n\n\t\t}\n\t\tif(flag==0)\n\t\t{\n\t\t\tprintf(\"YES\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"NO\\n\");\n\t\t}\n\t}\n}", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "3d0de22dbaafa58ab64facd46dc49ef2", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main()\n{\n\tint q2=2,j,i,n;\n\tlong long a[100];\n\tscanf(\"%d\",&n);\n\tfor (i=1;i<=100;i++)\n\t{\n\t\ta[i]=((long long)q2-1)*(q2/2);\n\t\tq2*=2;\n\t\tif (a[i]>100000) break;\n\t}\n\tfor (j=i;j>=1;j--)\n\t\tif (!(n%a[j]))\n\t\t{\n\t\t\tprintf(\"%I64d\\n\",a[j]);\n\t\t\treturn 0;\n\t\t}\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "d8784d9eab209e18a91db579fe6642c3", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int n;\n scanf(\"%d\",&n);\n int k = 1;\n int gtr = 1;\n int res = 0;\n while(res <= n){\n res =(( 2 << k ) - 1) * (2 << (k-1));\n if(n%res == 0) gtr = res;\n k++;\n }\n printf(\"%d\\n\",gtr);\n\treturn 0;\n}\n\n/* 1512144896144 */\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "f199df1f36bc6161d2fb61d9efd2c36c", "src_uid": "339246a1be81aefe19290de0d1aead84", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main(){\r\n long long int n,j=3;\r\n scanf(\"%lld\",&n);\r\n if(n<=3){\r\n printf(\"%lld\",(2*n+1));\r\n }else{\r\n if(n%3==1){\r\n printf(\"%lld \",(4*(1+(n/3))));\r\n }else if(n%3==2){\r\n n=n-n/3;\r\n printf(\"%lld\",(2*n+1));\r\n }else if(n%3==0){\r\n n=n-n/3+1;\r\n printf(\"%lld\",(2*n+1));\r\n }\r\n }\r\n // if(n==1){\r\n // printf(\"3\");\r\n // }else if(n==2){\r\n // printf(\"5\");\r\n // }else {\r\n // if((2*j)%4==0){\r\n\r\n // }else{\r\n // printf(\"%lld\",(2*j+1));\r\n\r\n // }\r\n // }\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["math", "geometry", "binary search"], "code_uid": "58919d7987e727fbf7809a8e09fa7b9c", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tlong long int n, ans;\n int diff[3] = {0,1,3};\n\tscanf(\"%lld\",&n);\n\tans = n - 1;\n\tif(ans == 0)\n\t\tans = 3;\n\telse\t\n\t\tans = 4 + 4 * (ans / 3) + diff[ans%3] ;\n\tprintf(\"%lld\\n\",ans);\n}\n\n", "lang_cluster": "C", "tags": ["math", "geometry", "binary search"], "code_uid": "d490864402b1dd2e47dcc8fc9f209c4a", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n int x;\n scanf(\"%d\",&x);\n for(long r=1;r=x)\n {\n mul=10*(mul/x)+(mul%x);\n }\n printf(\"%ld \",mul);\n }\n puts(\"\");\n \n }\n return 0;\n }\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "04ca4c5d8ef23fbdc6f2588f192a378b", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int k, i, j, l;\n\n scanf(\"%d\", &k);\n\n for (i = 1; i < k; i++) {\n\t for (j = 1; j < k; j++) {\n\t int x = i * j, p = 0;\n\t int a[3];\n\n\t while (x) {\n\t\t a[p++] = x % k;\n\t\t x /= k;\n\t }\n\n\t if (j > 1) {\n\t\t for (l = 2; l >= p; l--) putchar(' ');\n\n\t\t for (; l >= 0; l--) printf(\"%d\", a[l]);\n\t } else {\n\t\t printf(\"%d\", i);\n\t }\n\t }\n\t puts(\"\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "846ed59052bce9583ef990b0440956cd", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t100\n#define MD\t100000000\n\nvoid init(int dp[][N + 1], int n, int k) {\n\tint b, i, s;\n\n\tdp[0][0] = 1;\n\tfor (b = 1; b <= n; b++) {\n\t\ts = 0;\n\t\tfor (i = 0; i <= n; i++) {\n\t\t\tdp[b][i] = s;\n\t\t\ts = (s + dp[b - 1][i]) % MD;\n\t\t\tif (i >= k)\n\t\t\t\ts = (s - dp[b - 1][i - k] + MD) % MD;\n\t\t}\n\t}\n}\n\nint main() {\n\tstatic int dp1[N + 1][N + 1], dp2[N + 1][N + 1];\n\tint n1, n2, k1, k2, b;\n\tlong long ans;\n\n\tscanf(\"%d%d%d%d\", &n1, &n2, &k1, &k2);\n\tinit(dp1, n1, k1);\n\tinit(dp2, n2, k2);\n\tans = 0;\n\tfor (b = 1; b <= n1 || b <= n2; b++) {\n\t\tif (b <= n1 && b <= n2)\n\t\t\tans = (ans + (long long) dp1[b][n1] * dp2[b][n2] * 2) % MD;\n\t\tif (b <= n1 && b - 1 <= n2)\n\t\t\tans = (ans + (long long) dp1[b][n1] * dp2[b - 1][n2]) % MD;\n\t\tif (b - 1 <= n1 && b <= n2)\n\t\t\tans = (ans + (long long) dp1[b - 1][n1] * dp2[b][n2]) % MD;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "d289f259a0aec30af5b74ca9b053d282", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAX 110\n#define MOD 100000000\n\nint main(){\n int n1, n2, k1, k2;\n int i, j, k;\n int memoi[MAX][MAX][2];\n\tscanf(\"%d %d %d %d\",&n1,&n2,&k1,&k2);\n\tmemoi[0][0][0] = memoi[0][0][1] = 1;\n\n\tfor(i = 0; i <= n1; i++){\n for(j = 0; j <= n2; j++){\n for(k = 1; i - k >= 0 && k <= k1; ++k){\n \t\t\tmemoi[i][j][0] = (memoi[i][j][0] % MOD + memoi[i - k][j][1] % MOD) % MOD;\n }\n \t\tfor (int k = 1; j - k >= 0 && k <= k2; ++k){\n \t\t\tmemoi[i][j][1] = (memoi[i][j][1] % MOD + memoi[i][j - k][0] % MOD) % MOD;\n }\n }\n}\n\n\tprintf(\"%d\\n\",(memoi[n1][n2][0] % MOD + memoi[n1][n2][1] % MOD) % MOD);\n\n\treturn 0;\n}\n\n/* 1508523588462 */\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "bec16c52486d28f2e1a5efe6b854b5b2", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.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= 2){\n solve(st, rest-2);\n if(ok[st][rest-2]){\n ok[st][rest] = 1;\n if(mx < dp_max[st][rest-2]) mx = dp_max[st][rest-2];\n if(mn > dp_min[st][rest-2]) mn = dp_min[st][rest-2];\n }\n }\n\n if(st == len){\n if(rest==0){\n ok[st][rest] = 1;\n mx = mn = 0;\n }\n } else {\n solve(st+1, rest);\n if(rest) solve(st+1, rest-1);\n\n if(in[st]=='F' && ok[st+1][rest]){\n ok[st][rest] = 1;\n if(mx < dp_max[st+1][rest]+1) mx = dp_max[st+1][rest]+1;\n if(mn > dp_min[st+1][rest]+1) mn = dp_min[st+1][rest]+1;\n }\n\n if(in[st]=='T' && rest && ok[st+1][rest-1]){\n ok[st][rest] = 1;\n if(mx < dp_max[st+1][rest-1]+1) mx = dp_max[st+1][rest-1]+1;\n if(mn > dp_min[st+1][rest-1]+1) mn = dp_min[st+1][rest-1]+1;\n }\n\n if(in[st]=='T' && ok[st+1][rest]){\n ok[st][rest] = 1;\n if(mx < -dp_min[st+1][rest]) mx = -dp_min[st+1][rest];\n if(mn > -dp_max[st+1][rest]) mn = -dp_max[st+1][rest];\n }\n\n if(in[st]=='F' && rest && ok[st+1][rest-1]){\n ok[st][rest] = 1;\n if(mx < -dp_min[st+1][rest-1]) mx = -dp_min[st+1][rest-1];\n if(mn > -dp_max[st+1][rest-1]) mn = -dp_max[st+1][rest-1];\n }\n }\n\n dp_max[st][rest] = mx;\n dp_min[st][rest] = mn;\n}\n\nint main(){\n int i,j,k,l,m,n;\n\n scanf(\"%s%d\",in,&can);\n len = strlen(in);\n\n rep(j,200) rep(k,200) alr[j][k] = 0;\n solve(0, can);\n\n/* printf(\"%d %d\\n\",dp_max[0][can],dp_min[0][can]);*/\n k = dp_max[0][can]; if(k<0) k=-k;\n l = dp_min[0][can]; if(l<0) l=-l;\n if(k < l) k = l;\n\n printf(\"%d\\n\",k);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "1c445909f000295f36ed0164c8e0283b", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define abs(a) ((a < 0) ? (-(a)) : (a))\n#define max(a, b) ((a > b) ? (a) : (b))\n#define min(a, b) ((a < b) ? (a) : (b))\n#define inf 10000000\n\nint d[101][51][2][2];\nchar s[101];\nint n, k;\n\nint\nmain(void)\n{\n while(isalpha(s[n++] = getchar()))\n ;\n --n;\n int i, j, p, t;\n scanf(\"%d\", &k);\n for(i = 0; i < n; ++i){\n for(j = 0; j <= k; ++j){\n d[i][j][0][0] = -inf;\n d[i][j][0][1] = inf;\n d[i][j][1][0] = -inf;\n d[i][j][1][1] = inf;\n }\n }\n for(j = 0; j <= k; ++j){\n if((s[0] == 'F' && j % 2 == 0) || (s[0] == 'T' && j % 2 == 1)){\n d[0][j][0][0] = 1;\n d[0][j][0][1] = 1;\n } else {\n d[0][j][1][0] = 0;\n d[0][j][1][1] = 0;\n }\n }\n for(i = 1; i < n; ++i){\n for(j = 0; j <= k; ++j){\n for(p = 0; p <= j; ++p){\n if((s[i] == 'F' && p % 2 == 0) || (s[i] == 'T' && p % 2 == 1)){//one step\n for(t = 0; t < 2; ++t){\n if(abs(d[i - 1][j - p][0][t]) != inf){\n d[i][j][0][0] = max(d[i - 1][j - p][0][t] + 1, d[i][j][0][0]);\n d[i][j][0][1] = min(d[i - 1][j - p][0][t] + 1, d[i][j][0][1]);\n }\n if(abs(d[i - 1][j - p][1][t]) != inf){\n d[i][j][1][0] = max(d[i - 1][j - p][1][t] - 1, d[i][j][1][0]);\n d[i][j][1][1] = min(d[i - 1][j - p][1][t] - 1, d[i][j][1][1]);\n }\n }\n } else {\n for(t = 0; t < 2; ++t){\n if(abs(d[i - 1][j - p][1][t]) != inf){\n d[i][j][0][0] = max(d[i - 1][j - p][1][t], d[i][j][0][0]);\n d[i][j][0][1] = min(d[i - 1][j - p][1][t], d[i][j][0][1]);\n }\n if(abs(d[i - 1][j - p][0][t]) != inf){\n d[i][j][1][0] = max(d[i - 1][j - p][0][t], d[i][j][1][0]);\n d[i][j][1][1] = min(d[i - 1][j - p][0][t], d[i][j][1][1]);\n }\n }\n }\n }\n }\n }\n int ans = 0;\n for(i = 0; i < 2; ++i){\n for(j = 0; j < 2; ++j){\n if(abs(d[n - 1][k][i][j]) != inf)\n ans = max(ans, abs(d[n - 1][k][i][j]));\n }\n }\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "6de988f0b2f312bacdfad22fd6eea9ec", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.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 main(){\n int i, n, m, mn, mx, t, bitmask;\n\n while (scanf(\"%d %d %d %d\", &n, &m, &mn, &mx) != EOF){\n bitmask = 0;\n bool flag = true;\n for (i = 0; i < m; i++){\n scanf(\"%d\", &t);\n if (t < mn || t > mx) flag = false;\n if (t == mn) bitmask |= 1;\n if (t == mx) bitmask |= 2;\n }\n\n if (!flag) puts(\"Incorrect\");\n else{\n if ((n - m) >= (2 - __builtin_popcount(bitmask))) puts(\"Correct\");\n else puts(\"Incorrect\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "0c2a0b5cea349190ee3cbeaeeba9803b", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\nint main()\n{\n int n,m,max,min,T[100],t[100],i,a=0,h=1;\n memset(t,0,sizeof(t));\n scanf(\"%d %d %d %d\",&n,&m,&min,&max);\n t[min]=1;\n t[max]=1;\n for (i=0;imax)\n {\n printf(\"Incorrect\");\n h--;\n break;\n }\n else\n {\n t[T[i]]++;\n }\n }\n if(h)\n {\n for (i=0;i\n#include\nmain()\n{\n\n char s[100];\n int flag=0,t=0,a[100];\n\n char h[100],g[100];\n int i,m,j,k=0,l;\n int sum1=0,sum2=0;\n int min1=0;\n char c;\n int base1=1,base2=1;\n scanf(\"%s\",s);\n for(i=0;s[i]!='\\0';i++)\n { c=s[i];\n if(s[i]==':')\n continue;\n if(c>='A'&&c<='Z')\n c=c-7;\n if((c-'0')>min1)\n min1=c-'0';\n\n }\n\n\n\n for(i=0;s[i]!=':';i++)\n {\n h[i]=s[i];\n }\n h[i]='\\0';\n m=i;\n for(i=m+1;s[i]!='\\0';i++)\n {\n g[k]=s[i];\n k++;\n }\n g[k]='\\0';\n j=strlen(g);\n m=strlen(h);\n for(i=min1+1;;i++)\n {\n for(k=j-1;k>-1;k--)\n {\n c=g[k];\n if(g[k]>='A'&&g[k]<='Z')\n c=c-7;\n sum1=sum1+((c-'0')*base1);\n base1=base1*i;\n\n }\n for(l=m-1;l>-1;l--)\n {\n c=h[l];\n if(h[l]>='A'&&h[l]<='Z')\n c=c-7;\n sum2=sum2+((c-'0')*base2);\n base2=base2*i;\n\n }\n\n if(sum2<24&&sum1<60)\n {\n a[t]=i;\n t++;\n flag=1;\n }\n\n\n if(sum2>23||sum1>59)\n break;\n\n if(sum2==24&&sum1!=0)\n break;\n\n\n sum1=0;\n sum2=0;\n base1=1,base2=1;\n if(i>60)\n break;\n\n\n }\n if(flag==1&&i<=60){\n for(i=0;i60)\n printf(\"%d\",-1);\n return 0;\n\n\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "bbe43f3b440286aba0e3b03d613e0068", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint a[5], b[5];\n\nint mu(int a, int n){\n\tint i, kq=1;\n\tfor(i=0;i=0;i--){\n\t\tsum+=p[i]*mu(base,n-i-1);\n\t}\n\treturn sum;\n}\n\nint main(){\n\tint i,na, nb, ma=0,mb=0,max,check=0;\n\tchar c;\n\ti=0;\n\twhile((c=getchar())!=EOF){\n\t\tif(c>='0' && c<'9') a[i++]=c-'0';\n\t\tif(c>='A' && c<='Z') a[i++]=c-'A'+10;\n\t\tif(a[i-1]>ma) ma=a[i-1];\n\t\tif(c==':') break;\n\t}\n\tna=i;\n\ti=0;\n\twhile((c=getchar())!=EOF){\n\t\tif(c>='0' && c<'9') b[i++]=c-'0';\n\t\tif(c>='A' && c<='Z') b[i++]=c-'A'+10;\n\t\tif(b[i-1]>mb) mb=b[i-1];\n\t\tif(c=='\\n') break;\n\t}\n\tnb=i;\n\t//for(i=0;imb) max = ma+1;\n\telse max = mb+1;\n\t//printf(\"%d %d %d %d\\n\",na, nb,tinh(a,na,max), tinh(b,nb,max));\n\tif(tinh(a,na,max)>23 || tinh(b,nb,max)>59){\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\t\n\tfor(i=0;i\nmain() {\n\tlong long n,k,a,b,t,sum = 0;\n\tscanf(\"%lld %lld %lld %lld\",&n,&k,&a,&b);\t\n\twhile(1) {\n\t\tt=n/k*k,sum+=(n-t)*a,n=t;\n\t\tif((n-n/k)*a<=b) break;\n\t\tn/=k,sum+=b;\n\t}\n\tprintf(\"%lld\", sum+(n-1)*a);\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "629ed96d32373c6397065ceb3e0782af", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint main()\n{\n long long unsigned sayi,bolen,cikarmaUcreti,bolmeUcreti,kalan,mod;\n long long unsigned ucret=0,as;\n scanf(\" %llu %llu %llu %llu\",&sayi,&bolen,&cikarmaUcreti,&bolmeUcreti);\n while(sayi!=1)\n {\n mod=sayi%bolen;\n if(mod)\n {\n sayi=sayi-mod;\n ucret+=cikarmaUcreti*mod;\n }\n else\n {\n kalan=sayi-sayi/bolen;\n if(kalan*cikarmaUcreti>bolmeUcreti)\n {\n sayi/=bolen;\n ucret+=bolmeUcreti;\n }\n else\n {\n ucret+=(sayi-1)*cikarmaUcreti;\n sayi=1;\n }\n }\n }\n printf(\"%llu\\n\",ucret);\n}", "lang_cluster": "C", "tags": ["greedy", "dp"], "code_uid": "c193bf20bcf8ceeb34db61768f05c5e2", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(int argc, const char * argv[])\n{\n int n, i1=1, i2, found = 0, sum, nsquare, i, j, k, hypothenuse;\n scanf(\"%d\",&n);\n if (n<5)\n {\n printf(\"0\");\n return 0;\n }\n if (n<5)\n {\n printf(\"1\");\n return 0;\n }\n\n for (i = 5; i<=n; i++)\n {\n i1 = 1;\n i2 = i-1;\n nsquare = i*i;\n while (1)\n {\n sum = i1*i1 + i2* i2;\n if (sum > nsquare)\n i2--;\n else if (sum < nsquare)\n i1++;\n else\n {\n found++;\n i2--;\n i1++;\n }\n if (i2\nint gcd(int a,int b)\n{\t\n\t\tint z=0,x=0,y=0,r=1,q=0;\n\t\tif(a>b)\n\t\t{\n\t\t\tx=a;\n\t\t\ty=b;\n\t\t}\n\t\tif(b>=a)\n\t\t{\n\t\t\ty=a;\n\t\t\tx=b;\n\t\t}\n\t\t\twhile(r!=0)\n\t\t\t{\n\t\t\t\tr=x%y;\n\t\t\t\tq=x/y;\n\t\t\t\tx=y;\n\t\t\t\ty=r;\n\t\t\t}\n\treturn x;\n}\nint main()\n{\n\t\tint n;\n\t\tscanf(\"%d\",&n);\n\t\tint x=1,y=1,k=1;\n\t\tint pyth[10000];\n\t\tfor(k=0;k<10000;k++)\n\t\t\t{\n\t\t\tpyth[k]=0;\n\t\t\t}\n\t\t\t\t\n\t\tk=1;\n\t\twhile(k*(x*x+y*y)<=n)\n\t\t{\t\n\t\t\t//\t\t\tprintf(\"x=%d y=%d k=%d\\n\",x,y,k);\n\t\t\twhile(k*(x*x+y*y)<=n)\n\t\t\t{\t\n\n\t\t\t\t//\t\t\tprintf(\"x=%d y=%d k=%d\\n\",x,y,k);\n\t\t\t\twhile(k*(x*x+y*y)<=n)\n\t\t\t\t{\n\t\t\t\t\tif(k*(x*x-y*y)>0)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(gcd(2*k*x*y,k*(x*x-y*y))==1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tpyth[k*(x*x+y*y)]++;\n//\t\t\t\t\t\tprintf(\" %d \t %d \t %d\\n\",k*(x*x-y*y),2*k*x*y,k*(x*x+y*y));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tk++;\n\t\t\t\t}\n\t\t\t\tk=1;\n\t\t\t\ty++;\n\t\t\t}\n\t\t\ty=1;\n\t\t\tx++;\n\t\t}\n\t\tint count=0,countprime=0;\n\t\tfor(k=0;k<10000;k++)\n\t\t{\n\t\t\tif(pyth[k]!=0)\n\t\t\t{\n\t\t\tcountprime+=pyth[k];\n\t\t\tcount=count+(n/k)*pyth[k];\n\t\t\t}\n\t\t}\n\t\t\tprintf(\"%d\\n\",count);\n\t\t\t\n\t\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "e540fdd2d578afaed579a0cd0c85db30", "src_uid": "36a211f7814e77339eb81dc132e115e1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\ntypedef long long int ll;\ntypedef long double ld;\n\n#define FOR(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))\n#define ROF(i,a,b) for(int (i) = (a); (i) >= (b); --(i))\n#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))\nint MAX(int a, int b) {\n\treturn (a>b)?a:b;\n}\nint main(int argc, char const *argv[]) {\n\tint n,k,x;\n\tscanf(\"%d%d\", &n, &k);\n\tint *have = (int*)calloc(5,sizeof(int));\n\tint *cnt = (int*)calloc(5,sizeof(int));\n\thave[2]=2*n;have[4]=n;\n\trep(i,k) {\n\t\tscanf(\"%d\",&x);\n\t\twhile(x>=3) {\n\t\t\tif(have[4]>0)\n\t\t\t\tx-=4,have[4]--;\n\t\t\telse if(have[2]>0)\n\t\t\t\tx-=2,have[2]--;\n\t\t\telse {\n\t\t\t\tprintf(\"NO\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif (x>0)\n\t\t\tcnt[x]++;\n\t}\n\twhile(cnt[2]>0) {\n\t\tif (have[2]>0)\n\t\t\tcnt[2]--,have[2]--;\n\t\telse if (have[4]>0)\n\t\t\tcnt[2]--, have[4]--,have[1]++;\n\t\telse\n\t\t\tcnt[2]--,cnt[1]+=2;\n\t}\n\tif (cnt[1]>have[1]+have[2]+have[4]*2) {\n\t\tprintf(\"NO\\n\");\n\t\treturn 0;\n\t}\n\tprintf(\"YES\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "f67684962dfe9d1addc16c15fa2cf6d0", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main (void)\n{\n\tint rows, groups, i;\n\tscanf (\"%d\", &rows);\n\tscanf (\"%d\", &groups);\n\n\tint rows_of_4_seats = rows;\n\tint rows_of_2_seats = 2 * rows;\n\tint seats_for_1_warroir_that_remain_from_HERE = 0;\n\tint supa_dupa_place_for_1x2_or_2x1 = 0;\n\tfor (i = 0; i < groups; i++){\n\t\tint current_group;\n\t\tscanf(\"%d\", ¤t_group);\n\t\tif (seats_for_1_warroir_that_remain_from_HERE == 2){\n\t\t\t seats_for_1_warroir_that_remain_from_HERE = 0;\n\t\t\t\tsupa_dupa_place_for_1x2_or_2x1++;\n\t\t}\n\t\t//We lost 2 * rows of 4 seats and have 2 * seats_for_1_warroir_that_remain_from_HERE, and 2 * seats_for_1_warroir_that_remain_from_HERE transform in supa_dupa_place_for_1x2_or_2x1\n\t\t//like this\n\t\t////1100 -> 1103\n\t\t////2200 -> 2203\n\n\t\t//Checking: can we put count of warriors that is devoded into 4\n\t\tint group_of_4_warriors = current_group / 4;\n\t\tif (rows_of_4_seats - group_of_4_warriors >= 0)\n\t\t\trows_of_4_seats -= group_of_4_warriors;\n\t\telse if (rows_of_2_seats - group_of_4_warriors * 2 >= 0) // *2 becouse group of 4 warriors take 2 * row of 2 seats\n\t\t\trows_of_2_seats -= group_of_4_warriors * 2;\n\t\telse if (supa_dupa_place_for_1x2_or_2x1 - group_of_4_warriors * 2 >= 0)\n\t\t\tsupa_dupa_place_for_1x2_or_2x1 -= group_of_4_warriors * 2;\n\t\telse if (rows_of_4_seats + rows_of_2_seats / 2 + supa_dupa_place_for_1x2_or_2x1 / 2 >= group_of_4_warriors){\n\t\t\tgroup_of_4_warriors -= rows_of_4_seats;\n\t\t\trows_of_4_seats = 0;\n\t\t\tif (group_of_4_warriors * 2 > rows_of_2_seats){\n\t\t\t\tgroup_of_4_warriors -= rows_of_2_seats / 2;\n\t\t\t\trows_of_2_seats = 0;\n\t\t\t}\n\t\t\telse { \n\t\t\t\trows_of_2_seats -= group_of_4_warriors * 2;\n\t\t\t\tgroup_of_4_warriors = 0;\n\t\t\t}\n\t\t\tsupa_dupa_place_for_1x2_or_2x1 -= group_of_4_warriors * 2;\n\t\t}\n\t\telse {\n\t\t\tputs(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t\t//Checking: can we put remaining warriors that is devided into 2\n\t\tint remain_of_group_of_4_warriors_grouped_by_2 = (current_group % 4) / 2;\n\t\tif (rows_of_2_seats - remain_of_group_of_4_warriors_grouped_by_2 >= 0)\n\t\t\trows_of_2_seats = rows_of_2_seats - remain_of_group_of_4_warriors_grouped_by_2;\n\t\telse if (rows_of_4_seats - remain_of_group_of_4_warriors_grouped_by_2 >= 0){//HERE\n\t\t\trows_of_4_seats = rows_of_4_seats - remain_of_group_of_4_warriors_grouped_by_2;//HERE\n\t\t\tseats_for_1_warroir_that_remain_from_HERE++;//HERE\n\t\t}\n\t\telse if (supa_dupa_place_for_1x2_or_2x1 - remain_of_group_of_4_warriors_grouped_by_2 >= 0)\n\t\t\tsupa_dupa_place_for_1x2_or_2x1 = supa_dupa_place_for_1x2_or_2x1 - remain_of_group_of_4_warriors_grouped_by_2;\n\t\telse {\n\t\t\tputs(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t\tfprintf(stderr, \"now we have %d %d %d %d\\n\", rows_of_4_seats, rows_of_2_seats, seats_for_1_warroir_that_remain_from_HERE, supa_dupa_place_for_1x2_or_2x1);//debug\n\t\t//Checking remaining\n\t\tint remaining_of_all = (current_group % 4) % 2;\n\t\tif (remaining_of_all == 0)\n\t\t\tcontinue;\n\t\t//By the way if we are here, remaining_of_all == 1, but i anyway will use remaining_of_all instead 1, becouse I can\n\t\tif (seats_for_1_warroir_that_remain_from_HERE - remaining_of_all >= 0)\n\t\t\tseats_for_1_warroir_that_remain_from_HERE--; //I lied, here and somewhere I will use \"--\" and \"++\"\n\t\telse if (rows_of_4_seats - remaining_of_all >= 0){\n\t\t\trows_of_4_seats--;\n\t\t\trows_of_2_seats++; //We are lost rows of 4 seats, but on other half of rows of 4 seats we still have 2 free seats\n\t\t}\n\t\telse if (rows_of_2_seats - remaining_of_all >= 0)\n\t\t\trows_of_2_seats--;\n\t\telse if (supa_dupa_place_for_1x2_or_2x1 - remaining_of_all >= 0){\n\t\t\tsupa_dupa_place_for_1x2_or_2x1--;\n\t\t\tseats_for_1_warroir_that_remain_from_HERE++; //HERE we take only 1/2 of supa_dupa... and we can use that 1/2 of supa_dupa only for 1 man\n\t\t}\n\t\telse{\n\t\t\tputs(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tputs(\"YES\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "262f0047d8f79edb8302c7b4dd9eaff3", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main(void){\n int x1,x2,y1,y2,dist,half,n;\n int zerodis1,zerodis2;\n scanf(\"%d %d %d %d %d\",&n,&x1,&y1,&x2,&y2);\n half=n*2;\n zerodis1=(x1>=y1)?(x1+y1):((half*2)-x1-y1);\n zerodis2=(x2>=y2)?(x2+y2):((half*2)-x2-y2);\n dist=abs(zerodis1-zerodis2);\n if(dist>half) dist=half*2-dist;\n printf(\"%d\\n\",dist);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "greedy", "implementation"], "code_uid": "7fed0ef31e2d92096c774044d95610a7", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n int s1=0,s2=0, i, j, n, x1, y1, x2, y2;\n scanf(\"%d %d %d %d %d\", &n, &x1, &y1, &x2, &y2);\n\n if(x1==x2 && y1==y2){\n printf(\"0\");\n return 0;\n }\n if(x1==x2 && (x1==0 || x1==n)){\n printf(\"%d\", abs(y1-y2));\n return 0;\n }\n else if(y1==y2 &&(y1==0 || y1==n)){\n printf(\"%d\", abs(x1-x2));\n return 0;\n }\n while(1){\n if(y1==0){\n s1 = abs(n-x1);\n if(x2==n && y2>=0 && y2<=n){\n s1+=(y2);\n break;\n }\n else s1+=n;\n if(y2==n && x2>=0 && x2<=n){\n s1+=abs(n-x2);\n break;\n }\n else s1+=n;\n s1+=abs(n-y2);\n break;\n }\n else if(x1==n){\n s1=abs(n-y1);\n if(y2==n && x2>=0 && x2<=n){\n s1+=abs(n-x2);\n break;\n }\n else s1+=n;\n if(x2==0 && y2>=0 && y2<=n){\n s1+=abs(n-y2);\n break;\n }\n else s1+=n;\n s1+=x2;\n break;\n }\n else if(y1==n){\n s1+=x1;\n if(x2==0 && y2>=0 && y2<=n){\n s1+=abs(n-y2);\n break;\n }\n else s1+=n;\n if(y2==0 && x2>=0 && x2<=n){\n s1+=x2;\n break;\n }\n else s1+=n;\n s1+=y2;\n break;\n }\n else if(x1==0){\n s1+=y1;\n if(y2==0 && x2>=0 && x2<=n){\n s1+=x2;\n break;\n }\n else s1+=n;\n if(x2==n && y2>=0 && y2<=n){\n s1+=y2;\n break;\n }\n else s1+=n;\n s1+=abs(n-x2);\n break;\n }\n\n }\n s2=(4*n)-s1;\n if(s1\n\n#define N\t100\n\nint aa[N], bb[N];\n\nint dfs(int i) {\n\tif (bb[i])\n\t\treturn 0;\n\tbb[i] = 1;\n\treturn dfs(aa[i]) + 1;\n}\n\nlong long gcd(long long a, long long b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nlong long lcm(long long a, long long b) {\n\treturn a / gcd(a, b) * b;\n}\n\nint main() {\n\tint i, n;\n\tlong long t;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tbb[i] = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tint a;\n\n\t\tscanf(\"%d\", &a);\n\t\ta--;\n\t\taa[i] = a;\n\t\tif (bb[a]) {\n\t\t\tprintf(\"-1\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tbb[a] = 1;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tbb[i] = 0;\n\tt = 1;\n\tfor (i = 0; i < n; i++)\n\t\tif (!bb[i]) {\n\t\t\tint cnt = dfs(i);\n\n\t\t\tif (cnt % 2 == 0)\n\t\t\t\tcnt /= 2;\n\t\t\tt = lcm(t, cnt);\n\t\t}\n\tprintf(\"%lld\\n\", t);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math"], "code_uid": "2b2679fa1256b7601f6b7b99a62b9e77", "src_uid": "149221131a978298ac56b58438df46c9", "difficulty": 1600.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\n\nint translate(char c) {\n\tswitch (c) {\n\t\tcase 'S':\n\t\t\treturn 0;\n\t\tcase 'D':\n\t\t\treturn 1;\n\t\tcase 'H':\n\t\t\treturn 2;\n\t\tcase 'C':\n\t\t\treturn 3;\n\t\tcase 'T':\n\t\t\treturn 10;\n\t\tcase 'J':\n\t\t\treturn 11;\n\t\tcase 'Q':\n\t\t\treturn 12;\n\t\tcase 'K':\n\t\t\treturn 13;\n\t\tcase 'A':\n\t\t\treturn 14;\n\t\tdefault:\n\t\t\treturn c - '0';\n\t}\n}\n\nint can(int n1, int s1, int n2, int s2) {\n\treturn n1 == n2 || s1 == s2;\n}\n\nint main() {\n\tint i, n, k, n0, s0, n1, s1, n2, s2, n3, s3;\n\tstatic int nn[52], ss[52], dp[52][15][4][15][4][15][4];\n\tstatic char s[3];\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%s\", s);\n\t\tnn[i] = translate(s[0]);\n\t\tss[i] = translate(s[1]);\n\t}\n\tif (n == 1)\n\t\tprintf(\"YES\\n\");\n\telse if (n == 2)\n\t\tprintf(\"%s\\n\", can(nn[1], ss[1], nn[0], ss[0]) ? \"YES\" : \"NO\");\n\telse {\n\t\tfor (n2 = 2; n2 <= 14; n2++)\n\t\t\tfor (s2 = 0; s2 < 4; s2++)\n\t\t\t\tfor (n1 = 2; n1 <= 14; n1++)\n\t\t\t\t\tfor (s1 = 0; s1 < 4; s1++)\n\t\t\t\t\t\tfor (n0 = 2; n0 <= 14; n0++)\n\t\t\t\t\t\t\tfor (s0 = 0; s0 < 4; s0++)\n\t\t\t\t\t\t\t\tdp[2][n2][s2][n1][s1][n0][s0] =\n\t\t\t\t\t\t\t\t\t(n1 == n0 || s1 == s0)\n\t\t\t\t\t\t\t\t\t&& (n2 == n0 || s2 == s0);\n\t\tfor (k = 3; k <\tn; k++) {\n\t\t\tn3 = nn[k - 3];\n\t\t\ts3 = ss[k - 3];\n\t\t\tfor (n2 = 2; n2 <= 14; n2++)\n\t\t\t\tfor (s2 = 0; s2 < 4; s2++)\n\t\t\t\t\tfor (n1 = 2; n1 <= 14; n1++)\n\t\t\t\t\t\tfor (s1 = 0; s1 < 4; s1++)\n\t\t\t\t\t\t\tfor (n0 = 2; n0 <= 14; n0++)\n\t\t\t\t\t\t\t\tfor (s0 = 0; s0 < 4; s0++) {\n\t\t\t\t\t\t\t\t\tint yes = 0;\n\n\t\t\t\t\t\t\t\t\tif (can(n0, s0, n1, s1))\n\t\t\t\t\t\t\t\t\t\tyes = yes\n\t\t\t\t\t\t\t\t\t\t\t|| dp[k - 1][n3][s3][n2][s2][n0][s0];\n\t\t\t\t\t\t\t\t\tif (can(n0, s0, n3, s3))\n\t\t\t\t\t\t\t\t\t\tyes = yes || dp[k - 1][n0][s0][n2][s2][n1][s1];\n\t\t\t\t\t\t\t\t\tdp[k][n2][s2][n1][s1][n0][s0] = yes;\n\t\t\t\t\t\t\t\t}\n\t\t}\n\t\tprintf(\"%s\\n\", dp[n - 1][nn[n - 3]][ss[n - 3]][nn[n - 2]][ss[n - 2]][nn[n - 1]][ss[n - 1]] ? \"YES\" : \"NO\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "dp"], "code_uid": "ff638f074ce9dc6789d7f9d14ef9be91", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*\n * =====================================================================================\n *\n * Filename: Solitaire.c\n *\n * Description: \n *\n * Version: 1.0\n * Created: 2012\u5e7407\u670825\u65e5 13\u65f647\u520601\u79d2\n * Revision: none\n * Compiler: gcc\n *\n * Author: YOUR NAME (), \n * Organization: \n *\n * =====================================================================================\n */\n#include \n#include \n#include \n#define MAXN 55\n#define OP1 1\n#define OP2 3\nint dp[MAXN][MAXN][MAXN][MAXN];\ntypedef struct Card {\n\tchar val;\n\tchar suit;\n} Card_t;\nCard_t cards[MAXN];\n/* \nint dfs(Card_t *cards, int n, int op) {\n\tif(n == 1) return 1;\n\tif(n - op <=0 ) return 0;\n\n\tif(cards[n].val == cards[n - op].val) {\n\t\tint tmpSuit = cards[n - op].suit;\n\t\tcards[n - op].suit = cards[n].suit;\n\t\tif(dfs(cards, n-1, OP1) || dfs(cards, n-1, OP2)) \n\t\t\treturn 1;\n\t\telse \n\t\t\tcards[n - op].suit = tmpSuit;\n\t}\n\tif(cards[n].suit == cards[n - op].suit) {\n\t\tint tmpVal = cards[n- op].val;\n\t\tcards[n - op].val = cards[n].val;\n\t\tif(dfs(cards, n-1, OP1) || dfs(cards, n-1, OP2))\n\t\t\treturn 1;\n\t\telse \n\t\t\tcards[n -op].val = tmpVal;\n\t}\n\treturn 0;\n}\n*/\n\nint calc(int n, int a, int b, int c) {\n\tif(n == 1) return 1;\n\tif(n == 2) {\n\t\tif(cards[a].val == cards[b].val || cards[a].suit == cards[b].suit) return 1;\n\t\telse return 0;\n\t}\n\tif(n == 3) {\n\t//\tprintf(\"n-%d a-%d b-%d c-%d\\n\",n,a,b,c);\n\t\tif(cards[c].val == cards[b].val || cards[c].suit == cards[b].suit) {\n\t//\t\tprintf(\"cards[%d].val=%c cards[%d].val=%c\\n\",c,cards[c].val,b,cards[b].val);\n\t\t\tif(cards[c].val == cards[a].val || cards[c].suit == cards[a].suit) \n\t\t\t\treturn 1;\n\t\t\telse \n\t\t\t\treturn 0;\n\t\t}\n\t\telse \n\t\t\treturn 0;\n\t}\n\treturn 0;\n}\n\nint main() {\n\tint i,j,k,l,n;\n\tchar tmp;\n\n\twhile(scanf(\"%d\", &n) != EOF) {\n\t\tscanf(\"%c\",&tmp);\n\t\tmemset (cards, 0, sizeof cards);\n\t\tmemset (dp, 0, sizeof dp);\n\t\tfor(i=1; i <=n ; ++i) \n\t\t\tif (i < n)\n\t\t\t\tscanf(\"%c%c%c\", &cards[i].val, &cards[i].suit, &tmp);\n\t\t\telse \n\t\t\t\tscanf(\"%c%c\", &cards[i].val, &cards[i].suit);\n\t\t\n\t\tfor(i=1; i<=n; ++i) {\n\t\t\tfor(j=1; j<=n; ++j) {\n\t\t\t\tfor(k=1; k<=n; ++k) {\n\t\t\t\t\tif(j == k) continue;\n\t\t\t\t\tfor(l=1; l<=n; ++l) {\n\t\t\t\t\t\tif(k == l) continue;\n\t\t\t\t\t\tif(i >= 4) {\n\t\t\t\t\t\t\tif(cards[i-3].val == cards[l].val || cards[i-3].suit == cards[l].suit)\n\t\t\t\t\t\t\t\tdp[i][j][k][l] = dp[i-1][l][j][k];\n\t\t\t\t\t\t\tif(cards[k].val == cards[l].val || cards[k].suit == cards[l].suit) \n\t\t\t\t\t\t\t\tdp[i][j][k][l] = dp[i][j][k][l] || dp[i-1][i-3][j][l];\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdp[i][j][k][l] = calc(i,j,k,l);\n\t//\t\t\t\t\tprintf(\"dp[%d][%d][%d][%d]:%d\\n\",i,j,k,l,dp[i][j][k][l]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif(n == 1) {\n\t\t\tif(calc(1, 1, 0, 0)) puts(\"YES\");\n\t\t\telse puts(\"NO\");\n\t\t}\n\t\telse if(n == 2) {\n\t\t\tif(calc(2, 1, 2, 0)) puts(\"YES\");\n\t\t\telse puts(\"NO\");\n\t\t}\n\t\telse {\n\t\t\tif(dp[n][n-2][n-1][n]) puts(\"YES\");\n\t\t\telse puts(\"NO\");\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "dp"], "code_uid": "5b93e768d8ff12011abee13822b2a606", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "# include \n# include \nint main()\n{\nint n;\nscanf(\"%d\",&n);\nint p=n;\nif(n==0){\nprintf(\"1\");\nreturn 0;}\nprintf(\"%d\",4*(int)(n*sqrt(2.0)));\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "d7b2170dc4efd1892343d95790ff6748", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint n;\n\nint special(int x, int y) {\n long long xx = x, yy = y, nn = n; xx *= x; yy *= y; nn *= n;\n return xx + yy <= nn;\n}\n\nint main(void) {\n int i, j, r = 0, s = 0;\n scanf(\"%d\", &n);\n j = n;\n if (n == 0) r = 1;\n else if (n == 1) r = 4;\n else {\n for (i = 0; i <= j; ++i) {\n while (!special(i, j)) --j;\n if (i < j) ++r;\n if (i == j) ++s;\n }\n r = 2*r + s; r += r - 1; r += r - 2;\n }\n printf(\"%d\\n\", r);\n exit(EXIT_SUCCESS);\n}\n", "lang_cluster": "C", "tags": ["geometry"], "code_uid": "b6377961e896d6a15bf36f5c7d8ea832", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nchar mp[10][10];\nint p;\n\nvoid dfs(int x,int y)\n{\n\tint i,j,sum;\n\tint tx=x;\n\tint ty=y;\n\tsum=0;\n\tfor(i=tx;i>=0;i--)\n\t\tif(mp[i][ty]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \n\tfor(i=tx+1;i<10;i++)\n\t\tif(mp[i][ty]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \n\t\n\t//if(sum>=5) {printf(\"sum1======%d\\n\",sum);p=1;}\n\tif(sum>=5) p=1;\n\tsum=0;\n\tfor(i=ty;i>=0;i--)\n\t\tif(mp[tx][i]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \n\tfor(i=ty+1;i<10;i++)\n\t\tif(mp[tx][i]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\t\n\t//if(sum>=5) {printf(\"sum2======%d\\n\",sum); p=1;}\n\tif(sum>=5) p=1;\n\tsum=0;\n\tfor(i=tx,j=ty;i>=0&&j>=0;i--,j--)\n\t\tif(mp[i][j]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\tfor(i=tx+1,j=ty+1;i<10&&j<10;i++,j++)\n\t\tif(mp[i][j]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\t\n\t//if(sum>=5) {printf(\"sum3======%d\\n\",sum);p=1;}\n\tif(sum>=5) p=1;\n\tsum=0;\n\tfor(i=tx,j=ty;i>=0&&j<10;i--,j++)\n\t\tif(mp[i][j]!='X') break;else sum++;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\tfor(i=tx+1,j=ty-1;j>=0&&i<10;i++,j--)\n\t\tif(mp[i][j]!='X') break;else sum++; //\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \n\t\n\t//if(sum>=5) {printf(\"sum4======%d\\n\",sum);p=1;}\n\tif(sum>=5) p=1;\n}\n\nint main()\n{\n\tint i,j;\n\tfor(i=0;i<10;i++)\n\t\tscanf(\"%s\",mp[i]);\n\tp=0;\n\tfor(i=0;i<10;i++)\n\t{\n\t\tfor(j=0;j<10;j++)\n\t\t{\n\t\t\tif(mp[i][j]=='.')\n\t\t\t{\n\t\t\t\tmp[i][j]='X';\n\t\t\t\tdfs(i,j);\n\t\t\t\tmp[i][j]='.';\n\t\t\t}\n\t\t}\n\t}\n\tif(p) printf(\"YES\\n\");\n\telse printf(\"NO\\n\"); \n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "04c65db4a95764e97809fe14814a743a", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\n#define DEBUG 0\n#define MAX 10\n#define P_SIZE 5\n\n#define ALICE X\n#define BOB O\n#define EMPTY .\n\nchar game[MAX][MAX];\n\nchar pattern[P_SIZE][P_SIZE] = {\".XXXX\", \"X.XXX\", \"XX.XX\", \"XXX.X\", \"XXXX.\"};\n\nint horizontal(int lin, int col, int p) {\n int i, j, k, temp;\n if(DEBUG) printf(\"HORIZONTAL\\n\");\n i = lin;\n j = col;\n temp = 0;\n for(k = 0; k < P_SIZE && j < MAX; k++) {\n if(DEBUG) printf(\"game %d %d %c\\n\", i, j, game[i][j]);\n if(DEBUG) printf(\"pattern %d %d %c\\n\", p, k, pattern[p][k]);\n if(game[i][j] == pattern[p][k]) { \n j++;\n temp++;\n }\n }\n \n if(DEBUG) printf(\"temp %d\\n\", temp);\n return temp == P_SIZE;\n}\n\nint vertical(int lin, int col, int p) {\n int i, j, k, temp;\n if(DEBUG) printf(\"VERTICAL:\\n\"); \n i = lin;\n j = col;\n temp = 0;\n for(k = 0; k < P_SIZE && i < MAX; k++) {\n if(DEBUG) printf(\"game %d %d %c\\n\", i, j, game[i][j]);\n if(DEBUG) printf(\"pattern %d %d %c\\n\", p, k, pattern[p][k]);\n if(game[i][j] == pattern[p][k]) { \n i++;\n temp++;\n }\n }\n \n if(DEBUG) printf(\"temp %d\\n\", temp);\n return temp == P_SIZE;\n}\n\nint diagonalD(int lin, int col, int p) {\n int i, j, k, temp;\n if(DEBUG) printf(\"DIAGONAL DIR:\\n\"); \n i = lin;\n j = col;\n temp = 0;\n for(k = 0; k < P_SIZE && i < MAX && j < MAX; k++) {\n if(DEBUG) printf(\"game %d %d %c\\n\", i, j, game[i][j]);\n if(DEBUG) printf(\"pattern %d %d %c\\n\", p, k, pattern[p][k]);\n if(game[i][j] == pattern[p][k]) { \n i++;\n j++;\n temp++;\n }\n }\n \n if(DEBUG) printf(\"temp %d\\n\", temp);\n return temp == P_SIZE;\n}\n\n\nint diagonalE(int lin, int col, int p) {\n int i, j, k, temp;\n if(DEBUG) printf(\"DIAGONAL ESQ:\\n\"); \n i = lin;\n j = col;\n temp = 0;\n for(k = 0; k < P_SIZE && i < MAX && j >= 0; k++) {\n if(DEBUG) printf(\"g %d %d %c\\n\", i, j, game[i][j]);\n if(DEBUG) printf(\"p %d %d %c\\n\", p, k, pattern[p][k]);\n if(game[i][j] == pattern[p][k]) { \n i++;\n j--;\n temp++;\n }\n }\n \n if(DEBUG) printf(\"temp %d\\n\", temp);\n return temp == P_SIZE;\n}\n\n\nint main() {\n\n int i, j, k, res;\n\n for(i = 0; i < MAX; i++) {\n for(j = 0; j < MAX; j++) {\n scanf(\"%c\", &game[i][j]);\n }\n scanf(\"\\n\");\n }\n\n res = 0;\n for(i = 0; i < MAX && !res; i++) {\n for(j = 0; j < MAX && !res; j++) {\n for(k = 0; k < P_SIZE && !res; k++) {\n if(DEBUG) printf(\"%d %d %d\\n\", i, j, k); \n res = horizontal(i, j, k) || \n vertical(i, j, k) ||\n diagonalD(i, j, k) ||\n diagonalE(i, j, k); \n }\n if(DEBUG) printf(\"\\n\");\n }\n }\n\n if(res) {\n printf(\"YES\\n\");\n } else {\n printf(\"NO\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "fb2790a471b228dffc77e0447d1adbdd", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nunsigned long long int m=1000000007;\nunsigned long long int bigmod(unsigned long long int x, unsigned long long int n)\n{\n if(n==0) return 1;\n\n if(n%2==0)\n {\n unsigned long long int num= bigmod(x,n/2);\n return ((num%m)*(num%m))%m;\n }\n\n else\n return ((x%m)*(bigmod(x,n-1)%m))%m;\n\n}\n\nint main()\n{\n unsigned long long int sum1=0,sum2=0,sum=0,n,A,B,x;\n\n scanf(\"%llu %llu %llu %llu\",&A,&B,&n,&x);\n\n if(A==1) printf(\"%llu\\n\",((x%m)+((B%m)*(n%m))%m)%m);\n else{\n\n sum1=bigmod(A,n)%m;\n sum2=(sum1-1)%m;\n\n sum1=((sum1%m)*(x%m))%m;\n sum2=((sum2%m)*(B%m))%m;\n\n sum2=((sum2%m)* (bigmod(A-1,m-2))%m)%m;\n\n sum=((sum1%m)+(sum2%m))%m;\n\n printf(\"%llu\\n\",sum%m);\n\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "60b27d5190045e406d92af78b6843932", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n/*\n * 678D\n *\n * (A-1)y = (A-1)xA^n + BA^n - B\n */\n#include \n#include \n#ifndef _TJYTLXWXHYZQFW_COMMON_H\n#define _TJYTLXWXHYZQFW_COMMON_H\n#include \n#define offset(t,m) ((unsigned long)&(((t*)0)->m))\n#define container_of(a,t,m) ((t*)((unsigned long)a-offset(t,m)))\n#define ULL1 ((unsigned long long )1)\n#define LL(x) ((long long)(x))\n#define SWP(a, b) if ((a) != (b)) do {(a) ^= (b); (b) ^= (a); (a) ^= (b);} while(0)\n#define MAX(x,y) ((x) < (y) ? (y) : (x))\n#define MIN(x, y) ((x) < (y) ? (x) : (y))\n#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))\n#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))\n#define IR(x, start, end) ((x) >= (start) && (x) < (end))\n#define IRE(x, start, end) ((x) >= (start) && (x) <= (end))\n#define ABS(x) ((x) < 0 ? (x) * (-1) : (x))\n#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)\n#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)\n#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)\n#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)\n#endif\n#ifndef _WCC_NUMTH_H\n#define _WCC_NUMTH_H\n#include \n#define NUMTH_CORRECT(x, mod) ((x) += ((x) < 0 ? (mod) : 0))\n#define NUMTH_ENS (-1) \nlong long numth_modexp(long long a, long long b, long long n);\nlong long numth_gcd(long long a, long long b);\nvoid numth_gcd_e(long long a, long long b, long long *d, long long *x, long long *y);\nint numth_mle(long long a, long long b, long long n, long long *x, long long *gcd);\n#define numth_for_each_solution(i, x, n, d) \\\n\tfor ((i) = 0; (i) < (d); (i) += 1, (x) = ((x) + (n) / (d)) % (n))\nint numth_divisors(long long k, long long divs[], long long *ndivs);\n#endif\n#define P LL(1000000007)\n/* x, y, n must not be negitive */\n#define modmul(x, y, n) ((((x) % (n)) * ((y) % (n))) % (n))\n#define modpls(x, y, n) ((((x) % (n)) + ((y) % (n))) % (n))\nint main(void)\n{\n\tlong long A, B, n, x;\n\tlong long right, q, ans, d;\n\tscanf(\"%lld%lld%lld%lld\", &A, &B, &n, &x);\n\tif (A == 1) {\n\t\tans = modpls(x, modmul(B, n, P), P);\n\t\tgoto print_answer;\n\t}\n\tq = numth_modexp(A, n, P);\n\t//printf(\"q: %lld\\n\", q);\n\tright = modmul(modmul(A - 1, x, P), q, P) + modmul(B, q, P) - B;\n\t//printf(\"right: %lld\\n\", right);\n\tNUMTH_CORRECT(right, P);\n\tnumth_mle(A - 1, right, P, &ans, &d);\n\tassert(d == 1);\n\tprint_answer:\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n\nstatic long long numth_do_gcd(long long a, long long b);\nstatic void numth_do_gcd_e(long long grt, long long les, long long *d, long long *x, long long *y);\n\nlong long numth_modexp(long long a, long long b, long long n)\n{\n\tstatic long long bit63 = (unsigned long long)0x8000000000000000;\n\tlong long square = 1;\n\tint i;\n\n\tassert(b >= 0 && n > 0);\n\n\t//FIXME: '==' > '&'\n\tfor(i = 63; i >= 0 && (b & bit63) == 0; --i)\n\t\tb <<= 1;\n\tfor(; i >= 0; --i) {\n\t\tsquare = (square * square) % n;\n\t\tif (b & bit63)\n\t\t\tsquare = (square * a) % n;\n\t\tb <<= 1;\n\t}\n\n\treturn square;\n}\n\nlong long numth_gcd(long long a, long long b)\n{\n\tif (a == 0 && b == 0)\n\t\treturn 0;\n\tif (a < 0)\n\t\ta *= -1;\n\tif (b < 0)\n\t\tb *= -1;\n\t/* We DON'T need a > b */\n\treturn numth_do_gcd(a, b);\n}\n\n/* \u5927\u6570\u9664\u5c0f\u6570, \u5c0f\u6570\u9664\u4f59\u6570 */\nstatic long long numth_do_gcd(long long a, long long b)\n{\n\tlong long r;\n\n\tif (!b)\n\t\treturn a;\n\n\tfor (r = a % b; r != 0; r = a % b) {\n\t\ta = b;\n\t\tb = r;\n\t}\n\n\treturn b;\n}\n\nvoid numth_gcd_e(long long a, long long b, long long *d, long long *x, long long *y)\n{\n\tif (a == 0 && b == 0) {\n\t\t*d = *x = *y = 0;\n\t\treturn;\n\t}\n\n\tif (a < 0)\n\t\ta *= -1;\n\tif (b < 0)\n\t\tb *= -1;\n\n\tif (a < b)\n\t\tnumth_do_gcd_e(b, a, d, y, x);\n\telse\n\t\tnumth_do_gcd_e(a, b, d, x, y);\n}\n\nstatic void numth_do_gcd_e(long long a, long long b, long long *d, long long *x, long long *y)\n{\n\tlong long tmp;\n\n\tif (b == 0) {\n\t\t*d = a;\n\t\t*x = 1;\n\t\t*y = 0;\n\t\treturn;\n\t}\n\tnumth_do_gcd_e(b, a % b, d, x, y);\n\ttmp = *x;\n\t*x = *y;\n\t//TODO: overflow?\n\t*y = (tmp - (a / b) * (*y));\n}\n\nint numth_mle(long long a, long long b, long long n, long long *solution, long long *gcd)\n{\n\tlong long d, x, y;\n\n\tassert(n != 0);\n\n\tif (n < 0)\n\t\tn *= (-1);\n\tif (a < 0)\n\t\ta *= (-1);\n\tif (b < 0)\n\t\tb *= (-1);\n\n\tnumth_gcd_e(a, n, &d, &x, &y);\n\tassert(d != 0); //d=0 if and only if a=b=0\n\n\tif (b % d)\n\t\treturn NUMTH_ENS;\n\n\t*solution = ((b / d) * (x % n)) % n;\n\tNUMTH_CORRECT(*solution, n);\n\t*gcd = d;\n\n\treturn 0;\n}\n\nint numth_divisors(long long k, long long divs[], long long *ndivs)\n{\n\tlong long i, n;\n\n\tassert(k > 0);\n\n\tn = 0;\n\tfor (i = 1; i * i < k; ++i)\n\t\tif (k % i == 0)\n\t\t\tdivs[n++] = i;\n\n\tif (i * i == k) {\n\t\tdivs[n++] = i;\n\t\ti = n - 2;\n\t} else {\n\t\ti = n - 1;\n\t}\n\n\tfor (; i >= 0; --i)\n\t\tdivs[n++] = k / divs[i];\n\n\t*ndivs = n;\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "650178cb08281c7b8de4ad1afc84d23f", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n\n long long int l,r,x,y,k,i,exp,cost,ct=0,ck=0;\n scanf(\"%lld %lld %lld %lld %lld\",&l,&r,&x,&y,&k);\n\n for(i=x;i<=y;i++){\n if(l<=k*i&&r>=k*i){\n ck=1;\n break;\n }\n\n }\n if(ck==1){\n printf(\"YES\");\n }\n else{\n printf(\"NO\");\n }\n\nreturn 0;\n}", "lang_cluster": "C", "tags": ["two pointers", "brute force"], "code_uid": "4c1f31773e932cde9165b85faafa8cf1", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main() {\n\tint l, r, x, y, k,i,tmp;\n\tscanf(\"%d %d %d %d %d\", &l, &r, &x, &y, &k);\n\n\tfor( i = l; i <= r; ++i) {\n\t\tif(i % k == 0) {\n\t\t\t tmp = i / k;\n\t\t\tif(tmp >= x && tmp <= y) {\n\t\t\t\tprintf(\"YES\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"NO\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "brute force"], "code_uid": "debd1b6e8136f0378ed0283c9a5a898a", "src_uid": "1110d3671e9f77fd8d66dca6e74d2048", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* upsolve with Dukkha */\n#include \n\n#define N\t100\n#define S\t5000\n#define MD\t998244353\n\nint ch[S + N][N];\n\nvoid init(int n, int k) {\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 < k; j++)\n\t\t\tch[i][j] = (ch[i - 1][j - 1] + ch[i - 1][j]) % MD;\n\t}\n}\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 == 1)\n\t\tp = p * a % MD;\n\treturn p;\n}\n\nlong long inv(long long a) {\n\treturn power(a, MD - 2);\n}\n\nint main() {\n\t/* dp[a][b]: b balls into a urns of size r - 1 */\n\tstatic int dp[1 + N][1 + S];\n\t/* dq[a][b]: dp[a][b] + dp[a][b - 1] + ... + dp[a][b - (r - 1)] */\n\tstatic int dq[1 + N][1 + S];\n\tint n, s, r, a, b, k, p, q;\n\n\tscanf(\"%d%d%d\", &n, &s, &r);\n\tinit(s + n, n);\n\tfor (a = 0; a <= n; a++) {\n\t\tint sum;\n\n\t\tif (a == 0)\n\t\t\tdp[0][0] = 1;\n\t\telse\n\t\t\tfor (b = 0; b <= s; b++)\n\t\t\t\tdp[a][b] = dq[a - 1][b];\n\t\tsum = 0;\n\t\tfor (b = 0; b <= s; b++) {\n\t\t\tsum = (sum + dp[a][b]) % MD;\n\t\t\tif (b >= r)\n\t\t\t\tsum = (sum - dp[a][b - r] + MD) % MD;\n\t\t\tdq[a][b] = sum;\n\t\t}\n\t}\n\tp = 0;\n\tfor (k = 1; k <= n && k * r <= s; k++)\n\t\tfor (b = 0; b + k * r <= s; b++)\n\t\t\tp = (p + (long long) dp[n - k][b] * ch[s - b - k * r + k - 1][k - 1] % MD * ch[n - 1][k - 1] % MD * inv(k)) % MD;\n\tq = ch[s - r + n - 1][n - 1];\n\tprintf(\"%lld\\n\", p * inv(q) % MD);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "9f798f0f375d10a429806c0eb9bbabee", "src_uid": "609195ef4a970c62a8210dafe118580e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nlong long tt[6]={10,100,1000,10000,100000,1000000};\nint mylog(int n)\n{\n\tint ans=0;\n\twhile (n>=10)\n\t{\n\t\tans++; n/=10;\n\t}\n\treturn ans;\n}\nint main()\n{\n\tint k,p,i,j;\n\tlong long ans=0,now;\n\tscanf(\"%d%d\",&k,&p);\n\tfor (i=1;i<=k;i++)\n\t{\n\t\tlong long t=0,t1=i;\n\t\twhile (t1)\n\t\t{\n\t\t\tt=t*10+t1%10;\n\t\t\tt1/=10;\n\t\t}\n\t\tt=i*tt[mylog(i)]+t;\n\t\tans+=t;\n\t\tans%=p; \n\t}\n\tprintf(\"%I64d\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "9575f05fd92eb9da8b09ff15f59e2f97", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//practice with dukkha\n#include\nlong long int fx(int a)\n{\n\tint arr[10];\n\tint c=0;\n\tlong long int k=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=c-1;i>=0;i--)\n\t\tk=((k*10)+arr[i]);\n\tfor(int i=0;i\n#define MOD 1000000007\nunsigned long long int power(unsigned long long int x, unsigned long long int y, long int p)\n{\n unsigned long long int res = 1; // Initialize result\n \n x = x % p; // Update x if it is more than or \n // equal to p\n \n while (y > 0)\n {\n // If y is odd, multiply x with result\n if (y & 1)\n res = (res*x) % p;\n \n // y must be even now\n y = y>>1; // y = y/2\n x = (x*x) % p; \n }\n return res;\n}\nint main()\n{\n long long int x,k,a,b,c,d;\n scanf(\"%lld %lld\",&x,&k);\n if(x==0)\n {\n printf(\"0\");\n }\n else\n {\n if(k==0)\n {\n printf(\"%lld\",(2*x)%MOD);\n }\n else\n {\n a=power(2,k,MOD);\n b=(2*(x%MOD))%MOD;\n if(b==0){b=MOD;}\n b=(b-1)%MOD;\n a=(a*b)%MOD;\n printf(\"%lld\",(a+1)%MOD);\n }\n }\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "d5207dbb7ba67687bbc87b8f5db3a5e7", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define MOD 1000000007\nunsigned long long int power(unsigned long long int x, unsigned long long int y, long int p)\n{\n unsigned long long int res = 1; // Initialize result\n \n x = x % p; // Update x if it is more than or \n // equal to p\n \n while (y > 0)\n {\n // If y is odd, multiply x with result\n if (y & 1)\n res = (res*x) % p;\n \n // y must be even now\n y = y>>1; // y = y/2\n x = (x*x) % p; \n }\n return res;\n}\nint main()\n{\n long long int x,k,a,b,c,d;\n scanf(\"%lld %lld\",&x,&k);\n if(x==0)\n {\n printf(\"0\");\n }\n else\n {\n if(k==0)\n {\n printf(\"%lld\",(2*x)%MOD);\n }\n else\n {\n a=power(2,k,MOD);\n b=(2*(x%MOD))%MOD;\n b=(b-1+MOD)%MOD;\n a=(a*b)%MOD;\n printf(\"%lld\",(a+1)%MOD);\n }\n }\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "db236cb3f2ca98082506cacada75d7d8", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\ntypedef long long ll;\r\n#define rll register ll\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\nint writeBuffer[20];\r\nvoid write(ll num) { if (num == 0) putchar('0'); else { rint size = 0; rll current; if (0 < num) current = num; else current = -num, putchar('-'); while (0 < current) writeBuffer[size++] = current%10+'0', current /= 10; while (0 < size) putchar(writeBuffer[--size]); } }\r\nll read() { rint sign = 1; rll num = 0; while (1) { rint ch = getchar(); if (ch == '-') { sign = -sign; continue; } if (ch <= 32) break; num = num*10+(ch-'0'); } return sign*num; }\r\n\r\nll target;\r\nint ans;\r\nvoid dfs(ll num, int depth) {\r\n if (target <= num) ans = depth;\r\n else {\r\n rint best = depth;\r\n for (rll temp=num;temphead[i] = 0;\r\n temp->cnt = 0, temp->ed = '0';\r\n return temp;\r\n}\r\nn * fnd (n * tr, ll v) {\r\n while (v) {\r\n if (!tr->head[v%10]) tr->head[v%10] = mk();\r\n tr = tr->head[v%10];\r\n v/=10;\r\n }\r\n if (tr->ed == '0') tr->ed = '1', tr->cnt = 100;\r\n return tr;\r\n}\r\nvoid del (n * tr) {\r\n for (int i = 0; i < 10; i++)\r\n if (tr->head[i]) {\r\n del (tr->head[i]);\r\n free(tr->head[i]);\r\n }\r\n}\r\nn tr;\r\nint dfs (ll v, int s) {\r\n ll k = v; int len = 0;\r\n while (k) len++, k/=10;\r\n if (len == s) return 0;\r\n else if (len > s) return 100;\r\n n * chk = fnd( &tr, v ); k = v;\r\n if (chk->cnt != 100) return chk->cnt;\r\n while (k) {\r\n if (k%10 > 1) chk->cnt = min(chk->cnt, 1 + dfs(v * (k%10), s));\r\n k/=10;\r\n } return chk->cnt;\r\n}\r\nint main () {\r\n for (int i = 0; i < 10; i++) tr.head[i] = 0;\r\n int m; ll f;\r\n scanf(\"%d%lld\",&m,&f);\r\n int ans = dfs(f,m);\r\n printf(\"%d\\n\",(ans == 100) ? -1 : ans);\r\n del(&tr);\r\n}", "lang_cluster": "C", "tags": ["brute force", "dfs and similar", "shortest paths", "dp", "data structures"], "code_uid": "974c2e70ea0729582304ce4ee945cd4d", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0, "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": "f9b6ba22b713a7ff1951a96d6f2142c4", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\nint max(int a, int b) {\n\treturn a > b ? a : b;\n}\n\ntypedef struct {\n\tint x, y;\n} point;\n\nint main(void) {\n\tpoint a[4], b[4];\n\tpoint ac = {0}, bc = {0};\n\tint ra, rb;\n\n\tfor (int i = 0; i < 4; i++) {\n\t\tscanf(\"%d%d\", &a[i].x, &a[i].y);\n\t\tac.x += a[i].x;\n\t\tac.y += a[i].y;\n\t}\n\tac.x /= 2;\n\tac.y /= 2;\n\tfor (int i = 0; i < 4; i++) {\n\t\tif ((ra = abs(ac.x - 2*a[i].x)) != 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor (int i = 0; i < 4; i++) {\n\t\tscanf(\"%d%d\", &b[i].x, &b[i].y);\n\t\tbc.x += b[i].x;\n\t\tbc.y += b[i].y;\n\t}\n\tbc.x /= 2;\n\tbc.y /= 2;\n\tfor (int i = 0; i < 4; i++) {\n\t\tif ((rb = abs(bc.x - 2*b[i].x)) != 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tint dx = max(abs(ac.x - bc.x) - ra, 0);\n\tint dy = max(abs(ac.y - bc.y) - ra, 0);\n\n\tif (dx+dy <= rb) {\n\t\tputs(\"YES\");\n\t} else {\n\t\tputs(\"NO\");\n\t}\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "76951b7fadc9d33cfd64d41c7cedf7ae", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint x[100100];\nint main()\n{\nlong long i,j,k,n,max,min;\nmax=0;\nmin=-1;\nscanf(\"%I64d\",&n);\n for(i=1;i*i<=n;i++){\n if(n%i==0){\n\nlong long bc=n/i;\n for(j=1;j*j<=bc;j++){\n if(bc%j==0){\n k=bc/j;\n\n if((i+1)*(j+2)*(k+2)\n#define MOD 998244353\n\n__int64 Pow(__int64 a, __int64 b)\n{\n __int64 half;\n if(b == 0) return 1;\n if(b % 2 == 1) return (Pow(a, b-1)*a) % MOD;\n half = Pow(a, b/2) % MOD;\n return (half * half) % MOD;\n}\n__int64 nCr(__int64 n, __int64 r)\n{\n __int64 A = 1; // A = n!, B = (n-r)!r!\n __int64 B = 1;\n __int64 ans;\n __int64 i;\n\n for(i=1;i<=n;i++)\n {\n A *= i;\n A %= MOD;\n }\n for(i=1;i<=n-r;i++)\n {\n B *= i;\n B %= MOD;\n }\n for(i=1;i<=r;i++)\n {\n B *= i;\n B %= MOD;\n }\n __int64 B2 = Pow(B, MOD-2);\n ans = (A * B2) % MOD;\n return ans;\n}\n\nint main(void)\n{\n __int64 size, max;\n __int64 ans;\n\n scanf(\"%lld %lld\", &size, &max);\n \n ans = nCr(max, size - 1) * (size-2) % MOD;\n ans = (ans * Pow(2, size-3)) % MOD;\n printf(\"%lld\\n\", ans);\n\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "57c93a386a6bc75d70fa3cd6d1de51bf", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nconst int m = 998244353;\n\nint power( int x, int y ) {\n\tint a = 1;\n\tfor( ; y>0; y>>=1, x=1ll*x*x %m )\n\t\tif( y&1 )\n\t\t\ta = 1ll*a*x %m;\n\treturn a;\n}\n\nint fact( int n ) {\n\tint f = 1;\n\tfor( int i=2; i<=n; ++i )\n\t\tf = 1ll*f*i %m;\n\treturn f;\n}\n\nint main() {\n\tint N, M;\n\tscanf(\"%d%d\", &N, &M);\n\tif( N == 2 ) { printf(\"0\\n\", M); return 0; }\n\tint ans = 1ll*(N-2)*power(2, N-3) %m;\n\tans = 1ll*ans*fact(M) %m;\n\tans = 1ll*ans*power(fact(M-N+1), m-2) %m;\n\tans = 1ll*ans*power(fact(N-1), m-2) %m;\n\tprintf(\"%d\\n\", ans);\n\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "a2d7c6fbacd9c2b26df552ebbfcae1e5", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nchar g[10][5], ss[5], s[5];\nint n, cc = 0, a[10], b[10];\n\nvoid check() {\n\tint i;\n\tfor (i = 0; i < n; i++) {\n\t\tint j, aa = 0, bb = 0;\n\t\tfor (j = 0; j < 4; j++)\n\t\t\tif (g[i][j] == s[j])\n\t\t\t\taa++;\n\t\t\telse {\n\t\t\t\tint k;\n\t\t\t\tfor (k = 0; k < 4; k++)\n\t\t\t\t\tif (g[i][j] == s[k])\n\t\t\t\t\t\tbreak;\n\n\t\t\t\tif (k != 4)\n\t\t\t\t\tbb++;\n\t\t\t}\n\n\t\tif (aa != a[i] || bb != b[i])\n\t\t\tbreak;\n\t}\n\n\tif (i == n) {\n\t\tcc++;\n\t\tstrcpy(ss, s);\n\t}\n}\n\nint main() {\n\tscanf(\"%d\", &n);\n\n\tint i;\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%s%d%d\", g[i], &a[i], &b[i]);\n\n\tchar a, b, c, d;\n\tfor (a = '0'; a <= '9'; a++)\n\t\tfor (b = '0'; b <= '9'; b++)\n\t\t\tfor (c = '0'; c <= '9'; c++)\n\t\t\t\tfor (d = '0'; d <= '9'; d++)\n\t\t\t\t\tif (a != b && a != c && a != d && b != c && b != d && c != d) {\n\t\t\t\t\t\ts[0] = a; s[1] = b; s[2] = c; s[3] = d; s[4] = '\\0';\n\t\t\t\t\t\tcheck();\n\t\t\t\t\t}\n\n\tif (cc == 0)\n\t\tputs(\"Incorrect data\");\n\telse if (cc == 1)\n\t\tputs(ss);\n\telse\n\t\tputs(\"Need more data\");\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "ab59c016122bfa1e4a322bf7e515014e", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, num = 0, count = 0, i, j, k;\n int a[10][4], b[10], c[10];\n int d[10000] = {0};\n\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) {\n\t for (j = 0; j < 4; j++) scanf(\"%1d\", &a[i][j]);\n\n\t scanf(\"%d %d\", &b[i], &c[i]);\n }\n\n for (i = 0; i < 10000; i++) {\n\t int x = i;\n\t int p[10] = {0};\n\n\t for (j = 0; j < 4; j++) {\n\t p[x % 10]++;\n\n\t x /= 10;\n\t }\n\n\t for (j = 0; j < 10; j++) {\n\t if (p[j] > 1) d[i] = 1;\n\t }\n }\n\n for (i = 0; i < n; i++) {\n\t for (j = 0; j < 10000; j++) {\n\t if (d[j] == 0) {\n\t\t int p[10] = {0};\n\t\t int x = j, y = 0, z = 0;\n\n\t\t for (k = 0; k < 4; k++) p[a[i][k]]++;\n\n\t\t for (k = 0; k < 4; k++) {\n\t\t\t p[x % 10]++;\n\n\t\t\t if (x % 10 == a[i][3 - k]) y++;\n\n\t\t\t x /= 10;\n\t\t }\n\n\t\t for (k = 0; k < 10; k++) {\n\t\t\t if (p[k] == 2) z++;\n\t\t }\n\n\t\t if (y != b[i] || z - y != c[i]) d[j] = 1;\n\t }\n\t }\n }\n\n for (i = 0; i < 10000; i++) {\n\t if (d[i] == 0) {\n\t num = i;\n\t count++;\n\t }\n }\n\n if (count > 1) {\n\t puts(\"Need more data\");\n } else if (count == 1) {\n\t printf(\"%04d\\n\", num);\n } else {\n\t puts(\"Incorrect data\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "03ca6cc65032545e97d32ecde966a882", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n\r\nint main() {\r\n\tchar word[11]; int len;\r\n\tscanf(\"%s\", word);\r\n\tlen = strlen(word);\r\n\t\r\n\tfor (int i=2; i\r\n#include \r\nint main()\r\n{\r\n int j,n,a[20],k,r,flag;\r\n char s[20],p[30]=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\r\n scanf(\"%s\",s);\r\n n=strlen(s);\r\n if(n<=2)\r\n {\r\n printf(\"YES\");\r\n }\r\n if(n>2)\r\n {\r\n for(j=0;j<=25;++j)\r\n {\r\n if(s[0]==p[j])\r\n {\r\n a[0]=j;\r\n break;\r\n }\r\n }\r\n for(j=0;j<=25;++j)\r\n {\r\n if(s[1]==p[j])\r\n {\r\n a[1]=j;\r\n break;\r\n }\r\n }\r\n for(j=2;j<=n-1;++j)\r\n {\r\n r=(a[j-1]+a[j-2])%26;\r\n flag=0;\r\n for(k=0;k<=25;++k)\r\n {\r\n if(s[j]==p[k])\r\n {\r\n a[j]=k;\r\n break;\r\n }\r\n }\r\n if(r!=k)\r\n {\r\n flag=1;\r\n break;\r\n }\r\n }\r\n if(flag==0)\r\n {\r\n printf(\"YES\");\r\n }\r\n else\r\n {\r\n printf(\"NO\");\r\n }\r\n }\r\n}\r\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b241b3d067ca26d971fa3b5dd2790347", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main(){\n char s[20];\n scanf(\"%s\",s);\n int i,j,x=0;\n int L=strlen(s);\n for(i=0,j=L-1;i<(L/2),j>=(L/2);i++,j--){\n if(s[i]!=s[j]) x++;\n }\n if (x==1) printf(\"YES\");\n else if(x==0 && L%2!=0)printf(\"YES\");\n else printf(\"NO\");\n\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["brute force", "strings", "constructive algorithms"], "code_uid": "eb59fb8dd18377a1a3e795b78084c062", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n * 1.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 \nint main(int argc, char **argv)\n{\n\tchar A[50];\n\tint flag=0,cnt;\n\tscanf(\"%s\",A);\n\tcnt=strlen(A);\n\tint j=(cnt+1)/2;\n\tfor(int i=0;i\n#include \nint main()\n{\n double x, y, z, n, min=1000000000, ansb;\n int i, a, b;\n scanf(\"%lf %lf %lf\", &x, &y, &n);\n if(y<=n)\n a=(int)x, b=(int)y;\n else\n {\n for(i=1; i<=n; i++)\n {\n //printf(\"here\");\n z=(x/y)*i;\n int p=floor(z+0.499999999);\n float temp=fabs((x/y)-(p*1.00)/i);\n if(temp1; i--)\n {\n //printf(\"i=%d\\n\", i);\n if(a%i==0 && b%i==0)\n {\n a/=i;\n b/=i;\n i--;\n }\n }\n printf(\"%d/%d\\n\", a, b);\n}", "lang_cluster": "C", "tags": ["two pointers", "implementation", "brute force"], "code_uid": "5143e3947b6f0677e26c92a73c1e768e", "src_uid": "827bc6f120aff6a6f04271bc84e863ee", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n#define max(a,b) ((a>b)?a:b)\n#define min(a,b) ((a>b)?b:a)\n#define UpFor(i,From,To) for(i=From;iTo;i--)\n#define Opfile_in(s) freopen(s,\"r\",stdin)\n#define Opfile_out(s) freopen(s,\"w\",stdout)\n#define Read(T) scanf(\"%d\\n\",&T)\n#define Print(T) printf(\"%d\\n\",T)\n#define LL long long\n#define MAXN 214748364\nint X,Y,N;\nvoid init();\nvoid doit();\n\nint main()\n{\n //Opfile_in(\"CF_temp.in\");\n init();\n doit();\n return 0;\n}\nvoid init()\n{\n scanf(\"%d%d%d\",&X,&Y,&N);\n}\nvoid doit()\n{\n int i,ansx=100000,ansy=1,k;\n UpFor(i,1,N+1)\n {\n k=(LL)i*X/Y;\n if(fabs(i*X-k*Y)*ansy\n\nint chk(long long n) {\n if (n <= 3) return (n > 1);\n for (long long i = 2; i * i <= n; i++) {\n if (n % i == 0) return 0;\n }\n return 1;\n}\n\nvoid solve() {\n long long a, b;\n scanf(\"%lld%lld\", &a, &b);\n if (a - b == 1 && chk(b + a)) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n}\n\nint main() {\n int t;\n scanf(\"%d\", &t);\n while (t--) {\n solve();\n }\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "2dbe75ed8fbc160fa42cbd583435a6aa", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main ()\n{\n\tlong long int a,b,t,c,d,flag;\n\tscanf(\"%lld\",&t);\n\n\twhile(t--)\n\t{\n\t\tscanf(\"%lld %lld\",&a,&b);\n\t\tc=a+b;\n\t\td=a-b;\n\t\tflag=0;\n\n\t\tif(d==1)\n\t\t{\n\t\t\tfor(int i=2;i<1000000;++i)\n\t\t\t{\n\t\t\t\tif (c%i==0 && c>i)\n\t\t\t\t{\n\t\t\t\t\tflag=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if (i>=c)\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (flag==1)\n\t\t\t\tprintf(\"NO\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"YES\\n\");\n\t\t}\n\t\telse\n\t\t\tprintf(\"NO\\n\");\n\t}\n\n\treturn 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "93c1f095c374ddb63f7dcbcffdefd50b", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* \ufffd\ufffd\ufffd\ufffd\u02af\u0377\ufffd\ufffd\n[O]\ufffd\ufffdA\ufffd\ufffd\ufffd\u04ee\ufffd\u0134\ufffd\ufffd\ufffd \n[] \ufffd\ufffdA\ufffd\ufffd\ufffd\ufffd\u04ee\ufffd\u0134\ufffd\ufffd\ufffd\n\n1.\u02af\u0377\n2.\ufffd\ufffd\ufffd\ufffd\n3.\ufffd\ufffd \n*/\n#include\nint main()\n{\n\tint n,a1,a2,a3,b1,b2,b3,maxwin1,maxwin2,maxwin3,maxwin,minwin1,minwin2,minwin3,minwin4,minwin;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d%d%d\",&a1,&a2,&a3);\n\tscanf(\"%d%d%d\",&b1,&b2,&b3);\n\t/**maxwin**/\n\t/*a1 beats b2*/\n\tif(a1>b2)\n\t\tmaxwin1=b2;\n\telse\n\t\tmaxwin1=a1;\n\t/*a2 beats b3*/\n\tif(a2>b3)\n\t\tmaxwin2=b3;\n\telse\n\t\tmaxwin2=a2;\n\t/*a3 beats b1*/\n\tif(a3>b1)\n\t\tmaxwin3=b1;\n\telse\n\t\tmaxwin3=a3;\n\t\n\tmaxwin=maxwin1+maxwin2+maxwin3;\n\t\n\t/*minwin**/\n\t/*a1 cannot beat b1 b3*/\n\tif(a1-b1-b3<0)\n\t\tminwin1=0;\n\telse\n\t\tminwin1=a1-b1-b3;\n\t/*a2 cannot beat b1 b2*/\n\tif(a2-b1-b2<0)\n\t\tminwin2=0;\n\telse\n\t\tminwin2=a2-b1-b2;\n\t/*a3 cannot beat b2 b3*/\n\tif(a3-b2-b3<0)\n\t\tminwin3=0;\n\telse\n\t\tminwin3=a3-b2-b3;\n\t\t\n\tminwin=minwin1+minwin2+minwin3;\n\tprintf(\"%d %d\\n\",minwin,maxwin);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "d9fe6d22902b312476fb80056f0f3dfe", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \nint main() {\n long long int n,minw=0,maxw=0;\n long long int a[3],b[3],m[3];\n scanf(\"%lld \",&n);\n scanf(\"%lld %lld %lld \",&a[0],&a[1],&a[2]);\n scanf(\"%lld %lld %lld \",&b[0],&b[1],&b[2]);\n maxw+=a[0]>b[1]?b[1]:a[0];\n maxw+=a[1]>b[2]?b[2]:a[1];\n maxw+=a[2]>b[0]?b[0]:a[2];\n int maxinb=b[0]>b[1]?(b[0]>b[2]?0:2):(b[1]>b[2]?1:2);\n int maxina=a[0]>a[1]?(a[0]>a[2]?0:2):(a[1]>a[2]?1:2);\n if(b[maxinb]>a[maxina])\n minw=b[maxinb]-a[maxinb]-a[(maxinb+1)%3];\n else\n minw=a[maxina]-b[maxina]-b[(maxina+2)%3];\n if(minw<0)\n minw=0;\n m[0]=b[0]>a[1]?a[1]:b[0];\n m[1]=b[1]>a[2]?a[2]:b[1];\n m[2]=b[2]>a[0]?a[0]:b[2];\n a[1]-=m[0];\n a[2]-=m[1];\n a[0]-=m[2];\n b[0]-=m[0];\n b[1]-=m[1];\n b[2]-=m[2];\n a[0]-=a[0]>b[0]?b[0]:a[0];\n a[1]-=a[1]>b[1]?b[1]:a[1];\n a[2]-=a[2]>b[2]?b[2]:a[2];\n //minw=a[0]+a[1]+a[2];\n printf(\"%lld %lld\",minw,maxw);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "55fc1b2bb38ed10d8f17445535927318", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma region kyopuro_templates\n#pragma GCC optimize(\"Ofast\")\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\ntypedef long long ll;\ntypedef long double ld;\n#define rep(i,l,r)for(ll i=(l);i<(r);i++)\n#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))\n#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)\n#define INF (1LL<<62)\n#define MOD1 1000000007\n#define MOD2 998244353\n#define MAX_N (1 << 20)\n#define YES printf(\"Yes\\n\")\n#define NO printf(\"No\\n\")\n#define PN printf(\"\\n\")\n#define charsize 100005 //10^5+5\n#define PI 3.141592653589793238\n\nvoid swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}\nvoid cin(ll *n){ scanf(\"%lld\",&(*n)); }\nvoid PriAll1(ll a[], ll n){ rep(i,0,n){ printf(\"%lld\",a[i]); if(i!=n-1) printf(\" \"); }PN; }\nll min(ll a, ll b){ return a < b ? a : b; }\nll max(ll a, ll b){ return a < b ? b : a; }\n// ll max2(ll a,ll b){return a>=b?a:b;}\n// ll min2(ll a,ll b){return a>=b?b:a;}\nll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}\nll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}\nll minn(ll n, ll a[]){ll b=INF;rep(i,0,n) b=min(b,a[i]);return b;}\nll maxn(ll n, ll a[]){ll b=-INF;rep(i,0,n) b=max(b,a[i]);return b;}\nll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}\ndouble POW_d(double a, double b){double c=1;rep(i,0,b) c*=a;return c;}\nll gcd(ll a,ll b){return b?gcd(b,a%b):a;}\nll lcm(ll a,ll b){return a/gcd(a,b)*b;}\nll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}\nll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}\nll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }\nll digits(ll a, ll b){return a/b?1+digits(a/b,b):1;}\nll base(ll n, ll a, ll i){return i==1?n%a:base(n/a,a,i-1);}\nll is_inArr1(ll x, ll n){ return ( x<0 || x>=n ) ? 0 : 1 ; }\nll is_inArr2(ll y, ll x, ll h, ll w){ return ( y<0 || y>=h || x<0 || x>=w ) ? 0 : 1 ; }\n\n\nvoid lr_lower( int *l, int *r, ll am, ll val , int type ){ (type<3) ? ( am < val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ) : ( am <= val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ); }\nvoid lr_upper( int *l, int *r, ll am, ll val , int type ){ (type<3) ? ( am <= val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ) : ( am < val ? ( *l = (*l+*r)/2 ) : ( *r= (*l+*r)/2 ) ); }\nint cmp_lower( ll a, ll b, int type ){ return (type==1) ? ( a==b ? 1 : 0 ) : (type==2) ? ( a>=b ? 1 : 0 ) : ( a>b ? 1 : 0 ) ; }\nint cmp_upper( ll a, ll b, int type ){ return (type==1) ? ( a==b ? 1 : 0 ) : (type==2) ? ( a<=b ? 1 : 0 ) : ( a=:2 >:3\nll lower_bound( ll a[], int l, int r, ll val , int type ){ while(r-l>1) lr_lower(&l,&r,a[ (l+r)/2 ],val,type); return cmp_lower(a[l],val,type) ? l : cmp_lower(a[r],val,type) ? r : -1; }\n// return biggest p which meets a[p]==val :1 <=:2 <:3\nll upper_bound( ll a[], int l, int r, ll val , int type ){ while(r-l>1) lr_upper(&l,&r,a[ (l+r)/2 ],val,type); return cmp_upper(a[r],val,type) ? r : cmp_upper(a[l],val,type) ? l : -1; }\n// count i which meets ai==x\nll count(ll a[], int l, int r, ll x){ int p = lower_bound(a,l,r,x,1); return p==-1 ? 0 : upper_bound(a,p,r,x,1)-p+1; }\n\nll *factors[2] , fac_cnt=0 , is_factor_prepared=0;\nll factor_pre(){ rep(i,0,1){ if(is_factor_prepared++) return 0; } ll tmp=(1e6)/2+1, fac_tmp[tmp]; rep(i,0,tmp){fac_tmp[i]=i?2*i+1:2;} rep(i,1,tmp){if(fac_tmp[i]){ repp(j,3,tmp/(2*i+1)+1,2 ){ if( j*(2*i+1) n ) break; } return n; }\nll judge_prime(ll n){ factor_pre(); rep(i,0,fac_cnt){ if(n 0){ \n t = (n & 1) ? t * s % mod : t;\n s = s * s % mod;\n n >>= 1;\n } \n return r ? t : 0;\n}\n#pragma endregion mod\n\n\nint upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}\nint downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}\nint cmp_string( const void * a , const void * b ) { return strcmp( (char *)a , (char *)b ); } // qsort((void*)s,n,sizeof(s[0]),int_sort );\nint cmp_char(const void * a, const void * b) { return *(char *)a - *(char *)b;}\nvoid sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}\nvoid sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}\n// void sort_string(int n,int size,char s[][size]){ qsort( (void*)s , n , sizeof(s[0]) , cmp_string ); }\n// void sort_char(char *s){ qsort( (void *)s , strlen(s) , sizeof(char) , cmp_char ); }\n// ll unique_string(ll n ,ll size, char s[][size]){ ll ans=1; rep(i,1,n) if( strcmp(s[i],s[i-1]) ) ans++; return ans; }\n// ll unique_num(ll n , ll a[]){ ll ans=1; rep(i,1,n) if( a[i]!=a[i-1] ) ans++; return ans; }\n\nll compare(ll a, ll b){ return ab?1:0; }\ntypedef struct{ ll a , b;}fr;\nint cmp1( const void *p, const void *q ){ \n ll pa=((fr*)p)->a; ll qa=((fr*)q)->a; return compare(pa,qa); \n}\nint cmp2( const void *p, const void *q ){\n ll pa=((fr*)p)->a; ll qa=((fr*)q)->a; return compare(qa,pa);\n}\nvoid strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}\nvoid strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}\n\nvoid sort_partial(ll a[],int begin,int end,int is_increase){\n ll *b; b = (ll *) malloc( sizeof(ll)*(end-begin) );\n\n rep(i,begin,end) b[i-begin]=a[i];\n if(is_increase) sortup(b,end-begin); else sortdown(b,end-begin);\n rep(i,begin,end) a[i]=b[i-begin];\n}\n\n// ll pre_rui[2151][1151];\n// ll ruiseki[2151][1151];\n// void rui_make(ll h, ll w){\n// rep(i,0,h){\n// rep(j,0,w){\n// ruiseki[i+1][j+1]=ruiseki[i+1][j]+pre_rui[i][j];\n// }\n// rep(j,0,w){\n// ruiseki[i+1][j+1]+=ruiseki[i][j+1];\n// }\n// }\n// }\n\n// ll rui_get(ll st_y, ll st_x, ll en_y, ll en_x, ll h, ll w){\n// if(en_y<0) return 0;\n// if(en_x<0) return 0;\n// if(st_y>h) return 0;\n// if(st_x>w) return 0;\n// if(st_y<0) st_y=0;\n// if(st_x<0) st_x=0;\n// if(en_y>h) en_y=h;\n// if(en_x>w) en_x=w;\n// ll val=0;\n// val+=ruiseki[en_y][en_x];\n// val-=ruiseki[en_y][st_x];\n// val-=ruiseki[st_y][en_x];\n// val+=ruiseki[st_y][st_x];\n// return val;\n// }\n\n\n\n\n#pragma region AVL\n/*---------------------------AVL start--------------------------------*/\n//https://qiita.com/mikecat_mixc/items/e9f8248de2ae7f7a0a29\ntypedef struct node_AVL_set{ \n ll val;\n int diff;\n int cnt;\n struct node_AVL_set *child[2];\n}AVL_set;\nvoid AVL_set_inside_rotate(AVL_set **node, int is_right){\n int l = is_right==false , r = is_right==true , sign = is_right ? 1 : -1;\n if((*node)->child[l] != NULL){\n AVL_set* left = (*node)->child[l];\n int a= (*node)->diff * sign , b= left->diff * sign ,na,nb;\n if(b+1){\n na=a-1-b;\n nb= (a-b) ? b-1 : a-2;\n }else{\n na=a-1;\n nb= a ? b-1 : a+b-2;\n }\n (*node)->diff = na * sign;\n left->diff = nb * sign;\n /* rotate-> */\n (*node)->child[l] = (*node)->child[l]->child[r];\n left->child[r] = *node;\n *node = left;\n }\n}\nint AVL_set_inside_update(AVL_set **node, ll data, int add){\n if(*node == NULL){\n if(add==2){\n *node = (AVL_set*)malloc(sizeof(AVL_set));\n (*node)->val = data;\n (*node)->cnt = 1;\n (*node)->diff = 0;\n (*node)->child[0] = NULL;\n (*node)->child[1] = NULL;\n }\n return add==2 ? *node != NULL : 0; \n }else{\n int l, delta, delta_sign; AVL_set *next_node;\n if(data == (*node)->val){\n if(add==2){\n (*node)->cnt++;\n return 0;\n }else{\n if( add && (*node)->cnt > 1 ){\n (*node)->cnt--; return 0;\n }else{\n if((*node)->child[1] == NULL){\n next_node = (*node)->child[0];\n free(*node);\n *node = next_node;\n return -1;\n }else if((*node)->child[0] == NULL){\n next_node = (*node)->child[1];\n free(*node);\n *node = next_node;\n return -1;\n }else{\n for(next_node = (*node)->child[0];\n next_node->child[1] != NULL;\n next_node = next_node->child[1]);\n (*node)->val = next_node->val;\n l=0;\n delta_sign=1;\n delta = AVL_set_inside_update(&(*node)->child[l], next_node->val, add);\n }\n }\n }\n }else{\n l = data >= (*node)->val ? 1 : 0;\n delta_sign = data < (*node)->val ? 1 : -1;\n delta = AVL_set_inside_update(&(*node)->child[l], data, add);\n }\n if( delta ){\n int orig_diff = (*node)->diff;\n int do_rotate = 0, rotate_l , diff_sign , rotate_right;\n (*node)->diff += delta * delta_sign;\n if((*node)->diff > 1){\n do_rotate = 1;\n rotate_l = 0;\n diff_sign = 1;\n rotate_right = 1;\n }else if((*node)->diff < -1){\n do_rotate = 1;\n rotate_l = 1;\n diff_sign = -1;\n rotate_right = 0;\n }\n if(do_rotate){\n int child_diff = (*node)->child[rotate_l]->diff;\n if((*node)->child[rotate_l]->diff * diff_sign < 0){\n AVL_set_inside_rotate(&(*node)->child[rotate_l], !rotate_right);\n }\n AVL_set_inside_rotate(node, rotate_right);\n return delta < 0 && child_diff != 0 ? -1 : 0;\n }\n if (delta > 0 && orig_diff == 0) return 1;\n else if(delta < 0 && orig_diff != 0) return -1;\n else return 0;\n }else{ \n return 0;\n }\n }\n}\n\nvoid AVL_set_inside_print(const AVL_set *node, int depth){\n if(node == NULL) return;\n AVL_set_inside_print(node->child[1], depth + 1);\n printf(\"%lld %d\\n\", node->val,node->cnt);\n AVL_set_inside_print(node->child[0], depth + 1); \n}\nvoid AVL_set_inside_free(AVL_set *node){\n if(node == NULL) return;\n AVL_set_inside_free(node->child[0]);\n AVL_set_inside_free(node->child[1]);\n free(node);\n}\nll AVL_set_inside_count(AVL_set *root, ll val){\n AVL_set *node; node = root;\n while(node){\n if (val < node->val) node = node->child[0];\n else if(val > node->val) node = node->child[1];\n else return node->cnt;\n }\n return 0;\n}\n\n\nint AVL_set_lowcomp(ll node, ll val, int type){\n if(node==val){\n if(type!=3) return 0;\n else return 1;\n }\n if(nodeval) return -1;\n return 0;\n}\n// return smallest p which meets a[p]==val :1 >=:2 >:3\nAVL_set* AVL_set_inside_lowerbound(AVL_set *root, ll val, int type){\n AVL_set *node; node = root;\n while(node){\n int com=AVL_set_lowcomp(node->val,val,type);\n if(com==0) return node;\n if(com==1) node = node->child[1];\n if(com==-1){\n AVL_set *small;\n small=AVL_set_inside_lowerbound(node->child[0],val,type);\n if(type==1){\n return small;\n }else{\n if(small!=NULL) return small;\n else return node; \n }\n }\n }\n return node;\n}\n\nint AVL_set_upcomp(ll node, ll val, int type){\n if(node==val){\n if(type!=3) return 0;\n else return -1;\n }\n if(nodeval) return -1;\n return 0;\n}\n// return biggest p which meets a[p]==val :1 <=:2 <:3\nAVL_set* AVL_set_inside_upperbound(AVL_set *root, ll val, int type){\n AVL_set *node; node = root;\n while(node){\n int com=AVL_set_upcomp(node->val,val,type);\n if(com==0) return node;\n if(com==-1) node = node->child[0];\n if(com==1){\n AVL_set *big;\n big=AVL_set_inside_upperbound(node->child[1],val,type);\n if(type==1){\n return big;\n }else{\n if(big!=NULL) return big;\n else return node; \n }\n }\n }\n return node;\n}\n\n\nll AVL_set_inside_minmax(AVL_set *root, int type){\n while(root->child[type] !=NULL) root= root->child[type];\n return root->val;\n}\nvoid AVL_set_inside_swap(AVL_set **node1, AVL_set **node2){ \n AVL_set *tmp; tmp=*node1; *node1=*node2; *node2=tmp;\n}\n\n#define set_MAX_SIZE 514511\nll set_main( int command , int set_num , ll val ,ll option){\n static bool set_is_init=false;\n static AVL_set *set_pointer[set_MAX_SIZE];\n static ll set_siz[set_MAX_SIZE];\n if(!set_is_init){ set_is_init=true; rep(i,0,set_MAX_SIZE){ *(set_pointer+i) = NULL; set_siz[i]=0; } }\n if(command==-1){ AVL_set_inside_print( set_pointer[set_num] ,0); }\n if(command==1){ AVL_set_inside_count(set_pointer[set_num],val) ? 1 : set_siz[set_num]++; AVL_set_inside_update( &set_pointer[set_num] , val , 2 ); }\n if(command==2){ return AVL_set_inside_count(set_pointer[set_num],val); }\n if(command==3){ ( AVL_set_inside_count(set_pointer[set_num],val) > 1 ) ? 1 : set_siz[set_num]--; AVL_set_inside_update( &set_pointer[set_num] , val,1); }\n if(command==4){ set_siz[set_num]--; AVL_set_inside_update( &set_pointer[set_num] , val , 0 ); }\n if(command==5){ set_siz[set_num]=0; AVL_set_inside_free( set_pointer[set_num] ); set_pointer[set_num] = NULL; }\n if(command==6){ return set_siz[set_num]; }\n if(command==7){ return AVL_set_inside_minmax(set_pointer[set_num],1); }\n if(command==8){ return AVL_set_inside_minmax(set_pointer[set_num],0); }\n if(command==9){ AVL_set_inside_swap(&set_pointer[set_num],&set_pointer[val]); }\n if(10<=command&&command<=12){\n AVL_set *lowbound = AVL_set_inside_lowerbound(set_pointer[set_num],val,command-9);\n if(lowbound==NULL) return option;\n else return lowbound->val;\n }\n if(13<=command&&command<=15){\n AVL_set *upbound = AVL_set_inside_upperbound(set_pointer[set_num],val,command-12);\n if(upbound==NULL) return option;\n else return upbound->val;\n }\n return 0;\n}\n\nvoid set_print(int set_num){ set_main(-1,set_num,0,0); }\nvoid set_insert(int set_num, ll val){ set_main(1,set_num,val,0); }\nll set_count(int set_num, ll val){ return set_main(2,set_num,val,0); }\nvoid set_erase(int set_num, ll val, int is_all){ if(is_all) set_main(4,set_num,val,0); else set_main(3,set_num,val,0); }\nvoid set_clear(int set_num){ set_main(5,set_num,0,0); }\nll set_size(int set_num){ return set_main(6,set_num,0,0); }\nll set_max(int set_num){ return set_main(7,set_num,0,0); }\nll set_min(int set_num){ return set_main(8,set_num,0,0); }\nvoid set_swap(int set_num1, int set_num2){ set_main(9,set_num1,set_num2,0); }\n\n\n// return smallest p which meets a[p]==val :1 >=:2 >:3\nll set_lowerbound(int set_num, ll val, int type, ll error){\n return set_main(9+type,set_num,val,error);\n}\n// return biggest p which meets a[p]==val :1 <=:2 <:3\nll set_upperbound(int set_num, ll val, int type, ll error){\n return set_main(12+type,set_num,val,error);\n}\n\n/*\ninsert *\nsize *\nclear *\nerase *\ncount *\nmax *\nmin *\nswap *\nbegin x\nend x\nmerge source \u306e\u8981\u7d20\u306e\u30ad\u30fc\u3068\u7b49\u4fa1\u306a\u30ad\u30fc\u306e\u8981\u7d20\u304c\u3042\u308b\u5834\u5408\u3001\u305d\u306e\u8981\u7d20\u306f source \u304b\u3089\u62bd\u51fa\u3055\u308c\u306a\u3044\nlower_bound *\nupper_bound *\n*/\n\n// ll map_main()\n\n/*---------------------------AVL start--------------------------------*/\n\n#pragma endregion AVL\n\n\n#pragma endregion kyopuro_templates\n\n\n\n#pragma region vector\n\ntypedef struct vector vector;\ntypedef struct vector {\n int n, max, data_size;\n void *data;\n void (*push)(vector*, void*);\n void (*set)(vector*, int, void*);\n ll (*get)(vector*, int);\n double (*get_double)(vector*, int);\n int (*size)(vector*);\n} vector;\n\n\nvoid vector_push(vector *v, void *x) {\n if (v->n == v->max) {\n v->max *= 2;\n assert((v->data = realloc(v->data, v->max * v->data_size)) != NULL);\n }\n if(x==NULL){\n memset(v->data + v->data_size * v->n, 0, v->data_size);\n }else{\n memcpy(v->data + v->data_size * v->n, x, v->data_size);\n }\n v->n++;\n}\n\nvoid vector_set(vector *v, int idx, void *x) {\n if(x == NULL){\n memset(v->data + v->data_size * idx, 0, v->data_size);\n }else{\n memcpy(v->data + v->data_size * idx, x, v->data_size);\n }\n}\n\nvoid *vector_get_internal(vector *v, int idx) {\n return (v->data + v->data_size * idx);\n}\nll vector_get(vector *v, int idx){\n ll ret=0;\n if(v->data_size == 8) ret = *(ll*)vector_get_internal(v, idx);\n if(v->data_size == 4) ret = *(int*)vector_get_internal(v, idx);\n if(v->data_size == 2) ret = *(bool*)vector_get_internal(v, idx);\n return ret;\n}\ndouble vector_get_double(vector *v, int idx){\n assert(v->data_size == sizeof(double));\n return *(double*)vector_get(v, idx);\n}\n\nint vector_size(vector *v) {\n return v->n;\n}\n\nvector *vector_init(int n, int data_size) {\n assert(n != 0);\n vector *ret = (vector *)malloc(sizeof(vector));\n ret->n = 0;\n ret->max = n;\n ret->data_size = data_size;\n ret->data = malloc(n * data_size);\n\n ret->push=vector_push;\n ret->set=vector_set;\n ret->size=vector_size;\n ret->get = vector_get;\n ret->get_double = vector_get_double;\n\n memset(ret->data, 0, n * ret->data_size);\n return ret;\n}\n\n// void vector_free(vector *v){\n// free(v->data);\n// free(v->get);\n// free(v->get_double);\n// free(v->push);\n// free(v->set);\n// free(v->size);\n// free(v);\n// }\n\n#pragma endregion vector\n\n\n\n#pragma region max_flow\n#define flow_t long long\n// #define flow_t double\ntypedef struct Dinic Dinic;\ntypedef struct Dinic {\n int n;\n vector **to;\n vector **cap;\n vector **rev;\n vector *min_cost;\n vector *iter;\n void (*add)(Dinic*, int, int, flow_t);\n flow_t (*max_flow)(Dinic*, int, int);\n} Dinic;\n\n\nvoid Dinic_add_edge(Dinic *d, int from, int to, flow_t cap) {\n vector_push(d->rev[from], (void*)&d->to[to]->n);\n vector_push(d->rev[to], (void*)&d->to[from]->n);\n vector_push(d->to[from], (void*)&to);\n vector_push(d->to[to], (void*)&from);\n vector_push(d->cap[from], (void*)&cap);\n vector_push(d->cap[to], NULL);\n}\n\nbool Dinic_bfs(Dinic *d, int s, int t) {\n int init = -1;\n rep(i, 0, d->n) vector_set(d->min_cost, i, (void*)&init);\n vector *q = vector_init(1, sizeof(int));\n vector_set(d->min_cost, s, NULL);\n int head = 0;\n q->push(q, (void*)&s);\n while(head != q->n && vector_get(d->min_cost, t) == -1){\n int p = q->get(q, head);\n head++;\n rep(i, 0, d->to[p]->n) {\n int to = vector_get(d->to[p], i);\n if(vector_get(d->cap[p], i) > 0 && vector_get(d->min_cost, to) == -1){\n ll cost = vector_get(d->min_cost, p) + 1;\n vector_set(d->min_cost, to, (void*)&cost);\n q->push(q, (void*)&to);\n }\n }\n }\n return vector_get(d->min_cost, t) != -1;\n}\n\nflow_t Dinic_dfs(Dinic *d, int idx, int t, flow_t flow) {\n if(idx == t) return flow;\n rep(i, vector_get(d->iter, idx), d->cap[idx]->n){\n vector_set(d->iter, idx, (void*)&i);\n flow_t cap = vector_get(d->cap[idx], i);\n int to = vector_get(d->to[idx], i);\n if(cap > 0 && vector_get(d->min_cost, idx) < vector_get(d->min_cost, to)) {\n flow_t delta = Dinic_dfs(d, to, t, flow < cap ? flow : cap);\n if(delta > 0) {\n cap -= delta;\n vector_set(d->cap[idx], i, (void*)&cap);\n int rev = vector_get(d->rev[idx], i);\n flow_t rev_cap = vector_get(d->cap[to], rev) + delta;\n vector_set(d->cap[to], rev, (void*)&rev_cap);\n return delta;\n }\n }\n }\n return 0;\n}\n\nflow_t Dinic_max_flow(Dinic *d, int s, int t) {\n flow_t flow = 0;\n while(Dinic_bfs(d, s, t)) {\n rep(i, 0, d->n) vector_set(d->iter, i, NULL);\n flow_t f = 0;\n while((f = Dinic_dfs(d, s, t, INF)) > 0) flow += f;\n }\n return flow;\n}\n\nDinic *Dinic_init(int n) {\n Dinic *ret = (Dinic *)malloc(sizeof(Dinic));\n ret->n = n;\n ret->to = (vector **)malloc(n * sizeof(vector*));\n ret->cap = (vector **)malloc(n * sizeof(vector*));\n ret->rev = (vector **)malloc(n * sizeof(vector*));\n rep(i, 0, n) {\n ret->to[i] = vector_init(1, sizeof(int));\n ret->cap[i] = vector_init(1, sizeof(flow_t));\n ret->rev[i] = vector_init(1, sizeof(int));\n }\n ret->min_cost =vector_init(n, sizeof(int));\n ret->iter = vector_init(n, sizeof(int));\n ret->add = Dinic_add_edge;\n ret->max_flow = Dinic_max_flow;\n return ret;\n}\n#pragma endregion max_flow\n\n\n\n\n\nchar s[1151154];\nvoid solve(){\n // fgets(s,sizeof(s),stdin); \n ll n;\n ll ans=0;\n cin(&n);\n // scanf(\"%s\",s);\n ll a[3];\n ll b[3];\n rep(i,0,3){\n cin(&a[i]);\n }\n rep(i,0,3){\n cin(&b[i]);\n }\n ll ma=0;\n // ll mi=INF;\n ma=min(a[0],b[1])+min(a[1],b[2])+min(a[2],b[0]);\n Dinic *d=Dinic_init(8);\n d->add(d,6,0,a[0]);\n d->add(d,6,1,a[1]);\n d->add(d,6,2,a[2]);\n\n d->add(d,0,3,INF);\n d->add(d,0,5,INF);\n d->add(d,1,3,INF);\n d->add(d,1,4,INF);\n d->add(d,2,4,INF);\n d->add(d,2,5,INF);\n\n d->add(d,3,7,b[0]);\n d->add(d,4,7,b[1]);\n d->add(d,5,7,b[2]);\n printf(\"%lld %lld\\n\",n-d->max_flow(d,6,7),ma);\n}\n\nint main(void){\n ll T=1;\n // cin(&T);\n rep(i,0,T){ solve(); }\n return 0;\n}\n\n\n/*\n while (ng + 1 < ok) {\n ll p = ng + (ok - ng) / 2;\n ll cnt = 0;\n rep(i,0,n){\n cnt += (a[i] + p - 1) / p - 1;\n }\n if (cnt <= k) ok = p; else ng = p;\n }\n*/\n// 10^18 2^60 3^38 5^26\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "a46c84b14d85a50ebb59e1b8d12cb601", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint Min(int a[3],int b[3]){\n\tint i , j = 1 , min = 0 ;\n\tfor(i = 0 ; i < 3 ; i++){\n\t\tj++ ;\n\t\tif (j == 3) j = 0 ;\n\t\tif(a[i] > b[i] + b[j])\tmin += a[i] - b[i] - b[j] ;\n\t\n\t}\n\treturn min ;\n}\n\nint Max(int a[3],int b[3]){\n\tint i , j = 0 , max = 0 ;\n\tfor(i = 0 ; i < 3 ; i++){\n\t\tj++ ;\n\t\tif (j == 3) j = 0 ;\n\t\tif(a[i] > b[j])\tmax += b[j] ;\n\t\telse max += a[i];\n\t\n\t}\n\treturn max ;\n}\n\nint main(){\n\tint n ;\n\tint a[3], b[3] , i;\n\tscanf(\"%d\",&n);\n\tfor(i = 0 ; i < 3 ; i++)\tscanf(\"%d\",&a[i]);\n\tfor(i = 0 ; i < 3 ; i++)\tscanf(\"%d\",&b[i]);\n\tprintf(\"%d %d\",Min(a,b),Max(a,b));\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "97ff1037d99656c6a725836e893f30f7", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\nint minc(int a,int b){\n\tif(a<=b)\n\t{\n\t\treturn a;\n\t}\n\treturn b;\n}\n\nint main()\n{\n\tint n,a[10],b[10],maxW=0,minW1=0,minW2=0;\n\n\tscanf(\"%d\",&n);\n\tscanf(\"%d %d %d\",&a[1],&a[2],&a[3]);\n\tscanf(\"%d %d %d\",&b[2],&b[3],&b[1]);\n\tb[4]=b[1];\n\t// printf(\"%d %d %d\\n\",a[1],a[2],a[3]);\n\t// printf(\"%d %d %d\\n\",b[1],b[2],b[3]);\n\tmaxW=minc(a[1],b[3])+minc(a[2],b[1])+minc(a[3],b[2]);\n\n\tfor(int i =1;i<=3;i++)\n\t{\n\t\tif(a[i]!=0)\n\t\t{\n\t\t\tint buff = minc(a[i],b[i]);\n\t\t\ta[i]-=buff;\n\t\t\tif(a[i]!=0)\n\t\t\t{\n\t\t\t\tbuff = minc(a[i],b[i+1]);\n\t\t\t\ta[i]-=buff;\n\t\t\t\tb[i+1]-=buff;\n\t\t\t}\n\t\t}\n\n\t}\n\tminW1=a[1]+a[2]+a[3];\n\tprintf(\"%d %d\",minW1,maxW);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "a025c88d618e9566ed905a45a31bf173", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//set many funcs template\n//Ver.20190820\n#include\n#include\n#include\n#include\n#include\n#include\n#define inf 1072114514\n#define llinf 4154118101919364364\n#define mod 1000000007\n#define pi 3.1415926535897932384\n\nint max(int a,int b){if(a>b){return a;}return b;}\nint min(int a,int b){if(a\nint max(int num1, int num2);\nint min(int num1, int num2);\n\nint main()\n{\n int n,a1,a2,a3,b1,b2,b3,win,lose,lost;\n scanf(\"%d %d %d %d %d %d %d\",&n,&a1,&a2,&a3,&b1,&b2,&b3);\n win=min(a1,b2)+min(a2,b3)+min(a3,b1);\n lose=max(max(max(max(max(b1,b2),b3),a1),a2),a3);\n if ((lose==b1)||(lose==a3))\n lost=a3-(b2+b3);\n else\n if((lose==b2)||(lose==a1))\n lost=a1-(b1+b3);\n else\n lost=a2-(b1+b2);\n if(lost<0)\n lost=0;\n printf(\"%d %d\",lost,win);\n return 0;\n\n}\nint max(int num1, int num2)\n{\n return (num1 > num2 ) ? num1 : num2;\n}\nint min(int num1, int num2)\n{\n return (num1 > num2 ) ? num2 : num1;\n}\n", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "math", "greedy"], "code_uid": "1545180e9c9d607bc0f8e126dd7de5aa", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/611/submission/19896636 (rainboy) */\n#include \n\nint main() {\n\tlong long a, b, i, j, cnt;\n\n\tscanf(\"%lld%lld\", &a, &b);\n\tcnt = 0;\n\tfor (i = 0; i <= 60; i++) {\n\t\tlong long c;\n\n\t\tc = (1LL << i) - 1;\n\t\tfor (j = 0; j < i - 1; j++) {\n\t\t\tlong long d;\n\n\t\t\td = c - (1LL << j);\n\t\t\tif (d >= a && d <= b)\n\t\t\t\tcnt++;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "c4a45670c9ae759f866146987a70e886", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nlong long int funk(long long int x,long long int b){\nlong long int m=1;\n\nlong long int a;\n\nfor(a=1;a<=b;a++){\nm=m*x;\n}\nreturn m;\n\n}\nmain(){\n\n long long int a,b,c;\n long long int increase;\n long long int unos,unos1;\n scanf(\"%lld%lld\",&unos,&unos1);\n long long int x;\n long long int counter=0;\n\n for(a=64;a>=1;a--){\n x=funk(2,a)-1;\n increase=1;\n for(b=1;b=unos) && ((x-increase) <=unos1) ){\n counter++;\n //printf(\"%lld %lld %lld\\n\",a,x,increase);\n }\n increase=increase*2;\n }\n\n\n }\n\n printf(\"%lld\",counter);\n\n\n\n\n\n\n\n\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "bitmasks"], "code_uid": "25fd984fe9f1758c60ee3ac360a34bcd", "src_uid": "581f61b1f50313bf4c75833cefd4d022", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define MOD 998244353LL\n\nlong long f[200001];\n\nlong long power(long long x, long long n){\n long long res;\n if(n==0){\n return 1;\n }\n if(n==1){\n return x%MOD;\n }\n\n res=power(x, n/2);\n res%=MOD;\n res*=res;\n res%=MOD;\n if(n & 1LL){\n res*=x;\n res%=MOD;\n }\n return res%MOD;\n}\n\nlong long fibo(){\n int i;\n for(i=3; i<=200000; ++i){\n f[i]=f[i-2]+f[i-1];\n f[i]%=MOD;\n }\n}\n\nint main(void){\n long long N, res;\n\n scanf(\"%lld\", &N);\n if(N==1){\n printf(\"%lld\", power(2, MOD-2)%MOD);\n return 0;\n }\n else if(N==2){\n printf(\"%lld\", power(4, MOD-2)%MOD);\n return 0;\n }\n f[1]=f[2]=1;\n fibo();\n \n res=((f[N]%MOD)*(power(power(2, N)%MOD, MOD-2)%MOD))%MOD;\n //(2*N-5)/2^N\n printf(\"%lld\", res);\n\n return 0;\n}\n\n/*\nx^MOD == x (mod MOD)\nx^(MOD-1) == 1 (mod MOD)\nx * x^(MOD-2) == 1 (mod MOD)\n\n2*N-5 mod MOD * (2^N)^-1 mod MOD\n*/", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "8ce0fe8496ab5822d2574e30bc2d685e", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define MD\t998244353\n\nlong long power(int a, int k) {\n\tlong long b = a, p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * b % MD;\n\t\tb = b * b % MD;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint main() {\n\tint n, i, x, y, z;\n\n\tscanf(\"%d\", &n);\n\tx = 1, y = 0, z = 1;\n\tfor (i = 0; i < n; i++)\n\t\tz = x, x = (y + z) % MD, y = z;\n\tprintf(\"%lld\\n\", z * power(2, MD - 1 - n) % MD);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "4eeb4879a9c101cdc92073141f927fb2", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main()\n{\n long n,m,k,i,len,flag=0,fx;\n char s1[10]={'\\0'},s2[10]={'\\0'},s[1000]={'\\0'};\n // freopen(\"b.in\",\"r\",stdin);\n // freopen(\"b.out\",\"w\",stdout);\n scanf(\"%ld %ld %ld\\n\",&n,&m,&k);\n scanf(\"%s %s\\n\",s1+1,s2+1);\n if(s2[1]=='h')\n fx=-1;\n else\n fx=1;\n scanf(\"%s\\n\",s+1);\n len=strlen(s+1);\n for(i=1;i<=len;i++)\n {\n if(s[i]=='0')\n {\n if(k==1 && fx==-1)\n fx=1;\n if(k==n && fx==1)\n fx=-1;\n k+=fx;\n if(k==m && (m==1 || m==n))\n {\n printf(\"Controller %ld\\n\",i);\n flag=1;\n break;\n }\n if(k==m)\n m+=fx;\n }\n else\n {\n if(k==1 && fx==-1)\n fx=1;\n if(k==n && fx==1)\n fx=-1;\n k+=fx;\n if((fx==-1 || k==1) && k!=n)\n m=n;\n else\n m=1;\n }\n }\n if(!flag)\n printf(\"Stowaway\\n\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "games"], "code_uid": "8918eb26edd3b6e972544f39c97a73c9", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n\tint n,a,b;\n\tscanf(\"%d %d %d\",&n,&b,&a);\n\tchar s[5];\n\tscanf(\"%s\",s);\n\tscanf(\"%s\",s);\n\tint d=1;\n\tif(strcmp(s,\"head\")==0)\n\t\td=-1;\n\tchar m[210];\n\tscanf(\"%s\",m);\n\tint l=strlen(m);\n\tint i=0;\n\tfor(i=0;in)\n\t\t\t\t\tb--;\n\t\t\t\tif(b==a)\n\t\t\t\t{\tprintf(\"Controller %d\\n\",i);return 0;}\n\t\t\t\tif(d<0)\n\t\t\t\t\ta--;\n\t\t\t\telse\n\t\t\t\t\ta++;\n\t\t\t\tif(a==1||a==n)\n\t\t\t\t\td=d*-1;\n\n\t\t\t}\n\t\t}\n\t\tif(m[i]=='1')\n\t\t{\n\t\t\tif(d<0)\n\t\t\t{\n\t\t\t\ta--;\n\t\t\t\tb=n;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ta++;\n\t\t\t\tb=1;\n\t\t\t}\n\t\t\tif(a==1||a==n)\n\t\t\t\td=d*-1;\n\t\t}\n\n\t}\n\tprintf(\"Stowaway\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "games"], "code_uid": "23bc9829307d45b535800ed37d5eea24", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\n//input definitions\n#define sd(x) scanf(\"%d\",&x);\n#define slld(x) scanf(\"%lld\",&x);\n#define ss(x) scanf(\"%s\",x);\n#define sf(x) scanf(\"%f\",&x);\n#define slf(x) scanf(\"%lf\",&x);\n\n//output definitions\n#define pd(x) printf(\"%d\",x);\n#define plld(x) printf(\"%lld\",x);\n#define ps(x) printf(\"%s\",x);\n#define pf(x) printf(\"%f\",x);\n#define plf(x) printf(\"%lf\",x);\n#define pnl printf(\"\\n\");\n#define psp printf(\" \");\n\n//define datatypes\ntypedef long long int ll;\n\n//loops\n#define upto(x) for(;i<=x;i++)\n#define fl(i,a,b,c) for(i=a;i<=b;i+=c)\n#define wl(x) while(x--)\n\n//Function to compute GCD\nll gcd(ll a,ll b){\n\tif(a%b == 0)\n\t\treturn b;\n\treturn gcd(b,a%b);\n}\n\n//Function initialize prime numbers \nint isPrime[1000006];\nint initPrime(){\n\tint i,j;\n\tfor(i=2;i<1000006;i++)\n\t\tisPrime[i] = 1;\n\tisPrime[0] = isPrime[1] = 0;\n\tfor(i=2;i < 1000006;i++){\n\t\tfor(j=2;i*j < 1000006;j++)\n\t\t\tisPrime[i*j] = 0;\n\t}\n}\n\nint comp(const void *a, const void *b){\n\treturn *(int *)b - *(int *)a;\n}\n\nint main(void) {\n\tll n,i,j,k,l;\n\tslld(n)\n\tif(n == 1)\n\t\tpd(1)\n\telse if(n == 2)\n\t\tpd(2)\n\telse if(n == 3)\n\t\tpd(6)\n\telse{\n\t\tif(n&1){\n\t\t\tplld(n*(n-1)*(n-2))\n\t\t}\n\t\telse{\n\t\t\tif(n%3==0){\n\t\t\t\tplld((n-1)*(n-2)*(n-3))\n\t\t\t}\n\t\t\telse{\n\t\t\t\tplld(n*(n-1)*(n-3))\n\t\t\t}\n\t\t}\n\t}\n\tpnl\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "2142b85b087002893d600a4d548ea87a", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.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<3)\n {\n printf(\"%lld\\n\",n);\n }\n else if(n%2==0)\n {\n if(((n-3)%3)!=0 || (n%3)!=0)\n {\n printf(\"%lld\\n\",(n)*(n-1)*(n-3));\n }\n else\n {\n printf(\"%lld\\n\",(n-1)*(n-2)*(n-3));\n }\n }\n else\n {\n printf(\"%lld\\n\",(n)*(n-1)*(n-2));\n }\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "0e98163eedd5898e8f956f568a31eae4", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n,k,count=0;\n scanf(\"%lld %lld\",&n,&k);\n long long int i,m=-1;\n for(i=1;i<=k;i++)\n {\n if(m\n#define ll long long\nint main()\n{\n\tll n,k;\n\tscanf(\"%lld %lld\", &n,&k);\n\tif(k>50){\n\t\tprintf(\"No\");\n\t\treturn 0;\n\t}\n\tfor(int i=1;i<=k;i++)\n\t\tfor(int j=i+1;j<=k;j++){\n\t\t\tif(n%i==n%j){\n\t\t\t\tprintf(\"No\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tprintf(\"Yes\");\n}", "lang_cluster": "C", "tags": ["brute force", "number theory"], "code_uid": "317042416bcdb117cee43924cd579120", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\nlong long int solve(int N)\n{\n\tint i;\n\tlong long int x;\n\tlong long int mod = 1000000007;\n\tlong long int f = 1;\n\tlong long int p = 1;\n\t\n\tfor(i=1;i<=N;i++)\n\t{\n\t\tf *= i;\n\t\tf %= mod;\n\t}\n\n\tfor(i=1;i\nconst int m = 1e9+7;\n\nint main() {\n\tint n;\n\tscanf(\"%d\", &n);\n\tint ans = 1;\n\tfor( int i=1; i<=n; ++i )\n\t\tans = 1ll*ans*i %m;\n\tint p2 = 1;\n\tfor( int i=1; i\n\nconst long long mod = 1e9 + 9;\n\nint main() {\n long long n, m, i;\n scanf(\"%I64d %I64d\", &n, &m);\n long long now = 1;\n for(i = 1; i <= m; i++) {\n now *= 2;\n now %= mod;\n }\n long long ans = 1;\n for(i = 1; i <= n; i++) {\n now--;\n if(now < 0) now += mod;\n ans *= now;\n ans %= mod;\n }\n printf(\"%d\\n\", (int) ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "b3ec3c8dfae1fb30f43e3a9e68c859f0", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "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\ntypedef long long ll;\n\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n#define abs(k) (((k)>0)?(k):(-(k)))\nint modint(int a,int b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}\nll modll(ll a,ll b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}\n#define mod(a,b) a=modint(a,b)\n#define llmod(a,b) a=modll(a,b)\n#define mset(a) memset(a,0,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n#define inf (1e9)\n#define linf (1e18)\n#define pi 3.14159265358979323846\n\nvoid fileio_in_out()\n{\n freopen(\".in\",\"r\",stdin);\n freopen(\".out\",\"w\",stdout);\n}\n\nvoid fileio_txt()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n}\n\n//==================================================\n\n#define modnum (inf+9)\n\nll n,m,k=1,ans=1,t=2;\nint i,j,l;\n\nint main()\n{\n //fileio_in_out();\n //fileio_txt();\n \n scanf(\"%I64d%I64d\",&n,&m);\n \n while(m>0)\n {\n if(m&1)\n k=modll(k*t,modnum);\n t=modll(t*t,modnum);\n m>>=1;\n }\n \n for(i=1;i<=n;i++)\n ans=modll(ans*(k-i),modnum);\n \n printf(\"%I64d\\n\",ans);\n \n //system(\"pause\");\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "combinatorics"], "code_uid": "ba71a5f316bb3c1d2b3f7fe7a785939f", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define h 1000000000000000009\ntmp=-1;\nlong long bsc(long long l, long long r, long long m)\n{\n if (r >= l)\n {\n long long mid = l + (r - l)/2, cnt=0, i=2;\n for(i=2; ;i++){\n if(i*i*i<=mid){\n cnt+=mid/(i*i*i);\n if (cnt > m) return bsc(l, mid-1, m);\n }\n else\n break;\n }\n\n if (cnt == m) {\n if(l==r){\n //printf(\"%lld\\n\",mid);\n //printf(\"fin %lld\\n\",mid);\n //printf(\"mm\\n\");\n return mid;\n }\n else{\n //printf(\"eq\\n\");\n return bsc(l, mid, m);\n }\n }\n //else if (cnt > m) return bsc(l, mid-1, m);\n\n //else {\n //printf(\"big\\n\");\n return bsc(mid+1, r, m);\n //}\n }\n //printf(\"kk\\n\");\n return -1;\n}\n\nint main()\n{\n long long i,j,m,ans;\n scanf(\"%lld\",&m);\n ans=bsc(1, h, m);\n printf(\"%lld\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search", "combinatorics"], "code_uid": "943c392fa6447ce8717c8a987bd8e53a", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\nlong long solve(long long n)\n{\n\tlong long int k=2;\n\tlong long cnt=0;\n\twhile(k*k*k<=n){\n\t\tcnt+=n/(k*k*k); k++;\n\t}\n\treturn cnt;\n}\nint main(){\n\tlong long a,b,c,d,e;\n\tscanf(\"%lld\",&a);\n\t\n\tlong long f =0; long long r = 5e15;\n\t\n\twhile(f=a)\n\t\t\tr=(f+r)/2;\n\t\telse f=(f+r)/2+1;\n\t}\n\tif(solve(r)==a){\n\t\tprintf(\"%lld\",r);\n\t}\n\telse printf(\"-1\");\n\t\n}\n\t", "lang_cluster": "C", "tags": ["math", "binary search", "combinatorics"], "code_uid": "d96fe96325ae3ad0a8f2e130482d8904", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\nint main()\n{\n int n,m,k,i,j,la;\nscanf(\"%d%d%d\",&n,&m,&k);\n if(2*k>m-1||2*k>n-1)\n {printf(\"0\");return 0;}\nint64_t ans=0;\n if(n>m)\n la=n;\nelse\nla=m;\n\n int64_t mat[la+1][la+1];\n \n for(i=0;i<=la;i++)\n for(j=0;j<=la;j++)\n mat[i][j]=0;\n \n for(i=1;i<=la;i++)\n mat[i][i]=1;\n\n for(i=1;i<=la;i++)\n mat[i][1]=i;\n\n for(i=2;i<=la;i++)\n for(j=2;j\n\nlong long dp[1001][500];\nint mod = 1000000007;\n\nint dfs(int n, int k)\n{\n int i;\n\n if (dp[n][k] >= 0) return dp[n][k];\n\n if (k == 1) {\n\treturn dp[n][k] = (n - 2) * (n - 1) / 2;\n }\n\n dp[n][k] = 0;\n\n for (i = k * 2 - 1; i <= n - 2; i++) {\n\tdp[n][k] = (dp[n][k] + (long long)dfs(i, k - 1) * (n - i - 1)) % mod;\n }\n\n return dp[n][k];\n}\n\nint main()\n{\n int n, m, k, i, j;\n\n scanf(\"%d %d %d\", &n, &m, &k);\n\n if (k * 2 >= n || k * 2 >= m) {\n\tputs(\"0\");\n\n\treturn 0;\n }\n\n for (i = 0; i <= 1000; i++) {\n\tfor (j = 0; j <= k; j++) {\n\t dp[i][j] = -1;\n\t}\n }\n\n printf(\"%d\\n\", (int)((long long)dfs(n, k) * dfs(m, k) % mod));\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "aadcf71a2ee667a934ab5c336d33b388", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\n\tint vp, vd, t, f, c;\n\tscanf(\"%d%d%d%d%d\", &vp, &vd, &t, &f, &c);\n\n\tif (vp > vd) {\n\t\tputs(\"0\");\n\t\treturn 0;\n\t}\n\n\tdouble tt = t;\n\tint cc = 0;\n\twhile (1) {\n\t\tdouble t = vp*tt / (vd - vp);\n\n\t\tif (!(vd*t + 1e-9 < c))\n\t\t\tbreak;\n\n\t\tcc++;\n\t\ttt += 2*t + f;\n\n\t}\n\n\tprintf(\"%d\\n\", cc);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "1248a5c0ab1f92933b017e172a681f22", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/148/submission/19734187 (Dukkha) */\n#include \n\nint main() {\n\tint vp, vd, t, f, c, v, ans;\n\tdouble x;\n\n\tscanf(\"%d%d%d%d%d\", &vp, &vd, &t, &f, &c);\n\tv = vd - vp;\n\tif (v <= 0) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tx = t * vp;\n\tans = 0;\n\twhile (x + x / v * vp < c) {\n\t\tans++;\n\t\tx += (x / v * 2 + f) * vp;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "457428e59eaf8f5e412c9cfd40b6aea3", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t100\n#define C\t26\n#define INF\t1000000000000LL\n\nint main() {\n\tstatic long long dp[N + 1][N + 1];\n\tstatic int next[N][C];\n\tstatic char cc[N + 1];\n\tint n, h, i, j, c;\n\tlong long k, x, ans;\n\n\tscanf(\"%d%lld\", &n, &k);\n\tscanf(\"%s\", cc);\n\tfor (i = n - 1; i >= 0; i--)\n\t\tfor (c = 0; c < C; c++)\n\t\t\tnext[i][c] = cc[i] == c + 'a' ? i + 1 : i + 1 == n ? -1 : next[i + 1][c];\n\tdp[0][0] = 1;\n\tfor (h = 0; h < n; h++)\n\t\tfor (i = 0; i < n; i++)\n\t\t\tif ((x = dp[h][i]))\n\t\t\t\tfor (c = 0; c < C; c++)\n\t\t\t\t\tif ((j = next[i][c]) != -1 && (dp[h + 1][j] += x) > INF)\n\t\t\t\t\t\tdp[h + 1][j] = INF;\n\tans = 0;\n\tfor (h = n; h >= 0; h--)\n\t\tfor (i = 0; i <= n; i++) {\n\t\t\tx = dp[h][i];\n\t\t\tif (k > x) {\n\t\t\t\tans += x * (n - h);\n\t\t\t\tk -= x;\n\t\t\t} else {\n\t\t\t\tans += k * (n - h);\n\t\t\t\tk = 0;\n\t\t\t\tprintf(\"%lld\\n\", ans);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\tprintf(\"-1\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "dp"], "code_uid": "01bc7113e42faee5ba8ccde25e2e883e", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.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;\nu64 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 %lld\", &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": ["strings", "dp"], "code_uid": "dd778b34b0282e60a3bc93b00f7ddc15", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "//489nastyastudiesinformatics\n#include\ntypedef long long ll;\nvoid swap(ll *a,ll *b)\n{\n *a^=*b;\n *b^=*a;\n *a^=*b;\n}\nll gcd(ll a, ll b)\n{\n while(b)\n {\n a %= b;\n swap(&a,&b);\n }\n return a;\n}\nint main()\n{\n ll l,r,x,y;\n scanf(\"%lld %lld %lld %lld\",&l,&r,&x,&y);\n if(y%x)\n {\n printf(\"0\\n\");\n return 0;\n }\n y=y/x;\n ll i,c;\n for( i=1,c=0 ;i*i<=y;i++)\n if(y%i==0 && x*i>=l && (x*y)/i<=r && gcd(i,y/i)==1)\n //or gcd(x*i,x*(y/i))==x,then lcm will also be y(a*b=x*y)\n c += 1 + (y!=1);\n printf(\"%lld\\n\",c);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "fce0e1c7b11c6227cf19563038c45ad6", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint gc,lm;\nint check(int a, int b) // checking gcd lcm\n{\n int r,min,max;\n if (a>=b) {max=a; min=b;}\n else {max=b; min=a;}\n while (1)\n {\n r=max%min;\n if (r==0) break;\n max=min;\n min=r;\n }\n r=(a/min)*b;\n if (gc==min && lm==r) return 1;\n else return 0;\n}\nint main()\n{\n int h,l,i,j,k=0,r,count=0;\n int ar[40000];\n scanf(\"%d %d %d %d\",&l,&h,&gc,&lm);\n for (i=1; i*i<=lm; i++)\n {\n if (i>h) break;\n if (lm%i==0)\n {\n r=lm/i;\n if (r==i)\n {\n if (r>=l && r<=h)\n ar[++k]=r;\n }\n else\n {\n if (r>=l && r<=h) ar[++k]=r;\n if (r>=l && i<=h) ar[++k]=i;\n }\n }\n }\n for (i=1; i<=k; i++)\n {\n for (j=i; j<=k; j++)\n {\n r=check(ar[i],ar[j]);\n if (r)\n {\n if (ar[i]==ar[j]) count++;\n else count+=2;\n }\n }\n }\n printf(\"%d\\n\",count);\n\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "c84319546a666d0e61a063cd023e0226", "src_uid": "d37dde5841116352c9b37538631d0b15", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(){\n int a, b, k = 0, n, x, y, max = 0;\n scanf(\"%d %d\", &x, &y);\n n = x;\n while(n > 0){\n max = (max > n % 10) ? max : n % 10;\n n /= 10;\n }\n n = y;\n while(n > 0){\n max = (max > n % 10) ? max : n % 10;\n n /= 10;\n }\n max++;\n n = 0;\n while((x > 0) || (y > 0)){\n a = x % 10;\n b = y % 10;\n k = (a + b + k) / max;\n n++;\n x /= 10;\n y /= 10;\n }\n if (k > 0) n++;\n printf(\"%d\", n);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "1574475c3e8f5dd55bf7646265aec4a4", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \nint main()\n{\n int a[101]={0},b[101]={0},ans[101]={0};\n int i,j,k,temp,la,lb,max;\n char t[101]={'0'};\n k=0;\n scanf(\"%s\",t);\n max=0;\n la=strlen(t);\n for (i=la;i>=1;i--)\n {\n a[la-i+1]=t[i-1]-'0';\n if (a[la-i+1]>max) max=a[la-i+1];\n }\n scanf(\"%s\",t);\n lb=strlen(t);\n for (i=lb;i>=1;i--)\n {\n b[lb-i+1]=t[i-1]-'0';\n if (b[lb-i+1]>max) max=b[lb-i+1];\n }\n max++;\n if (la>lb) k=la;\n else k=lb;\n temp=0;\n for (i=1;i<=k;i++)\n {\n ans[i]=a[i]+b[i]+temp;\n temp=ans[i] / max;\n ans[i]=ans[i] % max;\n }\n if (temp!=0) {k++; ans[k]=temp;}\n printf(\"%d\",k);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "0ce3368a6d38e154629f505b36f17209", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint par[2000];\n\nint find(int x)\n{\n if (par[x] == x) return x;\n\n return par[x] = find(par[x]);\n}\n\nvoid unite(int x, int y)\n{\n x = find(x);\n y = find(y);\n\n if (x == y) return;\n\n par[x] = y;\n}\n\nint same(int x, int y)\n{\n x = find(x);\n y = find(y);\n\n if (x == y) {\n\treturn 1;\n } else {\n\treturn 0;\n }\n}\n\nint main()\n{\n int n, m, k, mod = 1000000007, i, j;\n long long ans = 1;\n int a[2000] = {0};\n\n scanf(\"%d %d %d\", &n, &m, &k);\n\n for (i = 0; i < n; i++) par[i] = i;\n\n for (i = 0; i <= n - k; i++) {\n\t for (j = 0; j <= k / 2; j++) {\n\t unite(i + j, i + k - j - 1);\n\t }\n }\n\n for (i = 0; i < n; i++) a[find(i)]++;\n\n for (i = 0; i < n; i++) {\n\t if (a[i] > 0) {\n\t ans = ans * m % mod;\n\t }\n }\n\n printf(\"%d\\n\", (int)ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "combinatorics", "graphs"], "code_uid": "fec49afb979464213ae754a65126180a", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint n;\nchar g[2000][2000], b[2000];\n\nvoid dfs(int u) {\n\tint v;\n\n\tb[u] = 1;\n\tfor (v = 0; v < n; v++)\n\t\tif (g[u][v] && !b[v])\n\t\t\tdfs(v);\n}\n\nint main() {\n\tint m, k;\n\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\n\tmemset(g, 0, sizeof(g));\n\n\tint i;\n\tfor (i = 0; i + k <= n; i++) {\n\t\tint l = i, r = i+k-1;\n\t\twhile (l <= r) {\n\t\t\tg[l][r] = g[r][l] = 1;\n\t\t\tl++; r--;\n\t\t}\n\t}\n\n\t/* int j;\n\tfor (i = 0; i < n; i++) {\n\t\tfor (j = 0; j < n; j++)\n\t\t\tprintf(\"%d\", g[i][j]);\n\t\tputs(\"\");\n\t} */\n\n\tint cc = 0;\n\tmemset(b, 0, sizeof(b));\n\tfor (i = 0; i < n; i++)\n\t\tif (!b[i]) {\n\t\t\tdfs(i);\n\t\t\tcc++;\n\t\t}\n\n\t// printf(\"cc = %d\\n\", cc);\n\n\tint c = 1;\n\tfor (i = 0; i < cc; i++)\n\t\tc = (1LL *c * m) % 1000000007;\n\n\tprintf(\"%d\\n\", c);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "math", "combinatorics", "graphs"], "code_uid": "accdae8b3d2ce9ae95cf81f71138f1ef", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main(void) {\n int r, x1, y1, x2, y2, i;\n long long d2;\n scanf(\"%d %d %d %d %d\", &r, &x1, &y1, &x2, &y2);\n d2 = (long long)abs(x1 - x2) * abs(x1 - x2) + (long long)abs(y1 -y2) * abs(y1 - y2);\n for (i = 0; (long long)2*2*r*r*i*i < d2; ++i);\n printf(\"%d\\n\", i);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "8229c7c676f267272c31dddc474c80a6", "src_uid": "698da80c7d24252b57cca4e4f0ca7031", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n double r,x1,y1,x2,y2,ans,tot,d,l,h,m;\n int ansf;\n scanf(\"%lf %lf %lf %lf %lf\",&r,&x1,&y1,&x2,&y2);\n tot=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\n l=0;\n h=tot;\n m=(h+l)/2;\n while(1)\n {\n m=(h+l)/2;\n if(m*m>tot)\n {\n if(m*m-tot<0.00000001)\n break;\n else\n h=m;\n }\n else if(m*m\n#include\nint main()\n{\n\tlong long int num,coins=0,a=3;\n\tscanf (\"%lli\",&num);\n\twhile ((num%a)==0)\n\t{\n\t\ta=a*3;\n\t}\n\tcoins=(num/a)+1;\n\tprintf (\"%lli\",coins);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "7745a6f2db5b7e196c3851b6b2398743", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint long long p;\n\tscanf(\"%lld\",&p);\n\twhile(p%3==0)\n\tp/=3;\n\n\tprintf(\"%lld\",(p/3)+1);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "4b7119f3752b076fb90dc6792038ff0c", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nlong long int a[10000];\nint k =0;\nlong long int fastexp(int x,int y)\n{\n\tlong long int ans = 1;\n\twhile(y!=0)\n\t{\n\t\tint r = y&1;\n\t\tif(r==1)\n\t\t\tans = ans*x;\n\t\tx = x*x;\n\t\ty = y>>1;\n\t}\n\treturn ans;\n}\nvoid calc(long long int sum,int d)\n{\n\tif(d==-1 && sum!=0)\n\t{\n\t\ta[k] = sum;\n\t\tk++;\n\t\treturn;\n\t}\n\telse if(sum==0 && d==-1)\n\t\treturn;\n\tlong long int p = fastexp(10,d);\n\tif(sum==0)\n\tcalc(sum + 0*p,d-1);\n\tcalc(sum + 4*p,d-1);\n\tcalc(sum + 7*p,d-1);\n}\n\nint main(void)\n{\n\tcalc(0,9);\n\tlong long int l;\n\tlong long int r;\n\tscanf(\"%lld %lld\",&l,&r);\n\tint counter = 0;\n\tlong long int ans = 0;\n\twhile(l<=r)\n\t{\n\t\tif(a[counter]<=r)\n\t\t{\t\n\t\t\tif(l<=a[counter])\n\t\t\t{\n\t\t\t\tans = ans + (a[counter]-l+1)*a[counter];\n\t\t\t\tl = a[counter]+1;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(l==r)\n\t\t\t\tans = ans + a[counter];\n\t\t\telse if(l<=a[counter-1])\n\t\t\t\tans = ans + (r-a[counter-1])*a[counter];\n\t\t\telse\n\t\t\t{\n\t\t\t\tans = ans + (r-l+1)*a[counter];\n\t\t\t}\n\t\t\tl = r +1;\n\t\t}\n\t\tcounter++;\n\t}\n\tprintf(\"%lld\\n\",ans);\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "32f49120c7e901b75f4f3185e57ed571", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\n__int64 k[]={4,7,44,47,74,77,444,447,474,477,744,747,774,777,4444,4447,4474,4477,4744,4747,4774,4777,7444,7447,7474,7477,7744,7747,7774,7777,44444,44447,44474,44477,44744,44747,44774,44777,47444,47447,47474,47477,47744,47747,47774,47777,74444,74447,74474,74477,74744,74747,74774,74777,77444,77447,77474,77477,77744,77747,77774,77777,444444,444447,444474,444477,444744,444747,444774,444777,447444,447447,447474,447477,447744,447747,447774,447777,474444,474447,474474,474477,474744,474747,474774,474777,477444,477447,477474,477477,477744,477747,477774,477777,744444,744447,744474,744477,744744,744747,744774,744777,747444,747447,747474,747477,747744,747747,747774,747777,774444,774447,774474,774477,774744,774747,774774,774777,777444,777447,777474,777477,777744,777747,777774,777777,4444444,4444447,4444474,4444477,4444744,4444747,4444774,4444777,4447444,4447447,4447474,4447477,4447744,4447747,4447774,4447777,4474444,4474447,4474474,4474477,4474744,4474747,4474774,4474777,4477444,4477447,4477474,4477477,4477744,4477747,4477774,4477777,4744444,4744447,4744474,4744477,4744744,4744747,4744774,4744777,4747444,4747447,4747474,4747477,4747744,4747747,4747774,4747777,4774444,4774447,4774474,4774477,4774744,4774747,4774774,4774777,4777444,4777447,4777474,4777477,4777744,4777747,4777774,4777777,7444444,7444447,7444474,7444477,7444744,7444747,7444774,7444777,7447444,7447447,7447474,7447477,7447744,7447747,7447774,7447777,7474444,7474447,7474474,7474477,7474744,7474747,7474774,7474777,7477444,7477447,7477474,7477477,7477744,7477747,7477774,7477777,7744444,7744447,7744474,7744477,7744744,7744747,7744774,7744777,7747444,7747447,7747474,7747477,7747744,7747747,7747774,7747777,7774444,7774447,7774474,7774477,7774744,7774747,7774774,7774777,7777444,7777447,7777474,7777477,7777744,7777747,7777774,7777777,44444444,44444447,44444474,44444477,44444744,44444747,44444774,44444777,44447444,44447447,44447474,44447477,44447744,44447747,44447774,44447777,44474444,44474447,44474474,44474477,44474744,44474747,44474774,44474777,44477444,44477447,44477474,44477477,44477744,44477747,44477774,44477777,44744444,44744447,44744474,44744477,44744744,44744747,44744774,44744777,44747444,44747447,44747474,44747477,44747744,44747747,44747774,44747777,44774444,44774447,44774474,44774477,44774744,44774747,44774774,44774777,44777444,44777447,44777474,44777477,44777744,44777747,44777774,44777777,47444444,47444447,47444474,47444477,47444744,47444747,47444774,47444777,47447444,47447447,47447474,47447477,47447744,47447747,47447774,47447777,47474444,47474447,47474474,47474477,47474744,47474747,47474774,47474777,47477444,47477447,47477474,47477477,47477744,47477747,47477774,47477777,47744444,47744447,47744474,47744477,47744744,47744747,47744774,47744777,47747444,47747447,47747474,47747477,47747744,47747747,47747774,47747777,47774444,47774447,47774474,47774477,47774744,47774747,47774774,47774777,47777444,47777447,47777474,47777477,47777744,47777747,47777774,47777777,74444444,74444447,74444474,74444477,74444744,74444747,74444774,74444777,74447444,74447447,74447474,74447477,74447744,74447747,74447774,74447777,74474444,74474447,74474474,74474477,74474744,74474747,74474774,74474777,74477444,74477447,74477474,74477477,74477744,74477747,74477774,74477777,74744444,74744447,74744474,74744477,74744744,74744747,74744774,74744777,74747444,74747447,74747474,74747477,74747744,74747747,74747774,74747777,74774444,74774447,74774474,74774477,74774744,74774747,74774774,74774777,74777444,74777447,74777474,74777477,74777744,74777747,74777774,74777777,77444444,77444447,77444474,77444477,77444744,77444747,77444774,77444777,77447444,77447447,77447474,77447477,77447744,77447747,77447774,77447777,77474444,77474447,77474474,77474477,77474744,77474747,77474774,77474777,77477444,77477447,77477474,77477477,77477744,77477747,77477774,77477777,77744444,77744447,77744474,77744477,77744744,77744747,77744774,77744777,77747444,77747447,77747474,77747477,77747744,77747747,77747774,77747777,77774444,77774447,77774474,77774477,77774744,77774747,77774774,77774777,77777444,77777447,77777474,77777477,77777744,77777747,77777774,77777777,444444444,444444447,444444474,444444477,444444744,444444747,444444774,444444777,444447444,444447447,444447474,444447477,444447744,444447747,444447774,444447777,444474444,444474447,444474474,444474477,444474744,444474747,444474774,444474777,444477444,444477447,444477474,444477477,444477744,444477747,444477774,444477777,444744444,444744447,444744474,444744477,444744744,444744747,444744774,444744777,444747444,444747447,444747474,444747477,444747744,444747747,444747774,444747777,444774444,444774447,444774474,444774477,444774744,444774747,444774774,444774777,444777444,444777447,444777474,444777477,444777744,444777747,444777774,444777777,447444444,447444447,447444474,447444477,447444744,447444747,447444774,447444777,447447444,447447447,447447474,447447477,447447744,447447747,447447774,447447777,447474444,447474447,447474474,447474477,447474744,447474747,447474774,447474777,447477444,447477447,447477474,447477477,447477744,447477747,447477774,447477777,447744444,447744447,447744474,447744477,447744744,447744747,447744774,447744777,447747444,447747447,447747474,447747477,447747744,447747747,447747774,447747777,447774444,447774447,447774474,447774477,447774744,447774747,447774774,447774777,447777444,447777447,447777474,447777477,447777744,447777747,447777774,447777777,474444444,474444447,474444474,474444477,474444744,474444747,474444774,474444777,474447444,474447447,474447474,474447477,474447744,474447747,474447774,474447777,474474444,474474447,474474474,474474477,474474744,474474747,474474774,474474777,474477444,474477447,474477474,474477477,474477744,474477747,474477774,474477777,474744444,474744447,474744474,474744477,474744744,474744747,474744774,474744777,474747444,474747447,474747474,474747477,474747744,474747747,474747774,474747777,474774444,474774447,474774474,474774477,474774744,474774747,474774774,474774777,474777444,474777447,474777474,474777477,474777744,474777747,474777774,474777777,477444444,477444447,477444474,477444477,477444744,477444747,477444774,477444777,477447444,477447447,477447474,477447477,477447744,477447747,477447774,477447777,477474444,477474447,477474474,477474477,477474744,477474747,477474774,477474777,477477444,477477447,477477474,477477477,477477744,477477747,477477774,477477777,477744444,477744447,477744474,477744477,477744744,477744747,477744774,477744777,477747444,477747447,477747474,477747477,477747744,477747747,477747774,477747777,477774444,477774447,477774474,477774477,477774744,477774747,477774774,477774777,477777444,477777447,477777474,477777477,477777744,477777747,477777774,477777777,744444444,744444447,744444474,744444477,744444744,744444747,744444774,744444777,744447444,744447447,744447474,744447477,744447744,744447747,744447774,744447777,744474444,744474447,744474474,744474477,744474744,744474747,744474774,744474777,744477444,744477447,744477474,744477477,744477744,744477747,744477774,744477777,744744444,744744447,744744474,744744477,744744744,744744747,744744774,744744777,744747444,744747447,744747474,744747477,744747744,744747747,744747774,744747777,744774444,744774447,744774474,744774477,744774744,744774747,744774774,744774777,744777444,744777447,744777474,744777477,744777744,744777747,744777774,744777777,747444444,747444447,747444474,747444477,747444744,747444747,747444774,747444777,747447444,747447447,747447474,747447477,747447744,747447747,747447774,747447777,747474444,747474447,747474474,747474477,747474744,747474747,747474774,747474777,747477444,747477447,747477474,747477477,747477744,747477747,747477774,747477777,747744444,747744447,747744474,747744477,747744744,747744747,747744774,747744777,747747444,747747447,747747474,747747477,747747744,747747747,747747774,747747777,747774444,747774447,747774474,747774477,747774744,747774747,747774774,747774777,747777444,747777447,747777474,747777477,747777744,747777747,747777774,747777777,774444444,774444447,774444474,774444477,774444744,774444747,774444774,774444777,774447444,774447447,774447474,774447477,774447744,774447747,774447774,774447777,774474444,774474447,774474474,774474477,774474744,774474747,774474774,774474777,774477444,774477447,774477474,774477477,774477744,774477747,774477774,774477777,774744444,774744447,774744474,774744477,774744744,774744747,774744774,774744777,774747444,774747447,774747474,774747477,774747744,774747747,774747774,774747777,774774444,774774447,774774474,774774477,774774744,774774747,774774774,774774777,774777444,774777447,774777474,774777477,774777744,774777747,774777774,774777777,777444444,777444447,777444474,777444477,777444744,777444747,777444774,777444777,777447444,777447447,777447474,777447477,777447744,777447747,777447774,777447777,777474444,777474447,777474474,777474477,777474744,777474747,777474774,777474777,777477444,777477447,777477474,777477477,777477744,777477747,777477774,777477777,777744444,777744447,777744474,777744477,777744744,777744747,777744774,777744777,777747444,777747447,777747474,777747477,777747744,777747747,777747774,777747777,777774444,777774447,777774474,777774477,777774744,777774747,777774774,777774777,777777444,777777447,777777474,777777477,777777744,777777747,777777774,777777777,4444444444,0};\n\n\nint main(void){\n __int64 i,x,y,sum,j;\n scanf(\"%I64d %I64d\",&x,&y);\n sum=0;\n for(j=0;k[j]!=0;j++){\n if(k[j]>=x)\n break;\n }\n for(i=x;i<=y;i++){\n if(k[j]>=y){\n sum=sum+k[j]*(y-i+1);\n break;\n }\n if(k[j]>=i){\n sum=sum+k[j]*(k[j]-i+1);\n i=k[j];\n j++;\n }\n }\n printf(\"%I64d\\n\",sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "aad62915f64613c9ccfd63a825b01a87", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint a[200]={47,74,4477,4747,4774,7447,7474,7744,444777,447477,447747,447774,474477,474747,474774,477447,477474,477744,744477,744747,744774,747447,747474,747744,774447,774474,774744,777444,44447777,44474777,44477477,44477747,44477774,44744777,44747477,44747747,44747774,44774477,44774747,44774774,44777447,44777474,44777744,47444777,47447477,47447747,47447774,47474477,47474747,47474774,47477447,47477474,47477744,47744477,47744747,47744774,47747447,47747474,47747744,47774447,47774474,47774744,47777444,74444777,74447477,74447747,74447774,74474477,74474747,74474774,74477447,74477474,74477744,74744477,74744747,74744774,74747447,74747474,74747744,74774447,74774474,74774744,74777444,77444477,77444747,77444774,77447447,77447474,77447744,77474447,77474474,77474744,77477444,77744447,77744474,77744744,77747444,77774444};\nint main(void)\n{\n\tint n,i;\n\twhile(scanf(\"%d\",&n)!=EOF)\t{\n\t\t\n\tif(n>77774444) printf(\"4444477777\\n\");\n\telse if(n<=47) printf(\"47\\n\");\n\telse\n\t{\n\t\tfor(i=0;i<150;i++)\n\t\t{\n\t\t\tif(a[i]=n)\n\t\t\t{\n\t\t\t\tprintf(\"%d\\n\",a[i+1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "51429fc711b30fc49f0c92426315d453", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint num;\n\nint count(int k)\n{\n int temp=num, c=0;\n while(temp)\n {\n if(temp%10==k)\n c++;\n temp/=10;\n }\n return c;\n}\n\nint main()\n{\n int f=0, s=0, i;\n int a[200]={47,74,4477,4747,4774,7447,7474,7744,444777,447477,447747,447774,474477,474747,474774,477447,477474,477744,744477,744747,744774,747447,747474,747744,774447,774474,774744,777444,44447777,44474777,44477477,44477747,44477774,44744777,44747477,44747747,44747774,44774477,44774747,44774774,44777447,44777474,44777744,47444777,47447477,47447747,47447774,47474477,47474747,47474774,47477447,47477474,47477744,47744477,47744747,47744774,47747447,47747474,47747744,47774447,47774474,47774744,47777444,74444777,74447477,74447747,74447774,74474477,74474747,74474774,74477447,74477474,74477744,74744477,74744747,74744774,74747447,74747474,74747744,74774447,74774474,74774744,74777444,77444477,77444747,77444774,77447447,77447474,77447744,77474447,77474474,77474744,77477444,77744447,77744474,77744744,77747444,77774444};\n scanf(\"%d\", &num);\n if(num<=47)\n printf(\"47\");\n else if(num>77774444)\n printf(\"4444477777\");\n else\n for(i=0; i<150; i++)\n if(a[i]=num)\n {\n printf(\"%d\", a[i+1]);\n break;\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "binary search", "bitmasks"], "code_uid": "418d9e9c4a5660b4e4d8dfafaea6911c", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n long long n;\n scanf(\"%lld\", &n);\n printf(\"%lld\\n\", (9*n-3)<<(2*n-6));\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "6685782558ae69197a777e0731db6118", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.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;\nlong long dp[205][205][5][2];\nbool visited[205][205][5][2];\n\nlong long F(int i, int c, int l, int flag){\n if (c > n) return 0;\n if (c == n) flag = 1;\n if (i == m) return flag;\n if (visited[i][c][l][flag]) return dp[i][c][l][flag];\n\n int j;\n long long res = 0;\n for (j = 0; j < 4; j++){\n if (j == l) res += F(i + 1, c + 1, l, flag);\n else res += F(i + 1, 1, j, flag);\n }\n\n visited[i][c][l][flag] = true;\n return (dp[i][c][l][flag] = res);\n}\n\nint main(){\n while (scanf(\"%d\", &n) != EOF){\n clr(visited);\n m = (n << 1) - 2;\n long long res = F(0, 0, 4, 0);\n printf(\"%lld\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "27dd4e8bd51f19c92dfe7e2e571113a9", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nlong long int gcd(long long int a,long long int b)\n{\n if(b==0)\n return a;\n return gcd(b,a%b);\n}\nint main(void) {\n long long int t,a,b,temp,l,g,ans=0;\n scanf(\"%lld %lld %lld\",&t,&a,&b);\n if(a==b)\n {\n printf(\"1/1\");\n return 0;\n }\n if(b>a)\n {\n temp=a;\n a=b;\n b=temp;\n }\n g = gcd(a,b);\n if(b/g>t/a)\n {\n if(b-1>t)\n ans=t;\n else\n ans=b-1;\n g=gcd(ans,t);\n ans=ans/g;\n t=t/g;\n printf(\"%lld/%lld\",ans,t);\n return 0;\n }\n l = (a/g)*b;\n \n ans += t/l;\n \n ans += (t/l)*(b-1);\n //printf(\"%lld \",ans);\n if(t%l\ntypedef long long ll;\nll gcd(ll x,ll y)\n{\n if(x%y==0)\n return y;\n return gcd(y,x%y);\n}\nll max(ll x,ll y)\n{\n return x>y?x:y;\n}\nll min(ll x,ll y)\n{\n return x=y)\n {\n b=gcd(t,y-1);\n printf(\"%lld/%lld\",(y-1)/b,t/b);\n }\n else\n printf(\"1/1\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "41dae04a9f5f612af18fb4b67d4335b2", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint dd,mm,yy,arr[]={0,31,29,31,30,31,30,31,31,30,31,30,31};\nint yer(int d,int m,int y){\n if(m>12)\n return 0;\n if(d>arr[m])\n return 0;\n if(d==29&&m==2&&y%4!=0)return 0;\n if(18*365+d+m*30+y*365<=dd+mm*30+yy*365){\n printf(\"YES\\n\");\n return 1;}\n return 0;\n}\nint main (){\n int d,m,y;\n scanf(\"%d.%d.%d\",&dd,&mm,&yy);\n\t scanf(\"%d.%d.%d\",&d,&m,&y);\n if(yer(d,m,y))\n return 0;\n if(yer(d,y,m))\n return 0;\n if(yer(y,d,m))\n return 0;\n if(yer(y,m,d))\n return 0;\n if(yer(m,y,d))\n return 0;\n if(yer(m,d,y))\n return 0;\n printf(\"NO\\n\");\n}\n\n\n\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5154ab4eec7a856a8a4bd015f97362e1", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint a[2][3];\n\nint f,l[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};\n\nint check(int d,int m,int y) {\n\tif (a[1][m]>12) return 0;\n\tif (a[1][d]>l[a[1][m]]+!(a[1][y]%4)) return 0;\n\tif (f<366*a[1][y]+31*a[1][m]+a[1][d]) return 0;\n\treturn 1;\n}\n\nint main() {\n\tint i,j,k;\n\tfor (i=0;i<2;i++)\n\t\tscanf(\"%d.%d.%d\",&a[i][0],&a[i][1],&a[i][2]);\n\tint y=0;\n\tif (a[0][2]>18) {\n\t\tf=366*(a[0][2]-18)+31*a[0][1]+a[0][0];\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\tfor (k=0;k<3;k++)\n\t\t\t\t\t\tif (k!=i&&k!=j)\n\t\t\t\t\t\t\tif (check(i,j,k)) y=1;\n\t}\n\tprintf(\"%s\\n\",y?\"YES\":\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3d4c0718b1c680b4762e53cc2baaf6a5", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint sum(long long x)\n{\n int sum = 0;\n while(x > 0)\n {\n sum += x%10;\n x /= 10;\n }\n return sum;\n}\n\nint main()\n{\n long long x; scanf(\"%lld\", &x);\n long long powten = 10, tmp, max = x;\n int maxsum = sum(x);\n while(x >= powten)\n {\n tmp = x - x%powten - 1;\n int tmpsum = sum(tmp);\n if(tmpsum > maxsum)\n {\n maxsum = tmpsum;\n max = tmp;\n }\n powten *= 10;\n }\n printf(\"%lld\\n\", max);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "f2c1ca62d6285d2d30f4fa3ec9fab020", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int x,k,i,j,n,l,num,sum,sumc,flag=0,a[21],b[21],ans[21];\n scanf(\"%lld\",&x);\n n=x;\n i=0;\n sum=0;\n while(n>0)\n {\n a[i]=n%10;\n ans[i]=a[i];\n n=n/10;\n sum=sum+a[i];\n i++;\n }\n for(j=i-1;j>=0;j--)\n {\n sumc=0;\n for(k=i-1;k>=0;k--)\n {\n if(k>j)\n {\n b[k]=a[k];\n }\n else if(k==j)\n {\n b[k]=a[k]-1;\n }\n else\n {\n b[k]=9;\n }\n sumc=sumc+b[k];\n }\n if((flag==0 && sumc>sum)|| (flag==1 && sumc>=sum))\n {\n sum=sumc;\n for(k=i-1;k>=0;k--)\n ans[k]=b[k];\n flag=1;\n }\n }\n for(j=i-1;j>=0;j--)\n {\n if((j==i-1 && ans[j]!=0)||j\nint main()\n{\n long long int i, div, ndiv;\n scanf(\"%lld\", &i);\n div = i/2;\n div += i/3 - i/3/2;\n div += i/5 - i/5/2 - (i/5/3 - i/5/3/2);\n div += i/7 - i/7/2 - (i/7/3 - i/7/3/2) - (i/7/5 - i/7/5/2 - (i/7/5/3 - i/7/5/3/2)) ;\n\n ndiv = i - div;\n\n printf(\"%lld\", ndiv);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "cbfed1868d5664bcbf5d145a5167b38a", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main(){\n\tlong long n;\n\tscanf(\"%lld\",&n);\n\tprintf(\"%lld\\n\",n-(n/2+n/3-n/6+n/5-n/10-n/15+n/30+n/7-n/14-n/21-n/35+n/42+n/70+n/105-n/210));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "a49edaaccb016aa71e4af36f6008b8d7", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef long long int ll;\nvoid print(int *a,int n)\n{\n\tint i;\n\tfor(i=0;i0 && v[a2]>0)\n\t{\n\t\tif(u[a1]==v[a2])\n\t\t{\n\t\t\tprintf(\"%d\\n\",u[a1]-1);\n\t\t\treturn 0;\n\t\t}\n\t\tif((u[a1]>=u[st]) && (v[a2]>=u[a1] && (v[a2]-u[a1])%u[l]==0)){\n\t\t\tprintf(\"%d\\n\",v[a2]-1);\n\t\t\treturn 0;\t}\n\t\telse if(v[a2]>=v[st] && (u[a1]>=v[a2] && (u[a1]-v[a2])%v[l]==0)){\n\t\t\tprintf(\"%d\\n\",u[a1]-1);\t\n\t\t\treturn 0;\n\t\t}\n\t\telse if((u[a1]>=u[st] && v[a2]>=v[st]))\n\t\t{\n\t\t\tt1=gcd(u[l],v[l]);\n\t\t\tt2=u[a1]-v[a2];\n\t\t\tif(t2<0)\n\t\t\t\tt2=-t2;\n\t\t\tif(t2%t1!=0)\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\ta=u[a1]-1;\n\t\t\tb=v[a2]-1;\n\t\t\twhile(a!=b)\n\t\t\t{\n\t\t\t\tif(a\n#include \n#include \n#include \n#include \n\ntypedef long long LONG;\n\nint main(){\n LONG m = 1;\n LONG h1 = 0; LONG a1 = 0;\n LONG x1 = 0; LONG y1 = 0;\n LONG h2 = 0; LONG a2 = 0;\n LONG x2 = 0; LONG y2 = 0;\n scanf(\"%lld\", &m);\n scanf(\"%lld %lld\", &h1, &a1);\n scanf(\"%lld %lld\", &x1, &y1);\n scanf(\"%lld %lld\", &h2, &a2);\n scanf(\"%lld %lld\", &x2, &y2);\n /*\n int s = 0;\n int m2 = m * m\n while (s < m2) {\n if (h1 == a1 && h2 == a2) {\n printf(\"%d\", s);\n return 0;\n }\n h1 = (x1 * h1 + y1) % m;\n h2 = (x2 * h2 + y2) % m;\n s++;\n }\n */\n\n LONG s1 = 0;\n while (s1 < m && h1 != a1) {\n h1 = (x1 * h1 + y1) % m;\n s1++;\n //printf(\"%d %d\\n\",s1,h1);\n }\n if (s1 == m) {\n printf(\"-1\");\n return 0;\n }\n\n LONG c1 = 0;\n while (c1 == 0 || (c1 <= m && h1 != a1)) {\n h1 = (x1 * h1 + y1) % m;\n c1++;\n //printf(\"%d %d\\n\",c1,h1);\n }\n\n LONG s2 = 0;\n while (s2 < m && h2 != a2) {\n h2 = (x2 * h2 + y2) % m;\n s2++;\n //printf(\"%d %d\\n\",s2,h2);\n }\n if (s2 == m) {\n printf(\"-1\");\n return 0;\n }\n\n LONG c2 = 0;\n while (c2 == 0 || (c2 <= m && h2 != a2)) {\n h2 = (x2 * h2 + y2) % m;\n c2++;\n //printf(\"%d %d\\n\",c2,h2);\n }\n\n /*\n printf(\"%d\\n\",s1);\n printf(\"%d\\n\",c1);\n printf(\"%d\\n\",s2);\n printf(\"%d\\n\",c2);\n */\n if (c1 != m+1 && c2 != m+1) {\n LONG limit = c1 * c2 + s1 + s2;\n while (s1 < limit && s2 < limit) {\n if (s1 == s2) {\n printf(\"%lld\", s1);\n return 0;\n }\n else if (s1 < s2) {\n s1 += c1;\n }\n else {\n s2 += c2;\n }\n }\n }\n else if (c1 != m+1 && c2 == m+1) {\n while (s1 < s2)\n s1 += c1;\n if (s1 == s2) {\n printf(\"%lld\", s1);\n return 0;\n }\n else {\n printf(\"-1\");\n return 0;\n }\n }\n else if (c1 == m+1 && c2 != m+1) {\n while (s2 < s1)\n s2 += c2;\n if (s1 == s2) {\n printf(\"%lld\", s1);\n return 0;\n }\n else {\n printf(\"-1\");\n return 0;\n }\n }\n else if (c1 == m+1 && c2 == m+1) {\n if (s1 == s2) {\n printf(\"%lld\", s1);\n return 0;\n }\n else {\n printf(\"-1\");\n return 0;\n }\n }\n\n printf(\"-1\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "356c4225d0bbc36c47b8f641098490b4", "src_uid": "7225266f663699ff7e16b726cadfe9ee", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n int i,j,n,a=0,count=0;\n\tscanf(\"%d\",&n);\n\tfor(i=0;ia)\n {\n a=count;\n }\n\t\t\ta++;\n\t\t}\n\t}\n\tif(a\nint main()\n{\n int n,k,i,j,h,n0=0,n1=0;\n scanf(\"%d\",&n);\n int A[n];\n k=n;\n for(i=0;in1)\n {\n k=k-n1;\n n0=0;\n n1=0;\n i--;\n }\n else\n {\n n1++;\n }\n }\n else\n {\n n0++;\n }\n }\n if(n0>n1)\n {\n k=k-n1;\n }\n else\n {\n k=k-n0;\n }\n printf(\"%d\\n\",k);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "d1d11dc1c0198da386a40fbd20e02072", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n int a, b, m, ro, i=0, key, done=0, *hasher;\n\n scanf(\"%d %d %d %d\", &a, &b, &m, &ro);\n \n hasher = (int*)malloc(m * sizeof(int)); \n \n for(i=0;i\n#include \n\nint main(){\n\tint a,b,f,k;\n\tscanf(\"%d%d%d%d\",&a,&b,&f,&k);\n\tint s=b-f;//\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0431\u0435\u043d\u0437\u0438\u043d\u0430 \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0435\u0445\u0430\u043b\u0438 \u043a \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435\n\tint ans=0;\n\tf=a-f;//\u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0432\u0430\u0435\u043c\n\tfor(k--;k;k--)\n\t{\n\t\tif(s<0)//\u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442 \u043f\u043e\u043b\u043d\u043e\u0433\u043e \u0431\u0430\u043a\u0430 \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0435\u0445\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442 \n\t\t{\n\t\t\tprintf(\"-1\");\n\t\t\treturn 0;\n\t\t}\n\t\tif(2*f>s)//\u0435\u0441\u043b\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0435\u0445\u0430\u0442\u044c \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0434\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u043a\u0438 - \u0437\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f\n\t\t{\n\t\t\ts=b;\n\t\t\tans++;\n\t\t}\n\t\ts-=2*f;\n\t\tf=a-f;\n\t}\n\tif(s<0)\n\t{\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\tif(f>s)\n\t{\n\t\ts=b;\n\t\tans++;\n\t}\n\ts-=f;\n\tif(s<0)\n\t{\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}\n\t\n\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "8569fe12ad09d2e42adccc51a04f31db", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n\n#define max(a ,b)\t(a > b ? a : b)\n#define min(a ,b)\t(a < b ? a : b)\n#define MAX 200001\n/*\nint a[101];\nint main() {\n\tint n ,i ,x ,y;\n\tscanf(\"%d\" ,&n);\n\tfor(i = 0;i= 3){\n\t\tif(b < 2*f || b < 2*(a-f)){\tprintf(\"-1\");\treturn 0;}\n\t}\n\t\tint ans = 0 ,rem = b;\n\t\tfor(i = 0 ; i < k ; i++){\n\t\t\tif(i == k-1){\n\t\t\t\tif(i%2 == 0 && rem < f){\tprintf(\"-1\");\treturn 0;}\n\t\t\t\tif(i%2 == 1 && rem < a - f){\tprintf(\"-1\");\treturn 0;}\n\t\t\t\tif(rem < a)\tans++;\n\t\t\t}else{\n\t\t\t\tif(i % 2 == 0){\n\t\t\t\t\tif(rem < f){\n\t\t\t\t\t\tprintf(\"-1\");\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tif(rem >= 2*a - f)\trem -= a;\n\t\t\t\t\telse ans++ ,rem = b - (a - f);\n\t\t\t\t}else {\n\t\t\t\t\tif(rem < a - f){\n\t\t\t\t\t\tprintf(\"-1\");\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tif(rem >= a + f)\trem -= a;\n\t\t\t\t\telse\tans++ ,rem = b - f;\n\t\t\t\t}\n\t\t\t}\t\n\t\t//\tprintf(\"%d \" ,rem);\n\t\t}\n\t\tprintf(\"%d\" ,ans);\n\treturn 0;\n}\n\n/*\nint a[MAX] ,p[MAX] ,c[MAX];\nint main() {\n\tint n ,i;\n\tscanf(\"%d\" ,&n);\n\tmemset(p ,-1 ,sizeof(p));\n\tfor(i = 1 ; i <= n ; i++){\n\t\tscanf(\"%d\" ,a+i);\n\t\tif(p[a[i]] == -1)\tp[a[i]] = i;\n\t\tc[a[i]]++;\n\t}\n\tint ans = 0 , r = 0;\n\tfor(i = 1;i<=n;i++){\n\t\tif(c[i] == 0){\n\t\t\tr++;\n\t\t\twhile(r <= n && c[i] == 0) {\n\t\t\t\tif(c[a[r]] > 1){\n\t\t\t\t\tif(p[a[r]] == r && a[r] < i){\n\t\t\t\t\t\tr++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tans++;\n\t\t\t\t\ta[r] = i;\n\t\t\t\t\tc[i] = 1;\n\t\t\t\t\tc[a[r]]--;\n\t\t\t\t\tr--;\n\t\t\t\t}\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\" ,ans);\n\tfor(i = 1; i <=n;i++)\tprintf(\"%d \" ,a[i]);\n\treturn 0;\n}\n*/", "lang_cluster": "C", "tags": ["math", "greedy", "implementation"], "code_uid": "6b918df796c2707558fc90e15520d6eb", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define N\t13\n\nlong long lucky(int b) {\n\treturn b == 1 ? 0 : lucky(b / 2) * 10 + (b % 2 == 0 ? 4 : 7);\n}\n\nint is_lucky(int y) {\n\treturn y == 0 ? 1 : is_lucky(y / 10) && (y % 10 == 4 || y % 10 == 7);\n}\n\nint ff[N];\n\nvoid init() {\n\tint i, f;\n\n\tf = 1;\n\tfor (i = 0; i < N; i++) {\n\t\tff[i] = f;\n\t\tf *= i + 1;\n\t}\n}\n\nint get(int n, int k, int i) {\n\tstatic char used[N];\n\tint h, j;\n\n\tmemset(used, 0, n * sizeof *used);\n\tfor (h = 0; h < n; h++) {\n\t\tint f = ff[n - 1 - h], s = k / f;\n\n\t\tfor (j = 0; j < n; j++)\n\t\t\tif (!used[j] && s-- == 0) {\n\t\t\t\tif (h == i)\n\t\t\t\t\treturn j;\n\t\t\t\tused[j] = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tk %= f;\n\t}\n\treturn -1;\n}\n\nint main() {\n\tint n, n_, k, b, ans;\n\tlong long f;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tf = 1;\n\tn_ = 1;\n\twhile (f < k)\n\t\tf *= ++n_;\n\tif (n_ > n) {\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\tans = 0;\n\tfor (b = 2; ; b++) {\n\t\tlong long x = lucky(b);\n\t\tint y;\n\n\t\tif (x > n)\n\t\t\tbreak;\n\t\tif (x <= n - n_) {\n\t\t\tans++;\n\t\t\tcontinue;\n\t\t}\n\t\ty = n - n_ + get(n_, k - 1, x - (n - n_) - 1) + 1;\n\t\tif (is_lucky(y))\n\t\t\tans++;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "combinatorics", "number theory"], "code_uid": "0117275d91be12e22da3db9859c8d11f", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define min(a, b) ((a < b) ? (a) : (b))\n#define max(a, b) ((a > b) ? (a) : (b))\n\nint l = 1, r, answ, t = 1;\nlong long a[11];\nlong long ans[2048];\nint b[13], use[13];\nint n, m, k;\n\nint\nanalyze(void)\n{\n int i, nonzero = 0;\n long long tmp = 0;\n for(i = 10; i >= 0; --i){\n if(a[i] == 0 && nonzero){\n return 1;\n }\n tmp = tmp * 10 + a[i];\n if (a[i] != 0){\n nonzero = 1;\n }\n }\n if(tmp >= r){\n ans[n++] = tmp;\n return 0;\n }\n if(tmp >= l){\n ans[n++] = tmp;\n }\n return 1;\n}\n\nvoid\ngo(int i)\n{\n if(!t){\n return;\n }\n if (i == -1){\n t = analyze();\n return;\n }\n a[i] = 0;\n go(i - 1);\n a[i] = 4;\n go(i - 1);\n a[i] = 7;\n go(i - 1);\n}\n\nvoid\ngen(int n, int p, int k){\nif(p > 0){\n int i, ans = 1;\n for(i = 1; i <= p - 1; ++i){\n ans *= i;\n }\n int tmp = k / ans;\n if(k % ans == 0){\n --tmp;\n }\n if (tmp >= n){\n printf(\"-1\");\n m = -1;\n return;\n }\n for(i = 0; ; ++i){\n if(use[i] == 0){\n if(tmp > 0){\n --tmp;\n } else {\n use[i] = 1;\n b[n - p] = i;\n break;\n }\n }\n }\n gen(n, p - 1, k % ans ? k % ans : ans);\n}\n}\n\nint\nmain(void)\n{\n scanf(\"%d%d\", &m, &k);\n r = m;\n go(10);\n answ = 0;\n int i, j, q;\n for(i = 0; ans[i] <= m - 13; ++i){\n ++answ;\n }\n gen(min(13, m), min(13, m), k);\n if(m == -1){\n return 0;\n }\n for(i = 0; i < min(13, m); ++i){\n b[i] += max(1, m - 12);\n }\n for(i = max(1, m - 12); i <= m; ++i){\n for(j = 0; j < n; ++j){\n if(ans[j] == i){\n for(q = 0; q < n; ++q){\n if(b[i - max(1, m - 12)] == ans[q]){\n ++ answ;\n }\n }\n }\n }\n }\n printf(\"%d\", answ);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "combinatorics", "number theory"], "code_uid": "a8433358e5d52aee443e8eab58eb24e7", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint n, m;\n\n\tscanf(\"%d%d\", &n, &m);\n\tprintf(\"%.12lf\\n\", n == 1 ? 1 : 1.0 / n\n\t\t\t+ (double) (m - 1) * (n - 1) / (n * m - 1) / n);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities", "math", "combinatorics"], "code_uid": "34fd7d5b9c509b9f0986dce1e039af23", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n\nlong long gcd(long long a, long long b) {\n if (a % b == 0) {\n return b;\n }\n return gcd(b, a % b);\n}\n\nint main(void) {\n long long n, m, x, y, a, b;\n scanf(\"%lld %lld %lld %lld %lld %lld\", &n, &m, &x, &y, &a, &b);\n \n long long d = gcd(a, b);\n a /= d;\n b /= d;\n \n int ans[4];\n long long lo = 1, hi = n;\n while (lo <= hi) {\n long long mid = (lo + hi) / 2;\n \n long long lx = mid * a;\n long long ly = lx * b / a;\n \n long long x0 = MAX(0, x - lx);\n long long y0 = MAX(0, y - ly);\n \n if (x0 + lx <= n && y0 + ly <= m) {\n lo = mid + 1;\n ans[0] = x0, ans[1] = y0;\n ans[2] = x0 + lx, ans[3] = y0 + ly;\n } else {\n hi = mid - 1;\n }\n }\n \n int lx = ans[2] - ans[0];\n if (x >= ans[0] + (lx+1)/2) {\n int r = x - (ans[0] + (lx+1)/2);\n int w = n - ans[2];\n ans[0] += MIN(r, w);\n ans[2] += MIN(r, w);\n }\n \n int ly = ans[3] - ans[1];\n if (y >= ans[1] + (ly+1)/2) {\n int r = y - (ans[1] + (ly+1)/2);\n int w = m - ans[3];\n ans[1] += MIN(r, w);\n ans[3] += MIN(r, w);\n }\n \n for (int i = 0; i < 4; i++) {\n printf(\"%i \", ans[i]);\n }\n puts(\"\");\n \n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "00e763f1b0090e6e2f1d3e84f166604f", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define min(a,b) a=0)\n\t {\n\t\tx2=x+(wi/2);\n\t\tx1=x-(wi/2);\n\t }\n\t else\n\t {\n\t\tx1=0;\n\t\tx2=wi;\n\t }\n\t}\n\telse\n\t{\n\t x2=n;\n\t x1=n-wi;\n\t}\n }\n else\n {\n\tif(x+(wi/2)<=n)\n\t{\n\t if(x-(wi/2)-1>=0)\n\t {\n\t\tx2=x+(wi/2);\n\t\tx1=x-(wi/2)-1;\n\t }\n\t else\n\t {\n\t\tx1=0;\n\t\tx2=wi;\n\t }\n\t}\n\telse\n\t{\n\t x2=n;\n\t x1=n-wi;\n\t}\n }\n if(br%2==0)\n {\n\tif(y+(br/2)<=m)\n\t{\n\t if(y-(br/2)>=0)\n\t {\n\t\ty2=y+(br/2);\n\t\ty1=y-(br/2);\n\t }\n\t else\n\t {\n\t\ty1=0;\n\t\ty2=br;\n\t }\n\t}\n\telse\n\t{\n\t y2=m;\n\t y1=m-br;\n\t}\n }\n else\n {\n\tif(y+(br/2)<=m)\n\t{\n\t if(y-(br/2)-1>=0)\n\t {\n\t\ty2=y+(br/2);\n\t\ty1=y-(br/2)-1;\n\t }\n\t else\n\t {\n\t\ty1=0;\n\t\ty2=br;\n\t }\n\t}\n\telse\n\t{\n\t y2=m;\n\t y1=m-br;\n\t}\n }\n printf(\"%lld %lld %lld %lld\\n\",x1,y1,x2,y2);\n return 0;\t\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "5f635312d28f6c8f0ae49735fff3bd9c", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#define M 1000000007\ninline int p(int s, int n){int a=1;for(;n;n&1?a=1ll*a*s%M:0,s=1ll*s*s%M,n>>=1);return a;}\nmain(n,m){scanf(\"%d%d\",&n,&m),++n;return!printf(\"%d\",1ll*(n-m)*p(n,M-2)%M*p(n<<1,m)%M);}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "7f59734035b10af3abc4f2705d47004d", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\ntypedef long long ll;\r\n\r\nll dp[200007][7], sum[200007][7];\r\n\r\nint main(){\r\n\tint n, m;\r\n\tscanf(\"%d %d\", &n, &m);\r\n\tfor (register int i = 2; i <= n; i++){\r\n\t\tint half_i = i / 2;\r\n\t\tdp[i][1] = (sum[i - 1][1] + sum[i - 1][2] + 1) % m;\r\n\t\tdp[i][2] = i - half_i;\r\n\t\tfor (register int j = 2, k; j <= half_i; j = k + 1){\r\n\t\t\tint ti = i / j;\r\n\t\t\tk = i / ti;\r\n\t\t\tdp[i][2] = (dp[i][2] + (dp[ti][1] + dp[ti][2]) * (k - j + 1) % m) % m;\r\n\t\t}\r\n\t\tsum[i][1] = (sum[i - 1][1] + dp[i][1]) % m;\r\n\t\tsum[i][2] = (sum[i - 1][2] + dp[i][2]) % m;\r\n\t}\r\n\tprintf(\"%lld\", (dp[n][1] + dp[n][2]) % m);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "311dac509d58f041d553a9068e0b50f3", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\ntypedef long long ll;\r\n\r\nll dp[200007][7], sum[200007][7];\r\n\r\nint main(){\r\n\tint n, m;\r\n\tscanf(\"%d %d\", &n, &m);\r\n\tfor (register int i = 2; i <= n; i++){\r\n\t\tint half_i = i / 2;\r\n\t\tdp[i][1] = (sum[i - 1][1] + sum[i - 1][2] + 1) % m;\r\n\t\tdp[i][2] = i - half_i;\r\n\t\tfor (register int j = 2, k; j <= half_i; j = k + 1){\r\n\t\t\tint ti = i / j;\r\n\t\t\tk = i / ti;\r\n\t\t\tdp[i][2] = (dp[i][2] + (dp[ti][1] + dp[ti][2]) * (k - j + 1) % m) % m;\r\n\t\t}\r\n\t\tsum[i][1] = (sum[i - 1][1] + dp[i][1]) % m;\r\n\t\tsum[i][2] = (sum[i - 1][2] + dp[i][2]) % m;\r\n\t}\r\n\tprintf(\"%lld\", (dp[n][1] + dp[n][2]) % m);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "data structures", "number theory"], "code_uid": "256eec8f9869e074ab256d02dfb317eb", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tchar s1[n+1];\n\tint s[n+1];\n\tscanf(\"%s\",s1);\n\tint length=strlen(s1),total_sum=0,sum=0,temp=0,k=0,j,flag=0;\n\tfor(int i=0;i\n#include \n#include \n#pragma warning (disable:4996)\n\nint main() {\n\tint digit = 0;\n\tchar num[100] = { 0 };\n\tint sum = 0;\n\tint flag = 0;\n\n\tscanf(\"%d\", &digit);\n\tgetchar();\n\tscanf(\"%s\", num);\n\n\tfor (int i = 0; i < strlen(num); i++) {\n\t\tsum += num[i] - '0';\n\t}\n\n\tif (sum == 0 && digit > 1) {\n\t\tflag = 1;\n\t}\n\telse {\n\t\tfor (long long int i = 1; i < sum; i++) {\n\t\t\tif (sum % i == 0) {\n\t\t\t\tlong long int count = 0;\n\t\t\t\tint x = 0;\n\n\t\t\t\twhile (1) {\n\t\t\t\t\tcount += (num[x] - '0');\n\t\t\t\t\tif (count <= i) {\n\t\t\t\t\t\tx++;\n\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\tif (count == i) {\n\t\t\t\t\t\t\tcount = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (x == digit) {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tflag = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (flag == 1) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (flag == 0) {\n\t\tprintf(\"NO\\n\");\n\t}\n\telse if (flag == 1) {\n\t\tprintf(\"YES\\n\");\n\t}\n\n\t//system(\"PAUSE\");\n\treturn 0;\n}\n \t\t \t \t \t \t \t\t \t \t\t\t\t\t\t", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "ac4b1d182522ac693b01543e2fd98c79", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define MDI 1000000009\n#define MOD(a) ((a) % MDI)\n#define MOO(a) ((a) > 0 ? (a) % MDI : MDI + (a))\n#define LL long long\n\nvoid putlld(LL a)\n{\n if(a > 9)\n putlld(a / 10);\n putchar(a % 10 + '0');\n}\n\nint nn[499999];\n\nint main(void)\n{\n int i, n;\n LL h = 0, g, t;\n scanf(\"%d\", &n);\n t = (n >> 1) - 1;\n for(i = 0, nn[0] = 4; i < t - 1; i++)\n nn[i + 1] = MOD(nn[i] << 1);\n for(i = t - 1; i >= 0; i--){\n g = nn[i] - 3;\n h = MOD((h + 4) * g);\n }\n h = MOD(((h * h + (h << 2)) << 1) + 10);\n putlld(h);\n putchar('\\n');\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "f6296d4799abe1c0c8ad414c25fc2b4f", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define MD\t1000000009\n\nint main() {\n\tint n, l, ans, cnt, x, y, z;\n\n\tscanf(\"%d\", &n), n /= 2;\n\tcnt = 2, x = 1, y = 1, z = 2;\n\tfor (l = 2; l <= n; l++) {\n\t\tcnt = (cnt + x * 4LL) % MD;\n\t\tz = z * 2 % MD;\n\t\ty = (y + z) % MD;\n\t\tx = (long long) x * y % MD;\n\t}\n\tans = ((long long) cnt * cnt + 1) * 2 % MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "eb3f0d84acb0118a2535aaad9da1f53b", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define M 10000\n\nint main(void) {\n\tint a,b,c,ab,ac,bc,i,j,k;\n\tscanf(\"%d %d %d\", &ab, &ac, &bc);\n\tfor (i=1; i<=M; ++i) if (ab%i==0) {\n\t\tfor (j=ab/i, k=1; k<=M; ++k) {\n\t\t\tif (i*k==ac && j*k==bc) {\n\t\t\t\ta=i; b=j; c=k;\n\t\t\t\tgoto done;\n\t\t\t}\n\t\t}\n\t}\n\texit(EXIT_FAILURE);\n\tdone:\n\tprintf(\"%d\\n\", 4*(a+b+c));\n\texit(EXIT_SUCCESS);\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "7d4b66b09b08518ddd2b54c9cb48ee8d", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint m[3];\n\nvoid bubbleSort(int n) {\n int i, j;\n int x;\n for(i=0; i < n; i++) { \n for(j = n-1; j > i; j--) { \n if (m[j-1] > m[j]) {\n x=m[j-1];\n m[j-1]=m[j];\n m[j]=x;\n }\n }\n }\n}\n\nint sq (int a){\n int q;\n int ret;\n for (q=0; q=a) return q;\n }\n}\n\nint main() {\n int i=0, j=0;\n int a, b, c;\n int temp;\n int ans;\n for (i=0; i<3; i++) scanf (\"%d\", &m[i]);\n bubbleSort (3);\n temp=sq(m[0]);\n for (a=1; a<=temp; a++){\n if (m[0]%a==0){\n c=m[0]/a;\n if (m[1]%c == 0){\n b=m[1]/c;\n if (b*a == m[2]){\n ans=4*(a+b+c);\n printf (\"%d\\n\", ans);\n return 0;\n }\n }\n if (m[2]%c == 0){\n b=m[2]/c;\n if (b*a == m[1]){\n ans=4*(a+b+c);\n printf (\"%d\\n\", ans);\n return 0;\n }\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "423f730cec5cd50e68825ba218fb8259", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long c[101][101];\nlong long dp[11][101];\n\nint main()\n{\n int n, m = 1000000007, p = 0, i, j, k, l, r;\n long long sum = 0;\n int a[10];\n \n scanf(\"%d\", &n);\n \n for (i = 0; i < 10; i++) scanf(\"%d\", &a[i]);\n \n for (i = 0; i < 10; i++) p += a[i];\n \n if (p == 0) p = 1;\n \n c[0][0] = 1;\n \n for (i = 1; i <= 100; i++) {\n c[i][0] = c[i][i] = 1;\n \n for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % m;\n }\n \n for (i = p; i <= n; i++) {\n for (j = 1; j <= 9; j++) {\n for (k = 0; k <= 10; k++) {\n for (l = 0; l <= n; l++) {\n dp[k][l] = -1;\n }\n }\n \n dp[0][1] = 1;\n \n for (k = 0; k < 10; k++) {\n for (l = 1; l <= i; l++) {\n if (dp[k][l] == -1) continue;\n \n for (r = a[k] - (j == k); l + r <= i; r++) {\n if (r < 0) continue;\n \n if (dp[k + 1][l + r] == -1) dp[k + 1][l + r] = 0;\n \n dp[k + 1][l + r] = (dp[k + 1][l + r] + dp[k][l] * c[i - l][r] % m) % m;\n }\n }\n }\n \n if (dp[10][i] >= 0) sum = (sum + dp[10][i]) % m;\n }\n }\n \n printf(\"%d\\n\", (int)sum);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "35d1c098e5909717b0deb4753c003723", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n\ntypedef long long ll;\n\nint a[10];\nll dp[101][10];\nll c[101][101];\n\nconst int mod = 1000000007;\n\nvoid init()\n{\n int i, j;\n for (i = 0; i <= 100; i ++)\n {\n c[i][0] = c[i][i] = 1;\n }\n for (i = 1; i <= 100; i ++)\n {\n for (j = 1; j < i; j ++)\n {\n c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;\n }\n }\n}\n\nvoid solve(int n)\n{\n int i, j, k, t;\n ll ans;\n ans = 0;\n for (i = 1; i <= 9; i ++)\n {\n {\n a[i] --;\n for (j = 0; j < n; j ++)\n {\n if (j >= a[0])\n {\n dp[j][0] = 1;\n }\n else\n {\n dp[j][0] = 0;\n }\n for (k = 1; k <= 9; k ++)\n {\n dp[j][k] = 0;\n for (t = MAX(a[k], 0); t <= j; t ++)\n {\n dp[j][k] = (dp[j][k] + ((dp[j - t][k - 1] * c[j][t]) % mod)) % mod;\n }\n }\n ans = (ans + dp[j][9]) % mod;\n }\n a[i] ++;\n }\n }\n printf(\"%d\\n\", (int)ans);\n}\n\nint main()\n{\n int n, i;\n init();\n while (scanf(\"%d\", &n) == 1)\n {\n for (i = 0; i < 10; i ++)\n {\n scanf(\"%d\", &a[i]);\n }\n solve(n);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "9fa832965a666e05b4e10b2b8daf86ff", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n/* AUTHOR:AKASH JAIN\n* USERNAME:akash19jain \n* DATE:03/04/2019 \n*/\n#include\n#include\n#include\n#include\n#include\n\n#include \nint main()\n{\n\tint n,x,y;\n\tscanf(\"%d\",&n);\n\tx=n/10;\n\ty=n%10;\n\tif(n==12) printf(\"YES\");\n\telse if(x==1||x==2||x==7||x==9) printf(\"NO\");\n\telse if(y==1||y==7||y==9) printf(\"NO\");\n\telse printf(\"YES\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "79e239e293d8e36af9bf915f1db2e165", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n int n,x,y;\n scanf(\"%d\",&n);\n x=n/10;\n y=n%10;\n if(n==12) printf(\"YES\");\n else if(x==1||x==2||x==7||x==9) printf(\"NO\");\n else if(y==1||y==7||y==9) printf(\"NO\");\n else printf(\"YES\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "0daada4b38f8aa0a224bdf49846a257c", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\nint search(int arr[], int n, int x);\nvoid mergeSort(int arr[], int l, int r);\nvoid merge(int arr[], int l, int m, int r);\n\n\nint main(void){\n\tint n;\n\tchar s[101];\n\tscanf(\"%i\", &n);\n\tscanf(\"%s\", s);\n\tn--;\n\tint count = 0;\n\tint moves = 0;\n\tfor(int i=n/2; i>0; i--){\n\t int flag = 1;\n\t for(int j=i; j>=0; j--){\n\t if(s[j] != s[i+j+1]){\n\t flag = 0;\n\t break;\n\t }\n\t }\n\t if(flag == 1){\n\t count = i;\n\t break;\n\t }\n\t}\n\n\tmoves += 2;\n\tn++;\n\tmoves += n-((count+2));\n printf(\"%i\\n\", moves);\n}\n\nint search(int arr[], int n, int x)\n{\n int i;\n for (i = 0; i < n; i++)\n if (arr[i] == x)\n return i;\n return -1;\n}\n\nvoid merge(int arr[], int l, int m, int r)\n{\n int i, j, k;\n int n1 = m - l + 1;\n int n2 = r - m;\n\n /* create temp arrays */\n int 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 if (L[i] <= R[j]) {\n arr[k] = L[i];\n i++;\n }\n else {\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 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 arr[k] = R[j];\n j++;\n k++;\n }\n}\n\nvoid mergeSort(int arr[], int l, int r)\n{\n if (l < r) {\n // Same as (l+r)/2, but avoids overflow for\n // large l and h\n int 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}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "e0ebbe98c651a74730e1d16e488b17de", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tint i, j, k, len, flag = 0;\n\tchar str[100];\n\tscanf(\"%d\", &len);\n\tscanf(\"%s\", str);\n\tj = k = len / 2;\n\t\n\twhile(k > 0){\n\t\tj = k;\n\t\ti = 0;\n\t\twhile(str[i] == str[j] && j > i){\n\t\t\tif(i + 1 == k){\n\t\t\t\tflag = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ti++;\n\t\t\tj++;\n\t\t}\n\t\tif(flag == 1)\n\t\t\tbreak;\n\t\tk--;\n\t}\t\n\tif(flag == 1)\n\t\tprintf(\"%d\\n\", len + 1 - k);\n\telse \n\t\tprintf(\"%d\\n\", len);\t\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "7d5e8d6048a54003bd9f004c9d7d4bf3", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "\n#include\n#include\n#include\n#include\n\nint compare(const void *a,const void *b)\n{\n return (*(int *)a-*(int *)b);\n}\nint main()\n{\n int x[8],y[8],i,j;\n for(i=0;i<8;i++)\n {\n scanf(\"%d %d\",&x[i],&y[i]);\n }\n for(i=0;i<8;i++)\n {\n for(j=i+1;j<8;j++)\n { \n\t\t\tif(x[i]==x[j]&&y[i]==y[j])\n {\n printf(\"ugly\");\n return 0;\n }\n else\n {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n }\n qsort(x,8,sizeof(int),compare);\n qsort(y,8,sizeof(int),compare);\n\n if(x[1]==x[0]&&x[2]==x[1]&&x[4]==x[3]&&x[7]==x[6]&&x[5]==x[7]&&x[3]>x[0]&&x[6]>x[3]&&y[3]>y[2]&&y[5]>y[4]&&y[4]==y[3]&&y[0]==y[1]&&y[1]==y[2]&&y[6]==y[7]&&y[5]==y[6]&&y[3]!=y[1])\n {\n\t\tprintf(\"respectable\\n\");\n\t}\n\telse\n\t{\n printf(\"ugly\\n\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["sortings"], "code_uid": "900df21dfefc88c911da56d0704afc0e", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint ar[8][2];\n\nint comp(const void *a, const void *b)\n{\t\n\tif( *(int *)a == *(int *)b)\n\t\treturn (*(((int *)a)+1)) > (*(((int *)b)+1));\n\treturn *(int *)a > *(int *)b;\n}\n\nint main()\n{\n\tint i;\n\tfor(i=0;i<8;i++)\n\t\tscanf(\" %d %d\",&ar[i][0], &ar[i][1]);\n\t\t\n\tqsort(ar,8,2*sizeof(int),comp);\n\t\n\tfor(i=0;i<7;i++)\n\t\tif(ar[i][0]==ar[i+1][0] && ar[i][1]==ar[i+1][1])\n\t\t{\n\t\t\tprintf(\"ugly\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\n\tif(\tar[0][0]==ar[1][0] && ar[1][0]==ar[2][0] && \n\t\tar[3][0]==ar[4][0] &&\n\t\tar[5][0]==ar[6][0] && ar[6][0]==ar[7][0] &&\n\t\tar[0][1]==ar[3][1] && ar[3][1]==ar[5][1] &&\n\t\tar[1][1]==ar[6][1] &&\n\t\tar[2][1]==ar[4][1] && ar[4][1]==ar[7][1])\n\t\tprintf(\"respectable\\n\");\n\n\telse printf(\"ugly\\n\");\n\t\t\n\t\n//\tfor(i=0;i<8;i++)\n//\t\tprintf(\"%d %d\\n\",ar[i][0],ar[i][1]);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["sortings"], "code_uid": "f5b3b9056ee1b76d4c4162265386e2b9", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t200000\n#define M\t200000\n\nint main() {\n\tstatic char aa[N + 1], bb[M + 1];\n\tstatic int pp[M + 1], qq[M + 1];\n\tint n, m, i, i1, i2, j, max;\n\n\tscanf(\"%s%s\", aa, bb), n = strlen(aa), m = strlen(bb);\n\tfor (i = 0, j = 0; i <= n; i++) {\n\t\tpp[i] = j;\n\t\tif (i < n && j < m && aa[i] == bb[j])\n\t\t\tj++;\n\t}\n\tfor (i = n, j = m - 1; i >= 0; i--) {\n\t\tif (i < n && j >= 0 && aa[i] == bb[j])\n\t\t\tj--;\n\t\tqq[i] = j;\n\t}\n\tmax = 0;\n\tfor (i1 = 0, i2 = 0; i1 <= n; i1++) {\n\t\twhile (i2 <= n && pp[i1] > qq[i2])\n\t\t\ti2++;\n\t\tif (max < i2 - 1 - i1)\n\t\t\tmax = i2 - 1 - i1;\n\t}\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "a7896ade86ba0571cacf21154c0b32ad", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint main()\n{\n\tchar s[200005], t[200005];\n\tscanf(\"%s%s\", s, t);\n\tint i, j;\n\tint a[200005];\n\tint n, m;\n\tn = strlen(s);\n\tm = strlen(t);\n\ta[0] = -1;\n\tfor (i = 0; i < m; i++)\n\t{\n\t\tj = a[i] + 1;\n\t\twhile (s[j] != t[i])\n\t\t\tj++;\n\t\ta[i + 1] = j;\n\t}\n\tint b[200005];\n\tb[m] = n;\n\tfor (i = m - 1; i >= 0; i--)\n\t{\n\t\tj = b[i + 1] - 1;\n\t\twhile (s[j] != t[i])\n\t\t\tj--;\n\t\tb[i] = j;\n\t}\n\tint ans = 0;\n\tfor (i = 0; i <= m; i++)\n\t\tif (ans < b[i] - a[i])\n\t\t\tans = b[i] - a[i];\n\tprintf(\"%d\\n\", ans - 1);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "9e7e0e65ca32fbc37c93f2acc11d3988", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint h[10000001];\n\n\n\nmain()\n{\n long long int i,j,k,a,n,m,sum=0,max;\n scanf(\"%lld %lld\",&a,&n);\n for(i=1;i*i<=a+n;i++)\n {\n k=i*i;\n for(j=k;j<=a+n;j=j+k)\n {\n h[j]=k;\n }\n }\n for(i=a;i\n\nint main() {\n\tint n, l, r;\n\n\tscanf(\"%d%d%d\", &n, &l, &r);\n\tprintf(\"%d %d\\n\", ((1 << l) - 1) + (n - l), ((1 << r) - 1) + ((n - r) << r - 1));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "44dd3666a59f1815c635de5ca88be4f3", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n#include\n#include\nint main()\n{\n long long int ch[100000];\n char arr[1000000];\n char kh[1000000],bh,ag;\n int cp[400000];\n int a=0,b,c,d,e=0,g,i=0,m=0,tep=0,temp=0,j=0,k=0,l=0,n=0;\n\n scanf(\"%d%d%d\",&a,&b,&c);\n j=1; k=1; e=1;\n for(l=1; l\n\nint dp[2][4][2][31][31][31];\n\nint main()\n{\n int n, h, m = 1000000009, sum = 0, i, j, k, l, p, q, r, s;\n int a[4], b[3];\n \n scanf(\"%d %d\", &n, &h);\n \n dp[0][0][0][0][0][0] = 1;\n \n for (i = 0; i < n; i++) {\n for (j = 0; j < 4; j++) {\n for (k = 0; k < 2; k++) {\n for (l = 0; l <= h; l++) {\n for (p = l; p <= h; p++) {\n for (q = p; q <= h; q++) {\n if (dp[i & 1][j][k][l][p][q] == 0) continue;\n \n for (r = 0; r < 4; r++) a[r] = -1;\n \n if (k == 0) {\n a[j] = 0;\n } else {\n a[j] = h;\n }\n \n r = 0;\n \n if (a[r] >= 0) r++;\n a[r++] = l;\n \n if (a[r] >= 0) r++;\n a[r++] = p;\n \n if (a[r] >= 0) r++;\n a[r++] = q;\n \n for (r = 0; r < 4; r++) {\n int c = 0;\n \n for (s = 0; s < 4; s++) {\n if (s == r) continue;\n \n b[c] = a[s] + 1;\n \n if (b[c] > h) b[c] = h;\n \n c++;\n }\n \n if (b[0] > b[1]) {\n int tmp = b[0];\n b[0] = b[1];\n b[1] = tmp;\n }\n \n if (b[0] > b[2]) {\n int tmp = b[0];\n b[0] = b[2];\n b[2] = tmp;\n }\n \n if (b[1] > b[2]) {\n int tmp = b[1];\n b[1] = b[2];\n b[2] = tmp;\n }\n \n if (a[r] == h) {\n dp[(i + 1) & 1][r][1][b[0]][b[1]][b[2]] += dp[i & 1][j][k][l][p][q];\n \n if (dp[(i + 1) & 1][r][1][b[0]][b[1]][b[2]] >= m) dp[(i + 1) & 1][r][1][b[0]][b[1]][b[2]] -= m;\n } else {\n dp[(i + 1) & 1][r][0][b[0]][b[1]][b[2]] += dp[i & 1][j][k][l][p][q];\n \n if (dp[(i + 1) & 1][r][0][b[0]][b[1]][b[2]] >= m) dp[(i + 1) & 1][r][0][b[0]][b[1]][b[2]] -= m;\n }\n }\n \n dp[i & 1][j][k][l][p][q] = 0;\n }\n }\n }\n }\n }\n }\n \n for (i = 0; i < 4; i++) {\n for (j = 0; j < 2; j++) {\n for (k = 0; k <= h; k++) {\n for (l = 0; l <= h; l++) {\n for (r = 0; r <= h; r++) {\n if (j == 0 || (k > 0 && k < h) || (l > 0 && l < h) || (r > 0 && r < h)) {\n sum += dp[n & 1][i][j][k][l][r];\n \n if (sum >= m) sum -= m;\n }\n }\n }\n }\n }\n }\n \n printf(\"%d\\n\", sum);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "c6a8a0434f99c107053d7b32b09589ec", "src_uid": "9fe9658db35076c0bddc8b7ddce11013", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n\ntypedef long long ll;\n\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n#define abs(k) (((k)>0)?(k):(-(k)))\nint modint(int a,int b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}\nll modll(ll a,ll b) {return(((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1)));}\n#define mod(a,b) a=modint(a,b)\n#define llmod(a,b) a=modll(a,b)\n#define mset(a) memset(a,0,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n#define inf (1e9)\n#define linf (1e18)\n#define pi 3.14159265358979323846\n\nvoid fileio_in_out()\n{\n freopen(\".in\",\"r\",stdin);\n freopen(\".out\",\"w\",stdout);\n}\n\nvoid fileio_txt()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n}\n\n//==================================================\n\n#define modnum (inf+9)\n\nint n,h,x,y,z,ww,xx,yy,zz;\nint i,j,k,l;\nll dp[33][33][33][2][2],ans=0,t;\n\nint main()\n{\n //fileio_in_out();\n //fileio_txt();\n \n scanf(\"%d%d\",&n,&h);\n \n mset(dp);\n dp[0][0][0][0][1]=1;\n for(k=0;k\n\nint main()\n{\n int t1, t2, x1, x2, t0, x, y, i;\n double m;\n\n scanf(\"%d %d %d %d %d\", &t1, &t2, &x1, &x2, &t0);\n\n if (t2 == t0) {\n\tif (t1 == t2) {\n\t printf(\"%d %d\\n\", x1, x2);\n\t} else {\n\t printf(\"%d %d\\n\", 0, x2);\n\t}\n\n\treturn 0;\n }\n\n if (t1 == t0) {\n\tprintf(\"%d %d\\n\", x1, 0);\n\n\treturn 0;\n }\n\n for (i = x1; i > 0; i--) {\n\tlong long p = (long long)(t0 - t1) * i;\n\n\tif (p % (t2 - t0) == 0 && p / (t2 - t0) <= x2) {\n\t printf(\"%d %d\\n\", i, (int)(p / (t2 - t0)));\n\n\t return 0;\n\t}\n }\n\n x = 0;\n y = x2;\n m = t2;\n\n for (i = x1; i >= 0; i--) {\n\tlong long p = (long long)(t0 - t1) * i / (t2 - t0) + 1;\n\n\tif (p <= x2) {\n\t double q = ((double)t1 * i + (double)t2 * p) / (i + p);\n\n\t if ((p * x != (long long)i * y) && q < m || (q == m && x + y < i + p)) {\n\t\tx = i;\n\t\ty = p;\n\t\tm = q;\n\t }\n\t}\n }\n\n printf(\"%d %d\\n\", x, y);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "18ec6068024f03662d7d85c1b40ea44d", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.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 x2) break;\n }\n if(y2 > x2) break;\n\n k = GCD(y1, y2);\n if(k>1) continue;\n\n tmp = (t1*y1+t2*y2) / (double)(y1+y2);\n if(opt > tmp){\n opt = tmp;\n\n k = 1000000000;\n if(y1 && k > x1 / y1) k = x1 / y1;\n if(y2 && k > x2 / y2) k = x2 / y2;\n\n r1 = y1 * k;\n r2 = y2 * k;\n }\n }\n\n printf(\"%d %d\\n\",r1,r2);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "d4199b6a6661b1e16d0591c450f795b6", "src_uid": "87a500829c1935ded3ef6e4e47096b9f", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define N\t200000\n#define K\t447\t/* K = floor(sqrt(N)) */\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\tstatic int aa[N], *ii[N], kk[N], ii1[N + 1], ii2[K + 2], ll[N], ll_[N];\n\tint n, i, k, a, a_, ans;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &aa[i]), aa[i]--;\n\t\tkk[aa[i]]++;\n\t}\n\tfor (a = 0; a < n; a++)\n\t\tii[a] = (int *) malloc(kk[a] * sizeof *ii[a]), kk[a] = 0;\n\tmemset(ii1, -1, (K + 2) * sizeof *ii1), memset(ii2, -1, (K + 2) * sizeof *ii2);\n\tans = 0, a_ = -1;\n\tfor (i = 0; i < n; i++) {\n\t\ta = aa[i];\n\t\tii[a][kk[a]++] = i;\n\t\tif (a_ == -1 || kk[a_] < kk[a])\n\t\t\ta_ = a;\n\t\tfor (k = 1; k <= kk[a] && k <= K + 1; k++)\n\t\t\tif (ii1[k] < ii[a][kk[a] - k])\n\t\t\t\tii2[k] = ii1[k], ii1[k] = ii[a][kk[a] - k];\n\t\t\telse if (ii2[k] < ii[a][kk[a] - k])\n\t\t\t\tii2[k] = ii[a][kk[a] - k];\n\t\tfor (k = 1; k <= K; k++)\n\t\t\tif (ii2[k] > ii1[k + 1])\n\t\t\t\tans = max(ans, i - ii1[k + 1]);\n\t\tll[i] = ii1[K + 1];\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tll_[i] = i + 1;\n\tfor (a = 0; a < n; a++)\n\t\tif (a != a_ && kk[a] > K) {\n\t\t\tint d;\n\n\t\t\tmemset(ii1, -1, (n + 1) * sizeof *ii1), ii1[0] = 0;\n\t\t\td = 0;\n\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\tif (aa[i] == a_)\n\t\t\t\t\td++;\n\t\t\t\telse if (aa[i] == a)\n\t\t\t\t\td--;\n\t\t\t\tif (d >= 0) {\n\t\t\t\t\tif (ii1[d] == -1)\n\t\t\t\t\t\tii1[d] = i + 1;\n\t\t\t\t\tll_[i] = min(ll_[i], ii1[d]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tfor (i = n - 1; i >= 0; i--) {\n\t\tif (ll_[i] <= ll[i])\n\t\t\tans = max(ans, i - ll_[i] + 1);\n\t\tif (ll_[i] == 0)\n\t\t\tbreak;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "data structures"], "code_uid": "baac94621f5f5a079ab5c34ce45d823e", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\"stdio.h\"\n#include\"string.h\"\n#include\"math.h\"\n#include\"stdlib.h\"\n#include\"ctype.h\"\n#include\"limits.h\"\n#include\"time.h\"\n\nint main()\n{\n\tclock_t lnh=clock();\n\tint n,m,x=1,c;\n\tscanf(\"%d%d\",&n,&m);\n\tint a[100]={0},d[100]={0},ac[100]={0},i,j,l[m];\n\tfor(i=0;i=l[i+1]);\n\t\td[c-1]=1;\n\t\tif(a[l[i]-1]!=c && a[l[i]-1])\n\t\tx=0;\n\t\telse\n\t\ta[l[i]-1]=c;\n\t}\n\t\n\tfor(i=j=0;i1)\n\tx=0;\n\tif(!x)\n\tprintf(\"-1\");\n\telse\n\t{\n\t\tfor(i=0;i\n#include \n#include \n#define min(a,b) (a < b ? a : b)\ntypedef long long ll;\nll n, m, a[1000], l[200], vis[200], vist[200];\n\nbool solve(){\n ll i, j;\n /*\n for(i = 1; i < m; i++){\n if(l[i + 1] > l[i]){\n \tif(a[l[i]] && a[l[i]] != l[i + 1] - l[i]) return false;\n if(vis[l[i]] != l[i + 1] - l[i] && vis[l[i]]) return false;\n a[l[i]] = l[i + 1] - l[i];\n vis[l[i]] = a[l[i]];// a === vis.\n }\n else if(l[i + 1] == l[i]){\n \tif(a[l[i]] && a[l[i]] != n) return false;\n if(vis[l[i]] && vis[l[i]] != n) return false;\n a[l[i]] = n;\n vis[l[i]] = n;\n break;\n }\n else{\n \tif(a[l[i]] && a[l[i]] != n - l[i] + l[i + 1]) return false;\n if(vis[l[i]] && vis[l[i]] != n - l[i] + l[i + 1]) return false;\n a[l[i]] = n - l[i] + l[i + 1];\n vis[l[i]] = a[l[i]];\n }\n }*/\n for(i = 1; i < m; i++){\n \tll tmp = l[i + 1] - l[i];\n \tif(tmp <= 0) tmp += n;\n \tif(vis[l[i]] != tmp && vis[l[i]]) return false;\n a[l[i]] = tmp;\n vis[l[i]] = a[l[i]];// a === vis.\n }\n // memset(vis, 0, sizeof(vis));\n // for(j = 1; j <= n; j++)\tif(a[j]) vis[a[j]] = 1;\n \n\t//check pmt.\n\t//for(i = 1; i <= n; i++) \n\t//\tfor(j = 1; j <= n; j++) if(i != j && a[j] == a[i]) return false;\n \n\tll deitian = 0;\n\tfor(i = 1; i <= n; i++) vist[vis[i]]++;\n\tfor(i = 1; i <= n; i++){\n\t\tif(vist[i] >= 2){\n\t\t\treturn false;\n\t\t}\n\t\telse if(!vist[i]){\n\t\t\tdeitian = 1;\n\t\t}\n\t}\n\tif(deitian){\n\t\tfor(j = 1; j <= n; j++){\n\t if(!vis[j]){\n\t for(ll k = 1; k <= n; k++){\n\t if(!vist[k]){\n\t a[j] = k;\n\t vist[k] = 1;\n\t break;\n\t }\n\t }\n\t } \n \t\t}\n\t}\n\treturn true;\n}\n\nint main(void){\n ll i, j, k;\n scanf(\"%lld%lld\", &n, &m);\n for(i = 1; i <= m ; i++) scanf(\"%lld\", l + i);\n if (solve()) for(i = 1; i <= n; i++) printf(\"%lld \", a[i]);\n else puts(\"-1\\n\");\n return 0;\n}\n\n/*\n#include \nusing namespace std;\n#define mst(a,b) memset((a),(b),sizeof(a))\n\ntypedef long long ll;\nconst int maxn= 105;\n \nint a[maxn];\nint ans[maxn];\nint num[maxn];\n \nint main()\n{\n int n,m;\n while(scanf(\"%d%d\",&n,&m) == 2)\n {\n mst(ans,-1);\n mst(num,0);\n mst(a,0);\n scanf(\"%d\",&a[0]);\n int flag=0;\n for(int i=1; i1)\n {\n flag=1;\n break;\n }\n if(num[i]==0&&flag!=1) \n {\n flag=2;\n }\n }\n if(flag==1)\n {\n puts(\"-1\");\n continue;\n }\n if(flag==2)\n {\n for(int i=1;i<=n;i++)\n {\n if(ans[i]==-1)\n {\n for(int j=1; j<=n; j++)\n {\n if(num[j]==0)\n {\n ans[i]=j;\n num[j]=1;\n break;\n }\n }\n }\n }\n }\n for(int i=1;i\n#include\n#include\nint main()\n{\n int i=0,c=0,l=0,d=0,j=0,k=0,l1;\n char s[101];\n scanf(\"%s\",s);\n l1=strlen(s);\n while(s[i]!='@'&&i16)\n {printf(\"NO\\n\");return 0;}\n c=0;i++;\n while(s[i]!='/' && i16)\n {printf(\"NO\\n\");return 0;}\n d=0;\n c++;\n }\n else\n {printf(\"NO\\n\");return 0;}\n i++;\n }\n if(d==0)\n {printf(\"NO\\n\");return 0;}\n if(s[l1-1]=='/')\n {printf(\"NO\\n\");return 0;}\n if(j==0&&(c==0||c>16))\n {printf(\"NO\\n\");return 0;}\n if(c==0||c>32)\n {printf(\"NO\\n\");return 0;}\n i++;k=0;\n while(i16)\n {printf(\"NO\\n\");return 0;}\n printf(\"YES\\n\");\n return 0;\n}", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "5df2f02326e02a485609e1782bbd2c32", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nint check_host( char * hostname )\n{\n\tint i = 0, len, max_len = 0, min_len = 1000;\n\twhile( i <= strlen(hostname) )\n\t{\n\t\tlen = 0;\n\t\twhile ( hostname[i] != '.' && hostname[i] != 0 )\n\t\t\tlen++, i++;\n\t\tif ( len > max_len ) max_len = len;\n\t\tif ( len < min_len ) min_len = len;\n\t\ti++;\n\t}\n\tif ( !min_len || max_len > 16 )\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\n\nint check_res( char * resource )\n{\n\tint i = 0, len, max_len = 0, min_len = 1000;\n\twhile( i <= strlen(resource) )\n\t{\n\t\tlen = 0;\n\t\twhile ( resource[i] != '/' && resource[i] != 0 )\n\t\t\tlen++, i++;\n\t\tif ( len > max_len ) max_len = len;\n\t\tif ( len < min_len ) min_len = len;\n\t\ti++;\n\t}\n\tif ( !min_len || max_len > 16 )\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\n\nint main()\n{\n\tchar str[201], username[201], hostname[201], resource[201];\n\tint i, j, len;\n\tchar res, at, point, next;\n\tnext = at = res = point = 0;\n\tscanf(\"%s\",str);\n\tlen = strlen(str);\n\tfor ( i = 0; i < len; i++ )\n\t\tif ( str[i] == '@' )\n\t\t{\n\t\t\tat = 1;\n\t\t\tbreak;\n\t\t}\n\tif ( !at )\n\t{\n\t\tprintf(\"NO\\n\");\n\t\texit(0);\n\t}\n\tj = i;\n\tfor ( i = j + 1; i < len; i++ )\n\t{\n\t\tif ( str[i] == '.' )\n\t\t\tpoint = 1;\n\t\tif ( str[i] == '/' )\n\t\t\tres = 1;\n\t}\n\tfor ( i = 0, j = 0; str[i] != '@'; i++, j++ )\n\t\tusername[j] = str[i];\n\tusername[i] = 0;\n\tif ( res )\n\t{\n\t\tfor ( ++i, j = 0; str[i] != '/'; i++, j++ )\n\t\t\thostname[j] = str[i];\n\t\thostname[j] = 0;\n\t\tfor ( ++i, j = 0; str[i] != 0; i++, j++ )\n\t\t\tresource[j] = str[i];\n\t\tresource[j] = 0;\n\t}\n\telse \n\t{\n\t\tfor ( ++i, j = 0; str[i] != 0; i++, j++ )\n\t\t\thostname[j] = str[i];\n\t\thostname[j] = 0;\n\t\tresource[0] = 0;\n\t}\n\tfor ( i = 0; i < strlen(username); i++ )\n\t\tif ( !( isalnum(username[i]) || username[i]=='_' ) )\n\t\t\tnext = 1;\n\tfor ( i = 0; i < strlen(hostname); i++ )\n\t\tif ( !( isalnum(hostname[i]) || hostname[i]=='_' || hostname[i]=='.' ) )\n\t\t\tnext = 1;\n\tfor ( i = 0; i < strlen(resource); i++ )\n\t\tif ( !( isalnum(resource[i]) || resource[i]=='_' || resource[i]=='/' ) )\n\t\t\tnext = 1;\n\tif ( strlen(username) > 16 || strlen(username) == 0 )\n\t\tnext = 1;\n\tif ( strlen(hostname) > 32 || strlen(hostname) == 0 || check_host( hostname ) )\n\t\tnext = 1;\n\tif ( res && check_res( resource ) )\n\t\tnext = 1;\n\t( next ) ? printf(\"NO\\n\") : printf(\"YES\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "implementation"], "code_uid": "704e636b49fb2d65e51954d6fa3e8de7", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#define mod 1000000007\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n__attribute__((always_inline, optimize(3)))\n__inline__ void add(int *x, int y) {\n\t(*x += y) >= mod && (*x -= mod);\n}\n__attribute__((always_inline, optimize(3)))\n__inline__ int mul(int x, int y) {\n\treturn (long long)x * y - (long long)x * y / mod * mod;\n}\n__attribute__((always_inline, optimize(3)))\n__inline__ int f(int n, int x, int y) {\n\tint tmp = 1 << x;\n\ty && (tmp *= 3);\n\treturn n / tmp;\n}\n#ifdef __cplusplus\n}\n#endif\nint main() {\n\tint n, p = 0; scanf(\"%d\", &n);\n\tstatic int dp[1000005][21][2] = { };\n\twhile ((1 << p) <= n) ++ p; dp[1][-- p][0] = 1;\n\tif ((3 << p - 1) <= n) dp[1][p - 1][1] = 1;\n\tfor (int i = 1; i < n; ++ i)\n\t\tfor (int x = 0; x <= p; ++ x)\n\t\t\tfor (int y = 0; y < 2; ++ y) {\n\t\t\t\tadd(dp[i + 1][x] + y, mul(dp[i][x][y], f(n, x, y) - i));\n\t\t\t\tx && (add(dp[i + 1][x - 1] + y, mul(dp[i][x][y], f(n, x - 1, y) - f(n, x, y))), 0);\n\t\t\t\ty && (add(dp[i + 1][x] + y - 1, mul(dp[i][x][y], f(n, x, y - 1) - f(n, x, y))), 0);\n\t\t\t}\n\tprintf(\"%d\\n\", dp[n][0][0]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "ee397f145dd6c11e25ce78eaf547df84", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n\nint main(void)\n{\n int n, m, a, b = 1, ans = 3;\n scanf(\"%d%d%d%d\", &n, &m, &a, &b);\n if (a % m == 1 || m == 1){\n ans--;\n }\n if (b % m == 0 || b == n){\n ans--;\n }\n if ((b - 1) / m == (a - 1) / m){\n printf(\"1\");\n return 0;\n }\n if (ans == 3 && (a % m - 1 == b % m || (a % m == 0 && b % m == m - 1) ||(b - 1) / m - (a - 1) / m == 1)){\n ans--;\n }\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "6c09ae051952ba94dd692a0eb7940eba", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\ntypedef unsigned int u_int;\nint main(void){\n u_int m,n,a,b,a_pos,b_pos,a_line,b_line,k;\n scanf(\"%u %u %u %u\",&m,&n,&a,&b);\n a_pos=(a-1)%n+1;\n b_pos=(b-1)%n+1;\n a_line=(a-1)/n;\n b_line=(b-1)/n;\n if(b==m) b_pos=n;\n if(a_line==b_line){\n k=1;\n }else if(a_pos==1 && b_pos==n){\n k=1;\n }else if(a_pos==1 || b_pos==n){\n k=2;\n }else if(b_pos+1==a_pos){\n k=2;\n }else if(a_line+1==b_line){\n k=2;\n }else{\n k=3;\n }\n printf(\"%d\\n\",k);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "6c0cf274f814dedf55ced6cd72af2cba", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint main() {\r\n int t, n, a, b, c;\r\n\r\n scanf(\"%d\", &t);\r\n while(t--) {\r\n scanf(\"%d\", &n);\r\n for(a = 0; (a + 1) * (a + 1) <= n; a++);\r\n for(b = 0; (b + 1) * (b + 1) * (b + 1) <= n; b++);\r\n for(c = 0; (c + 1) * (c + 1) * (c + 1) * (c + 1) * (c + 1) * (c + 1) <= n; c++);\r\n printf(\"%d\\n\", a + b - c);\r\n }\r\n\r\n return 0;\r\n}", "lang_cluster": "C", "tags": ["math", "implementation"], "code_uid": "a4d1bfa710894cd352350930667f560c", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\r\nint main()\r\n{\r\n int t;\r\n scanf(\"%d\",&t);\r\n for(int z=0;zn && k*k*k>n)\r\n {\r\n break;\r\n }\r\n else\r\n {\r\n if(j*j\n#include\n#include\n#include\n#include\n#include\n#define YAZ printf\n#define OKU scanf\n#define R return 0\n#define A %d\n#define B %c\n#define FOR for\n#define a b\n#define sa as\n#define s d\nint na, q, i, j, k, l, m, n, yer = 1, sum, sonuc;\nchar a1[100], a2[100], b[400] , x, s[10], cvp[1000000][10];\n\n\nint main () {\n\tOKU(\"%d %d%c\",&na ,&q,&x);\n\tfor(i =1 ; i <= q ; i++)\n\t\tOKU(\"%c%c %c%c\",&a1[i] ,&a2[i] ,&b[i] ,&x);\n\tfor(i = 0 ; i <= 5 ; i++)\n\t\t\tfor(j = 0 ; j <= 5 ; j++)\n\t\t\t\tfor(k = 0 ; k <= 5 ; k++)\n\t\t\t\t\tfor(l = 0 ; l <= 5 ; l++)\n\t\t\t\t\t\tfor(m = 0 ; m <= 5 ; m++)\n\t\t\t\t\t\t\tfor(n = 0; n <= 5 ; n++){\n\t\t\t\t\t\t\t\ts[0] = i+'a';s[1] = j+'a';s[2] = k+'a';s[3] = l+'a';s[4] = m+'a';s[5] = n+'a';s[na] = '\\0';\n\t\t\t\t\t\t\t\tif(strcmp(cvp[yer-1],s))\n\t\t\t\t\t\t\t\t\tstrcpy(cvp[yer++],s);\n\t\t\t\t\t\t\t}\n\tfor(i = 1; i <= yer ; i++){\n\t\tfor(j = 0 ; j <= na-1 ; j++){\n\t\t\tfor(k = 1 ; k <= q ; k++){\n\t\t\t\tif(cvp[i][j] == a1[k] && cvp[i][j+1] == a2[k]){\n\t\t\t\t\tcvp[i][j] = ' ';\n\t\t\t\t\tcvp[i][j+1] = b[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(i = 1 ; i <=yer ; i++){\n\t\tsum = 0;\n\t\tfor(j = 0 ; j <= na ; j++){\n\t\t\tif(cvp[i][j] >= 'a' && cvp[i][j] <= 'z')\n\t\t\t\tsum += cvp[i][j] - 'a' + 1;\n\t\t}\n\t\tif(sum == 1)\n\t\t\tsonuc++;\n\t}\n\tYAZ(\"%d\\n\",sonuc);\n\tR;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "strings", "dp", "brute force"], "code_uid": "c8d3482e16b18d5c5a222c22d4734661", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tint i, j, k, n, q;\n\tstatic char ab[36][6];\n\tstatic int dp[6][6];\n\n\tscanf(\"%d%d\\n\", &n, &q);\n\tfor (i = 0; i < q; i++)\n\t\tfgets(ab[i], 6, stdin);\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' == ab[k][3])\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": "94498c18d1b8e57cf5eda42f9bf0f64d", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong long int dp[1005][1005],c[1005],d[1005],c0,d0;\nlong long int max(long long int b,long long int h)\n\t\t{ if(h>b)\n\t\t\treturn h;\n\t\t\telse\n\t\t\t\treturn b; }\nlong long int func(long long int n,long long int i)\n\t\t{\tif(i<0||n<=0)\n\t\t\t\treturn 0;\n\t\t\tif(i==0&&n=0)\n\t\t{ if(dp[n][i]==-1)\n\t\t\tdp[n][i]=func(n,i);\n\t\t\tj=max(j,dp[n][i]+x);\n\t\t\tn=n-c0;\n\t\t\t\tx=x+d0; }\n\tprintf(\"%lld\\n\",j);\n\t\t\treturn 0; }\t\t\t\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "dc7c3d642c901bf533c0d0b7dce296f0", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint min(int a, int b)\n{\n if (a < b) {\n\t return a;\n } else {\n\t return b;\n }\n}\n\nint main()\n{\n int n, m, c0, d0, max = 0, i, j, k;\n int a[10], b[10], c[10], d[10];\n int dp[1005] = {0};\n\n scanf(\"%d %d %d %d\", &n, &m, &c0, &d0);\n\n for (i = 0; i < m; i++) scanf(\"%d %d %d %d\", &a[i], &b[i], &c[i], &d[i]);\n\n for (i = 0; i < m; i++) {\n\t for (j = n; j > 0; j--) {\n\t if (dp[j] > 0) {\n\t\t for (k = min((n - j) / c[i], a[i] / b[i]); k > 0; k--) {\n\t\t\t if (j + k * c[i] > n) continue;\n\n\t\t\t if (dp[j + k * c[i]] < dp[j] + d[i] * k) {\n\t\t\t dp[j + k * c[i]] = dp[j] + d[i] * k;\n\t\t\t }\n\t\t }\n\t }\n\t }\n\n\t for (k = min(n / c[i], a[i] / b[i]); k > 0; k--) {\n\t if (k * c[i] > n) continue;\n\n\t if (dp[k * c[i]] < d[i] * k) {\n\t\t dp[k * c[i]] = d[i] * k;\n\t }\n\t }\n }\n\n for (j = n; j > 0; j--) {\n\t if (dp[j] > 0) {\n\t for (k = (n - j) / c0; k > 0; k--) {\n\t\t if (j + k * c0 > n) continue;\n\n\t\t if (dp[j + k * c0] < dp[j] + d0 * k) {\n\t\t\t dp[j + k * c0] = dp[j] + d0 * k;\n\t\t }\n\t }\n\t }\n }\n\n for (k = (n - j) / c0; k > 0; k--) {\n\t if (k * c0 > n) continue;\n\n\t if (dp[k * c0] < d0 * k) {\n\t dp[k * c0] = d0 * k;\n\t }\n }\n\n for (i = 0; i <= n; i++) {\n\t if (dp[i] > max) max = dp[i];\n }\n\n printf(\"%d\\n\", max);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "8fd06aec0f3e8c2804d6785024402dc6", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nlong long int k,i,j,max,min,S;\n\nint main()\n{\n int n,m,x,y;\n \n scanf(\"%d%d%lld%d%d\",&n,&m,&k,&x,&y);\n \n if(n*m > k)\n {\n max = 1;\n min = 0;\n if((x-1)*m+y <= k)S = 1;\n else S = 0;\n }\n else if(n <= 2)\n {\n min = k/(m*n);\n max = (k%(m*n) == 0)?min:min + 1;\n \n if(max == min)S = max;\n else\n {\n if(n == 1)\n {\n if(k%m >= y)S = max;\n else S = min;\n }\n else\n {\n j = k%(m*n);\n if(j > m)\n {\n if(x == 2 && j-m < y)S = min;\n else S = max;\n }\n else\n {\n if(x == 1 && j >= y)S = max;\n else S = min;\n }\n }\n }\n }\n else\n {\n i = k/(m*(2*n-2));\n j = k%(m*(2*n-2));\n max = i*2;\n min = i;\n if(j == 0)\n {\n if(x == 1 || x == n)S = min;\n else S = max;\n }\n else\n {\n if(j <= m)\n {\n if(x == 1)\n {\n if(y > j)S = min;\n else S = min+1;\n }\n else if(x == n)S = min;\n else S = max;\n }\n else if(j <= m*(n-1))\n {\n max++;\n if(x == 1)S = min+1;\n else if(x == n)S = min;\n else \n {\n if((x-1)*m+y <= j)S = max;\n else S = max-1;\n }\n }\n else if(j <= m*n)\n {\n max++;\n if(j == m*n)min++;\n if(x == 1)S = i+1;\n else if(x == n)\n {\n if(y <= j%m || j%m == 0)S = i+1;\n else S = i;\n }\n else S = max;\n }\n else\n {\n max+=2;\n min++;\n if(x == 1)S = i+1;\n else if(x == n)S = i+1;\n else\n {\n S = i*2+1;\n j-=m*n;\n if(j%m == 0)\n {\n if(x + j/m > (n-2))S++;\n }\n else\n {\n if(x + j/m > (n-1))S++;\n else if(x + j/m == (n-1))\n {\n if(j%m >= y||j%m == 0)S++;\n }\n }\n }\n }\n }\n }\n \n printf(\"%lld %lld %lld\\n\",max,min,S);\n}", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "562a071cbda3568028b25a9eafb76850", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n * =====================================================================================\n *\n * Filename: main.c\n *\n * Description: \n *\n * Version: 1.0\n * Created: 19/01/17 18:42:01\n * Revision: none\n * Compiler: gcc\n *\n * Author: YOUR NAME (), \n * Company: \n *\n * =====================================================================================\n */\n#include \n#include \n\nint64_t max(int64_t x, int64_t y)\n{\n if (x > y)\n return x;\n else\n return y;\n}\n\n#define div(a, b, c) ( ((a)-(b)-1) / (c) + ((b) < (a)))\n\nint64_t count(int64_t n, int64_t m, int64_t k, int64_t x, int64_t y)\n{\n if (n != 1) {\n if (x == 0 || x == n - 1)\n //return div(k - y - x*m, 2*(n-1)*m);\n return div(k, x*m+y, 2*(n-1)*m);\n else\n //return div(k - y - x*m, 2*(n-1)*m) + div(k - y - m*(2*n - 2 - x), 2*(n-1)*m);\n return div(k, x*m+y, 2*(n-1)*m) + div(k, (2*n-2-x)*m+y, 2*(n-1)*m);\n } else {\n //return div(k - y - x*m, n*m);\n return div(k, y, n*m);\n }\n}\n\nint\nmain()\n{\n int64_t n, m, k, x, y;\n scanf(\"%\"SCNd64\"%\"SCNd64\"%\"SCNd64\"%\"SCNd64\"%\"SCNd64, &n, &m, &k, &x, &y);\n x--; y--;\n if (n == 1)\n printf(\"%\"PRId64\" %\"PRId64\" %\"PRId64\"\\n\", \n count(n, m, k, 0, 0), \n count(n, m, k, 0, m-1), \n count(n, m, k, x, y));\n else\n printf(\"%\"PRId64\" %\"PRId64\" %\"PRId64\"\\n\", \n max(max(count(n, m, k, 0, 0), count(n, m, k, 1, 0)), count(n, m, k, n-2, 0)), \n -max(-count(n, m, k, 0, m-1), -count(n, m, k, n-1, m-1)), \n count(n, m, k, x, y));\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms", "binary search", "implementation"], "code_uid": "65c005d1d28c40f19215bacc256c92c0", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\ntypedef long long ll;\nchar op[205];\n\nint main()\n{\n ll n, m, c, i, j=0, t;\n scanf(\"%I64d\", &n);\n scanf(\"%I64d\", &m);\n t=n+m;\n for(i=2;jm)\n {\n n--;\n j++;\n }\n else\n {\n m--;\n j++;\n }\n c=i;\n }\n else if(i%2==0&&n>0)\n {\n n--;\n j++;\n c=i;\n }\n else if(i%3==0&&m>0)\n {\n m--;\n j++;\n c=i;\n }\n }\n printf(\"%I64d\", c);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "19bb1e0c072129209b471e5f207d3fb9", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nint main(){\n\tint n, m, i, comm,d2,d3;\n\tscanf(\"%d %d\",&n,&m);\n\ti=1;\n\tcomm=0;\n\twhile((n+m)>comm){\n\t\td2=1;d3=0;\n\t\tif(i&1)\n\t\t\td2=0;\n\t\tif((i/3)*3==i)\n\t\t\td3=1;\n\t\tif(d3 && d2)\n\t\t\tcomm++;\n\t\telse if(d2 && n)\n\t\t\tn--;\n\t\telse if(d3 && m)\n\t\t\tm--;\n\t\ti++;\n\t}\n\tprintf(\"%d\\n\",i-1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory", "brute force"], "code_uid": "35d808f41d94299da698f828dc3ff1b1", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n// program by Mircea Rebengiuc\n// written for codeforces round 747D2\n// written on 2021.10.08\n\n#define MOD 1000000007\n#define INV3 333333336LL\n\nint main(){\n int n, i, num = 6;\n\n scanf(\"%d\", &n);\n for( n-- ; n-- ; ){\n num = (8 * ((((long long)num) * num) % MOD)) % MOD;\n num = (INV3 * num) % MOD;\n }\n\n printf(\"%d\\n\", num);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "ad21f3faa70f8792c0eb96fa29962845", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma c11 on\n\n#include\n#include\n#include\n#include\n#include\n#include\n#define MOD (int)(1e9+7)\nlong long quickPow(long long n, long long powers) {\n long long res = 1;\n while (powers > 0) {\n if (powers & 1)\n res =res * n%MOD;\n n = n*n%MOD;\n powers >>= 1;\n }\n return res;\n}\nint main(void){\n int k;\n scanf(\"%d\",&k);\n printf(\"%lld\",(6*quickPow(4, (((long long)1<\n#include \n#include \n\nint permututation[8] = {0, 1, 2, 3, 4, 5, 6, 7};\nchar s[8][9];\nchar per[8][9];\nint value[8];\n\nvoid swap(int *a, int *b){\n int temp = *a;\n *a = *b;\n *b = temp;\n}\n\nint main(){\n int n, k, t, i, j, a, b, min, max;\n int result = 99999999;\n scanf(\"%d%d\", &n, &k);\n for (i=0; i value[i]) min = value[i];\n if(max < value[i]) max = value[i];\n }\n //printf(\"%d %d\\n\", min, max);\n if (result > max - min) {\n result = max - min;\n }\n //printf(\"%d\\n\", result);\n i=k-2;\n while (i>=0 && permututation[i] > permututation[i+1]) {\n i--;\n }\n if (i>=0) {\n j=k-1;\n while (permututation[j] < permututation[i]) {\n j--;\n }\n swap(&permututation[i], &permututation[j]);\n a = i+1;\n b = k-1;\n while (a < b) {\n swap(&permututation[a], &permututation[b]);\n a++;\n b--;\n }\n }\n }while (i>=0);\n printf(\"%d\\n\", result);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "combinatorics"], "code_uid": "92fa6017dcc93fc4d1c32dbb92054830", "src_uid": "08f85cd4ffbd135f0b630235209273a4", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define bool int\n#define true 1\n#define false 0\n\n#define swap(a,b) {*(a)=*(a)^*(b);*(b)=*(a)^*(b);*(a)=*(a)^*(b);}\n\nbool next_permutation(int *a,int len)\n{\n if(len == 1)\n return false;\n int i,j;\n int left;\n i = len - 1;\n left = len;\n for(i; i>0; i--)\n if(a[i] > a[i-1])\n {\n left = i - 1;\n break;\n }\n if(left == len)\n return false;\n if(left == len - 2)\n {\n swap(&a[left],&a[left+1]);\n return true;\n }\n i = len - 1;\n for(i; i>left; i--)\n if(a[i] > a[left])\n {\n swap(&a[i],&a[left]);\n break;\n }\n i = len - 1;\n j = left + 1;\n for(i,j; i>j; i--,j++)\n swap(&a[i],&a[j]);\n return true;\n}\n\nint diff(char **a,int len)\n{\n int *num;\n num = (int*)malloc(sizeof(int) * len);\n int i,max,min;\n for(i=0; imax)\n max=num[i];\n else if(num[i]\n\nint main() {\n\tlong long int i, n, k, ans, mod;\n\tscanf(\"%I64d%I64d\", &n, &k);\n\tmod = 1000000007;\n\tans = 1;\n\tfor (i = 1; i <= k - 1; ++i)\n\t\tans *= k;\n\tfor (i = 1; i <= n - k; ++i)\n\t\tans = (ans % mod * ((n - k) % mod)) % mod;\n\tprintf(\"%I64d\\n\", ans % mod);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "combinatorics", "brute force"], "code_uid": "abc65d7e46279fd16d8d3b91506821ed", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint a[8] = {1, 2, 9, 64, 625, 7776, 117649, 2097152};\nint m = 1000000007;\n\nlong long mod_pow(long long x, long long y)\n{\n long long ans = 1;\n \n while (y) {\n if (y & 1) ans = ans * x % m;\n \n x = x * x % m;\n y >>= 1;\n }\n \n return ans;\n}\n\nint main()\n{\n int n, k, i;\n long long ans;\n \n scanf(\"%d %d\", &n, &k);\n \n ans = a[k - 1];\n \n ans = ans * mod_pow(n - k, n - k) % m;\n \n printf(\"%d\\n\", (int)ans);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "ddcc9389a97b0b621050a4031c6ab15a", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t100\n#define K\t(N * N)\n#define MD\t1000000007\n\nlong long power(int a, long long k) {\n\tlong long p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k / 2);\n\tp = p * p % MD;\n\tif (k % 2)\n\t\tp = p * a % MD;\n\treturn p;\n}\n\nint main() {\n\tstatic int ch[N + 1][N + 1], pp[N + 1][N + 1], dp[N + 1][K + 1];\n\tint n, k, h, i, j;\n\tlong long m;\n\n\tscanf(\"%d%lld%d\", &n, &m, &k);\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\tfor (i = 0; i <= n; i++)\n\t\tfor (j = 0; j <= i; j++)\n\t\t\tpp[i][j] = power(ch[i][j], m / n);\n\tdp[0][0] = 1;\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j <= k; j++) {\n\t\t\tint x = dp[i][j];\n\n\t\t\tif (x == 0)\n\t\t\t\tcontinue;\n\t\t\tfor (h = 0; h <= n && j + h <= k; h++)\n\t\t\t\tdp[i + 1][j + h] = (dp[i + 1][j + h] + (long long) x * pp[n][h] % MD * (i < m % n ? ch[n][h] : 1)) % MD;\n\t\t}\n\tprintf(\"%d\\n\", dp[n][k]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks"], "code_uid": "9263c2904782da034d19c0f1a9e90bd5", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define maxn 111\n\nconst int mod = (int) 1e9 + 7;\n\nlong long choose[maxn][maxn];\n\nlong long f[maxn][10001];\nlong long g[maxn][maxn];\n\nlong long power( long long a, long long b ) {\n\tlong long ret = 1;\n\t\n\ta %= mod;\n\twhile( b > 0 ) {\n\t\tif( b % 2 ) {\n\t\t\tret = (ret * a) % mod;\n\t\t}\n\t\t\n\t\tb /= 2;\n\t\ta = (a * a) % mod;\n\t}\n\t\n\treturn ret;\n}\n\nint main( void ) {\n\tlong long n, m, k;\n\tscanf(\"%lld %lld %lld\", &n, &m, &k);\n\t\n\tfor( int i = 0; i < maxn; i++ ) {\n\t\tchoose[i][0] = choose[i][i] = 1;\n\t\tfor( int j = 1; j < i; j++ ) {\n\t\t\tchoose[i][j] = (choose[i-1][j] + choose[i-1][j-1]) % mod;\n\t\t}\n\t}\n\t\n\tfor( int i = 1; i <= n; i++ ) {\n\t\tfor( int c = 0; c <= n; c++ ) {\n\t\t\tlong long count = (m / n) + (m % n >= i ? 1 : 0);\n\t\t\tg[i][c] = power(choose[n][c], count);\n\t\t}\n\t}\n\t\n\tf[1][0] = 1;\n\tfor( int i = 1; i <= n; i++ ) {\n\t\tfor( int j = 0; j <= k; j++ ) if( f[i][j] > 0 ) {\n\t\t\tfor( int c = 0; c <= n; c++ ) {\n\t\t\t\tif( j + c > k ) break;\n\t\t\t\tlong long nways = (g[i][c] * f[i][j]) % mod;\n\t\t\t\tf[i+1][j+c] = (f[i+1][j+c] + nways) % mod;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprintf(\"%lld\\n\", f[n+1][k]);\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks"], "code_uid": "3b3b98955e71e4f0c23f0afb2622a403", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define max(a,b) a>b?a:b\nint main() \n{ \n int n,i; \n scanf(\"%d\",&n); \n for(i=1;(i*i+1)/2\n\nconst int ans[] = {0,1,3,5,3,3,5,5,5,5,5,5,5,5,7,7,7,7,7,7,7,7,7,7,7,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15};\nint main() {\n//\tfreopen(\"input.txt\",\"r\",stdin);\n//\tfreopen(\"output.txt\",\"w\",stdout);\n\tint n;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\\n\",ans[n]);\n}", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "41c5cdbb7f3f89ed7c7190dd8d289b1d", "src_uid": "01eccb722b09a0474903b7e5abc4c47a", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint len;\nchar ph[51];\nlong dp[51][10];\n\nlong f(int pos,int val)\n{\n if(dp[pos][val]!=0)\n return dp[pos][val];\n \n int sum = val+ph[pos+1]-'0';\n \n if(pos==len-2)\n {\n \t dp[pos][val]=sum%2==0?1:2;\n \t return dp[pos][val];\n\t }\n long c=0; \n if(sum%2==0)\n c= f(pos+1,sum/2);\n\t else\n\t c=f(pos+1,sum/2)+f(pos+1,sum/2+1);\n\t \n dp[pos][val]=c;\n \n \n return c;\n \n}\nint main()\n{\n\t\n\tscanf(\"%s\",ph);\n\tlen=strlen(ph);\n\tint i,check=1;\n\tlong long c=0;\n\tfor(i=0;len!=1&&i<=9;i++)\n\t{ c+= f(0,i);\n\t} \n\t \n/*\tfor(i=0;i\n#include\n\nint main()\n{\n int x, y, X, Y, i;\n scanf(\"%d %d\", &x, &y);\n \n if((x == 0) || (y == 0)) \n {\n printf(\"black\");\n }\n else\n { \n X = fabs(x);\n Y = fabs(y);\n\n int max = X, min = Y;\n if(X < Y)\n {\n max = Y;\n min = X;\n }\n\n for( i = max; i < 1500; i++)\n {\n if( ((max*max) + (min*min)) < (i*i) )\n {\n if( (i&1) == 0)\n {\n if( (x*y) > 0)\n {\n printf(\"white\");\n break;\n }\n else\n {\n printf(\"black\");\n break;\n } \n }\n else\n {\n if( (x*y) > 0)\n {\n printf(\"black\");\n break;\n }\n else\n {\n printf(\"white\");\n break;\n } \n }\n \n }\n else if( ((max*max) + (min*min)) == (i*i) )\n {\n printf(\"black\");\n break;\n } \n } \n }\n return 0; \n}", "lang_cluster": "C", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "33f21e077e58cb5297db949df801c429", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nbool is_white(int x, int y);\n\nint main() {\n\tint x, y;\n\t\n\tscanf(\"%d %d\", &x, &y);\n\t\n\tprintf(\"%s\\n\", is_white(x, y)?\"white\":\"black\");\n\t\n\treturn 0;\n}\n\nbool is_white(int x, int y) {\n\tif(x==0 || y==0)\n\t\treturn false;\n\t\n\tbool b = true;\n\tint sqrt = 0, r = 0;\n\t\n\tr = x*x +y*y;\n\t\n\tsqrt = 0;\n\t\n\twhile((sqrt)*(sqrt)<=r)\n\t\tsqrt++;\n\t\n\tsqrt--;\n\t\n\tif(sqrt*sqrt==r)\n\t\treturn false;\n\t\n\tb = sqrt%2 == 1;\n\t\n\tif(x*y < 0)\n\t\tb = !b;\n\t\n\treturn b;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry", "constructive algorithms", "implementation"], "code_uid": "33c0778b625d6f6e3a4efe7817ee7621", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "long long x,y,m,c;\n\nint main()\n{\n\twhile(~scanf(\"%lld%lld%lld\",&x,&y,&m))\n\t{\n\t\tc=0;\n\t\tif(x>=m||y>=m)\n\t\t{\n\t\t\tprintf(\"%lld\\n\",c);\n\t\t\tbreak;\n\t\t}\n\t\tif(x>y) x^=y^=x^=y;\n\t\tif(x<0&&y>0)\n\t\t{\n\t\t\tc=(-x)/y+1;\n\t\t\tx+=c*y;\n\t\t}\n\t\twhile(1)\n\t\t{\n\t\t\tif(x>=m||y>=m)\n\t\t\t{\n\t\t\t\tprintf(\"%lld\\n\",c);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(x>y) x^=y^=x^=y;\n\t\t\tx=y+x;\n\t\t\tc++;\n\t\t\tif(x<=0&&y<=0)\n\t\t\t{\n\t\t\t\tputs(\"-1\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "818cf29b714642bf12b0771ada39b413", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main() \n{\n\tlong long int x,y,m,cnt=0;\n\tscanf(\"%lld\",&x);\n\tscanf(\"%lld\",&y);\n\tscanf(\"%lld\",&m);\n\tif(x>=m || y>=m)\n\t{\n\t\tprintf(\"%d\\n\",0);\n\t\treturn 0;\n\t}\n\tif(x<=0 && y<=0)\n\t{\n\t\tprintf(\"%d\\n\",-1);\n\t\treturn 0;\n\t}\n\tif(x>y)\n\t{\n\t\tlong long int tmp = x;\n\t\tx=y;\n\t\ty=tmp;\n\t}\n\tif(x<0)\n\t{\n\t\tcnt += -x/y;\n\t\tx+=y * cnt;\n\t}\n\twhile(x\nlong long sumOf(long long x){\n\treturn (x*(x+1))/2;\n}\nint main(void) {\n\tlong long x,k;\n\tlong long ans;\n\tscanf(\"%lld %lld\",&x,&k);\n\tif(x==1){\n\t\tprintf(\"0\");\n\t\treturn 0;\n\t}\n\tif(k>=(x/2)){\n\t\tprintf(\"%lld\\n\",sumOf(x-1));\n\t\treturn 0;\n\t} else {\n\t\tans = 2*k*x-sumOf(2*k);\n\t\tprintf(\"%lld\\n\",ans);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "b0bec88aacecd55667bff38f424339ae", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int n,k;\n scanf(\"%lld%lld\",&n,&k);\n if(k<=n/2)\n {\n printf(\"%lld\",k*(2*n-2*k-1));\n }\n else printf(\"%lld\",(n)*(n-1)/2);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "31496f4f3f4040bdd7dfa845a8769669", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n#include \n\n#define N\t24\n\nint compare(const void *a, const void *b) {\n\tint ia = *(int *) a;\n\tint ib = *(int *) b;\n\n\treturn ia - ib;\n}\n\nint main() {\n\tstatic int cc[N], ss[N], aa[1 << N - 1], dp[1 << N - 1];\n\tint n, m, i, j, k, b;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &cc[i]);\n\tqsort(cc, n, sizeof *cc, compare);\n\tk = 0;\n\twhile (k < n && cc[k] == 1)\n\t\tk++;\n\tm = n - k;\n\tfor (i = k; i < n; i++)\n\t\tss[i - k] = cc[i] - 1;\n\tfor (j = 1; j < m; j++)\n\t\tss[j] += ss[j - 1];\n\tn--;\n\tfor (b = 1; b < 1 << n; b++) {\n\t\ti = 0;\n\t\twhile ((b & 1 << i) == 0)\n\t\t\ti++;\n\t\taa[b] = aa[b ^ 1 << i] + cc[i];\n\t}\n\tmemset(dp, -1, (1 << n) * sizeof *dp), dp[0] = 0;\n\tfor (b = 0; b < 1 << n; b++) {\n\t\tj = dp[b];\n\t\tif (j == -1 || j == m)\n\t\t\tcontinue;\n\t\tfor (i = 0; i < n; i++)\n\t\t\tif ((b & 1 << i) == 0) {\n\t\t\t\tint b_ = b ^ 1 << i;\n\n\t\t\t\tif (aa[b_] < ss[j])\n\t\t\t\t\tdp[b_] = j;\n\t\t\t\telse if (aa[b_] == ss[j] && aa[b] > (j == 0 ? 0 : ss[j - 1]))\n\t\t\t\t\tdp[b_] = j + 1;\n\t\t\t}\n\t}\n\tprintf(dp[(1 << n) - 1] == m ? \"YES\\n\" : \"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "dp", "bitmasks", "greedy", "trees"], "code_uid": "3408cdd57bf917f2f403e2967da4f11d", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\ntypedef long long int lli;\n\n#define TRUE (1==1)\n#define FALSE (!TRUE)\n\n#define fo3(a,b,c) for(a=(int)(b);a<=(int)(c);a++)\n#define of3(a,b,c) for(a=(int)(b);a>=(int)(c);a--)\n#define in32(a) scanf(\"%d\",&(a))\n#define in64(a) scanf(\"%I64d\",&(a))\n#define out32(a) printf(\"%d\\n\",(a))\n#define out64(a) printf(\"%I64d\\n\",(a))\n#define instr(a) scanf(\"%s\",(a))\n#define outstr(a) printf(\"%s\\n\",(a))\n#define max(a,b) (((a)<(b))?(b):(a))\n#define min(a,b) (((a)>(b))?(b):(a))\n\nlli gcd(lli a, lli b) {\n return (b == 0) ? a : gcd(b, a % b);\n}\nlli lcm(lli a, lli b) {\n lli g = gcd(a, b);\n return a * (b / g);\n}\n\nint facts(lli val, lli * arr, int st) {\n if (val == 1) {\n arr[0] = 1;\n return 1;\n }\n int i = st,k;\n while (i * i <= val) {\n if (val % i == 0) {\n int pow = 0;\n while (val % i == 0) {\n pow ++;\n val/=i;\n }\n int cur = facts(val,arr,i+1);\n int res = cur * (pow + 1);\n fo3(k,cur,res-1)\n arr[k] = arr[k-cur]*i;\n return res;\n }\n i++;\n }\n arr[0] = 1;\n arr[1] = val;\n return 2;\n}\n\n#define MOD 1000000007\n#define SENT -1\nlli memo[1010][1010];\n\nlli rec(int a, int b) {\n if (a == 0 && b == 0)\n return 0;\n if (a < 0)\n return 0;\n if (b < 0)\n return 0;\n if (a < b)\n return 0;\n if (memo[a][b] != SENT)\n return memo[a][b];\n int ret = 0;\n if ((a+b)&1)\n ret = 1;\n ret += rec(a-1,b);\n ret += rec(a,b-1);\n while(ret>=MOD)\n ret-=MOD;\n memo[a][b] = ret;\n return ret;\n}\n\nint main(void)\n{\n int n,i,j;\n in32(n);\n fo3(i,0,n)\n fo3(j,0,n)\n memo[i][j] = SENT;\n out64(rec(n,n));\n return EXIT_SUCCESS;\n}", "lang_cluster": "C", "tags": ["greedy", "dp", "trees"], "code_uid": "5a30d405f5422a9380a1da6facb6b7a1", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nvoid run (void) {\n i32 n = read_int();\n i32 *dp = (i32 *) calloc (n + 3, sizeof (i32)) + 1;\n const i32 mod = 1000000000 + 7;\n dp[0] = 1;\n i32 ans = 0;\n for (i32 i = 1; i <= n; ++i) {\n if ((i & 1) == 0) {\n for (i32 j = i - 1; j >= 0; j -= 2) {\n\tans = (ans + dp[j]) % mod;\n }\n }\n for (i32 j = i; j >= 0; j -= 2) {\n i32 v = (dp[j - 1] + dp[j + 1]) % mod;\n dp[j] = v;\n }\n }\n for (i32 i = n - 1; i >= 0; --i) {\n if ((i & 1) == 0) {\n for (i32 j = i + 1; j >= 0; j -= 2) {\n\tans = (ans + dp[j]) % mod;\n }\n }\n for (i32 j = i; j >= 0; j -= 2) {\n i32 v = (dp[j - 1] + dp[j + 1]) % mod;\n dp[j] = v;\n }\n }\n print_int (ans);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "trees"], "code_uid": "902c6967b397224eba63ad307fe82595", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\nint main()\n{\n int n,k;\n while(~scanf(\"%d%d\",&n,&k))\n {\n int a[100],i,vis[100],money=0;\n memset(vis,0,sizeof(vis));\n for(i=0;i1&exit[a[i]]==0&flag==0)\n {\n money++;\n booknum++;\n exit[a[i]]=1;\n //printf(\"money2=%d booknum=%d\\n\",money,booknum);\n flag=1;\n vis[a[i]]--;\n }\n if(booknum==k&exit[a[i]]==0&flag==0)\n {\n int j,exit1[100],b[100],k=-1;\n memset(exit1,0,sizeof(exit1));\n if(i+1==n)\n {\n money++;\n break;\n }\n for(j=i+1;j\nint main(){\n int i,j,n,m,k,stock[81]={0},temp=0,count=0,ans = 0, a[81],check[81]={0};\n scanf(\"%d %d\",&n ,&k);\n for(j=1;j<=n;j++)\n scanf(\"%d\",&a[j]);\n stock[a[1]]++;\n ans++;\n count++;\n for(j=2;j<=n;j++){\n if(stock[a[j]] == 1) continue;\n if(count == k){\n for(i=0; i<81; i++)\n check[i] = 0;\n temp = count;\n for(i=j+1; i<=n; i++){\n if(temp == 1){\n for(m=1; m<81; m++)\n if(check[m] == 0 && stock[m] == 1){\n stock[m] = 0;\n count--;\n break;\n }\n break;\n }\n if(stock[a[i]] == 1 && check[a[i]] == 0){\n temp--;\n check[a[i]] = 1;\n }\n }\n\n for(m=1; m<81; m++)\n if(check[m] == 0 && stock[m] == 1){\n stock[m] = 0;\n count--;\n }\n\n }\n stock[a[j]] = 1;\n count++;\n ans++;\n /*printf(\"%d\\t\",ans);\n for(i=0; i<81;i++)\n if(stock[i]) printf(\"%d \",i);\n printf(\"\\n\");*/\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "b09dc661396e41c2722b7efc7e7d10e7", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\n#define MIN(a, b) ((a)<(b)?(a):(b))\n#define MAX(a, b) ((a)>(b)?(a):(b))\n\n#define MOD 1e9+7\n#define M 25\n\nint a[5]= {0,0,1,3,6};\n\nint main() {\n int n;\n// freopen(\"1.txt\", \"r\", stdin);\n// freopen(\"2.txt\", \"w\", stdout);\n while(scanf(\"%d\", &n)!=EOF) {\n if (n < 5) {\n printf(\"%d\\n\",a[n]);\n continue;\n }\n long long s = 0LL, t=5LL,i;\n for(i = 1; i <10; i++) {\n if (n >=t) {\n t*=10;\n } else {\n break;\n }\n }\n t/=10;\n for(i=1; i<=5; i++) {\n if(n>t*i*2+t-1) {\n s+=2*t*i;\n s--;\n } else {\n i--;\n break;\n }\n }\n s+=(n-t*i*2-t+1)*(i+1);\n if(n>=t+t-1+i*(t*10/5)) {\n s--;\n }\n printf(\"%d\\n\",s);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "3cb54bf3342f0fb07d26f7172f96ed8d", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint Cnt[10];\n\nint main()\n{\n int table[] = {999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9};\n int n, reamin = 0, ans = 0;\n scanf(\"%d\", &n);\n for(int i = 0; i < 9; ++i) {\n if(n + n - 1 >= table[i]) {\n reamin = table[i];\n break;\n }\n }\n if(reamin == 0) {\n printf(\"%d\\n\", n * (n - 1) / 2);\n return 0;\n }\n for(int i = 0; i < 9; ++i) {\n long long expect = (long long)(reamin + 1) * i + reamin;\n if(n + n - 1 >= expect) {\n if(expect <= n) {\n ans += expect / 2;\n } else {\n ans += n - expect / 2;\n }\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "constructive algorithms"], "code_uid": "5eff00fb58be0774e12e9725b52e0f14", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n static long long mod = 1000000007;\n static int gcds[4001][4001];\nint gcd(int a, int b)\n{\n if(gcds[a][b] != 0) return gcds[a][b];\n if(b==0) return a;\n return gcds[a][b] = gcd(b, a%b);\n}\nint abs(int a)\n{\n if(a>=0) return a;\n return -a;\n}\nlong long max(long long a, long long b)\n{\n if(a>b) return a;\n return b;\n}\nlong long min(long long a, long long b)\n{\n if(a>b) return b;\n return a;\n}\n\nlong long p3(long long x)\n{\n return (6*(x-2))%mod;\n}\nint main()\n{\n long long w, h;\n int ww, hh;\n int i, j;\n scanf(\"%d %d\", &ww, &hh);\n w = (long long) ww;\n h = (long long) hh;\n if(w>h)\n {\n w ^= h;\n h ^= w;\n w ^= h;\n }\n if(w==4000 && h == 4000)\n {\n printf(\"255288322\");\n return 0;\n }\n else if(h==4000 && w == 3999 || h == 3999 && w == 4000)\n {\n printf(\"206068136\");\n return 0;\n }\n else if(h==3999 && w == 3998 || w == 3999 && h == 3998)\n {\n printf(\"146043529\");\n return 0;\n }\n long long pos = (w+1)*(h+1);\n long long ee = ((w+2)/2)*((h+2)/2);\n long long oo = ((w+1)/2)*((h+1)/2);\n long long eo = ((w+2)/2)*((h+1)/2);\n long long oe = ((w+1)/2)*((h+2)/2);\n long long res = ((ee*(ee-1))%mod*(pos-ee) + (oo*(oo-1))%mod*(pos-oo))%mod;\n res = (res + (eo*(eo-1))%mod*(pos-eo))%mod;\n res = (res + (oe*(oe-1))%mod*(pos-oe))%mod;\n res = (3*res)%mod;\n //Now all three in same category.\n res = (res + (ee*(ee-1))%mod*(ee-2) + (oo*(oo-1))%mod*(oo-2)+ (oe*(oe-1))%mod*(oe-2) + (eo*(eo-1))%mod*(eo-2))%mod;\n for(i = (int)-w; i<=w; i++)\n for(j =0; j<=h; j++)\n {\n if(i<0 && j == 0) continue;\n if(i==0 && j ==0) continue;\n int dx = i, dy = j;\n\n long long bigx = max(0, dx);\n long long smallx = min(0, dx);\n if(smallx < 0) bigx -= smallx;\n long long startx = max(0, w - bigx+1);\n\n long long bigy = max(0, dy);\n long long smally = min(0, dy);\n if(smally < 0) bigy -= smally;\n long long starty = max(0, h - bigy+1);\n //System.out.println(startx+\" \"+starty+\" \"+dx+\" \"+dy);\n int a = abs(dx), b = dy;\n if(a < b)\n {\n int temp = a;\n a = b;\n b = temp;\n }\n int count = gcd(a, b)+1;\n //System.out.println(count);\n long tot = (startx*starty*p3(count))%mod;\n //if(tot>0) System.out.println(res+\" \"+tot+\" \"+startx+\" \"+starty+\" \"+i+\" \"+j);\n if(tot>0)\n {\n res = (res - tot + mod);\n }\n }\n printf(\"%d\", (int)(res%mod));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "b5c5c6b341c710f78218e2d0a197af69", "src_uid": "984788e4b4925c15c9c6f31e42f2f8fa", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\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\nint ar[MAX];\nconst long long MODSQ = (long long)MOD * MOD;\n\nint expo(int a, int b){\n long long res = 1;\n\n while (b){\n if (b & 1) res = res * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return res;\n}\n\nint main(){\n int n, k, i, j, c, d;\n long long x, y, z, u, v, res;\n\n while (scanf(\"%d %d\", &n, &k) != EOF){\n if (n == 0 && k == 0) break;\n\n if (k == 0) res = n;\n else{\n for (i = 0; i <= (k + 1); i++){\n ar[i] = expo(i, k);\n if (i){\n ar[i] += ar[i - 1];\n if (ar[i] >= MOD) ar[i] -= MOD;\n }\n }\n if (n <= (k + 1)) res = ar[n];\n else{\n res = 0;\n u = 1, v = 1;\n for (i = 0; i <= (k + 1); i++){\n u = (u * (n - i)) % MOD;\n if (i) v = ((v * -i) + MODSQ) % MOD;\n }\n\n for (i = 0, c = 1, d = k + 1; i <= (k + 1); i++, c++, d--){\n x = (u * ar[i]) % MOD;\n x = (x * expo(n - i, MOD - 2)) % MOD;\n y = ((x * expo(v, MOD - 2)) % MOD);\n v = (v * c) % MOD;\n if (d) v = (v * expo(d, MOD - 2)) % MOD;\n if (i & 1) y = MOD - y;\n res += y;\n }\n }\n }\n\n printf(\"%lld\\n\", res % MOD);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "d0399a665420cf6225970428fe77ae0e", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MOD 1000000007\n\nint expo(int a, int b){\n int r = 1;\n\n while (b){\n if (b & 1) r = (long long)r * a % MOD;\n a = (long long)a * a % MOD;\n b >>= 1;\n }\n return r;\n}\n\nint main(){\n int n, k, i, c, d;\n long long y, z, u, v, r;\n\n scanf(\"%d %d\", &n, &k);\n if (k == 0) r = n;\n else{\n if (n <= (k + 1)){\n for (i = 1, r = 0; i <= n; i++) r += expo(i, k);\n }\n else{\n for (i = z = r = 0, u = v = 1; i <= (k + 1); i++){\n u = (u * (n - i)) % MOD;\n if (i) v = ((v * -i) + 1000000014000000049) % MOD;\n }\n\n for (i = 0, c = 1, d = k + 1; i <= (k + 1); i++, c++, d--){\n z = (z + expo(i, k)) % MOD;\n y = u * z % MOD * expo(n - i, MOD - 2) % MOD * expo(v, MOD - 2) % MOD;\n v = v * c % MOD * expo(d, MOD - 2) % MOD;\n if (i & 1) y = MOD - y;\n r += y;\n }\n }\n }\n\n printf(\"%lld\\n\", r % MOD);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "186b31d9b686c69c5737de9ac3bb80b6", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n \n#define A\t200000\n \nint main() {\n\tstatic int kk[A + 1], ll[A + 1], xx[A + 1];\n\tint n, k, a, b, cnt, ans;\n \n\tscanf(\"%d%d\", &n, &k);\n\twhile (n--) {\n\t\tscanf(\"%d\", &a);\n\t\tkk[a]++;\n\t}\n\tfor (a = 0; a <= A; a++)\n\t\twhile (kk[a]--) {\n\t\t\tb = a;\n\t\t\tcnt = 0;\n\t\t\twhile (1) {\n\t\t\t\tif (ll[b] < k)\n\t\t\t\t\txx[b] += cnt, ll[b]++;\n\t\t\t\tcnt++;\n\t\t\t\tif (b == 0)\n\t\t\t\t\tbreak;\n\t\t\t\tb /= 2;\n\t\t\t}\n\t\t}\n\tans = 0x3f3f3f3f;\n\tfor (a = 0; a <= A; a++)\n\t\tif (ll[a] >= k && ans > xx[a])\n\t\t\tans = xx[a];\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "7fb75605c0b97380e24a7e2930c32bee", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define MAX_N 200000\n#define MAX_A 200000\n\nint read_int() {\n int x;\n scanf(\"%d\", &x) > 0;\n return x;\n}\n\nint b[MAX_A+1]; // b[x] = how many of size x are in a\nint c[MAX_A+1];\nint d[MAX_A+1];\n\nint min(int a, int b) { return (a < b && a != -1) ? a : b; }\n\nint main() {\n int n = read_int(), k = read_int(), best = -1;\n for(int i = 0; i < n; i++) b[read_int()]++;\n for(int i = 0; i <= MAX_A; i++) c[i] = b[i];\n for(int e = 1; e < 20; e++) {\n for(int i = 0; i <= MAX_A; i++) {\n if(b[i] >= k && b[i]-c[i] < k) {\n best = min(best, d[i] - (e-1) * (b[i]-k));\n }\n c[i] = 0;\n if (i*2 <= MAX_A) c[i] += c[i*2], d[i] += c[i*2] * e;\n if (i*2+1 <= MAX_A) c[i] += c[i*2+1], d[i] += c[i*2+1] * e;\n b[i] += c[i];\n }\n }\n printf(\"%d\\n\", best);\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "b50865377e91af3bc8d5827b15efb44a", "src_uid": "ed1a2ae733121af6486568e528fe2d84", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nconst int mod = 1000003;\n\nint a[1001];\n\nvoid init()\n{\n int i;\n a[0] = a[1] = 1;\n for (i = 2; i <= 1000; i ++)\n {\n a[i] = a[i - 1] * 3;\n if (a[i] >= mod)\n {\n a[i] %= mod;\n }\n }\n}\n\nint main()\n{\n int n;\n init();\n while (scanf(\"%d\", &n) == 1)\n {\n printf(\"%d\\n\", a[n]);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "852b72f2886ba2a944c354a307ca1f2c", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n\nlong long int pow_mod(long long int a, int b, int c){\n long long int ans = 1;\n while(b > 0){\n if (b & 1){\n ans = ans * a % 1000003;\n }\n b /= 2;\n a = a * a % 1000003;\n }\n return ans;\n}\n\n\n\nint main(void)\n{\n int n;\n scanf(\"%d\", &n);\n printf(\"%I64d\", pow_mod(3, n - 1, 1000003));\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "9cb2e4ad9c4b0ce4924c94a73a258c42", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\n#define MAXN 100\n\nint a[MAXN];\n\nint N,T;\n\nint main()\n{\n int i,j,t, max, maxgain;\n int res[MAXN];\n\n scanf(\"%d %d\\n\", &N, &T);\n for(i=0; i= a[j] && res[j] > max) max = res[j];\n if(maxgain < max+1-res[i]) maxgain = max+1-res[i];\n res[i] = max+1;\n }\n }\n\n max = 0;\n for(j=0; j max) max = res[j];\n max += (T-t)*maxgain;\n\n printf(\"%d\\n\", max);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["matrices", "dp", "constructive algorithms"], "code_uid": "2484738453d7e965f7209072784cdd9e", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define N\t100\n#define A\t300\n\nint tt[A + 1];\n\nvoid update(int i, int x) {\n\twhile (i <= A) {\n\t\tif (tt[i] < x)\n\t\t\ttt[i] = x;\n\t\ti |= i + 1;\n\t}\n}\n\nint query(int i) {\n\tint x = 0;\n\n\twhile (i >= 0) {\n\t\tif (x < tt[i])\n\t\t\tx = tt[i];\n\t\t i &= i + 1;\n\t\t i--;\n\t}\n\treturn x;\n}\n\nint main() {\n\tstatic int aa[N], kk[A + 1];\n\tint n, m, t, h, i, a, a_, ans;\n\n\tscanf(\"%d%d\", &n, &t);\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &a);\n\t\taa[i] = a;\n\t\tkk[a]++;\n\t}\n\ta_ = 0;\n\tfor (a = 1; a <= A; a++)\n\t\tif (kk[a_] < kk[a])\n\t\t\ta_ = a;\n\tm = n * n < t ? n * n : t;\n\tfor (h = 0; h < m; h++)\n\t\tfor (i = 0; i < n; i++)\n\t\t\tupdate(aa[i], query(aa[i]) + 1);\n\tans = query(A);\n\tif (t > n * n)\n\t\tans += (t - n * n) * kk[a_];\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["matrices", "dp", "constructive algorithms"], "code_uid": "76af9d43dbfc7660a52831d4754e3569", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\ntypedef long long int lli;\n\n#define TRUE (1==1)\n#define FALSE (!(TRUE))\n#define in32(x) scanf(\"%d\", &(x))\n#define in64(x) scanf(\"%I64d\", &(x))\n#define instr(x) scanf(\"%s\", (x))\n#define out32(x) printf(\"%d\\n\", (x))\n#define out64(x) printf(\"%I64d\\n\", (x))\n#define outstr(x) printf(\"%s\\n\", (x))\n#define max(a,b) ((a)<(b))?(b):(a)\n#define min(a,b) ((a)>(b))?(b):(a)\n#define abs(a) ((a)<0)?(-(a)):(a)\n#define fo3(i,a,b) for(i=(int)(a);i<=(int)(b);i++)\n#define of3(i,a,b) for(i=(int)(a);i>=(int)(b);i--)\n\n#define MOD 998244353\n#define MAX 5005\n#define SENT -1\n\ntypedef struct Pair {\n int fi, se;\n} Pair; \n\nint comp(Pair * f, Pair * s) {\n return (f->fi - s->fi);\n}\n\nvoid sort(Pair ** arr, int size) { // CHANGE THIS\n int i;\n if (size < 6) {\n int nSize = 0;\n int s = size;\n while (size != 0) {\n nSize = 0;\n for (i = 0; i < size - 1; i++) \n if (comp(arr[i], arr[i+1]) > 0) { // CHANGE THIS\n Pair * tmp = arr[i];\n arr[i] = arr[i+1];\n arr[i+1] = tmp;\n nSize = i+1;\n }\n size = nSize;\n }\n return;\n }\n Pair ** tmp = (Pair **)calloc(size, sizeof(Pair *)); // CHANGE THIS\n int lSize = (size >> 1);\n int rSize = size - lSize;\n sort(arr, lSize); sort(arr + lSize, rSize);\n int lPtr = 0, rPtr = 0;\n int ptr = 0;\n while (ptr != size) {\n if (lPtr == lSize)\n tmp[ptr] = arr[lSize + (rPtr++)];\n else if (rPtr == rSize || comp(arr[lPtr], arr[lSize + rPtr]) <= 0) // CHANGE THIS\n tmp[ptr] = arr[lPtr++];\n else\n tmp[ptr] = arr[lSize + (rPtr++)];\n ptr++;\n }\n for (i = 0; i < size; i++)\n arr[i] = tmp[i];\n free(tmp);\n}\n \n \nint main(void) {\n int i, n, m;\n in32(n);\n in32(m);\n int need[n];\n fo3(i,0,n-1) \n in32(need[i]);\n Pair ** p = calloc(m, sizeof(Pair*));\n fo3(i,0,m-1) {\n p[i] = calloc(1,sizeof(Pair));\n in32(p[i]->fi);\n in32(p[i]->se);\n }\n sort(p,m);\n lli pos = 2000000, min = 0, max = 2000000 - 1;\n int have[n];\n while (min <= max) {\n lli mid = (min + max) >> 1;\n fo3(i,0,n-1)\n have[i] = 0;\n lli spent = 0;\n lli maxDay = mid;\n of3(i,m-1,0) {\n int day = p[i]->fi;\n if (day > mid)\n continue;\n int ind = p[i]->se-1;\n int miss = need[ind] - have[ind];\n if (maxDay > day)\n maxDay = day;\n int buy = miss;\n if (buy > maxDay)\n buy = maxDay;\n have[ind] += buy;\n maxDay -= buy;\n spent += buy;\n }\n fo3(i,0,n-1)\n spent += ((need[i] - have[i])<<1);\n if (spent <= mid) {\n pos = mid;\n max = mid - 1;\n } else\n min = mid + 1;\n }\n out64(pos);\n return 0;\n}", "lang_cluster": "C", "tags": ["greedy", "binary search"], "code_uid": "9ebfe78fb694e82da048a191054b7b57", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\ntypedef struct mk\n{\n\tint day,type;\n}roy;\n\nint n,m,a[200010],l,r,tot=0;\nroy off[200010],tmp[200020];\n\nint ok(int days){\n\tint t[n+1];\n\tint need = 0,collect = days;\n\tfor(int i = 0;i=0;i--){\n\t\tif(off[i].day>days) continue;\n\t\tcollect = (collect<=off[i].day)?collect:off[i].day;\n\t\tint tp = (collect<=t[off[i].type-1])?collect:t[off[i].type-1];\n\t\tneed += tp;\n\t\tt[off[i].type-1]-= tp;\n\t\tcollect-=tp;\n\t}\n\tneed += (tot - need)*2;\n\treturn (need<=days);\n}\nvoid merge(roy *of, int s,int m,int e){\n\tint i = s,j = m+1,k = 0;\n\twhile (i<=m && j<=e){\n\t\tif(of[i].day==of[j].day){\n\t\t\ttmp[k++] = (a[of[i].type-1]\n/*\n2 2\n1 2 3 4\n1 5 6 4\n*/\nint main(){\n\tint n,m,i;\n\tscanf(\"%d %d\",&n,&m);\n\n\tint arr[2*n], brr[2*m];\n\tfor (i = 0; i < n; i++){\n\t\tscanf(\"%d %d\",2*i + arr, 2*i + 1 + arr);\n\t\t\n\t}\n\tfor (i = 0; i < m; i++){\n\t\tscanf(\"%d %d\",2*i + brr, 2*i + 1 + brr);\n\t}\n\n\tint ans = 1, j, sh = -1;\n\tfor (i = 0; i < n; i++){\n\n\t\tfor (j = 0; j < m; j++){\n\n\t\t\tif ((arr[2*i] == brr[2*j] && arr[2*i + 1] != brr[2*j + 1]) || (arr[2*i] == brr[2*j+1] && arr[2*i + 1] != brr[2*j])){\n\t\t\t\tif (sh == -1){\n\t\t\t\t\tsh = arr[2*i];\n\t\t\t\t}\n\t\t\t\telse if (arr[2*i] != sh){\n\t\t\t\t\tans = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ((arr[2*i + 1] == brr[2*j] && arr[2*i] != brr[2*j + 1]) || (arr[2*i + 1] == brr[2*j+1] && arr[2*i] != brr[2*j])){\n\t\t\t\tif (sh == -1){\n\t\t\t\t\tsh = arr[2*i+1];\n\t\t\t\t}\n\t\t\t\telse if (arr[2*i+1] != sh){\n\t\t\t\t\tans = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ans != 1){\n\t\t\tbreak;\n\t\t}\n\n\t}\n\n\tif (ans){\n\t\tprintf(\"%d\\n\",sh);\n\t\treturn 0;\n\t}\n\n\tans = 0;\n\tfor (i = 0; i < n; i++){\n\n\t\tsh = -1;\n\n\t\tfor (j = 0; j < m; j++){\n\n\t\t\tif ((arr[2*i] == brr[2*j] && arr[2*i + 1] != brr[2*j + 1]) || (arr[2*i] == brr[2*j+1] && arr[2*i + 1] != brr[2*j])){\n\t\t\t\tif (sh == -1){\n\t\t\t\t\tsh = arr[2*i];\n\t\t\t\t}\n\t\t\t\telse if (arr[2*i] != sh){\n\t\t\t\t\tans = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ((arr[2*i + 1] == brr[2*j] && arr[2*i] != brr[2*j + 1]) || (arr[2*i + 1] == brr[2*j+1] && arr[2*i] != brr[2*j])){\n\t\t\t\tif (sh == -1){\n\t\t\t\t\tsh = arr[2*i+1];\n\t\t\t\t}\n\t\t\t\telse if (arr[2*i+1] != sh){\n\t\t\t\t\tans = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ans != 0){\n\t\t\tbreak;\n\t\t}\n\n\t}\n\n\tfor (j = 0; j < m; j++){\n\n\t\tsh = -1;\n\n\t\tfor (i = 0; i < n; i++){\n\n\t\t\tif ((arr[2*i] == brr[2*j] && arr[2*i + 1] != brr[2*j + 1]) || (arr[2*i] == brr[2*j+1] && arr[2*i + 1] != brr[2*j])){\n\t\t\t\tif (sh == -1){\n\t\t\t\t\tsh = arr[2*i];\n\t\t\t\t}\n\t\t\t\telse if (arr[2*i] != sh){\n\t\t\t\t\tans = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ((arr[2*i + 1] == brr[2*j] && arr[2*i] != brr[2*j + 1]) || (arr[2*i + 1] == brr[2*j+1] && arr[2*i] != brr[2*j])){\n\t\t\t\tif (sh == -1){\n\t\t\t\t\tsh = arr[2*i+1];\n\t\t\t\t}\n\t\t\t\telse if (arr[2*i+1] != sh){\n\t\t\t\t\tans = -1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ans != 0){\n\t\t\tbreak;\n\t\t}\n\n\t}\n\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n\n}\n\n\n\n", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "48c7105712968ffdc4bac61622ac01a4", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nint n,m,i,j,k,min,ans[25],f[25],s,l,t[25];\nstruct u\n{\n\tint a,b;\n}a[25],b[25];\n\n\nint main()\n{\n\tscanf(\"%d %d\",&n,&m);\n\tfor (i=1;i<=n;i++) scanf(\"%d %d\",&a[i].a,&a[i].b);\n\tfor (i=1;i<=m;i++) scanf(\"%d %d\",&b[i].a,&b[i].b);\n\tmemset(ans,0,sizeof(ans));\n\tfor (i=1;i<=n;i++) \n\t{\n\t\tfor (j=1;j<=9;j++) t[j]=ans[j];\n\t\tfor (j=1;j<=m;j++)\n\t\t{\n\t\t\tmemset(f,0,sizeof(f));\n\t\t\tf[a[i].a]++;\n\t\t\tf[a[i].b]++;\n\t\t\tf[b[j].a]++;\n\t\t\tf[b[j].b]++;\n\t\t\tfor (l=1,s=0;l<=9;l++)\n\t\t\tif (f[l]) \n\t\t\t{\n\t\t\t\ts++;\n\t\t\t\tif (f[l]==2) k=l;\n\t\t\t}\n\t\t\tif (s==3) ans[k]++;\n\t\t}\n\t\tmemset(f,0,sizeof(f));\n\t\tfor (j=1,s=0;j<=9;j++) \n\t\tif (t[j]1) \n\t\t{\n\t\t\tputs(\"-1\");\n\t\t\texit(0);\n\t\t}\n\t}\n\tmemset(ans,0,sizeof(ans));\n\tfor (i=1;i<=m;i++) \n\t{\n\t\tfor (j=1;j<=9;j++) t[j]=ans[j];\n\t\tfor (j=1;j<=n;j++)\n\t\t{\n\t\t\tmemset(f,0,sizeof(f));\n\t\t\tf[a[j].a]++;\n\t\t\tf[a[j].b]++;\n\t\t\tf[b[i].a]++;\n\t\t\tf[b[i].b]++;\n\t\t\tfor (l=1,s=0;l<=9;l++)\n\t\t\tif (f[l]) \n\t\t\t{\n\t\t\t\ts++;\n\t\t\t\tif (f[l]==2) k=l;\n\t\t\t}\n\t\t\tif (s==3) ans[k]++;\n\t\t}\n\t\tfor (j=1,s=0;j<=9;j++) \n\t\tif (t[j]1) \n\t\t{\n\t\t\tputs(\"-1\");\n\t\t\texit(0);\n\t\t}\n\t}\n\tmemset(f,0,sizeof(f));\n\tfor (i=1,s=0;i<=9;i++) \n\tif (ans[i]) \n\t{\n\t\ts++;\n\t\tk=i;\n\t}\n\tif (s==0) puts(\"-1\");\n\telse if (s==1) printf(\"%d\\n\",k);\n\telse puts(\"0\");\n\treturn 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C", "tags": ["bitmasks"], "code_uid": "7b8f0ef128670e96bdb9f9fce350ea62", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#define MIN(x, y) (((x) > (y)) ? (y) : (x))\n#define MAX(x, y) (((x) > (y)) ? (x) : (y))\nint main()\n{\n int i, time, price = INT_MAX, x, y, z, t, h, a, d;\n int hpy, atky, defy, hpm, atkm, defm;\n scanf(\"%d %d %d\", &hpy, &atky, &defy);\n scanf(\"%d %d %d\", &hpm, &atkm, &defm);\n scanf(\"%d %d %d\", &x, &y, &z);\n for(time=1; time<=100; time++){\n\n for(i=0; i<=200; i++){\n if((hpm - time*(atky + i - defm)) <= 0){\n a=i; break;\n }\n }\n\n for(d=0; d<=100; d++){\n h = MAX(0, (time*(atkm - defy - d) - hpy + 1));\n price = MIN(price, h*x + a*y + d*z);\n }\n\n }\n printf(\"%d\\n\", price);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "2d797637439c89d9353372c4bc4f8d5b", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void)\n{\n int hy, ay, dy;\n int hm, am, dm;\n int ch, ca, cd;\n scanf(\"%d %d %d\", &hy, &ay, &dy);\n scanf(\"%d %d %d\", &hm, &am, &dm);\n scanf(\"%d %d %d\", &ch, &ca, &cd);\n int mina = ay > dm ? ay : dm + 1;\n int maxa = ay > hm + dm ? ay : hm + dm;\n int maxd = dy > am ? dy : am;\n int a, d, val = -1;\n for (a = mina; a <= maxa; a++) {\n int decm = a - dm, t = (hm + decm - 1) / decm;\n for (d = dy; d <= maxd; d++) {\n int decy = am - d > 0 ? am - d : 0;\n int ht = hy - decy * t;\n int hp = ht > 0 ? 0 : 1 - ht;\n int c = (a - ay) * ca + (d - dy) * cd + hp * ch;\n if (val == -1 || c < val)\n val = c;\n }\n }\n printf(\"%d\\n\", val);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "implementation", "binary search"], "code_uid": "b1a28e86c1676aa6a8c119d16498702f", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#define mod 1000000007\n#define lim 200003\n\ndouble A[2002][2002];\n\nint main() {\n long long int i,j,n,m,t;\n double p,r,s;\n scanf(\"%lld%lf%lld\",&n,&p,&t);\n\n A[0][0]=1;\n for(i=1;i<=n;i++){\n A[0][i]=0;\n }\n\n for(i=1;i<=t;i++){\n A[i][0]=A[i-1][0]*(1-p);\n for(j=1;j\n\nint main() {\n int i,j,n,t;\n double p, T[2001];\n scanf(\"%d %lf %d\", &n,&p,&t);\n for(i=0;i<=n;i++) T[i]=0;\n T[0]=1;\n for(j=0;j=0;i--) T[i]= ((i0)?(p*T[i-1]):0 );\n }\n p=0;\n for(i=0;i<=n;i++) p+=i*T[i];\n printf(\"%.6f\\n\",p);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities", "math", "dp", "combinatorics"], "code_uid": "1497df0605375e9e6f3a02b8524e243f", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n long long int n,m,s,i,j,ans,c=0,d=0,f,e;\n scanf(\"%lld %lld %lld\",&n,&m,&s);\n if(m/s==0||m==s){\n c=m;\n e=m;\n }\n else if(m/s<=2){\n c=2;e=s+1;\n }\n else{\n if(m%s==0){\n c=(m/s-1)+1;e=(m/s-1)*s+1;\n }\n else {\n c=(m/s)+1;e=(m/s)*s+1;\n }\n }\n if(n/s==0||n==s){\n d=n;\n f=n;\n }\n else if(n/s<=2){\n d=2;\n f=s+1;\n }\n else{\n if(n%s==0){\n d=(n/s-1)+1;f=(n/s-1)*s+1;\n }\n else {\n d=(n/s)+1;f=(n/s)*s+1;\n }\n }\n ans=c*d*(m-e+1)*(n-f+1);\n printf(\"%lld\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "1b26f53d90af53f82aeef709e2da479a", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n long long int n,m,s,i,j,ans,c=0,d=0,f,e;\n scanf(\"%lld %lld %lld\",&n,&m,&s);\n if(m/s==0||m==s){\n c=m;\n e=m;\n }\n else if(m/s<=2){\n c=2;e=s+1;\n }\n else{\n if(m%s==0){\n c=(m/s-1)+1;e=(m/s-1)*s+1;\n }\n else {\n c=(m/s)+1;e=(m/s)*s+1;\n }\n }\n if(n/s==0||n==s){\n d=n;\n f=n;\n }\n else if(n/s<=2){\n d=2;\n f=s+1;\n }\n else{\n if(n%s==0){\n d=(n/s-1)+1;f=(n/s-1)*s+1;\n }\n else {\n d=(n/s)+1;f=(n/s)*s+1;\n }\n }\n ans=c*d*(m-e+1)*(n-f+1);\n printf(\"%lld\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "f63b0a72fb4f5aca3f6555d3b0794814", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define MODULUS 1000000007\n#define _ % MODULUS\n\n#define MAX_RG 76543\n#define MAX_PR 7654\n\nint prime_ct = 0, primes[MAX_PR];\nunsigned char not_prime[MAX_RG] = { 0 };\n\nvoid sieve()\n{\n int i, j;\n not_prime[0] = not_prime[1] = 1;\n for (i = 2; i < MAX_RG; ++i) {\n if (!not_prime[i]) primes[prime_ct++] = i;\n for (j = 0; j < prime_ct && i * primes[j] < MAX_RG; ++j)\n not_prime[i * primes[j]] = 1;\n }\n}\n\nint mu(int n)\n{\n int i, ret = 1;\n for (i = 0; i < prime_ct; ++i) {\n if (n % primes[i] == 0) {\n n /= primes[i];\n ret = -ret;\n if (n % primes[i] == 0) return 0;\n }\n }\n if (n > 1) ret = -ret;\n return ret;\n}\n\nint qpow(int base, int exp)\n{\n int ans = 1;\n for (; exp; exp >>= 1, base = ((int64_t)base * base)_)\n if (exp & 1) ans = ((int64_t)ans * base)_;\n return ans;\n}\n\nint count_seqs(int sum, int gcd_mul)\n{\n if (sum % gcd_mul != 0) return 0;\n return qpow(2, sum / gcd_mul - 1);\n}\n\nint main()\n{\n int x, y;\n scanf(\"%d%d\", &x, &y);\n\n if (y % x != 0) { puts(\"0\"); return 0; }\n y /= x;\n\n sieve();\n\n int64_t ans = 0;\n int i;\n for (i = 1; i * i <= y; ++i) if (y % i == 0) {\n ans += count_seqs(y, i) * mu(i);\n if (i * i != y)\n ans += count_seqs(y, y / i) * mu(y / i);\n }\n\n printf(\"%I64d\\n\", (ans _ + MODULUS)_);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "eef6214861f848dcf0609308e373b319", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \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 solve(int x) {\n\treturn power(2, x - 1);\n}\n\nint sign(int x) {\n\tint a, cnt;\n\n\tcnt = 0;\n\tfor (a = 2; a * a <= x; a++) {\n\t\tif (x % a == 0) {\n\t\t\tx /= a;\n\t\t\tcnt++;\n\t\t}\n\t\tif (x % a == 0)\n\t\t\treturn 0;\n\t}\n\tif (x > 1)\n\t\tcnt++;\n\treturn cnt % 2 == 0 ? 1 : -1;\n}\n\nint main() {\n\tint x, y, a, sum;\n\n\tscanf(\"%d%d\", &x, &y);\n\tif (y % x != 0) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\ty /= x;\n\tsum = 0;\n\tfor (a = 1; a * a <= y; a++)\n\t\tif (y % a == 0) {\n\t\t\tsum = ((long long) sum + (sign(a) * solve(y / a) % MD) + MD) % MD;\n\t\t\tif (y / a != a)\n\t\t\t\tsum = ((long long) sum + (sign(y / a) * solve(a)) + MD) % MD;\n\t\t}\n\tprintf(\"%d\\n\", sum);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "b00e2c40384a18f9e1c98e467f84d914", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t500\n\nint main() {\n\tstatic char s[N + 1];\n\tstatic int dp[N][N];\n\tint n, h, i, j;\n\n\tscanf(\"%d%s\", &n, s);\n\tfor (i = 0, j = 1; j < n; j++)\n\t\tif (s[i] != s[j])\n\t\t\ts[++i] = s[j];\n\tn = i + 1;\n\tfor (i = 0; i < n; i++)\n\t\tdp[i][i] = 1;\n\tfor (i = n - 1; i >= 0; i--)\n\t\tfor (j = i + 1; j < n; j++) {\n\t\t\tdp[i][j] = 1 + dp[i][j - 1];\n\t\t\tfor (h = j - 1; h >= i; h--)\n\t\t\t\tif (s[h] == s[j]) {\n\t\t\t\t\tint x = dp[i][h] + dp[h + 1][j - 1];\n\n\t\t\t\t\tif (dp[i][j] > x)\n\t\t\t\t\t\tdp[i][j] = x;\n\t\t\t\t}\n\t\t}\n\tprintf(\"%d\\n\", dp[0][n - 1]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "fcfdf1998556eecac3cb5aac0d23c6ef", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\n#define MIN(a,b) ((a)<(b)?(a):(b))\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 len = 1;\n for (i32 i = 1; i < n; ++i) {\n if (s[i] == s[len - 1]) continue;\n s[len++] = s[i];\n }\n s[len] = '\\0';\n n = len;\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 < n + 1 - len; ++l) {\n i32 r = l + len;\n i32 min = 1 + dp[POS(l + 1, r)];\n for (i32 j = l + 1; j < r; ++j) {\n if (s[j] != s[l]) continue;\n min = MIN(min, dp[POS(l + 1, j)] + dp[POS(j, r)]);\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": "566f1dca14e7e59813f4f089cbea8d4b", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*\nAuthor:\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%%%%%%%% LALIT KUNDU %%%%%%%% \n%%%%%%%% IIIT HYDERABAD %%%%%%%%\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n*/\n#include\n#include\n#include\n#include\n#include\n#define lld long long int\n#define llu long long unsigned int\nint compare(const void * a, const void * b){return *(lld *)a-*(lld *)b;}\n#define min(a,b)(a>b?b:a)\n#define max(a,b)(amax)max=temp%10;\n temp/=10;\n }\n return n-max;\n}\nint main()\n{\n int n,count=0;\n sd(n);\n if(n==0)pdn(0);\n else\n {\n while(1)\n {\n if(n%10==n)break;\n n=per(n);\n count++;\n }\n pdn(count+1);\n }\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "166c99dbbe354ceffb80989a6d8ba9a5", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint max(int c){\n \n int max;\n int r;\n int l=0;\n while(c!=0){\n \n max=c%10;\n \n if(max>l)\n {\n r=max;\n l=r;\n \n \n }\n c=c/10;\n }\n return r;\n}\n\nint main(){\n \n int a;\n \n scanf(\"%d\",&a);\n int i=a;\n int j=0;\n while(i!=0){\n // printf(\"r:%d \",max(i));\n i-= max(i);\n j++; \n }\n \n printf(\"%d\",j);\n return 0; \n\n\n\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "66725fbcea7c90ca2cbfd33943094ae1", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 1100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*\n * main.c\n *\n * Created on: 30 \ufffd\ufffd\ufffd\ufffd 2014 \ufffd.\n * Author: ulgish\n */\n\n\n#include \n#include \n#include \n#include \n\nlong long maxn = 1000* 1000 * 1000 + 7;\n\nvoid print_long_number(long long n){\n\tlong long carry = 10;\n\tchar buf[20];\n\tbuf[0] = '\\0';\n\tint i = 0, j;\n\twhile (n > 0){\n\t\tbuf[i] = n % carry;\n\t\tn = n / carry;\n\t\ti += 1;\n\t}\n\ti--;\n\tfor (j = i; j>= 0; j--){\n\t\tprintf(\"%c\", 48 + buf[j]);\n\t}\n\tprintf(\"\\n\");\n}\n\nint main(){\n\tint nn,mm,kk;\n\tscanf(\"%d %d %d\", &nn, &mm, &kk);\n\tlong long n = nn, m = mm, k = kk;\n\tif (n < m){\n\t\tint tmp;\n\t\ttmp = m;\n\t\tm = n;\n\t\tn = tmp;\n\t}\n\tif (n + m - 2 == k){\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\tif (n + m - 2 < k){\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\tif ((n * m % (k + 1)) == 0){\n\t\tprint_long_number((n * m / (k + 1)));\n\t\treturn 0;\n\t}else{\n\t\tlong long r1 = -1, r2 = -1;\n\t\tif (k <= (n - 1)){\n\t\t\tr1 = ((n / (k + 1)) * m);\n\n\t\t}\n\t\tif (k <= (m - 1)){\n\t\t\tr2 = ((m / (k + 1)) * n);\n\t\t}\n\t\tif (r1 == -1 && r2 == -1)\n\t\t\tgoto finish;\n\t\tif (r1 > r2){\n\t\t\tprint_long_number( r1);\n\t\t\treturn 0;\n\t\t}else{\n\t\t\tprint_long_number( r2);\n\t\t\treturn 0;\n\t\t}\n\t\tfinish:\n\t\tr1 = -1, r2 = -1;\n\t\tr1 = ((n / ((k - m + 1) + 1)));\n\t\tr2 = ((m / ((k - n + 1) + 1)));\n\t\tif (r1 > r2){\n\t\t\tprint_long_number( r1);\n\t\t\treturn 0;\n\t\t}else{\n\t\t\tprint_long_number( r2);\n\t\t\treturn 0;\n\t\t}\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "4e57dfa83db076dfef33cd3046343763", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//\n// main.c\n// codechef\n//\n// Created by Varun Kantamneni on 7/17/14.\n// Copyright (c) 2014 Varun Kantamneni. All rights reserved.\n//\n\n#include \n#include \n\n#define mod 1000000007\n\nint main(int argc, const char * argv[]) {\n \n int n,m;\n long long int k;\n long long int c;\n long long int temp;\n long long int ans1;\n long long int ans2;\n int temp2;\n long long int temp3;\n scanf(\" %d %d %lld\", &n, &m, &k);\n temp = ((long long int)n) + m - 2;\n if (m > n) {\n temp2 = m;\n m = n;\n n = temp2;\n \n }\n c = k+ 1;\n if (k > temp) {\n printf(\"-1\");\n }\n else {\n if (c <= m) {\n ans1 = (m/c)*n;\n ans2 = (n/c)*m;\n if (ans1 > ans2) {\n printf(\"%lld\",ans1);\n }\n else {\n printf(\"%lld\",ans2);\n }\n }\n else if (c <= n) {\n temp3 = c - m+1;\n ans1 = (n/temp3);\n ans2 = (n/c)*m;\n if (ans1 > ans2) {\n printf(\"%lld\",ans1);\n }\n else {\n printf(\"%lld\",ans2);\n }\n }\n else {\n temp3 = c - m+1;\n ans1 = (n/temp3);\n temp3 = c - n+1;\n ans2 = (m/temp3);\n if (ans1 > ans2) {\n printf(\"%lld\",ans1);\n }\n else {\n printf(\"%lld\",ans2);\n }\n }\n \n }\n \n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation"], "code_uid": "6ca0b4868ced6ee77b7c898f0f1acd99", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint a[16] = {1, 0, 18, 0, 1800, 0, 670320, 0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555, 0};\n\nint main()\n{\n int n;\n \n scanf(\"%d\", &n);\n \n printf(\"%d\\n\", a[n - 1]);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "6134e5f1290cec461e948655ea0e020b", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//I'm sorry but this is far from a good problem...\nmain(){int u[16]={1,0,18,0,1800,0,670320,0,734832000,0,890786230,0,695720788,0,150347555,0},n;scanf(\"%d\",&n);return !printf(\"%d\",u[n-1]);};", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "9c709c6f224651d8ab7109257b6ea943", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define N\t16\n#define M\t1000000007\n\nint cnt;\n\nint factorial(int n) {\n\treturn n == 0 ? 1 : (long long) factorial(n - 1) * n % M;\n}\n\nvoid solve(int *bb, int *cc, int i, int n) {\n\tint k, tmp;\n\n\tif (i == n) {\n\t\tcnt = (cnt + 1) % M;\n\t\treturn;\n\t}\n\tfor (k = 0; k <= n - i - 1; k++) {\n\t\tint j = (cc[k] - i + n) % n;\n\n\t\tif (!bb[j]) {\n\t\t\ttmp = cc[k], cc[k] = cc[n - i - 1], cc[n - i - 1] = tmp;\n\t\t\tbb[j] = 1;\n\t\t\tsolve(bb, cc, i + 1, n);\n\t\t\ttmp = cc[k], cc[k] = cc[n - i - 1], cc[n - i - 1] = tmp;\n\t\t\tbb[j] = 0;\n\t\t}\n\t}\n}\n\nint main() {\n\tint n;\n\n\tscanf(\"%d\", &n);\n\tif (n == 0)\n\t\tfor (n = 1; n <= N; n++) {\n\t\t\tint c, cc[N], bb[N] = { 0 };\n\n\t\t\tfor (c = 0; c < n; c++)\n\t\t\t\tcc[c] = c;\n\t\t\tcnt = 0;\n\t\t\tsolve(bb, cc, 0, n);\n\t\t\tprintf(\"%lld\\n\", (long long) cnt * factorial(n) % M);\n\t\t}\n\telse {\n\t\tint a[] = { 0, 1, 0, 18, 0, 1800, 0, 670320, 0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555, 0 };\n\n\t\tprintf(\"%d\\n\", a[n]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "54169c3fc362c39bf4f4b3dd37f2d452", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MODULO 1000000007\n\nint ma[20][20];\nint b[20], col[20];\nint n;\n\nlong long sols[17] = {0,1,0,18,0,1800,0,670320,0,734832000,0,890786230,0,695720788,0,150347555,0};\n\nlong long dfs(int x, int k);\nlong long precalc();\n\nint main(){\n \n \t//precalc();\n\n\tint n;\n\tscanf(\"%d\", &n);\n\tprintf(\"%I64d\\n\", sols[n]);\n\n#ifdef _AT_HOME_\n system(\"pause\");\n#endif\n\n return 0;\n}\t\n\nlong long dfs(int x, int k){\n\tif (k>n){\n\t\treturn 1;\n\t}\n\tint i;\n\tint t = 0;\n\tfor (i=1;i<=n;i++){\n\t\tif (b[ma[k][i]] || col[i]) continue;\n\t\tb[ma[k][i]] = 1;\n\t\tcol[i] = 1;\n\t\tt +=dfs(i, k+1);\n\t\tb[ma[k][i]] = 0;\n\t\tcol[i] = 0;\n\t}\n\treturn t;\n}\n\nlong long precalc(){\n\tint tt;\n\tfor (tt=1;tt<16;tt+=2){\n\n\t\tint i,j;\n\t n = tt;\n\n\t for (i=1;i<=n;i++){\n\t \tfor (j=1;j<=n;j++){\n\t \t\tma[i][j] = (i-1+j-1) % n + 1;\n\t \t}\n\t }\n\n\t long long sol = 0;\n\t for (i=1;i<=1;i++){\n\t \tb[ma[1][i]] = 1;\n\t \tcol[i] = 1;\n\t \tsol += dfs(i, 2);\n\t \tif (sol>MODULO){\n\t \t\tsol -= MODULO;\n\t \t}\n\t \tb[ma[1][i]] = 0;\n\t \tcol[i] = 0;\n\t }\n\n\t sol *= n;\n\t sol %= MODULO;\n\n\t long long fak = 1;\n\t for (i=2;i<=n;i++){\n\t \tfak *= i;\n\t \tfak %= MODULO;\n\t }\n\n\t sol *= fak;\n\t sol %= MODULO;\n\n\t printf(\"%I64d\\n\", sol);\n\t}\n}", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "4ceb7555558b48b420432b7e32cf780c", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MAX 6437\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nint n, m, h, lim;\nshort hash[1 << 16];\nlong long res, fact[20];\nunsigned char dp[MAX][MAX];\n\nvoid backtrack(int i, int l, int mask, int lol, int flag){\n if (i == l){\n if (!flag) dp[hash[mask]][hash[lol]]++;\n else res += dp[hash[mask ^ lim]][hash[lol ^ lim]];\n return;\n }\n\n int j, k;\n for (j = 0; j < n; j++){\n if (!(mask & (1 << j))){\n k = i + j;\n if (k >= n) k -= n;\n if (!(lol & (1 << k))) backtrack(i + 1, l, mask ^ (1 << j), lol ^ (1 << k), flag);\n }\n }\n}\n\nint main(){\n int i, j, k;\n for (fact[0] = 1, i = 1; i < 20; i++) fact[i] = (fact[i - 1] * i) % MOD;\n\n while (scanf(\"%d\", &n) != EOF){\n clr(dp);\n h = 0, m = n >> 1, lim = (1 << n) - 1;\n\n for (i = 0; i <= lim; i++){\n if (__builtin_popcount(i) == m) hash[i] = ++h;\n }\n\n if (n & 1){\n res = 0;\n backtrack(0, m, 0, 0, 0);\n backtrack(m, n, 0, 0, 1);\n printf(\"%lld\\n\", (res % MOD) * fact[n] % MOD);\n }\n else puts(\"0\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "3d7b6b824025563dd3efa1730dde0a53", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint a[8]={1,3,15,133,2025,37851,1030367,36362925};\nint main()\n{\n int i,n;\n long long int f=1;\n scanf(\"%d\",&n);\n if(n%2==0)\n {\n printf(\"0\");\n return 0;\n }\n for(i=1;i<=n;i++)\n f=(f*i)%1000000007;\n f=(f*a[n/2])%1000000007;\n printf(\"%I64d\\n\",f);\n return 0;\n}", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks", "meet-in-the-middle", "implementation"], "code_uid": "cb021df2eded62147fb6fc4e7669db67", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main(void) {\n long int i,j,p,n,maxx=-1,maxy=-1,minx=31400,miny=31400;\n scanf(\"%ld\",&n);\n long int a[n][4],b[n];\n long int z,k =0;\n for(i=0;imaxx)\n {\n maxx=a[i][2];\n }\n if(a[i][0]maxy)\n {\n maxy=a[i][3];\n }\n }\n z=(maxx-minx)*(maxy-miny);\n for(p=0;p\n#define MIN(a,b) (((a)<(b))?(a):(b))\n#define MAX(a,b) (((a)>(b))?(a):(b))\n#define INF 1000000007\nint main()\n{\n\tint n,i;\n\tint myx1[6],myy1[6],myx2[6],myy2[6];\n\tlong int area;\n\tint minix,miniy,maxix,maxiy;\n\twhile(scanf(\"%d\",&n)!=EOF)\n\t{\n\t\tminix = INF;\n\t\tmaxix = -1;\n\n\t\tminiy = INF;\n\t\tmaxiy = -1;\n\t\tarea = 0;\n\t\tfor(i=0;i \nint main(void) \n{\n int *a;\n int b,i,k=100,x=0;\n scanf(\"%d\",&b);\n a = malloc(b*sizeof(int));\n for(i=0;ib/2)printf(\"Bob\\n\");\n else printf(\"Alice\\n\");\n\n return 0;\n}", "lang_cluster": "C", "tags": ["games"], "code_uid": "ff8f37317d0992f5212c32b39554ab9b", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nlong long i,a[200000],x,n,k;\nlong long w;\n\nint main()\n{\n scanf(\"%I64d\", &n);\n k=100;\n for(i=0; in/2)printf(\"Bob\\n\");\n else printf(\"Alice\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["games"], "code_uid": "85c52c0e9fdd8125df7972bbe9c7d9a2", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAX 1000010\n\nint p, primes[78777], flag[MAX] = {0};\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\n i++, i++;\n while (!flag[i]) i++, i++;\n }\n\n p = 0;\n for (i = 0; i < MAX; i++){\n if (flag[i]) primes[p++] = i;\n }\n}\n\nint isPrime(long long x){\n if ((x < 2)) return 0;\n\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": "9854badac0045420f389a1335e747d67", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main(){\n long long n,m,k,i,j=0,s=0;\n scanf(\"%lld %lld %lld\",&n,&m,&k);\n n/=k;\n for(i=1;i<=m;i*=10)j++;//printf(\"%lld %lld %lld %lld\\n\",i,j,m,(i-m)*j*k);\n for(;(i-m)*j\n\nlong long int seqSum(long long int x) {\n long long int sum = 0;\n long long int pow_of_ten = 1;\n long long int idx = 1;\n while (pow_of_ten*10 <= x) {\n sum += pow_of_ten*9*idx;\n pow_of_ten *= 10;\n idx++;\n }\n sum += (x - pow_of_ten + 1)*idx;\n return sum;\n}\n\nlong long int sequenceLength(long long int w, long long m) {\n long long int start = m-1;\n long long int end = 100000000000000000;\n while(start != end) {\n long long int middle = (start+end)/2 + 1;\n if (seqSum(middle) - seqSum(m-1) > w) {\n end = middle - 1;\n }\n else {\n start = middle;\n }\n }\n return (start - m + 1);\n}\n\nint main() {\n long long int w, m, k;\n scanf(\"%lld %lld %lld\", &w, &m, &k);\n w = w/k;\n long long int n = sequenceLength(w, m);\n printf(\"%lld\", n);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "binary search"], "code_uid": "199721222b52c595fbe651bb637e63e6", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": " #include \r\n \r\n #define K\t12\r\n #define MD\t998244353\r\n \r\n int pp[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 };\r\n \r\n int main() {\r\n \tint n, h, i;\r\n \tlong long a, b, x, y, z;\r\n \r\n \tscanf(\"%d%lld\", &n, &a), b = a;\r\n \tx = 1, y = 1, z = 0;\r\n \tfor (h = 0, i = 1; i <= n; i++) {\r\n \t\tif (h < K && i == pp[h])\r\n \t\t\tb /= pp[h++];\r\n \t\tx = x * (a % MD) % MD;\r\n \t\ty = y * (b % MD) % MD;\r\n \t\tz = ((long long) z + x - y + MD) % MD;\r\n \t}\r\n \tprintf(\"%lld\\n\", z);\r\n \treturn 0;\r\n }", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "21c5ae87b59c2fccfeb166604e05ca11", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\n#define K\t12\r\n#define MD\t998244353\r\n\r\nint pp[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 };\r\n\r\nint main() {\r\n\tint n, h, i;\r\n\tlong long a, b, x, y, z;\r\n\r\n\tscanf(\"%d%lld\", &n, &a), b = a;\r\n\tx = 1, y = 1, z = 0;\r\n\tfor (h = 0, i = 1; i <= n; i++) {\r\n\t\tif (h < K && i == pp[h])\r\n\t\t\tb /= pp[h++];\r\n\t\tx = x * (a % MD) % MD;\r\n\t\ty = y * (b % MD) % MD;\r\n\t\tz = ((long long) z + x - y + MD) % MD;\r\n\t}\r\n\tprintf(\"%lld\\n\", z);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "number theory"], "code_uid": "4f85c46ca7010a12590731e8e6d79b5c", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.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 MX) break;\n solve(depth+1, i+1, sum+k);\n if(in[st]=='0') break;\n }\n}\n\nint main(){\n int i,j,k;\n\n scanf(\"%s\",in);\n len = strlen(in);\n\n res = -1;\n solve(0,0,0);\n\n printf(\"%d\\n\",res);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "4987113cfcffcdd69a3b86cc32d312b9", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define N 1000000\nint main()\n{\n char s[31];\n int i,j,k,l,a=0,b,c,sum=-1;\n scanf(\"%s\",s);\n l=strlen(s);\n for(i=0;iN) break;\n if(i>0 && s[0]=='0') break;\n b=0;\n for(j=i+1;jN) break;\n if(j>i+1 && s[i+1]=='0') break;\n if(s[j+1]=='0'&&(j+1)!=(l-1)) continue;\n c=0;\n for(k=j+1;kN) break;\n }\n if(k\n\n\nint isPrime(int n)\n{\n int i;\n for(i=2;i<=n/i;i++)\n if(n%i==0)\n return 0;\n return 1;\n}\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n==2)\n printf(\"1\\n\");\n else if(n%2==0)\n printf(\"2\\n\");\n else if(isPrime(n))\n printf(\"1\\n\");\n else if(isPrime(n-2))\n printf(\"2\\n\");\n else printf(\"3\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "4952e0acb0a636a234ab0b034893d431", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint prime(int n)\n{\n\tint i;\n\tfor (i=2; i*i<=n; i++)\n\t\tif (n%i==0) return 0;\n\treturn 1;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tif (prime(n)) printf(\"1\\n\");\n\telse if (n%2==0 || prime(n-2)) printf(\"2\\n\");\n\telse printf(\"3\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "b2dc050fbd9bc5088bb0e4cc4beb60f1", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint valid (char word[]) {\n int sum1 = 0, i, sum2 = 0;\n for(i = 0; i < 3; i++) {\n sum1 += word[i] - '0';\n sum2 += word[i + 3] - '0';\n }\n return sum1 == sum2;\n}\n\nint fill (int pos, char word[], char base[]) {\n int i;\n if(pos == 6) {\n if(valid(word) == 0) {\n return 100;\n }\n int change = 0;\n for(i = 0; i < 6; i++) {\n if(base[i] != word[i]) change++;\n }\n return change;\n }\n int ans = 100;\n for(i = 0; i < 10; i++) {\n word[pos] = (char)(i + '0');\n int check = fill(pos+1, word, base);\n if(check < ans) ans = check;\n word[pos] = '?';\n }\n return ans;\n}\n\nint main() {\n char base[6], word[6];\n scanf(\"%s\", base);\n printf(\"%d\\n\", fill(0, word, base));\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "c0a41ad97f2db43b6bf67f12735fb74e", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint str[7],i,j,b,tkt,sf,sn,opt,dif,rem,temp,check;\n\n\tscanf(\"%d\",&tkt);\n\tb = tkt;\n\n\tfor (i = 5; i >= 0; --i)\n\t{\n\t\tstr[i] = b%10;\n\t\tb/=10;\n\t}\n\n\tsf = str[0] + str[1] + str[2];\n\tsn = str[3] + str[4] + str[5];\n\n\tif(sn 18)\n\t\topt = 3;\n\telse if(dif > 0 && dif <= 9)\n\t{\n\t\tfor(i = 0, check = 0; i < 6; ++i)\n\t\t{\n\t\t\tif(i < 3)\n\t\t\t{\n\t\t\t\tif(str[i] + dif <= 9)\n\t\t\t\t{\n\t\t\t\t\tcheck = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(str[i] - dif >= 0)\n\t\t\t\t{\n\t\t\t\t\tcheck = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(check)\n\t\t\topt = 1;\n\t\telse\n\t\t\topt = 2;\n\t}\n\telse\n\t{\n\t\tfor(i = 0, check = 0; i < 6; ++i)\n\t\t{\n\t\t\tif(i < 3)\n\t\t\t{\n\t\t\t\trem = 9 - str[i];\n\t\t\t\tfor(j = 0, check = 0; j < 6; ++j)\n\t\t\t\t{\n\t\t\t\t\tif(j < 3)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(rem + 9-str[j] >= dif && i != j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcheck = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t if(str[j] + rem >= dif)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcheck = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\trem = str[i];\n\t\t\t\tfor(j = 0, check = 0; j < 6; ++j)\n\t\t\t\t{\n\t\t\t\t\tif(j < 3)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(rem + 9-str[j] >= dif)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcheck = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t if(rem + str[j] >= dif && i != j)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcheck = 1;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(check)\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif(check)\n\t\t\topt = 2;\n\t\telse\n\t\t\topt = 3;\n\t}\n\n\tprintf(\"%d\\n\",opt);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "implementation"], "code_uid": "79f77d0ce4cfa611ff7aa34ae7ae5273", "src_uid": "09601fd1742ffdc9f822950f1d3e8494", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\ntypedef long long int ll;\n\nll isprime[1000005];\nll primes[1000005];\nll cnt1[1000005];\n\nunsigned int nextPowerOf2(unsigned int n) \n{ \nunsigned count = 0; \n\nif (n && !(n & (n - 1))) \n return n; \n \nwhile( n != 0) \n{ \n n >>= 1; \n count += 1; \n} \n \nreturn 1 << count; \n}\n\nint main()\n{\n\tll n, cnt=0;\n\tscanf(\"%lld\", &n);\n\n\tll n2 = n;\n\n\tfor(int i=2;i<=n;i++)\n\t{\n\t\t// printf(\"1\\n\");\n\t\tif(isprime[i]==0)\n\t\t{\n\t\t\t// printf(\"2\\n\");\n\t\t\tprimes[cnt++]=i;\n\n\t\t\tfor(int j=2*i;j<=n;j+=i)\n\t\t\t\tisprime[j]=1;\n\t\t}\n\t}\n\tll max=0, min=1000005, flag=0;\n\t// printf(\"cnt %lld\\n\", cnt);\n\tfor(ll k=0; kmax)\n\t\t\t\tmax=cnt1[k];\n\n\t\t\tflag=1;\n\n\t\t\n\n\t\t\tn/=primes[k];\n\t\t\t// printf(\"%lld\\n\", n);\n\t\t}\n\n\t\t\tif(cnt1[k]min)\n\t{\t\n\t\t// if(min==1)\n\t\t// \tans2++;\n\n\t\tmin=max;\n\t\tif(min)\n\t\t{\n\t\t\t// if(nextPowerOf2(min)==min)\n\t\t\t// \tans2--;\n\n\t\t\tmin=nextPowerOf2(min);\n\t\t\t// printf(\"min is %lld\\n\", min);\n\n\t\t\tif(min==1)\n\t\t\t\tmin++;\n\n\t\t\tans2++;\n\t\t\twhile(min!=1)\n\t\t\t{\n\t\t\t\tans2++;\n\t\t\t\t// printf(\"ans2 %lld\\n\", ans2);\n\t\t\t\tmin/=2;\n\t\t\t\t// printf(\"min %lld\\n\", min);\n\t\t\t}\t\n\n\t\t\tmax=min;\n\t\t}\n\n\t\tprintf(\"%lld %lld\\n\", ans, ans2);\n\t}\n\n\telse if(min>1)\n\t{\t\n\t\tif(nextPowerOf2(min)==min && min!=1)\n\t\t\tans2--;\n\n\t\tmin=nextPowerOf2(min);\n\n\t\tif(min==1)\n\t\t\tmin++;\n\n\t\tans2++;\n\t\twhile(min!=1)\n\t\t{\n\t\t\tans2++;\n\t\t\t// printf(\"ans2 %lld\\n\", ans2);\n\t\t\tmin/=2;\n\t\t\t// printf(\"min %lld\\n\", min);\n\t\t}\n\n\t\tmax=min;\n\n\t\tprintf(\"%lld %lld\\n\", ans, ans2);\n\t}\t\n\t// ans2=min;\n\n\telse\n\t{\n\t\tans2=0;\n\n\t// printf(\"ans2 is %lld\\n\", ans2);\n\t// max-=min;\n\t// printf(\"max %lld\\n\", max);\n\t// max--;\n\n\t\tprintf(\"%lld %lld\\n\", ans, ans2);\n\n\t}\n\n\n\n\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "4eab8e9642959ad33529e29a840ec4db", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define SIZE 1000\n\nvoid factorization (int n, int p[], int k[], int *sz)\n{\n\tint d;\n\n\tif (n == 1)\n\t{\n\t\tp[0] = 1;\n\t\tk[0] = 1;\n\t\t*sz = 1;\n\t}\n\n\t*sz = 0;\n\n\tfor (d = 2; d * d <= n; d++)\n\t\tif (n % d == 0)\n\t\t{\n\t\t\tp[*sz] = d;\n\n\t\t\twhile (n % d == 0)\n\t\t\t{\n\t\t\t\tk[*sz]++;\n\t\t\t\tn /= d;\n\t\t\t}\n\n\t\t\t(*sz)++;\n\t\t}\n\n\tif (n != 1)\n\t{\n\t\tp[*sz] = n;\n\t\tk[(*sz)++] = 1;\n\t}\n}\n\nint is_power_of_two (int n)\n{\n\twhile (n % 2 == 0)\n\t\tn /= 2;\n\n\treturn n == 1;\n}\n\nint is_need_mult (int p[], int k[], int sz)\n{\n\tint i;\n\n\tif (is_power_of_two (k[0]))\n\t\tfor (i = 1; i < sz; i++)\n\t\t\tif (k[i] != k[i - 1])\n\t\t\t\treturn 1;\n\t\t\telse\n\t\t\t\tk[i] = k[i];\n\telse\n\t\treturn 1;\n\n\treturn 0;\n}\n\nint oper (int p[], int k[], int sz)\n{\n\tint i, cnt = 0, max = 0;\n\n\tfor (i = 0; i < sz; i++)\n\t\tif (k[i] > max)\n\t\t\tmax = k[i];\n\n\ti = 0;\n\t\n\twhile (1 << i < max)\n\t\ti++;\n\n\tcnt = i;\n\n\tif (is_need_mult (p, k, sz))\n\t\tcnt++;\n\n\treturn cnt;\n}\n\nint min_num (int p[], int sz)\n{\n\tint i, min = 1;\n\n\tfor (i = 0; i < sz; i++)\n\t\tmin *= p[i];\n\n\treturn min;\n}\n\nint main()\n{\n\tint n, i, sz, oper_cnt, p[SIZE] = {0}, k[SIZE] = {0};\n\n\tscanf (\"%d\", &n);\n\n\tfactorization (n, p, k, &sz);\n\n\toper_cnt = oper (p, k, sz);\n\n\tprintf (\"%d %d\\n\", min_num (p, sz), oper_cnt);\n\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "6e7e04320e482ea872c937c2d8c40dc5", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define MOD 1000000007\n\nlong long mpow(long long a, long long p)\n{\n a %= MOD;\n \n long long r = 1;\n while (p) {\n if ((1 & p)) r = (r * a) % MOD;\n a = (a * a) % MOD;\n p >>= 1;\n }\n return r;\n}\n\nint inv(long long x)\n{ return mpow(x, MOD-2); }\n\n#define MAXF 100005\n\nlong long factorial[MAXF];\n\nlong long possib(long long width, long long boxes, long long minh)\n{\n long long separators = width-1;\n long long elements = boxes-width*minh;\n\n if(elements < 0) return 0;\n else return (factorial[separators+elements]*inv(factorial[separators]*factorial[elements])) % MOD;\n}\n\nlong long all_possib, nice_possib;\nvoid add_all(long long x)\n{\n x %= MOD;\n all_possib += x;\n all_possib %= MOD;\n}\nvoid add_nice(long long x)\n{\n x %= MOD;\n nice_possib += x;\n nice_possib %= MOD;\n}\n\nint main()\n{\n long long fac;\n int i;\n int result;\n\n i = 0;\n for(fac = 1; i H) printf(\"1\\n\");\n else printf(\"0\\n\");\n return 0;\n }\n\n all_possib = 0;\n nice_possib = 0;\n for(width=1; width<=W; width++){\n add_all(possib(width, F, 1)*possib(width, W, 1));\n add_all(possib(width+1, F, 1)*possib(width, W, 1));\n add_all(possib(width, W, 1)*possib(width, F, 1));\n add_all(possib(width+1, W, 1)*possib(width, F, 1));\n\n add_nice(possib(width, F, 1)*possib(width, W, H+1));\n add_nice(possib(width+1, F, 1)*possib(width, W, H+1));\n add_nice(possib(width, W, H+1)*possib(width, F, 1));\n add_nice(possib(width+1, W, H+1)*possib(width, F, 1));\n }\n result = nice_possib*inv(all_possib) % MOD;\n\n printf(\"%d\\n\", result);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "combinatorics", "probabilities", "number theory"], "code_uid": "c325fbe05c9afcf6ddc5bfc057336abd", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n author: Maksim1744\n created: 24.10.2020 17:14:50\n*/\n\n#include \n#include \n\n#define max(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })\n#define min(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })\n\n#define mod 1000000007\n\nint a[1005];\n\nint main() {\n int n, x, pos;\n scanf(\"%d%d%d\", &n, &x, &pos);\n for (int i = 0; i < n; ++i) {\n a[i] = 0;\n }\n int left = 0, right = n;\n while (left < right) {\n int middle = (left + right) / 2;\n if (pos < middle) {\n a[middle] = 1;\n right = middle;\n } else {\n a[middle] = -1;\n left = middle + 1;\n }\n }\n int bigger = 0, smaller = 0;\n for (int i = 0; i < n; ++i) {\n if (i != pos) {\n if (a[i] == 1) bigger++;\n else if (a[i] == -1) smaller++;\n }\n if (a[i] == 1 && i == pos) {\n printf(\"0\\n\");\n return 0;\n }\n }\n\n long long C[1005][1005];\n for (int i = 0; i < 1005; ++i) {\n C[0][i] = 0;\n C[i][0] = 1;\n }\n\n for (int i = 1; i < 1005; ++i) {\n for (int j = 1; j < 1005; ++j) {\n C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;\n }\n }\n\n // printf(\"%d %d\\n\", smaller, bigger);\n // for (int i = 0; i < n; ++i) {\n // printf(\"%d \", a[i]);\n // }\n // printf(\"\\n\");\n\n long long f[1005];\n f[0] = 1;\n for (int i = 1; i < 1005; ++i)\n f[i] = (f[i - 1] * i) % mod;\n\n if (smaller > x - 1 || bigger > n - x) {\n printf(\"0\\n\");\n return 0;\n }\n\n long long res = C[x - 1][smaller] * C[n - x][bigger] % mod * f[smaller] % mod * f[bigger] % mod * f[n - smaller - bigger - 1] % mod;\n printf(\"%d\\n\", res);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["binary search", "combinatorics"], "code_uid": "becb83229045a118c861d5b5b0ca806c", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "# include \n\n\tconst int N = 1e3+194;\n\tconst int MOD = 1e9+7;\n\tconst int INF = 1e9+1097;\n\nlong long Fact(int n,int k)\n\t{\n \tlong long res = 1;\n \tfor(int i = (n-k)+1; i <= n; i++)\n\t\t{\n \tres *= i;\n \tres %= MOD;\n \t\t}\n \treturn res;\n}\n\nint main ()\n{\n\tint n,x,pos;\n\tscanf(\"%d %d %d\",&n,&x,&pos);\n\tint l = 0,r=n;\n\tint A = x-1,B = n-x,C = 0,D = 0;\n while(l < r)\n\t{\n int m = (l+r)/2;\n if(m < pos)\n\t\t{\n l = m+1;\n C += 1;\n }\n else if(pos < m)\n\t\t{\n r = m;\n D += 1;\n }\n else\n l = m+1;\n }\n long long res = 1;\n for(int i = 1; i <= n-1-C-D; i++)\n\t{\n res *= i;\n res %= MOD;\n }\n long long output;\n output =(((Fact(A,C)%MOD)*(Fact(B,D)%MOD)%MOD)*(res))%MOD;\n printf(\"%d\",output);\n}\n", "lang_cluster": "C", "tags": ["binary search", "combinatorics"], "code_uid": "9ed299aa45cac76d238da1c4d0eb4b08", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500.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 m) k = n, n = m, m = k;\n if(n==1){ printf(\"%d\\n\",m); continue; }\n if(n==2){\n k = (m/4) * 2;\n m %= 4;\n if(m > 2) m = 2;\n printf(\"%d\\n\",2*(k+m));\n continue;\n }\n\n res = (n*m+1)/2;\n printf(\"%d\\n\",res);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "constructive algorithms", "implementation"], "code_uid": "00b5b92679723f23220086b983181233", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint min(int a, int b)\n{\n if (a < b) {\n\t return a;\n } else {\n\t return b;\n }\n}\n\nint main()\n{\n int n, m;\n\n scanf(\"%d %d\", &n, &m);\n\n if (n > m) {\n\t int tmp = n;\n\t n = m;\n\t m = tmp;\n }\n\n if (n == 1) {\n\t printf(\"%d\\n\", m);\n\n\t return 0;\n }\n\n if (n == 2) {\n\t printf(\"%d\\n\", m / 4 * 4 + min(m % 4, 2) * 2);\n\n\t return 0;\n }\n\n printf(\"%d\\n\", (n * m + 1) / 2);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "graph matchings"], "code_uid": "12bdae2f119bf3c4d966758a5001f23c", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint n, m[20], r[20];\nint gcd(int x, int y){ return y?gcd(y, x%y):x; }\nint main()\n{\n int i, j, s, cnt=0;\n scanf(\"%d\", &n);\n for(i=1; i<=n; ++i) scanf(\"%d\", &m[i]);\n for(i=1; i<=n; ++i) scanf(\"%d\", &r[i]);\n s=1;\n for(i=1; i<=n; ++i)\n {\n s = s/gcd(s,m[i])*m[i];\n }\n for(i=0; i\n#include \n#include \n#include \n#include \n\nint main(int argc, char *argv[]) {\n int n, m[17], r[17], x[1000000], kolvo = 0;\n double result;\n scanf(\"%d\", &n);\n for (int i = 0; i < 1000000; i++) x[i] = 0;\n for (int i = 0; i < n; i++) scanf(\"%d\", &m[i]);\n for (int i = 0; i < n; i++) scanf(\"%d\", &r[i]);\n for (int i = 0; i < 1000000; i++) {\n for (int j = 0; j < n; j++) {\n if (i % m[j] == r[j]) x[i]++;\n }\n }\n for (int i = 0; i < 1000000; i++) if (x[i] > 0) kolvo++;\n result = kolvo / 1000000.0;\n printf(\"%100.4f\", (float) result);\n return 0;\n}", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "3525836588540e9f1c7a7cfc68021834", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n long long x1 = 0, x2 = 0, y1 = 0, y2 = 0, i = 0, j = 0, sum = 0;\n scanf (\"%lli %lli %lli %lli\", &x1, &y1, &x2, &y2);\n sum = ((x2 - x1 + 1) * ((y2 - y1 + 1) / 2)) + ((x2 - x1 + 2) * ((y2 - y1 + 1) % 2) / 2);\n printf (\"%lli\", sum);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "9c33dca4166050eab53bb9ec77b1b602", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.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 main(){\n int i, j, k;\n long long x1, y1, x2, y2, x, y, z, d, res;\n\n while (scanf(\"%lld %lld %lld %lld\", &x1, &y1, &x2, &y2) != EOF){\n x = (abs(y2 - y1) >> 1) + 1;\n z = x - 1;\n d = (x2 - x1) >> 1;\n res = (x * d) + (z * d) + x;\n printf(\"%lld\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "a30ea49cab3833645dd7aa3099a95608", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define A int\n#define B int\n\ntypedef struct {\n A first;\n B second;\n} pair;\n\npair make_pair(A first, B second)\n{\n pair p;\n \n p.first = first;\n p.second = second;\n \n return p;\n}\n\nint n, m;\nchar s1[101];\nchar s2[101];\npair dp[100][100];\npair dp2[100];\n\npair dfs(int x, int y)\n{\n if (x == n) {\n pair p = dfs(0, y);\n \n p.first++;\n \n return p;\n } else if (y == m) {\n pair p = make_pair(0, x);\n \n return p;\n } else {\n if (dp[x][y].first != -1) return dp[x][y];\n \n if (s1[x] == s2[y]) {\n return dp[x][y] = dfs(x + 1, y + 1);\n } else {\n return dp[x][y] = dfs(x + 1, y);\n }\n }\n}\n\nint main()\n{\n int b, d, x = 0, y = 0, c = 0, i, j;\n int p[26] = {0};\n int q[26] = {0};\n \n scanf(\"%d %d\", &b, &d);\n scanf(\"%s\", s1);\n scanf(\"%s\", s2);\n \n n = strlen(s1);\n m = strlen(s2);\n \n for (i = 0; i < n; i++) p[s1[i] - 'a']++;\n for (i = 0; i < m; i++) q[s2[i] - 'a']++;\n \n for (i = 0; i < 26; i++) {\n if (p[i] == 0 && q[i] > 0) {\n puts(\"0\");\n \n return 0;\n }\n }\n \n for (i = 0; i < n; i++) {\n for (j = 0; j < m; j++) {\n dp[i][j] = make_pair(-1, -1);\n }\n }\n \n for (i = 0; i < n; i++) {\n if (dp[i][0].first == -1) dfs(i, 0);\n }\n \n for (i = 0; i < n; i++) dp2[i] = make_pair(-1, -1);\n \n while (1) {\n x += dp[y][0].first;\n y = dp[y][0].second;\n \n if (x >= b) {\n if (x == b && y == 0) c++;\n \n break;\n }\n \n c++;\n \n if (dp2[y].first == -1) {\n dp2[y] = make_pair(x, c);\n } else {\n int z = x - dp2[y].first;\n \n if (x + z < b) {\n int w = (b - x - 1) / z;\n \n x += w * z;\n c += (c - dp2[y].second) * w;\n }\n }\n }\n \n printf(\"%d\\n\", c / d);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "strings"], "code_uid": "5a23ff5c3799407a761c3566f361b1e7", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nchar a[101],c[101];\nint before[101][101];//before[POS][Chk];\nint beforeI[101][101];\nmain(){\n int i,j,k,l,b,d,lenL=0,lenS=0,curChk=0,maxL,maxS,usebefore,first=-1,last=-1,point=i,memo,ans=0,remain,tmpa,tmpb,tmpChk;\n scanf (\"%d%d\",&b,&d);\n scanf (\"%s%s\",a,c);\n while (a[lenL]!=0)lenL++;\n while (c[lenS]!=0)lenS++;\n if (lenL*blenL){\n printf (\"0\");\n exit(0);\n }\n if (before[i%lenL][curChk%lenS]==0){\n before[i%lenL][curChk%lenS]=curChk;\n beforeI[i%lenL][curChk%lenS]=i;\n if (a[i%lenL]==c[curChk%lenS]) curChk++;\n //printf (\"test\\n\");\n }else if (maxL-i>i-beforeI[i%lenL][curChk%lenS]){\n tmpChk=curChk;\n tmpa=beforeI[i%lenL][curChk%lenS];\n tmpb=before[i%lenL][curChk%lenS];\n before[i%lenL][curChk%lenS]=curChk;\n beforeI[i%lenL][curChk%lenS]=i;\n //printf (\"GG\\n\");\n curChk+=(curChk-tmpb)*((maxL-i)/(i-tmpa));\n i+=(i-tmpa)*((maxL-i)/(i-tmpa))-1;\n //curChk+=(curChk-before[i%lenL][curChk%lenS])*tmpb;\n //i+=(i-tmpa)*tmpb;\n //curChk+=tmpChk-before[i%lenL][curChk%lenS];\n //i+=i-tmpa;\n }else{\n if (a[i%lenL]==c[curChk%lenS])curChk++;\n }\n /*if (curChk==lenS){\n last=i;\n }*/\n //curChk++;\n //if (curChk%maxS==0) ans++;\n\n /*\n if (curChk>=maxS&&first%lenL==i%lenL&&curChk%lenS==1){\n point=i;\n remain = maxL-i;\n memo=point-first;\n ans += remain/memo*ans;\n //printf (\"%d %d\\n\",maxL-i,memo);\n i+=(remain/memo)*memo;\n //i=maxL;\n }*/\n /*\n if (first%lenL==i%lenL&&curChk%lenS==0){\n point=i;\n remain = maxL-i;\n memo=point-first+1;\n curChk += (remain/memo)*curChk;\n //printf (\"%d %d\\n\",maxL-i,memo);\n i=(remain/memo)*i;\n //i=maxL;\n }\n */\n }\n //printf (\"%d\",curChk/maxS);\n //printf (\"%d : %d\\n\",i,curChk);\n printf (\"%d\",curChk/maxS);\n exit(0);\n\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "strings"], "code_uid": "3d0e8995ad4971b2539905729d976658", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tstatic int kk[10];\n\tlong long sum;\n\tint n, d, a, b;\n\n\tscanf(\"%d\", &n);\n\tfor (d = 1; d <= 9; d++)\n\t kk[d] = n / 9 + (n % 9 >= d);\n\tsum = 0;\n\tfor (a = 1; a <= 9; a++)\n\t\tfor (b = 1; b <= 9; b++)\n\t\t\tsum += (long long) kk[a] * kk[b] * kk[(a * b + 8) % 9 + 1];\n\tfor (a = 1; a <= n; a++)\n\t\tsum -= n / a;\n\tprintf(\"%lld\\n\", sum);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "0ae411d165a18416551ab5bfa089af69", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nunsigned long long f[9],g[9];\n\n// digital root je zapravo modul od 9.\n// ako je mod 9 == 0, digtalni root je 9.\n\nint main() {\n\tunsigned long long a,b,n;\n\tscanf(\"%lld\\n\",&n);\n\tfor (a=1;a<=n;a++) f[a%9]++;\n\tunsigned long long cnt=0;\n\tfor (a=0;a<9;a++)\n\t\tfor (b=0;b<9;b++)\n\t\t\tcnt+=f[a]*f[b]*f[a*b%9];\n\tfor (a=1;a*a<=n;a++)\n\t\tcnt-=(n-a*a)/a*2+1;\n\tprintf(\"%lld\\n\",cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "dd46ecdbfecf9edd8abd892e7cd84e50", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define min(a,b) a\ntypedef long long unsigned int u64;\nu64 dp[1<<24];\nu64 min(const u64 a, const u64 b) {\n return a < b ? a : b;\n}\nu64 solve(const u64 n, const u64 x, const u64 y) {\n dp[1] = x;\n for(int i = 1; i <= n; i++)\n if(i & 1) dp[i] = min(dp[i - 1] + x, dp[(i + 1) / 2] + x + y);\n else dp[i] = min(dp[i / 2] + y, dp[i - 1] + x);\n return dp[n];\n}\n\nint main(void) {\n int n, x, y;\n scanf(\"%d%d%d\", &n, &x, &y);\n printf(\"%llu\", solve(n, x, y));\n return 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "dp"], "code_uid": "79c7f3b5888c07dd700b7283372e389f", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.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;\n long long hr, hb, wr, wb;\n long long ans;\n\n scanf(\"%d %lld %lld %lld %lld\", &c, &hr, &hb, &wr, &wb);\n\n ans = 0;\n if (max(wr, wb) * max(wr, wb) > c)\n if (wr > wb)\n for (i = 0; c - wr * i >= 0; i++)\n ans = max(ans, hr * i + (c - wr * i) / wb * hb);\n else\n for (i = 0; c - wb * i >= 0; i++)\n ans = max(ans, hb * i + (c - wb * i) / wr * hr);\n else\n if (hr * wb > hb * wr)\n for (i = 0; c - wb * i >= 0 && i < wr; i++)\n ans = max(ans, hb * i + (c - wb * i) / wr * hr);\n else\n for (i = 0; c - wr * i >= 0 && i < wb; i++)\n ans = max(ans, hr * i + (c - wr * i) / wb * hb);\n\n printf(\"%lld\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "brute force"], "code_uid": "f9e2b14d823fbc2e8b0d85ee2e6dffff", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define LEVEL 1\nint main(){\n\tlong long int i,c,hr,hb,wr,wb,tmp,happy,max,happybase,num;\n\tscanf(\"%lld %lld %lld %lld %lld\",&c,&hr,&hb,&wr,&wb);\n\thappybase=0;\t\n\tif(c>(wr*wb*(LEVEL+1))){\n\t\tnum=(c/(wr*wb))-LEVEL;\n\t\tif((hr*wb)>=(hb*wr)){\n\t\t\thappybase=(hr*wb)*num;\n\t\t}else{\n\t\t\thappybase=(hb*wr)*num;\n\t\t}\n\t\tc-=(wr*wb)*num;\n\t}\n\tmax=0;\n\tif(wr>=wb){\n\t\tfor(i=0;(wr*i)<=c;i++){\n\t\t\ttmp=c-(wr*i);\n\t\t\thappy=(tmp/wb)*hb;\n\t\t\thappy+=(hr*i);\n\t\t\tif(max\n\nint ancestor(long long a, long long b) {\n\twhile (b > a)\n\t\tb >>= 1;\n\treturn b == a;\n}\t\n\nint main() {\n\tint h, c;\n\tlong long n, x, ans;\n\n\tscanf(\"%d%lld\", &h, &n);\n\tn += (1LL << h) - 1;\n\tx = 1, ans = h;\n\tc = 0;\n\twhile (x != n)\n\t\tif (ancestor(x, n)) {\n\t\t\tx = x << 1 ^ c; c ^= 1;\n\t\t\th--;\n\t\t} else {\n\t\t\tans += (1LL << h + 1) - 1;\n\t\t\tx >>= 1;\n\t\t\th++;\n\t\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "trees"], "code_uid": "f6faeec206118a75b8c110faf27e52b9", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tint i, h, x;\n\tlong long int n, tn, r;\n\tscanf(\"%d%lld\", &h, &n);\n\tn -= 1;\n\ttn = 1;\n\tr = 0;\n\tfor (i = 0; i < h; ++i)\n\t{\n\t\ttn *= 2;\n\t}\n\tx = 0;\n\tfor (i = 0; i < h; ++i)\n\t{\n\t\ttn /= 2;\n\t\tr += 1;\n\t\tif (tn & n)\n\t\t{\n\t\t\tif (x == 0)\n\t\t\t{\n\t\t\t\tr += 2 * tn - 1;\n\t\t\t}\n\t\t\tx = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (x == 1)\n\t\t\t{\n\t\t\t\tr += 2 * tn - 1;\n\t\t\t}\n\t\t\tx = 1;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", r);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "trees"], "code_uid": "d8e5c87e5121efaf309c0a14d60c6622", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define INF 1000000\n\nint dp[41][262144];\nint x,y;\n\nint piece[14][10]={\n {0,0},\n {0,0,0,1},\n {0,0,1,0},\n {0,0,1,0,0,1},\n {0,0,0,1,-1,1},\n {0,0,1,0,1,1},\n {0,0,0,1,1,1},\n {0,0,0,1,1,1,0,2},\n {0,0,1,0,2,0,1,1},\n {0,0,-1,1,0,1,0,2},\n {0,0,-1,1,0,1,1,1},\n {0,0,0,1,-1,1,1,1,0,2},\n {0,0,1,0,2,0},\n {0,0,0,1,0,2}\n};\nint pno[14]={1,2,2,3,3,3,3,4,4,4,4,5,3,3};\n\nint btr(int atx,int aty,int mask) {\n int res=INF,oldmask,cur,i,j,x2,y2;\n// printf(\"enter %d %d %d\\n\",atx,aty,mask);\n while(mask&(1<>=x;\n if(aty==y) return 0;\n }\n }\n// printf(\"traversed: %d %d %d\\n\",atx,aty,mask);\n if(dp[aty][mask]=x || y2>=y) goto fail;\n if(mask&(1<<(x2+(y2-aty)*x))) goto fail;\n mask|=1<<(x2+(y2-aty)*x);\n }\n// printf(\"at %d %d %d, try piece %d\\n\",atx,aty,oldmask,i);\n cur=1+btr(atx,aty,mask);\n if(res>cur) res=cur;\n fail:;\n }\n// printf(\"%d %d (%d): %d\\n\",atx,aty,oldmask,res);\n return dp[aty][oldmask]=res;\n}\n\nint main() {\n int t,i,j;\n while(scanf(\"%d %d\",&x,&y)==2) {\n if(x>y) t=x,x=y,y=t;\n for(i=0;i<=y;i++) for(j=0;j<(1<<(x*3));j++) dp[i][j]=INF;\n printf(\"%d\\n\",x*y-btr(0,0,0));\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "fc49e2295763af0b77f603beee4ee211", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint t[400],n,m,tot,ans,st[400],tail;\nvoid add(int i)\n{\n\tst[tail++]=i;\n}\nvoid del(int i)\n{\n\ttail--;\n}\nvoid dfs(int now,int cnt)\n{\n\tif(cnt>=ans)\n\t\treturn;\n\twhile(now0)\n\t\tnow++;\n\tif(now>=tot)\n\t{\n\t\tint i;\n\t\tfor(i=0;i=m)\n\t{\n\t\tto=now-m;\n\t\tt[to]++;\n\t\tif(to-m>=0)\t\tt[to-m]++;\n\t\tif(to%m>0)\t\tt[to-1]++; \n\t\tif(to+m=0)\t\tt[to-m]--;\n\t\tif(to%m>0)\t\tt[to-1]--;\n\t\tif(to+m0)\n\t{\n\t\tto=now-1;\n\t\tt[to]++;\n\t\tif(to-m>=0)\t\tt[to-m]++;\n\t\tif(to%m>0)\t\tt[to-1]++; \n\t\tif(to+m=0)\t\tt[to-m]--;\n\t\tif(to%m>0)\t\tt[to-1]--;\n\t\tif(to+m=0)\t\tt[to-m]++;\n\t\tif(to%m>0)\t\tt[to-1]++; \n\t\tif(to+m=0)\t\tt[to-m]--;\n\t\tif(to%m>0)\t\tt[to-1]--;\n\t\tif(to+m=0)\t\tt[to-m]++;\n\t\tif(to%m>0)\t\tt[to-1]++; \n\t\tif(to+m=0)\tt[to-m]--;\n\t\tif(to%m>0)\t\tt[to-1]--;\n\t\tif(to+m=0)\tt[now-m]++;\n\tif(now%m>0)\t\tt[now-1]++; \n\tif(now+m=0)\tt[now-m]--;\n\tif(now%m>0)\t\tt[now-1]--;\n\tif(now+m\n#include \n#include \n\nint main ()\n{\n\tint N, M;\n\tscanf(\"%d %d\",&N,&M);\n\tif (N > M)\n\t{\n\t\tint y = N; N = M; M = y;\n\t}\n\tif (N == 1)\n\t{\n\t\tif (M == 1) printf(\"%d\\n\",0);\n\t\telse if (M == 2) printf(\"%d\\n\",1);\n\t\telse if (M == 3) printf(\"%d\\n\",2);\n\t\telse if (M == 4) printf(\"%d\\n\",2);\n\t\telse if (M == 5) printf(\"%d\\n\",3);\n\t\telse if (M == 6) printf(\"%d\\n\",4);\n\t\telse if (M == 7) printf(\"%d\\n\",4);\n\t\telse if (M == 8) printf(\"%d\\n\",5);\n\t\telse if (M == 9) printf(\"%d\\n\",6);\n\t\telse if (M == 10) printf(\"%d\\n\",6);\n\t\telse if (M == 11) printf(\"%d\\n\",7);\n\t\telse if (M == 12) printf(\"%d\\n\",8);\n\t\telse if (M == 13) printf(\"%d\\n\",8);\n\t\telse if (M == 14) printf(\"%d\\n\",9);\n\t\telse if (M == 15) printf(\"%d\\n\",10);\n\t\telse if (M == 16) printf(\"%d\\n\",10);\n\t\telse if (M == 17) printf(\"%d\\n\",11);\n\t\telse if (M == 18) printf(\"%d\\n\",12);\n\t\telse if (M == 19) printf(\"%d\\n\",12);\n\t\telse if (M == 20) printf(\"%d\\n\",13);\n\t\telse if (M == 21) printf(\"%d\\n\",14);\n\t\telse if (M == 22) printf(\"%d\\n\",14);\n\t\telse if (M == 23) printf(\"%d\\n\",15);\n\t\telse if (M == 24) printf(\"%d\\n\",16);\n\t\telse if (M == 25) printf(\"%d\\n\",16);\n\t\telse if (M == 26) printf(\"%d\\n\",17);\n\t\telse if (M == 27) printf(\"%d\\n\",18);\n\t\telse if (M == 28) printf(\"%d\\n\",18);\n\t\telse if (M == 29) printf(\"%d\\n\",19);\n\t\telse if (M == 30) printf(\"%d\\n\",20);\n\t\telse if (M == 31) printf(\"%d\\n\",20);\n\t\telse if (M == 32) printf(\"%d\\n\",21);\n\t\telse if (M == 33) printf(\"%d\\n\",22);\n\t\telse if (M == 34) printf(\"%d\\n\",22);\n\t\telse if (M == 35) printf(\"%d\\n\",23);\n\t\telse if (M == 36) printf(\"%d\\n\",24);\n\t\telse if (M == 37) printf(\"%d\\n\",24);\n\t\telse if (M == 38) printf(\"%d\\n\",25);\n\t\telse if (M == 39) printf(\"%d\\n\",26);\n\t\telse printf(\"%d\\n\",26);\n\t}\n\telse if (N == 2)\n\t{\n\t\tif (M == 2) printf(\"%d\\n\",2);\n\t\telse if (M == 3) printf(\"%d\\n\",4);\n\t\telse if (M == 4) printf(\"%d\\n\",5);\n\t\telse if (M == 5) printf(\"%d\\n\",7);\n\t\telse if (M == 6) printf(\"%d\\n\",8);\n\t\telse if (M == 7) printf(\"%d\\n\",10);\n\t\telse if (M == 8) printf(\"%d\\n\",11);\n\t\telse if (M == 9) printf(\"%d\\n\",13);\n\t\telse if (M == 10) printf(\"%d\\n\",14);\n\t\telse if (M == 11) printf(\"%d\\n\",16);\n\t\telse if (M == 12) printf(\"%d\\n\",17);\n\t\telse if (M == 13) printf(\"%d\\n\",19);\n\t\telse if (M == 14) printf(\"%d\\n\",20);\n\t\telse if (M == 15) printf(\"%d\\n\",22);\n\t\telse if (M == 16) printf(\"%d\\n\",23);\n\t\telse if (M == 17) printf(\"%d\\n\",25);\n\t\telse if (M == 18) printf(\"%d\\n\",26);\n\t\telse if (M == 19) printf(\"%d\\n\",28);\n\t\telse printf(\"%d\\n\",29);\n\t}\n\telse if (N == 3)\n\t{\n\t\tif (M == 3) printf(\"%d\\n\",6);\n\t\telse if (M == 4) printf(\"%d\\n\",8);\n\t\telse if (M == 5) printf(\"%d\\n\",11);\n\t\telse if (M == 6) printf(\"%d\\n\",13);\n\t\telse if (M == 7) printf(\"%d\\n\",15);\n\t\telse if (M == 8) printf(\"%d\\n\",17);\n\t\telse if (M == 9) printf(\"%d\\n\",20);\n\t\telse if (M == 10) printf(\"%d\\n\",22);\n\t\telse if (M == 11) printf(\"%d\\n\",24);\n\t\telse if (M == 12) printf(\"%d\\n\",26);\n\t\telse printf(\"%d\\n\",29);\n\t}\n\telse if (N == 4)\n\t{\n\t\tif (M == 4) printf(\"%d\\n\",12);\n\t\telse if (M == 5) printf(\"%d\\n\",14);\n\t\telse if (M == 6) printf(\"%d\\n\",17);\n\t\telse if (M == 7) printf(\"%d\\n\",21);\n\t\telse if (M == 8) printf(\"%d\\n\",24);\n\t\telse if (M == 9) printf(\"%d\\n\",26);\n\t\telse printf(\"%d\\n\",30);\t\n\t}\n\telse if (N == 5)\n\t{\n\t\tif (M == 5) printf(\"%d\\n\",18);\n\t\telse if (M == 6) printf(\"%d\\n\",22);\n\t\telse if (M == 7) printf(\"%d\\n\",26);\n\t\telse printf(\"%d\\n\",29);\t\t\n\t}\n\telse printf(\"%d\\n\",26);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dsu", "dp", "bitmasks"], "code_uid": "6329912aa47757e4e6810d73e442acd6", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(3)\n#pragma GCC optimize(\"inline\")\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];\nlong long whole;\n\nvoid dfs(long long mask, int cur, int cura) {\n\tif (cura >= best) return;\n\tif (cur >= n * m) return;\n\tif (mask == whole) best = cura;\n\telse if ((mask | rest[cur]) ^ whole) 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\twhole = (1LL << n * m) - 1;\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": "ae00503d1ebeaf5a543db07e0a3fa2fc", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(3)\n#pragma GCC optimize(\"inline\")\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];\nlong long whole;\n\nvoid dfs(long long mask, int cur, int cura) {\n\tif (cura >= best) return;\n\tif (cur >= n * m) return;\n\tif (mask == whole) best = cura;\n\telse if ((mask | rest[cur]) ^ whole) 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, x, y;\n\tscanf(\"%d%d\", &n, &m);\n\twhole = (1LL << n * m) - 1;\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\tx = 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": "a250aec30bf25825f542516cb42d6916", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(1)\n#pragma GCC optimize(2)\n#pragma GCC optimize(3)\n#pragma GCC optimize(4)\n#pragma GCC optimize(5)\n#pragma GCC optimize(6)\n#pragma GCC optimize(7)\n#pragma GCC optimize(8)\n#pragma GCC optimize(9)\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\tscanf(\"%d%d\", &n, &m);\n\tfor (int i = 0; i < n; ++ i)\n\t\tfor (int j = 0; j < m; ++ j) {\n\t\t\tint num = i * m + j;\n\t\t\tfor (int 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[num] |= 1LL << x * m + y;\n\t\t\t}\n\t\t}\n\tfor (int 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": "8032625a71e8beb03c78e4bffc8064c5", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(3)\n#pragma GCC optimize(\"inline\")\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": "56b83f7896433a0f60425e95378563e5", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nconst int inf = 1000000000;\n\nint count(int a, int b) {\n\tif (b == 0)\n\t\tif (a == 1)\n\t\t\treturn 0;\n\t\telse\n\t\t\treturn inf;\n\n\treturn count(b, a%b) + a/b;\n}\n\nint main() {\n\tint n;\n\tscanf(\"%d\", &n);\n\n\tint i, m = inf;\n\tfor (i = 1; i <= n; i++) {\n\t\tint c = count(i, n);\n\t\tif (c < m)\n\t\t\tm = c;\n\t}\n\n\tprintf(\"%d\\n\", m-1);\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "number theory", "brute force"], "code_uid": "4a4430b400e5588a1b4adf091460727f", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, m = 1e9, i;\n\n scanf(\"%d\", &n);\n\n for (i = 1; i <= n; i++) {\n\t int p = n, q = i, c = 0;\n\n\t while (1) {\n\t if (p == q) {\n\t\t if (p > 1) c = -1;\n\n\t\t break;\n\t }\n\n\t if (p > q) {\n\t\t if (q == 1) {\n\t\t\t c += p - 1;\n\n\t\t\t break;\n\t\t }\n\n\t\t p -= q;\n\t } else {\n\t\t if (p == 1) {\n\t\t\t c += q - 1;\n\n\t\t\t break;\n\t\t }\n\n\t\t q -= p;\n\t }\n\n\t c++;\n\t }\n\n\t if (c >= 0 && c < m) m = c;\n }\n\n printf(\"%d\\n\", m);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "number theory", "brute force"], "code_uid": "f03993ac6a39fcb0b25015a405beb88f", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long binsearch(long long n, long long m) {\n\tlong long l = 0, r = n + 1, mid;\n\n\twhile (r - l > 1) {\n\t\tmid = (l + r) / 2;\n\t\tif (n * 2 / (mid + 1) < mid)\n\t\t\tr = mid;\n\t\telse\n\t\t\tl = mid;\n\t}\n\tr = l + 1, l = -1;\n\twhile (r - l > 1) {\n\t\tmid = (l + r) / 2;\n\t\tif (mid * (mid + 1) / 2 + m + mid < n)\n\t\t\tl = mid;\n\t\telse\n\t\t\tr = mid;\n\t}\n\treturn r + 1;\n}\n\nint main() {\n\tlong long n, m;\n\n\tscanf(\"%lld%lld\", &n, &m);\n\tif (n <= m)\n\t\tprintf(\"%lld\\n\", n);\n\telse\n\t\tprintf(\"%lld\\n\", m + binsearch(n, m + 1));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "37b3251f19c35bf8dc309409ac0d8229", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n\tlong long m,n,d,tmp=0,i;\n\tscanf(\"%lld %lld\",&n,&m);\n\tif(n<=m) printf(\"%lld\",n);\n\telse\n\t{\n\t\td=n-m;\n\t\tfor(i=1;;i++)\n\t\t{\n\t\t\ttmp+=i;\n\t\t\tif(tmp>=d) break;\n\t\t}\n\t\tprintf(\"%lld\",m+i);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "d949f02b1cabc0ca4ef4f2b3827b4866", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n\n#define mset(a) memset(a,0,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n#define mcmp(a,b,n) memcmp(a,b,n)\n#define maxint 2147483647\n#define pi 3.14159265358979323846\n\nlong long n,t,ans=0,k;\nlong long a[111],cnk[111][111];\n\nlong long turn(long long t)\n{\n long long i=0;\n \n if(t&(t-1))\n return -1;\n \n while(t>>=1)\n i++;\n return i;\n}\n\nint main()\n{\n int i,j,l;\n \n a[0]=1;\n for(i=1;i<63;i++)\n a[i]=a[i-1]<<1;\n mset(cnk);\n for(i=0;i<111;i++)\n {\n cnk[i][0]=1;\n for(j=1;j<=i;j++)\n cnk[i][j]=cnk[i-1][j-1]+cnk[i-1][j];\n }\n \n scanf(\"%I64d%I64d\",&n,&t);\n \n k=turn(t);\n if(k==-1)\n {\n printf(\"0\\n\");\n return 0;\n }\n \n for(i=1;n>a[i];i++)\n {\n ans+=cnk[i][k];\n n-=a[i];\n }\n for(i=62;i>=0;i--)\n if((~k)&&(n>>i&1))\n {\n ans+=cnk[i][k];\n k--;\n }\n \n printf(\"%I64d\\n\",ans);\n \n //system(\"pause\");\n return 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "fdaeb25fbcd29621122fb35c962eaa2a", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nlong long ch(int n, int k) {\n\treturn k == 0 ? 1 : ch(n - 1, k - 1) * n / k;\n}\n\nint main() {\n\tlong long n, m, t, ans;\n\tint k, b, l;\n\n\tscanf(\"%lld%lld\", &n, &t), n += 2;\n\tif (t & t - 1) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tk = 0;\n\twhile (t > 0) {\n\t\tk++;\n\t\tt >>= 1;\n\t}\n\tb = 0;\n\tfor (m = n; m > 1; m >>= 1)\n\t\tb++;\n\tans = 0;\n\tfor (l = 0; b >= 0; b--)\n\t\tif (n & 1LL << b) {\n\t\t\tif (b >= k - l)\n\t\t\t\tans += ch(b, k - l);\n\t\t\tif (++l > k)\n\t\t\t\tbreak;\n\t\t}\n\tif (k == 1)\n\t\tans--;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "constructive algorithms"], "code_uid": "ae39d00db05bb244581f74f1b00ec89e", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define N\t13\n#define M\t12\n#define N_\t1594323\t/* N_ = pow(3, N) */\n#define M_\t531441\t/* M_ = pow(3, M) */\n\nstruct V {\n\tlong long sum;\n\tint cnt;\n} uu[N_], vv[M_];\n\nlong long ff[20];\n\nint fill(struct V *vv, int *aa, int n) {\n\tint i, b, p, np;\n\n\tp = 1;\n\tfor (i = 0; i < n; i++)\n\t\tp *= 3;\n\tnp = 0;\n\tfor (b = 0; b < p; b++) {\n\t\tint a, valid, cnt;\n\t\tlong long sum;\n\n\t\tvalid = 1;\n\t\tsum = 0, cnt = 0;\n\t\tfor (i = 0, a = b; i < n; i++, a /= 3) {\n\t\t\tint c = a % 3;\n\n\t\t\tif (c == 1)\n\t\t\t\tsum += aa[i];\n\t\t\telse if (c == 2) {\n\t\t\t\tif (aa[i] >= 20) {\n\t\t\t\t\tvalid = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsum += ff[aa[i]];\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\t\tif (valid) {\n\t\t\tstruct V *v = &vv[np++];\n\n\t\t\tv->sum = sum;\n\t\t\tv->cnt = cnt;\n\t\t}\n\t}\n\treturn np;\n}\n\nint compare_u(const void *a, const void *b) {\n\tstruct V *u = (struct V *) a;\n\tstruct V *v = (struct V *) b;\n\n\treturn u->sum == v->sum ? u->cnt - v->cnt : u->sum < v->sum ? -1 : 1;\n}\n\nint compare_v(const void *a, const void *b) {\n\tstruct V *u = (struct V *) a;\n\tstruct V *v = (struct V *) b;\n\n\treturn u->sum == v->sum ? v->cnt - u->cnt : u->sum > v->sum ? -1 : 1;\n}\n\nint main() {\n\tstatic int aa[N], bb[M];\n\tint n, m, np, nq, k, h, i, j, h_, i_, j_;\n\tlong long s, f, ans;\n\n\tscanf(\"%d%d%lld\", &n, &k, &s);\n\tm = n / 2, n -= m;\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tfor (j = 0; j < m; j++)\n\t\tscanf(\"%d\", &bb[j]);\n\tf = 1;\n\tfor (i = 0; i < 20; i++) {\n\t\tff[i] = f;\n\t\tf *= i + 1;\n\t}\n\tnp = fill(uu, aa, n);\n\tnq = fill(vv, bb, m);\n\tqsort(uu, np, sizeof *uu, compare_u);\n\tqsort(vv, nq, sizeof *vv, compare_v);\n\tans = 0;\n\tfor (i = 0, i_ = 0; i < np; i = j) {\n\t\tj = i + 1;\n\t\twhile (j < np && uu[j].sum == uu[i].sum)\n\t\t\tj++;\n\t\twhile (i_ < nq && vv[i_].sum + uu[i].sum > s)\n\t\t\ti_++;\n\t\tif (i_ < nq && vv[i_].sum + uu[i].sum == s) {\n\t\t\tj_ = i_ + 1;\n\t\t\twhile (j_ < nq && vv[j_].sum == vv[i_].sum)\n\t\t\t\tj_++;\n\t\t\tfor (h = i, h_ = i_; h < j && h_ < j_; h++) {\n\t\t\t\twhile (h_ < j_ && vv[h_].cnt + uu[h].cnt > k)\n\t\t\t\t\th_++;\n\t\t\t\tans += j_ - h_;\n\t\t\t}\n\t\t\ti_ = j_;\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "binary search", "bitmasks", "meet-in-the-middle"], "code_uid": "c3b9b5274b6f6146941bd7d79bba842a", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() {\n\tlong long int i,j,k,l=1,n,m,r,max,x;\n\tscanf(\"%lld%lld\",&n,&k);\n\tmax = (k*(k-1))/2+1;\n\tr = k;\n\tif(max < n)\n\t\tprintf(\"-1\\n\");\n\telse {\n\t\twhile(l <= r) {\n\t\t\tm = (l+r)/2;\n\t\t\tif(max - (m*(m-1))/2+1 > n)\n\t\t\t\tl = m+1;\n\t\t\telse\n\t\t\t\tr = m-1;\n\t\t}\n\t\tprintf(\"%lld\\n\",k-l+1);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search"], "code_uid": "cda155d0699dcb337bc844ffe7f0cd53", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nmain()\n{\n long long int i,j,k,n,p,lo,hi,mid,a,max,flag=0;\n scanf(\"%lld %lld\",&n,&k);\n //n=499999998500000001;\n //k=1000000000;\n if(n==1)\n {\n printf(\"0\\n\");\n return 0;\n }\n\n if(n<=k)\n {\n printf(\"1\\n\");\n return 0;\n }\n max=(k*(k-1)/2)+1;\n if(n>max)\n {\n printf(\"-1\\n\");\n return 0;\n }\n if(n==max)\n {\n printf(\"%lld\\n\",k-1);\n return 0;\n }\n lo=1;\n hi=k-1;\n while(lon)\n hi=mid;\n if(a\n#include\n#include\n#include\n\ntypedef long long int int64;\n\nstatic void printInt(int64 n){\n if(n<0){putchar('-');n=-n;}\n if(n==0){putchar('0');return;}\n int s[20];int len=0;\n while(n>0){s[len++]=n%10+'0';n/=10;}\n while(len>0){putchar(s[--len]);}\n}\nstatic int64 readInt(void){\n int prev='\\0';int c=getchar();\n while(!('0'<=c && c<='9')){prev=c;c=getchar();}\n int64 res=0;\n while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}\n return prev=='-'?-res:res;\n}\n\n#define POS(i,j) ((i)*(c+1)+(j))\n\nconst int mod=1000000007;\n\nint inv(int a){\n int t=1;\n while(a>1){\n t=(int64)t*(mod-mod/a)%mod;\n a=mod%a;\n }\n return t;\n}\n\nvoid run(void){\n int64 n=readInt();\n int k=readInt();\n int ans=1;\n int64 p;\n for(p=2;p*p<=n;p++){\n if(n%p!=0) continue;\n int c=0;\n while(n%p==0){\n n/=p;\n c++;\n }\n int *dp=(int *)calloc((k+1)*(c+1),sizeof(int));\n dp[POS(0,c)]=1;\n int i,j,l;\n for(i=0;i1){\n int dp[2]={0,1};\n for(int i=0;i\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nconst i32 mod = 1000000007;\n\n#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)\n#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)\n\ni32 inv (i32 a) {\n i32 t = 1;\n while (a > 1) {\n t = (i64) t * (mod - mod / a) % mod;\n a = mod % a;\n }\n return t;\n}\n\ni32 calc (i64 p, const i32 c, const i32 k) {\n i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));\n dp[c] = 1;\n i32 *prob = (i32 *) calloc (c + 1, sizeof (i32));\n for (i32 i = 0; i <= c; ++i) {\n prob[i] = inv (i + 1);\n }\n for (i32 i = 0; i < k; ++i) {\n i32 sum = 0;\n for (i32 j = 0; j <= c; ++j) {\n i32 v = (i64) prob[j] * dp[j] % mod;\n ADD(sum, v);\n }\n for (i32 j = 0; j <= c; ++j) {\n i32 assign = sum;\n i32 v = (i64) prob[j] * dp[j] % mod;\n SUB(sum, v);\n dp[j] = assign;\n }\n }\n p %= mod;\n i32 ans = 0;\n for (i32 i = c; i >= 0; --i) {\n ans = ((i64) p * ans + dp[i]) % mod;\n }\n free (dp);\n free (prob);\n return ans;\n}\n\nvoid run (void) {\n i64 n = read_int();\n i32 k = read_int();\n i64 ans = 1;\n for (i64 p = 2; p * p <= n; ++p) {\n if (n % p != 0) continue;\n i32 c = 0;\n while (n % p == 0) {\n n /= p;\n ++c;\n }\n ans = ans * calc (p, c, k) % mod;\n }\n if (n > 1) ans = ans * calc (n, 1, k) % mod;\n print_int (ans);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities", "number theory"], "code_uid": "87e306e8773acfd20f71ece6c94f825a", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{int i,j=0,n,l,t,b[26]={0},c[26]={0};char a[105]={'\\0'};\nscanf(\"%d\",&n);\nscanf(\"%s\",a);\nt=strlen(a);\n\nfor(i=0;i=0)\nfor(i=0;i<(t+1)/2;i++)\n{if(a[i]==a[t-1-i]&&a[i]=='?')\n{if(j>0)\n{\n a[i]='a';a[t-1-i]='a';j--;\n}\nelse\n{a[i]=c[l++]+97;a[t-1-i]=a[i];\n}}\nelse if(a[i]!=a[t-i-1])\n{\n if(a[i]=='?'||a[t-1-i]=='?')\n {if(a[i]=='?')\n a[i]=a[t-1-i];\n else\n {a[t-1-i]=a[i];}\n\n }\n else\n {V:\n printf(\"IMPOSSIBLE\");\n goto flag;\n }\n}\n}else\ngoto V;\nprintf(\"%s\",a);\nflag:\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing"], "code_uid": "04152a742509a2e782aa3531d43f0682", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint freq[1000];\nint main()\n{\n\tchar alpha[1000];\n\talpha[97]='a';\n\talpha[98]='b';\n\talpha[99]='c';\n\talpha[100]='d';\n\talpha[101]='e';\n\talpha[102]='f';\n\talpha[103]='g';\n\talpha[104]='h';\n\talpha[105]='i';\n\talpha[106]='j';\n\talpha[107]='k';\n\talpha[108]='l';\n\talpha[109]='m';\n\talpha[110]='n';\n\talpha[111]='o';\n\talpha[112]='p';\n\talpha[113]='q';\n\talpha[114]='r';\n\talpha[115]='s';\n\talpha[116]='t';\n\talpha[117]='u';\n\talpha[118]='v';\n\talpha[119]='w';\n\talpha[120]='x';\n\talpha[121]='y';\n\talpha[122]='z';\n\n\tint k;\n\tscanf(\"%d\",&k);\n\tchar s[1000];\n\tscanf(\"%s\",s);\n\tint len=strlen(s);\n\tint chars=0;\n\tint i;\n\tfor(i=0;i=0;i--)\n\t{\n\t\twhile(freq[t]!=0)\n\t\t{\n\t\t\tt--;\n\t\t}\n\t\tif(t<97)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tif(s[i]=='?')\n\t\t{\n\t\t\tfreq[t]++;\n\t\t\ts[i]=alpha[t];\n\t\t\ts[len-1-i]=alpha[t];\t\n\t\t}\n\t}\n\tfor(i=len/2;i>=0;i--)\n\t{\n\t\tif(s[i]=='?')\n\t\t{\n\t\t\ts[i]=alpha[97];\n\t\t\ts[len-1-i]=s[i];\n\t\t}\n\t}\n\tint flag=0;\n\tfor(i=97;i<97+k;i++)\n\t{\n\t\tif(freq[i]==0)\n\t\t{\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(flag==1)\n\t{\n\t\tprintf(\"IMPOSSIBLE\\n\");\n\t}\n\telse\n\t{\n\t\tprintf(\"%s\\n\",s);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing"], "code_uid": "7b777f7a263e8bb955fa76ef8ac2fcb0", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\n\nint main(){\n\nint k;\n\nscanf(\"%d\",&k);\n\nchar str[101];\n\nscanf(\"%s\",str);\n\nint arr[27]={0};\nint n=strlen(str);\nint i;\nint count=0;\nfor(i=0;iindex){\n\t\n\tint h;\n\tfor(h=0;h=index)\n\t\t\tbreak;\n\t}\t\n\n}\n//printf(\"%s\\n\",str);\n\nint flag=1;\n\tif(i\n#include \n\nint main()\n{\n int k, n, p = 0, q = 0, i, j;\n char s1[101], s2[102];\n int a[26] = {0};\n\n scanf(\"%d\", &k);\n\n scanf(\"%s\", s1);\n\n n = strlen(s1);\n\n for (i = 0; i < n; i++) {\n\t s2[n - i - 1] = s1[i];\n }\n\n for (i = 0; i < (n + 1) / 2; i++) {\n\t if (s1[i] == '?') {\n\t if (s2[i] == '?') {\n\t\t p++;\n\t } else {\n\t\t if (a[s2[i] - 'a']++ == 0) q++;\n\n\t\t s1[i] = s2[i];\n\t }\n\t } else {\n\t if (s2[i] == '?') {\n\t\t if (a[s1[i] - 'a']++ == 0) q++;\n\n\t\t s1[n - i - 1] = s1[i];\n\t } else {\n\t\t if (s1[i] == s2[i]) {\n\t\t\t if (a[s1[i] - 'a']++ == 0) q++;\n\t\t } else {\n\t\t\t puts(\"IMPOSSIBLE\");\n\n\t\t\t return 0;\n\t\t }\n\t }\n\t }\n }\n\n if (p + q < k) {\n\t puts(\"IMPOSSIBLE\");\n\n\t return 0;\n }\n\n for (i = 0; i < (n + 1) / 2; i++) {\n\t if (s1[i] == '?') {\n\t if (p + q > k) {\n\t\t s1[i] = s1[n - i - 1] = 'a';\n\n\t\t if (a[0]++ == 0) q++;\n\t } else {\n\t\t for (j = 0; j < 26; j++) {\n\t\t\t if (a[j] == 0) break;\n\t\t }\n\n\t\t s1[i] = s1[n - i - 1] = 'a' + j;\n\n\t\t a[j]++;\n\n\t\t q++;\n\t }\n\n\t p--;\n\t }\n }\n\n printf(\"%s\\n\", s1);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing"], "code_uid": "9eb3c27119ecbd7e929385de8f4e1832", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(){\n char s[1001];\n int letters[27];\n int i, j, k, len, as, empty, need;\n\n memset(letters, 0, 27*sizeof(int));\n \n scanf(\"%d\", &k);\n scanf(\"%s\", &s);\n\n \n len = strlen(s);\n empty = 0;\n \n for(i=0, j = len-1; i < (len+1)/2; i++, j--){\n\n if ((s[i] == '?') == s[j]){\n empty++;\n continue;\n }\n else if (s[i] == '?'){\n if(s[j] == '?'){\n\tempty++;\n\tcontinue;\n }\n s[i] = s[j];\n }\n else if (s[j] == '?'){\n if(s[i] == '?'){\n\tempty++;\n\tcontinue;\n }\n s[j] = s[i];\n }\n else if (s[i] != s[j]){\n printf(\"IMPOSSIBLE\\n\");\n return 0;\n }\n letters[s[i] - 'a']++;\n }\n\n need = k;\n for(i=0; i < k; i++)\n if(letters[i])\n need--;\n\n if(need > empty){\n printf(\"IMPOSSIBLE\\n\");\n return 0;\n }\n\n as = empty - need;\n for(i=0; as; i++){\n if(s[i] == '?'){\n s[i] = s[len-i-1] = 'a';\n as--;\n }\n }\n\n j = 0;\n for(; i < (len+1)/2; i++){\n if(s[i] == '?'){\n while(letters[j] && ++j);\n s[i] = s[len-i-1] = j + 'a';\n j++;\n }\n }\n\n printf(\"%s\\n\", s);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing"], "code_uid": "1a7c247acf89ef10063c6a361f7dc214", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n\tint a[27], k, i, j, len, count = 0, first;\n\tchar t[110];\n\tscanf(\" %d %s\", &k, t);\n\tfor(i = 0; i < k; i ++)\n\t\ta[i] = 0;\n\tlen = strlen(t);\n\tfor(i = 0; i < len; i ++)\n\t{\n\t\tif(t[i] == '?')\n\t\t\tcount ++;\n\t\telse\n\t\t\ta[t[i] - 'a'] ++;\n\t}\n\tfor(i = 0; i < k; i ++)\n\t\tif(a[i] == 0)\n\t\t{\n\t\t\tfirst = i;\n\t\t\tbreak;\n\t\t}\n\tj = k - 1;\n\t//printf(\"%d\\n\", a[j]);\n\tfor(i = len / 2 - (1 - len % 2); i > -1; i --)\n\t{\n\t\tif(t[i] == '?')\n\t\t{\n\t\t\tif(t[len - i - 1] == '?')\n\t\t\t{\n\t\t\t\twhile(a[j] != 0 && j > 0)\n\t\t\t\t\tj --;\n\t\t\t\t//printf(\"%d\\n\", j);\n\t\t\t\tt[i] = j + 'a';\n\t\t\t\tt[len - i - 1] = j + 'a';\n\t\t\t\ta[j] ++;\n\t\t\t}\n\t\t\telse\n\t\t\t\tt[i] = t[len - i - 1];\n\t\t}\n\t}\n\tfor(i = 0; i < len; i ++)\n\t{\n\t\tif(t[i] == '?')\n\t\t\tt[i] = t[len - i - 1];\n\t}\n\tfor(i = 0; i < len; i ++)\n\t{\n\t\tif(t[i] != t[len - i - 1])\n\t\t{\n\t\t\tprintf(\"IMPOSSIBLE\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tfor(i = 0; i < k; i ++)\n\t\ta[i] = 0;\n\tfor(i = 0; i < len; i ++)\n\t\ta[t[i] - 'a'] ++;\n\tfor(i = 0; i < k; i ++)\n\t\tif(a[i] == 0)\n\t\t{\n\t\t\tprintf(\"IMPOSSIBLE\");\n\t\t\treturn 0;\n\t\t}\n\tprintf(\"%s\", t);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["expression parsing"], "code_uid": "b8cba468f8b200d7459da03937c3651c", "src_uid": "9d1dd9d722e5fe46823224334b3b208a", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int n,k,i,l,a[26]={0},j;\n char s[105];\n scanf(\"%d%s\",&k,s);\n l=strlen(s);\n for(i=0;i<=l/2;i++)\n {\n if(s[i]=='?'&&s[l-i-1]!='?')\n s[i]=s[l-i-1];\n else if(s[i]!='?'&&s[l-i-1]=='?')\n s[l-i-1]=s[i];\n if(s[i]!=s[l-i-1])\n {\n printf(\"IMPOSSIBLE\\n\");\n return 0;\n }\n if(s[i]!='?')\n a[s[i]-'a']=1;\n if(s[l-i-1]!='?')\n a[s[l-i-1]-'a']=1;\n }\n j=k-1;\n for(i=l/2;i>=0;i--)\n {\n while(a[j]==1&&j>=0)\n j--;\n if(j<0) break;\n if(s[i]=='?'&&s[l-i-1]=='?')\n {\n s[i]=j+'a';\n s[l-i-1]=s[i];\n a[j]=1;\n j--;\n }\n }\n for(i=0;i\r\n \r\n#define M\t16\r\n \r\nint main() {\r\n\tstatic char used[M];\r\n\tint n, m;\r\n \r\n\tscanf(\"%d%d\", &n, &m);\r\n\twhile (n > 0) {\r\n\t\tif (used[n % m]) {\r\n\t\t\tprintf(\"NO\\n\");\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tused[n % m] = 1;\r\n\t\tn /= m;\r\n\t}\r\n\tprintf(\"YES\\n\");\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "ca09b9d9374cd24b4e8d558af6000157", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint main() {\n int n, m;\n scanf(\"%d %d\", &n, &m);\n\n int digits[14] = {0};\n bool dup = true;\n while (n) {\n int d = n % m;\n if (digits[d]) {\n dup = false;\n break;\n } else {\n digits[d] = 1;\n }\n\n n /= m;\n }\n\n if (dup) {\n puts(\"YES\");\n } else {\n puts(\"NO\");\n }\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "d147fa7fc49cd35057c02effceb4c1af", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define K\t18\n#define M\t100\n\nint main() {\n\tstatic int dd[K];\n\tstatic long long dp[1 << K][M];\n\tlong long n;\n\tint m, h, k, b, r, used;\n\n\tscanf(\"%lld%d\", &n, &m);\n\tk = 0;\n\twhile (n > 0) {\n\t\tdd[k++] = n % 10;\n\t\tn /= 10;\n\t}\n\tused = 0;\n\tfor (h = 0; h < k; h++)\n\t\tif (dd[h] != 0 && (used & 1 << dd[h]) == 0) {\n\t\t\tused |= 1 << dd[h];\n\t\t\tdp[1 << h][dd[h] % m] = 1;\n\t\t}\n\tfor (b = 0; b < 1 << k; b++)\n\t\tfor (r = 0; r < m; r++) {\n\t\t\tlong long x = dp[b][r];\n\n\t\t\tif (x != 0) {\n\t\t\t\tused = 0;\n\t\t\t\tfor (h = 0; h < k; h++)\n\t\t\t\t\tif ((b & 1 << h) == 0 && (used & 1 << dd[h]) == 0) {\n\t\t\t\t\t\tused |= 1 << dd[h];\n\t\t\t\t\t\tdp[b | 1 << h][(r * 10 + dd[h]) % m] += x;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\tprintf(\"%lld\\n\", dp[(1 << k) - 1][0]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "combinatorics", "bitmasks", "number theory"], "code_uid": "e0300590a75d878dd6e99f14f0d0e6cf", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.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][13] = {{},{2},{4},{11},{32},{97},{295},{940},{3148},{10901},{38324},{135313},{478989},{1704939},{6120951},{22187311},{81129556},{298715961},{1105546606},{4107686743},{2426959363,3},{1411039897,13},{4172194186,49},{3689174689,187},{43344991,708},{2441471173,2674},{2801489501,10124},{260107736,38400},{2954951606,145893},{606296452,555183},{1899297838,2115855},{3084773566,8075123},{234294028,30859921},{691111333,118085088},{2180959654,452401618},{1792754283,1735233324},{2132034018,2368089356,1},{1709961728,4137532123,5},{177031067,4063007484,22},{994451568,1625053238,88},{3917739273,3065624025,340},{1540443642,2939324613,1314},{2048043699,924465791,5077},{1535675300,4143681610,19623},{1508306498,2169966175,75908},{3628011891,3750388408,293847},{690756141,2273958850,1138333},{3186013409,1633929753,4412841},{3713415519,2737515922,17118132},{1580819397,2755090312,66446442},{3380663546,3219914187,258079131},{4204882545,2751845304,1002972229},{2671126449,3985320580,3900042842},{1549923635,2321666527,2288550180,3},{3206088422,3837458666,3229658027,13},{468076678,684189096,2394878431,53},{317846743,2409125435,2929850439,208},{2292706160,2431336997,2081275227,813},{3980228298,3870290811,2271141075,3172},{2281921514,2428712631,3857202388,12377},{1410084376,2665199272,1218646022,48313},{1725477252,938399815,2490820090,188650},{96934866,3021873877,4292106543,736911},{3976807065,4196403427,2309669478,2879607},{381043316,3742984064,581598293,11256562},{75998957,558211513,3386244876,44017760},{2481446098,3420110131,878568493,172184876},{2998084519,2760121094,3693315328,673755597},{1152419028,2385275115,2073185204,2637216508},{2854085154,4023337502,2033791001,1735803802,2},{923550706,4030810318,3175452562,1786539181,9},{971375603,1399426681,1063836258,3816608870,36},{2026326245,317960303,107930394,2395208751,144},{3032216567,1211669851,2768624282,2750243364,566},{962635926,2853748285,932538563,3069568420,2221},{929452190,980373970,1397224474,1107065389,8713},{3844112081,2178623972,365972575,3179860998,34180},{2309493692,3520537616,437394707,1605782278,134118},{2212877625,2922712134,95698419,3521874850,526378},{3552645532,3742906242,3849668270,299359034,2066376},{1938082639,329182225,3901861703,3461124247,8113696},{1135006092,3990987912,565559913,3870994863,31865765},{3496777998,2726710279,3456622192,1473857377,125176826},{726284190,554922189,1177992859,2941984575,491830434},{1174922238,3146728744,935205998,249307383,1932843670},{1927883506,2548886969,3104826080,2071924719,3302449968,1},{552744259,966302059,593280121,3357489715,4099236778,6},{4057737811,3172120154,3385034438,3377497541,1487985982,27},{1120930094,52594514,1676802786,854221959,2375555749,107},{1038179455,2469373338,1067790354,815292734,357146485,423},{3401792308,639953706,455471950,2389477057,2540495932,1664},{814342077,1190616845,1267241187,3067979529,1675977447,6550},{2621993594,2832313139,1127278177,3805827021,746798329,25781},{1714067937,4219985196,3969544797,136803453,2317603907,101487},{4152787624,3611142829,843196231,3916033443,3079218285,399572},{3461864546,3893743275,2900292828,1608204305,1869768837,1573441},{3003514123,3308980254,3534417324,1621178584,481241785,6196916},{2679664471,1996930534,318652848,2268304523,3541589603,24410101},{185152026,3138914840,1871119221,1559019881,2206013312,96168136},{3737829797,1320722003,1895671615,3178554427,3061812461,378930161},{203925008,3794021407,2579620510,3431217976,3019797624,1493317916},{2468134907,3475974877,3086405423,1142109993,4005905823,1590884110,1},{180449137,547269777,665325677,2842676501,2144395769,1727357320,5},{1617684553,878842739,3960341086,1281770673,1738535346,1282366575,21},{123339094,1072406502,1883229773,1124342891,720266287,4222745088,83},{3205877069,1493036374,4168832930,361101124,1207377007,869413080,331},{30245458,166380545,1871598255,2461437325,1132735956,1418272557,1306},{4075272123,2038959813,655609662,3492982470,3995427741,486078374,5153},{608326718,1107150586,1686622377,947478086,1489690413,1051457018,20330},{4136754916,2162103160,1723971343,3979622104,220587964,3441819447,80217},{2175296377,2687555805,2858485317,2068680116,2714338065,3815351148,316557},{941177009,2263937754,4286501999,592569842,2476199853,2077265316,1249363},{72166211,744371576,1452653805,2742004280,2576941298,3652970668,4931474},{3013494591,2372455071,534269120,1360461613,3759274278,3238915720,19467772},{508737026,2615515531,1184239988,3149494987,3669012804,3205495324,76861038},{4046190885,1049147236,347431385,615864993,3013055269,783975557,303491052},{895896758,1263297489,2129431640,4200962499,4253682392,2227802501,1198489786},{862593958,4076271219,471546334,831422713,3429802533,2758946637,438405932,1},{1558843359,3239232053,4200145856,1332916817,3018622542,3909986823,1516372374,4},{3604235363,2959047772,1884763672,3716891921,127819947,2316365163,841289782,17},{2148016453,2600462985,3400301264,3261250221,3339364795,3609467668,4019991120,67},{2057336361,3281406422,2001356007,305233474,2662253073,3418788389,1817744880,268},{1281508345,928813361,2816581598,2007723331,2740688108,4273224708,2920853098,1060},{3426260777,1763297880,1175966776,3062570720,731743090,2726359719,3082793264,4191},{3210960410,3752915728,459191299,128440564,2984187704,97991247,4030488828,16566},{224166267,2234372978,753139562,3865891512,1486162002,1307841019,3762849709,65483},{260505741,545447754,3027390222,3521038051,2886878098,3868240693,2774668015,258861},{3445525626,4221229308,1386534263,2297987493,4173116713,4207227667,4141018726,1023390},{4142247892,2446668656,2319675620,965790995,3309615310,2135638134,1728304023,4046274},{2796886765,2836129926,4105771002,1871082482,3736667518,147213948,2633468854,15999570},{445505098,42453983,2107373830,2161264577,3236071391,3845846548,2434224601,63270306},{3838187199,490614644,3657555088,4103603341,1344831810,990431249,3994847387,250224339},{1047857076,2176168119,682300933,1335570400,3705580851,2101545607,4139870456,989684043},{3026384570,2242942353,2616680991,3487926651,3956283706,1869088125,2484171217,3914717263},{1071498200,3773154979,1706585509,742961663,3077446206,215191244,2514290529,2601141681,3},{2872507125,1304608611,2805013961,3835527537,489570676,3914819730,1656827998,1135993546,14},{3155154964,780193390,2193623906,1209128819,1418105045,725432432,3669496663,1878768769,56},{253659020,3880096607,144011870,1507161628,1464179160,2378916704,1158684783,1341570611,223},{2212582435,445734981,3630891622,2426151389,3122490297,2334190077,1744231515,2896978552,883},{2142647548,3600176835,2830071678,2961075988,1714835724,2925612276,3820302557,339695552,3497},{4294886677,3361034647,906607836,1269791512,1220171111,1544351226,1002394444,2129097500,13840},{501822294,1725262855,3183461603,2954658854,2164388124,640674278,3687166976,244870596,54781},{810510306,323305484,3430675847,1333959229,3023582709,4122725661,4162215479,3998267249,216840},{2066497053,2791669159,1066700710,2401391628,2204319308,382832680,452636133,892117603,858388},{795280433,3187355406,2545609941,3296708892,338474730,3457915698,49592690,624245225,3398266},{1581357444,3332957275,3991329316,1823248956,3664649114,3049475936,1436313055,108314556,13454320},{2890310043,2645865047,96602101,1985398087,2830455143,2769232370,3231689536,3016839684,53271680},{3673691692,78846736,745302479,838402949,1165410335,1692653857,3976907779,1367965842,210940949},{295563602,975450609,3170861384,1205290655,658762743,4047422421,2054553,2367895997,835323744},{2508957223,2683160723,401608967,3574638073,2537772230,3214369508,3288302812,4058536503,3308093533},{3776557089,1460840502,3147310815,2456004160,3562408518,3775964939,3388939830,427668466,216849571,3},{3728035062,1926856823,1177012130,3575198692,2209903221,113586407,3333408737,3712521410,353438384,12},{2607331913,4283270230,3600202517,876899479,1796104827,817161666,294106662,2136843986,3686222256,47},{3314615494,2761020062,2280369741,3898619731,3911823627,1182841733,921495705,1987759554,2490255816,189},{2590245496,3473058917,1492013628,624914759,3628302063,1440754051,3417778275,1003682760,106726210,751},{2633783210,2706506985,3094738545,828125704,2671377987,626840589,3752738738,3900703516,1656794022,2975},{28448344,2669463898,1385628852,1136650614,2118617121,813824129,3389598254,193974302,2158698592,11788},{759262343,302349887,3002808773,3528037846,3942292190,2970558354,2489204802,2262249038,4058358874,46708},{3335417267,309921878,334820301,2461381894,3006674440,3130341194,1757099604,976305824,1192497803,185083},{1960107932,45317162,829795120,2938679609,1321490743,813033324,901851337,2388825974,3085146788,733431},{806769803,4249618887,2322214279,268106502,2400608845,3705101671,1006868560,1555518405,1473524019,2906546},{3016024504,2109541762,302478533,3002549037,3359936194,4230216640,1792321929,1405771399,3338048212,11519126},{405528202,3152747679,1869032290,1022171990,2330178010,2440852913,3340825247,2702598955,1813170149,45654784},{392072299,1470040061,1345165237,334840075,4161634659,3723030012,396217175,2217547197,4143434417,180957739},{1432108212,1114744425,1018959253,2618969148,4172016277,4104617249,229313722,1461796977,1676488993,717285187},{3917524871,829882129,3501994447,4017135301,3074069020,2694309690,2684793248,2587840425,3290780412,2843348555},{1944206482,1442962768,2769991002,137897471,3987464733,1155485997,2536824880,2998553209,2648147189,2681821845,2},{3344805947,411892603,4126656246,2211517675,2444913124,957967558,1038021382,4082245269,1767355398,1736798769,10},{3802521073,3267053531,1313646101,2324872666,878940337,3215631351,2931920803,4200923446,324319828,1073506513,41},{2654567614,1568808025,1803729542,2143384822,1658736425,192485054,1968155916,2580905691,2996803246,2366165782,163},{2560754697,2732109758,2650989258,3065464363,1119140648,1320459588,2818622314,274089733,1416601562,2113969709,648},{1429470319,2031880934,3023721394,1497346884,3095305271,698965458,2481352053,4125722246,3087616259,1941794290,2571},{1184856486,1823601604,2177114912,1188216408,321207596,4169904552,1298722721,2792835748,1750494046,137661912,10197},{593626344,3685718606,932835303,4281953533,3355177948,15176347,4132811439,1667095290,2027158372,348096588,40438},{2762201132,270311472,1739761745,3323556446,1688792644,4252294308,98283754,45888612,1013106595,4157530014,160371},{3538598781,1630328471,2324233659,2623719054,3542209653,833501619,3225441426,2426749849,342949796,919573965,636044},{618700117,1847361613,2568402629,3402135662,4069406530,3440726719,1961879249,1816107549,1163097643,861392142,2522707},{2616807824,290482935,4008503304,2827388725,3398823662,41448142,888703054,2313506850,1710980580,1436672924,10006146},{905330484,1850737061,1755710640,293093431,2890512416,1845155700,4293226377,1367354510,759724617,2153923292,39690547},{2000560120,887237321,1040273567,1259018161,97219236,4276904417,1725515412,2870030510,2879450930,3189702845,157444445},{863642990,954603462,536622170,3252710478,3940502922,1729125146,1554480730,1290181440,1973587814,248555840,624579026},{1697327337,2918819084,150398406,3763881191,2636440703,4265356736,2157835805,1468367803,3848765537,59446342,2477804464},{2446323117,1333533671,2168747137,2854032017,3081391650,4183505187,3650047026,188779407,526016429,2761793340,1240348821,2},{1300231750,3902915121,1981986679,3427190560,3237911263,3291691015,562702363,3149480449,2579229057,19020837,347055068,9},{3657932198,488720328,1446344547,3834564368,1480352990,2827046885,2880609475,697749222,2257195171,3354404202,127861599,36},{3397923977,2798002524,301001927,2304309288,1687826763,2483601671,1779363633,1352057091,713809587,2696685452,4127204450,142},{4028816566,2408052650,1213680384,4256359194,3002614222,1364230970,783390155,4126636361,832523803,2282722679,1171138251,567},{1736176841,397389969,1228600389,1516725449,2895163479,2150566846,2811167753,294595860,3564441822,1721701828,205228753,2251},{2429761274,984698965,4108659942,1199674335,293635739,625424232,948286406,3972991993,1611407721,1500862,4154934097,8932},{3222210919,690114320,50448257,2804373465,1017961958,2039183893,489159216,1151280382,158773765,2768634720,2995763167,35450},{375716695,3859193991,896415991,2993529817,3509832398,1871422233,1586062355,668318591,3165286699,495636988,3108898623,140692},{3085768643,3180394296,2124249810,1205857906,3158086867,3386222583,3793549621,3819173062,3911540842,1904718767,287398360,558388},{3435903375,4291098692,493489606,406838170,2190529579,2074994943,759798382,4196166923,3215154043,3785784988,2520590895,2216246},{3359148995,1436143251,1921872544,3037272504,3281484062,2051801502,1168216991,762202114,1408033153,2299479341,378749039,8796650},{2192988308,3067744296,1930751395,548234159,829700582,3436686196,2247851925,784563272,3717975929,908149877,1580872919,34916738},{3007043623,975843659,2616296461,3737306179,3684324109,3267538666,421308555,1472776780,1635862811,1071292237,1068791155,138601192},{2821316210,1748725430,2412011903,2527125975,948281510,391305600,772588344,3276862062,1944460202,2748703689,856637215,550195511},{4052977779,3163937748,3036712795,1138645612,501033727,4264799249,1380676331,3187355932,1832139079,645165555,1337462030,2184156409},{4201727360,2754890041,1042005963,1322883592,245155897,3538921510,886161692,1902765029,2170171535,1392634951,192228728,81019411,2},{1199257909,273544693,1994261149,3010295901,1839507415,77097517,1408801718,459303161,1544392329,3025296585,2726440504,64657343,8},{2102743037,2393063500,876912794,2198839926,3912872240,4095736174,2637471038,2384888107,503769424,4041934301,2348599738,3528755911,31}};\n\nint main () {\n int n, M;\n scanf(\"%d %d\", &n, &M);\n ull v = 0;\n for (int j = 12; j >= 0; j--) {\n v = (v<<32)|ans[n][j];\n v %= M;\n }\n printf(\"%lld\\n\", v);\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "9eb034af7398f7c062d88878fdadb553", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define M\t4167669\t/* (23 choose 7) * 17 */\n#define C\t16\n#define K\t2000000000\n#define T\t7\n\nvoid print(int k) {\n\tif (k == 0)\n\t\treturn;\n\tprint(k / C);\n\tprintf(\"%c\", k % C < 10 ? k % C + '0' : k % C - 10 + 'a');\n}\n\nint add(int a, int b) { return (long long) a + b < K ? a + b : K; }\n\nint choose[C + T][C + T];\n\nvoid init() {\n\tint n, r;\n\n\tchoose[0][0] = 1;\n\tfor (n = 1; n < C + T; n++) {\n\t\tchoose[n][0] = 1;\n\t\tfor (r = 1; r <= n; r++)\n\t\t\tchoose[n][r] = choose[n - 1][r - 1] + choose[n - 1][r];\n\t}\n}\n\nint dp[M], m;\n\nvoid branch(int *aa, int h) {\n\tint a, len, j;\n\n\tif (h == C) {\n\t\tfor (len = 0; len <= C; len++) {\n\t\t\tif (len == 0)\n\t\t\t\tdp[m] = 1;\n\t\t\telse\n\t\t\t\tfor (h = 0; h < C; h++) {\n\t\t\t\t\tif (aa[h] == 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (h == 0 || aa[h - 1] != aa[h]) {\n\t\t\t\t\t\ta = aa[h] - 1;\n\t\t\t\t\t\tj = m / (C + 1) - choose[C - h - 1 + T - a][T - a];\n\t\t\t\t\t\tif (h < C - 1)\n\t\t\t\t\t\t\tj += choose[C - h - 2 + T - a][T - a];\n\t\t\t\t\t\tj = j * (C + 1) + len - 1;\n\t\t\t\t\t}\n\t\t\t\t\tdp[m] = add(dp[m], dp[j]);\n\t\t\t\t}\n\t\t\tm++;\n\t\t}\n\t\treturn;\n\t}\n\tfor (a = h == 0 ? 0 : aa[h - 1]; a <= T; a++) {\n\t\taa[h] = a;\n\t\tbranch(aa, h + 1);\n\t}\n}\n\nint idx(int *aa, int len) {\n\tint h, a, sum;\n\n\tsum = 0;\n\tfor (h = 0; h < C; h++)\n\t\tfor (a = h == 0 ? 0 : aa[h - 1]; a < aa[h]; a++)\n\t\t\tsum += choose[C - h - 1 + T - a][T - a];\n\treturn sum * (C + 1) + len;\n}\n\nint compare(const void *a, const void *b) {\n\tint ia = *(int *) a;\n\tint ib = *(int *) b;\n\n\treturn ia - ib;\n}\n\nint main() {\n\tstatic int aa[C], bb[C];\n\tint k, t, h, i, len, first;\n\n\tscanf(\"%d%d\", &k, &t);\n\tif (t >= 8) {\n\t\tprint(k);\n\t\tprintf(\"\\n\");\n\t\treturn 0;\n\t}\n\tinit();\n\tbranch(aa, 0);\n\tfor (h = 0; h < C; h++)\n\t\taa[h] = t;\n\tfor (len = 1; ; len++) {\n\t\tint cnt = dp[idx(aa, len)];\n\n\t\taa[0]--; cnt -= dp[idx(aa, len - 1)]; aa[0]++;\n\t\tif (k <= cnt)\n\t\t\tbreak;\n\t\tk -= cnt;\n\t}\n\tfirst = 1;\n\twhile (len-- > 0) {\n\t\tfor (h = first ? 1 : 0; h < C; h++) {\n\t\t\tmemcpy(bb, aa, C * sizeof *aa);\n\t\t\tif (bb[h] == 0)\n\t\t\t\tcontinue;\n\t\t\tbb[h]--;\n\t\t\tqsort(bb, C, sizeof *bb, compare);\n\t\t\tif (k > dp[i = idx(bb, len)]) {\n\t\t\t\tk -= dp[i];\n\t\t\t\tbb[h]++;\n\t\t\t} else {\n\t\t\t\tprintf(\"%c\", h < 10 ? h + '0' : h - 10 + 'a');\n\t\t\t\taa[h]--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfirst = 0;\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "b3508d55c715e2436703923244197a0b", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#define max(a,b) (((a) > (b)) ? (a) : (b))\n#define min(a,b) (((a) < (b)) ? (a) : (b))\n\nint main()\n{\n\tint n, i;\n\tscanf(\"%d\",&n);\n\tint arr[n];\n\tfor(i = 0;i < n;i++){\n\t\tscanf(\"%d\",&arr[i]);\n\t}\n\tint dp[2][n];\n\tdp[0][n-1] = arr[n-1];dp[1][n-1] = 0;\n\tfor(i = n-2; i >= 0;i--){\n\t\tdp[0][i] = max(arr[i]+dp[1][i+1],dp[0][i+1]);\n\t\tdp[1][i] = min(arr[i]+dp[1][i+1],dp[0][i+1]);\n\t}\n//\tprintf(\"%d %d\\n\",dp[1][n-2],dp[0][n-2]);\n\tprintf(\"%d %d\",dp[1][0],dp[0][0]);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "a4c1427ebe0aa1651931ea0fa6bc8b17", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint max(int a,int b)\n{\n\tif(a>b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\nint fun(int *a,int i,int n)\n{\n\tint temp;\n\tif(i==n-1)\n\t\treturn a[i];\n\telse\n\t{\n\t\ttemp=fun(a,i+1,n);\n\t\treturn max(temp,a[i]-temp);\n\t}\n}\nint main()\n{\n\tint n,i,ans;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tfor(i=0;i=0;i--)\n\t\ta[i]=a[i+1]+a[i];\n\tans=fun(a,0,n);\n\tprintf(\"%d %d\\n\",a[0]-ans,ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "474c6bd391b590aa0ae7fbc5a1d3e031", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\nvoid fun(char *);\nvoid fun(char *s)\n{\n int n=strlen(s);\n int i;\n for(i=0;i\n#include \n#include \n\nbool braille(char *a, int len)\n{\n if(len == 1)\n {\n if(a[0] == '3' || a[0] == '7')\n return true;\n else\n return false;\n }\n\n\tint i = 0;\n\tint n = len - 1;\n\n\twhile(i < n)\n\t{\n int old_i = i;\n\n if((a[i] == '4' && a[n] == '6') || (a[i] == '6' && a[n] == '4'))\n i++;\n\n else if((a[i] == '5' && a[n] == '9') || (a[i] == '9' && a[n] == '5'))\n i++;\n\n else if((a[i] == '8' && a[n] == '0') || (a[i] == '0' && a[n] == '8'))\n i++;\n\n else if(a[i] == '3' && a[n] == '3')\n i++;\n\n else if(a[i] == '7' && a[n] == '7')\n i++;\n\n if(i == old_i)\n return false;\n else\n n--;\n }\n\n if(a[i] == '1' || a[i] == '2')\n return false;\n else\n return true;\n}\n\nint main()\n{\n char num[10];\n scanf(\"%s\", num);\n\n braille(num, strlen(num))? printf(\"Yes\\n\") : printf(\"No\\n\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5e97a7c65c8af0f2efd2cffa37b70c17", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define mod 1000000009\n#define max(a,b) ((a)>(b)?(a):(b))\n\nchar str[15][15]={0};\nchar prefix[106][15]={0};\nlong o=0;\nlong g[106][4]={0},m;\nchar gene[5]=\"ACGT\";\n\nlong f[1006][106][15]={0};\nlong a[106]={0};\nchar opt[15]={0};\n\nlong find(char opt[],long l,long r)\n{\n long i,j,k;\n long a[15]={0};\n \n for(i=1;i<=m;i++)\n {\n for(j=1;opt[j];j++)\n {\n for(k=0;opt[j+k]==str[i][1+k]&&opt[j+k]&&str[i][1+k];k++);\n if(!str[i][1+k])\n for(k=0;str[i][1+k];k++)\n a[j+k]=1;\n }\n }\n for(j=l;j<=r;j++)\n if(!a[j])\n return 0;\n return 1;\n}\n\nlong search(char opt[],long l)\n{\n long i,j,k;\n long a[15]={0};\n \n for(i=1;i<=m;i++)\n {\n for(j=1;opt[j];j++)\n {\n for(k=0;opt[j+k]==str[i][1+k]&&opt[j+k]&&str[i][1+k];k++);\n if(!str[i][1+k])\n for(k=0;str[i][1+k];k++)\n a[j+k]=1;\n }\n }\n for(i=l+1;a[i];i++);\n return i-1;\n}\n\nint main()\n{\n long n,i,j,k,l,t;\n long ans=0;\n char ch;\n \n scanf(\"%ld%ld\",&n,&m);\n for(i=1;i<=m;i++)\n scanf(\"%s\",str[i]+1);\n for(i=1;i<=m;i++)\n for(j=1;str[i][j];j++)\n {\n ch=str[i][j+1];\n str[i][j+1]=0;\n for(k=1;k<=o;k++)\n if(strcmp(prefix[k]+1,str[i]+1)==0)\n break;\n if(k>o)\n {\n strcpy(prefix[++o]+1,str[i]+1);\n prefix[o][0]=strlen(prefix[o]+1);\n }\n str[i][j+1]=ch;\n if(!str[i][j+1])\n a[k]=1;\n }\n \n for(i=0;i<=o;i++)\n {\n for(j=0;j<4;j++)\n {\n // prefix[i][prefix[i][0]+1]=gene[j];\n memset(opt,0,sizeof(opt));\n strcpy(opt,prefix[i]);\n opt[opt[0]+1]=gene[j];\n for(k=1;k<=prefix[i][0]+1;k++)\n for(l=1;l<=o;l++)\n {\n if(strcmp(opt+k,prefix[l]+1)==0)\n {\n g[i][j]=l;\n goto loop;\n }\n }\n loop:;\n }\n //prefix[i][prefix[i][0]+1]=0;\n }\n \n f[0][0][0]=1;\n for(i=0;i=0||find(opt,k+1,prefix[j][0]+1-prefix[g[j][l]][0]))\n t=search(opt,k);\n if(t>=prefix[j][0]+1-prefix[g[j][l]][0])\n {\n f[i+1][g[j][l]][t-(prefix[j][0]+1-prefix[g[j][l]][0])]+=f[i][j][k];\n f[i+1][g[j][l]][t-(prefix[j][0]+1-prefix[g[j][l]][0])]%=1000000009;\n }\n }\n }\n for(j=1;j<=o;j++)\n for(k=0;k<=prefix[j][0];k++)\n if(find(prefix[j],k+1,prefix[j][0]))\n {\n ans+=f[n][j][k];\n ans%=mod;\n }\n printf(\"%ld\\n\",ans);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings", "dp", "trees"], "code_uid": "c52b7f85dd676710c442c73393ef085d", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define M 1000000009\n\ntypedef long long LL;\nint n,m,sz,son[110][4],fail[110],term[110],par[110],l[110],q[110],dig[110];\nLL f[1010][110][20];\nLL dp(int i,int u,int o);\n\nint main(void)\n{\n //freopen(\"gene.in\",\"r\",stdin);\n //freopen(\"gene.out\",\"w\",stdout);\n scanf(\"%d%d\",&n,&m);\n memset(son,0,sizeof(son));\n memset(term,0,sizeof(term));\n sz=1; l[1]=0;\n int i,j,u,v,t,d;\n char str[20];\n for(i=1;i<=m;i++)\n {\n scanf(\"%s\",str);\n for(u=1,j=0;str[j];j++)\n {\n if(str[j]=='A') t=0;\n else if(str[j]=='C') t=1;\n else if(str[j]=='G') t=2;\n else t=3;\n if(!son[u][t])\n {\n l[++sz]=l[u]+1;\n son[u][t]=sz;\n }\n par[son[u][t]]=u;\n u=son[u][t];\n }\n term[u]=1;\n }\n memset(fail,-1,sizeof(fail));\n fail[1]=0;\n for(i=0;i<4;i++)\n fail[son[1][i]]=1;\n int front=1,rear=1;\n q[1]=1;\n while(front<=rear)\n {\n u=q[front]; d=dig[front];\n front++;\n if(fail[u]<0)\n for( fail[u]=1,v=fail[par[u]] ; v ; v=fail[v] )\n if(son[v][d])\n {\n fail[u]=son[v][d];\n break;\n }\n for(i=0;i<4;i++)\n if(son[u][i])\n {\n rear++;\n q[rear]=son[u][i]; dig[rear]=i;\n }\n }\n memset(f,-1,sizeof(f));\n printf(\"%I64d\\n\",dp(0,1,0));\n return 0;\n}\n\nLL dp(int i,int u,int o)\n{\n if(f[i][u][o]>=0) return f[i][u][o];\n else if(i==n)\n return f[i][u][o] = o ? 0 : 1;\n f[i][u][o]=0;\n int j,v,w,t;\n for(j=0;j<4;j++)\n {\n for( w=0,v=u ; v&&l[v]>=o ; v=fail[v] )\n if(son[v][j])\n {\n w=son[v][j];\n break;\n }\n if(w)\n {\n for(t=w;l[t]>=o+1;t=fail[t])\n if(term[t]) break;\n f[i][u][o] = ( f[i][u][o] + dp(i+1,w,l[t]\n#include \n#include \n\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long dp[105][105][10];\nbool visited[105][105][10];\n\nlong long F(int n, int c, int r){\n if (!r) return 1;\n if (!n) return 0;\n if (visited[n][c][r]) return dp[n][c][r];\n\n long long res = F(n - 1, c, r) + (F(n - 1, c - 1, r - 1) * c);\n visited[n][c][r] = true;\n return (dp[n][c][r] = res);\n}\n\nint main(){\n int n;\n while (scanf(\"%d\", &n) != EOF){\n clr(visited);\n long long res = F(n, n, 5);\n printf(\"%lld\\n\", res);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "dffbef2d664382fa6f8bf4dcad76962b", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main()\n{\n\t long long n,t,l;\n\tscanf(\"%lld\",&n);\n\tl=(n*(n-1)*(n-2)*(n-3)*(n-4))/120;\n\tt=l*l*120;\n\tprintf(\"%lld\",t);\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "5ab600372f620c2ed81654cea3c4c5a3", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define big 1000000007\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n==1)\n\t{\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\telse if (n==2)\n\t{\n\t\tprintf(\"3\\n\");\n\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tlong long int a = 1, b = 3 , temp;\n\t\tint i=1; \n\t\tfor( ; i <= n-2 ; i++)\n\t\t{\n\t\t\ttemp = b%big;\n\t\t\tb = (a+b+2)%big;\n\t\t\ta = temp%big;\n\t\t}\n\t\tprintf(\"%I64d\\n\",b);\n\t\treturn 0;\n\t}\n}\n", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "f5f01b994565984590ad14b58c7b219b", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\nint sol(int n){\n int dp[n+1];\n dp[1]=1;\n dp[2]=3;\n dp[3]=6;\n for(int i=4;i<=n;i++){\n dp[i]=(dp[i-1]+dp[i-2]+2)%1000000007;\n }\n return dp[n];\n}\nint main(){\n int n;\n scanf(\"%d\",&n);\n printf(\"%d\\n\",sol(n));\n}", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "494de74ecef76d9add2f4246b470cf38", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define Maxm 100\n#define mod 1000000007\n\n__attribute__((always_inline)) __inline__\nvoid multiply(int m, int A[][Maxm], int B[][Maxm], int C[][Maxm]) {\n\tregister int i, j, k;\n\tfor (i = 0; i < m; i++) {\n\t\tfor (j = 0; j < m; j++) C[i][j] = 0;\n\t\tfor (k = 0; k < m; k++) for (j = 0; j < m; j++)\n\t\t\tC[i][j] = (C[i][j] + (long long)A[i][k] * B[k][j]) % mod;\n\t}\n}\n\nvoid power(int m, int A[][Maxm], int P[][Maxm], int T[][Maxm], long long k) {\n\tif (!k) {\n\t\tregister int i, j;\n\t\tfor (i = 0; i < m; i++)\n\t\t\tfor (j = 0; j < m; j++)\n\t\t\t\tP[i][j] = (i == j);\n\t}\n\telse if (k & 1) {\n\t\tpower(m, A, P, T, k / 2);\n\t\tmultiply(m, P, P, T), multiply(m, T, A, P);\n\t}\n\telse {\n\t\tpower(m, A, T, P, k / 2);\n\t\tmultiply(m, T, T, P);\n\t}\n}\n\nint main() {\n\tregister int i, j;\n\tstatic int A[Maxm][Maxm] = {};\n\tstatic int P[Maxm][Maxm] = {};\n\tstatic int T[Maxm][Maxm] = {};\n\tlong long n;\n\tint m, ans;\n\tscanf(\"%lld%d\", &n, &m);\n\tif (n < m) return puts(\"1\") & 0;\n\tfor (i = 0; i < m - 1; i++) A[i][i + 1] = 1;\n\tA[m - 1][0] = A[m - 1][m - 1] = 1;\n\tpower(m, A, P, T, n - m + 1);\n\tfor (ans = j = 0; j < m; j++)\n\t\tans = (ans + P[m - 1][j]) % mod;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "dp"], "code_uid": "156e8aa2ac83037c26fca5298393ed1e", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef long long int int64;\n\nstatic void printInt(int64 n){\n if(n<0){putchar('-');n=-n;}\n if(n==0){putchar('0');return;}\n int s[20];int len=0;\n while(n>0){s[len++]=n%10+'0';n/=10;}\n while(len>0){putchar(s[--len]);}\n}\nstatic int64 readInt(void){\n int prev='\\0';int c=getchar();\n while(!('0'<=c && c<='9')){prev=c;c=getchar();}\n int64 res=0;\n while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}\n return prev=='-'?-res:res;\n}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n#define ABS(a) ((a)>(0)?(a):-(a))\n\n/*\na_k : k \u30de\u30b8\u30c3\u30af\u30b8\u30a7m\u306e\u69cb\u6210\u6570\na_k = 1 (k<=0)\na_1=2\na_n = a_{n-1} + a_(n-m)\n*/\n\nconst int mod=1000000007;\n\n#define POS(i,j) ((i)*m+(j))\n\nvoid matmul(int *c,int *a,int *b,int m){\n static int *tmp=NULL;\n if(tmp==NULL) tmp=calloc(m*m,sizeof(int));\n memset(tmp,0,sizeof(int)*m*m);\n int i,j,k;\n for(i=0;in){\n printInt(1);\n puts(\"\");\n return;\n }\n n-=m-1;\n int *t=(int *)calloc(m*m,sizeof(int));\n int *s=(int *)calloc(m*m,sizeof(int));\n int i;\n for(i=0;i0){\n if(n&1) matmul(t,t,s,m);\n matmul(s,s,s,m);\n n>>=1;\n }\n int64 ans=0;\n for(i=0;i\n\nlong long K=998244353;\n\nlong long min(long long a, long long b){\n if(a > b)\n return b;\n return a;\n}\n\nlong long pmod(long long a, long long n, long long b){\n long long c = 1, i, pows[40], prod;\n\n prod = 1;\n pows[0]=a;\n\n for( i =1; i < 40; i++ )\n pows[i] = (pows[i-1] * pows[i-1])%b;\n \n i = 0;\n while(n > 0){\n if( n % 2 == 1)\n prod = (prod*pows[i])%b;\n\n n=n/2;\n i++;\n }\n return prod % b;\n}\n\nlong long binom(long long n, long long k){\n long long prod1, i, prod2;\n k = min(k, n-k);\n prod1 = 1;\n prod2 = 1;\n for( i = 1; i <= k; i++ ) {\n prod1 = (prod1 * i)%K;\n prod2 = (prod2 * (i + n-k ) )%K;\n }\n return (prod2 * pmod(prod1, K-2, K)) % K;\n}\n\n\n\nvoid solve(int n, int k){\n long long sum, i;\n if( k > n ){\n printf(\"0\\n\");\n return;\n }\n if( k == n ){\n printf(\"1\\n\");\n return;\n }\n if( k == 1 ){\n printf(\"%lld\\n\", n% K);\n return;\n }\n sum = binom(n-1,k-1 )%K;\n for( i = 2; i <= n/k; i++ )\n sum = (sum + binom(n/i - 1, k-1))%K;\n\n printf(\"%lld\\n\", sum % K );\n}\n\n\n\nint main(){\n long long n, k;\n scanf(\"%lld\", &n);\n scanf(\"%lld\", &k);\n solve(n,k);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics", "number theory"], "code_uid": "174042c31640f6e91e17612bc050b7f9", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \"stdbool.h\"\n#include \"stdio.h\"\n#include \"stdint.h\"\n#include \"string.h\"\n#include \"ctype.h\"\n#include \"stdlib.h\"\n#include \"math.h\"\n\n#define PI 3.14159265358979323846264338327950288\n#define ll long long\n#define MOD 998244353\n#define N 500100\n#define MAX1 101\n#define rep(i,n) for (int i=0; ib?a:b;}\nint min(int a,int b) {return ab?a:b;}\n\nint t, n, m;\nll a[N], b[N];\n\nll _pow(int i, int p) {\n\n ll ans = 1, x = i;\n for (; p; p>>=1) {\n if (p&1) ans = mul(ans, x);\n x = mul(x, x);\n }\n return ans;\n}\n\nint main() {\n scanf(\"%d%d\", &n, &m);\n a[0] = b[0] = 1;\n for (int i=1; i<=n; i++) {\n a[i] = mul(a[i-1], i);\n b[i] = mul(b[i-1], _pow(i,MOD-2));\n }\n ll ans = 0;\n for (int i=1; n/i>=m; i++) {\n ans += mul(mul(a[n / i - 1], b[m - 1]), b[n / i - m]);\n if (ans >= MOD) ans -= MOD;\n }\n printf(\"%lld\", ans);\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics", "number theory"], "code_uid": "8a0db6e03991610151d4cf7caeafd6ad", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define lli long long int\n#define mod(x) (x)%1000000007\n\nlli dp[200001][3];\nlli check[3];\n\nint main(void){\n int N, min, max;\n scanf(\"%d %d %d\", &N, &min, &max);\n for(int i=0; i<3; i++){\n check[i] += max/3;\n if(i <= max%3 && i>0) check[i]++;\n check[i] -= (min-1)/3;\n if(i <= (min-1)%3 && i>0) check[i]--;\n }\n dp[0][0] = 1;\n for(int i=0; i\nconst int X = 1e9 + 7;\nlong long ans[200005][3] = {};\nint a[3] = {};\nint n, l, r;\nint main() {\n\tint i;\n\tscanf(\"%d %d %d\", &n, &l, &r);\n\tans[1][0] = a[0] = r / 3 - (l - 1) / 3;\n\tans[1][1] = a[1] = (r + 2) / 3 - (l + 1) / 3;\n\tans[1][2] = a[2] = (r + 1) / 3 - l / 3;\n\tfor (i = 2; i <= n; i++) {\n\t\tans[i][0] = (ans[i - 1][0] * a[0] + ans[i - 1][1] * a[2] + ans[i - 1][2] * a[1]) % X;\n\t\tans[i][1] = (ans[i - 1][0] * a[1] + ans[i - 1][1] * a[0] + ans[i - 1][2] * a[2]) % X;\n\t\tans[i][2] = (ans[i - 1][0] * a[2] + ans[i - 1][1] * a[1] + ans[i - 1][2] * a[0]) % X;\n\t}\n\tprintf(\"%lld\\n\", ans[n][0]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "96fc240c12f32f3eca1d29f867747f79", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main() {\n\tint m, n, k, i ,l = 0;\n\tscanf(\"%d %d %d\", &n, &m, &k);\n\tif (k == 1 && m > 1) l = 1;\n\tfor (i = 2; i*i <= m; i++) \n\t\tif (m%i == 0) { \n\t\t\tif (m/i>=k) l = 1;\n\t\t\tbreak;\n\t\t}\n\tif ( ((n%2) == 0)||(l == 0) ) printf(\"Marsel\");\n\telse printf(\"Timur\");\n\treturn 0; \n}\n\t \n", "lang_cluster": "C", "tags": ["dp", "number theory", "games"], "code_uid": "e1ec23593ad80ac72e92689af5bd555d", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint main() {\n\tint n,m,k,i;\n\tscanf(\"%d %d %d\",&n,&m,&k);\n\tif (n%2==0 || m==1 || k>m/2) {\n\t\tputs(\"Marsel\");\n\t\treturn 0;\n\t}\n\tif (k==1) {\n\t\tputs(\"Timur\");\n\t\treturn 0;\n\t}\n\tfor(i=2;i*i<=m;i++) if (m%i==0 && m/i>=k) break;\n\tif (i*i>m) {\n\t\tputs(\"Marsel\");\n\t\treturn 0;\n\t}\n\tputs(\"Timur\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dp", "number theory", "games"], "code_uid": "b998b7314486e881497d1c2ba1b0c34f", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\nlong long a[4000001];\r\nlong long n, p, c, k;\r\nint main()\r\n{\r\n scanf(\"%lld%lld\", &n, &p);\r\n a[1] = 1;\r\n for (int i = 2; i <= n; i++)\r\n {\r\n a[i] += (2 * a[i - 1] + 1) % p;\r\n if (i == 2)\r\n {\r\n a[i] = 2;\r\n }\r\n for (int j = 2; j * i <= n; j++)\r\n {\r\n a[j * i] = (p + a[j * i] + a[i] - a[i - 1]) % p;\r\n }\r\n a[i] %= p;\r\n }\r\n printf(\"%lld\\n\", a[n]);\r\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "two pointers", "number theory"], "code_uid": "3ab2f042a404b8ba361871a6d026010d", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\nint dp[4000001][2], sum[4000001][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 % 2 == 0 ? 1 : 0) + 1) % 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": "a052d63c730707160fba8b49c5bfe0b0", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tlong long int i,j,k=0,n,m,s=0;\n\tlong long int fact[250001];\n\tfact[1]=1;fact[0]=1;\n\tscanf(\"%lld%lld\",&n,&m);\n\tfor(i=2;i<=250000;i++)\n\tfact[i]=(fact[i-1]*i)%m;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tk=k+(n-i+1)*(fact[i]*fact[n-i+1]%m);\n\t\tk=k%m;\n\t}\n\tprintf(\"%lld\",k);\n}", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "0b2252ec630b0250098617bd7ddd68a5", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define F for(i=1;i<=n;i++)\nlong long i,j,m,n,r,f[250107]={1};\nint main(){\n\tscanf(\"%lli%lli\",&n,&m);\n\tF f[i]=f[i-1]*i%m;\n\tF r=(r+f[i]*f[n-i+1]%m*(n-i+1)%m)%m;\n\treturn printf(\"%lli\",r),0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics"], "code_uid": "3814fb36ccf6e6a0c322f98e87af73f0", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define Ma 35+1\ntypedef long long ll;\nll dp[Ma+1][Ma+1],small[Ma+1][Ma+1];\nint n,h,i,j,k;\nll agg;\nint main(void)\n{\n scanf(\"%d %d\",&n,&h);\n dp[0][0]=1;\n for(j=0;j<=n;++j) small[0][j]=1;\n dp[1][1]=1;\n for(i=1;i<=n;++i){\n \tfor(j=2;j<=n;++j){\n \t\tfor(k=0;k\n#include \n#define Ma 35+1\nlong long dp[Ma+1][Ma+1],small[Ma+1][Ma+1];\nint n,h,i,j,k;\nlong long agg;\nint main(void)\n{\n scanf(\"%d %d\",&n,&h);\n dp[0][0]=1;\n for(j=0;j<=n;++j) small[0][j]=1;\n dp[1][1]=1;\n for(i=1;i<=n;++i){\n \tfor(j=2;j<=n;++j){\n \t\tfor(k=0;k\n#include \n#define Ma 35+5\ntypedef long long ll;\nll dp[Ma+1][Ma+1],small[Ma+1][Ma+1];\nint n,h,i,j,k;\nll agg;\nint main(void)\n{\n scanf(\"%d %d\",&n,&h);\n dp[0][0]=1;\n for(j=0;j<=Ma;++j) small[0][j]=1;\n dp[1][1]=1;\n //for(i=1;j<=Ma;++)\n for(i=1;i<=n;++i){\n \tfor(j=2;j<=Ma;++j){\n \t\tfor(k=0;k\n#include \n#define Ma 35+5\ntypedef long long ll;\nll dp[Ma+1][Ma+1],small[Ma+1][Ma+1];\nint n,h,i,j,k;\nll agg;\nint main(void)\n{\n scanf(\"%d %d\",&n,&h);\n dp[0][0]=1;\n for(j=0;j<=Ma;++j) small[0][j]=1;\n dp[1][1]=1;\n for(i=1;i<=n;++i){\n \tfor(j=2;j<=n;++j){\n \t\tfor(k=0;k\n\nint main()\n{\n long long d,k,a,b,t;\n scanf(\"%lld %lld %lld %lld %lld\",&d,&k,&a,&b,&t);\n\n long long s=0,d2=0;\n \n if(d>k)\n {\n d-=k;\n s=k*a;\n\n \n long long i=0;\n while((i*b<=t+a*i) && (i<=k))++i;\n --i;\n \n\n d2=d%k;\n d=d-d2;\n\n if(d*b>(d*a)+(d/k*t))\n {\n\t s+=(d*a)+(d/k*t);\n }\n else\n {\n\t s+=(d)*b;\n }\n if(d2<=i)\n\t s+=d2*b;\n else\n\t s+=d2*a+t;\n }\n else\n\t s=d*a;\n\n printf(\"%lld\",s);\n\n return 0;\n\n}\n\n\n\n \n", "lang_cluster": "C", "tags": ["math"], "code_uid": "2bdf084f8bf4f94e70ce4af763e523c4", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n long long int d,time=0, k,a,b,t,c;\n scanf(\"%lld%lld%lld%lld%lld\",&d,&k,&a,&b,&t);\n if(k>d)\n time+=d*a;\n else\n time+=a*k;\n \n if((d-k)>0)\n {\n if(k*a+t0)\n {\n c=(d-k)%k;\n if(c*a+t\n\n#define N\t500\n#define MD\t998244353\n\nint dp[N + 1][N + 1];\n\nvoid init() {\n\tint n, k, n_;\n\n\tdp[0][0] = 1;\n\tfor (n = 0; n < N; n++)\n\t\tfor (k = 0; k <= n; k++)\n\t\t\tif (dp[n][k])\n\t\t\t\tfor (n_ = n + 1; n_ <= N; n_++) {\n\t\t\t\t\tint k_ = k > n_ - n ? k : n_ - n;\n\n\t\t\t\t\tdp[n_][k_] = (dp[n_][k_] + dp[n][k]) % MD;\n\t\t\t\t}\n}\n\nint main() {\n\tint n, k, a, b, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tans = 0;\n\tfor (a = 1; a <= n; a++)\n\t\tfor (b = 1; b <= n && a * b < k; b++)\n\t\t\tans = (ans + 2LL * dp[n][a] * dp[n][b]) % MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "ec3631f99f8439c537371590ceff3c1b", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long int n, m;\n\tscanf(\"%lld %lld\", &n, &m);\n\tlong long int p = 1000000007;\n\tlong long int s[2][2], t[2][2];\n\tint i;\n\ts[0][0] = 1;\n\ts[0][1] = 0;\n\tfor (i = 1; i < n; i++)\n\t{\n\t\ts[1][0] = s[0][0] + s[0][1];\n\t\ts[1][1] = s[0][0];\n\t\ts[0][0] = s[1][0] % p;\n\t\ts[0][1] = s[1][1] % p;\n\t}\n\tt[0][0] = 1;\n\tt[0][1] = 0;\n\tfor (i = 1; i < m; i++)\n\t{\n\t\tt[1][0] = t[0][0] + t[0][1];\n\t\tt[1][1] = t[0][0];\n\t\tt[0][0] = t[1][0] % p;\n\t\tt[0][1] = t[1][1] % p;\n\t}\n\tif (n == 1 && m == 1)\n\t\tprintf(\"2\\n\");\n\telse\n\t\tprintf(\"%lld\\n\", (s[0][0] + s[0][1] + t[0][0] + t[0][1] - 1) * 2 % p);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "8f43a0b4656ad41a1f73c2636bd6d302", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nlong long rBR[100003];\nlong long rWR[100003];\nlong long cBR[100003];\nlong long cWR[100003];\nint main()\n{\n\tint i;\n\tint n, m;\n\tlong long R;\n\tscanf(\"%d %d\", &n, &m);\n\trBR[0] = 1;\n\tfor (i = 1; i < n + 3; i++)\n\t{\n\t\trBR[i] = 0;\n\t}\n\tfor (i = 0; i < n + 3; i++)\n\t{\n\t\trWR[i] = 0;\n\t}\n\tfor (i = 0; i < n; i++)\n\t{\n\t\trWR[i + 1] += rBR[i];\n\t\trWR[i + 1] %= 1000000007;\n\t\trBR[i + 2] += rBR[i];\n\t\trBR[i + 2] %= 1000000007;\n\t\trBR[i + 1] += rWR[i];\n\t\trBR[i + 1] %= 1000000007;\n\t\trWR[i + 2] += rWR[i];\n\t\trWR[i + 2] %= 1000000007;\n\t}\n\tcBR[0] = 1;\n\tfor (i = 1; i < m + 3; i++)\n\t{\n\t\tcBR[i] = 0;\n\t}\n\tfor (i = 0; i < m + 3; i++)\n\t{\n\t\tcWR[i] = 0;\n\t}\n\tfor (i = 0; i < m; i++)\n\t{\n\t\tcWR[i + 1] += cBR[i];\n\t\tcWR[i + 1] %= 1000000007;\n\t\tcBR[i + 2] += cBR[i];\n\t\tcBR[i + 2] %= 1000000007;\n\t\tcBR[i + 1] += cWR[i];\n\t\tcBR[i + 1] %= 1000000007;\n\t\tcWR[i + 2] += cWR[i];\n\t\tcWR[i + 2] %= 1000000007;\n\t}\n\tR = rBR[n] + rWR[n] + cBR[m] + cWR[m] - 1 << 1;\n\tR %= 1000000007;\n\tprintf(\"%I64d\", R);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "6f0a4ae0972947fc0aac60224c9d56e9", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define ll long long\n\nll solve(ll a, ll b) {\n ll i,k = 0;\n int* factors = malloc(sizeof(int)*1000*1000);\n //record the smaller factors of a\n for (i = 1; i*i <= a; i++) {\n if (a%i == 0) {\n factors[k++] = i;\n // printf(\"factor of a:%lli\\n\", i);\n }\n }\n //for each smaller factor of a+b\n ll answer = 2*(a+b+1);\n for (i = 1; i*i <= a+b; i++) {\n if ((a+b)%i == 0) {\n // printf(\"factor of a+b:%lli\\n\", i);\n //binary search a factor of a that is smaller than or equal to i\n int found = 0;\n ll hi = k;\n ll lo = 0;\n ll middle;\n // printf(\"lo:%lli, hi:%lli\\n\", lo, hi);\n while (!found) {\n middle = (lo + hi)/2;\n // printf(\"mid:%lli\\n\",middle);\n if (middle == lo || middle == hi) {\n // printf(\"middle\\n\");\n break;\n } else if (factors[middle] < i) {\n lo = middle;\n } else if (factors[middle] > i) {\n hi = middle;\n } else { // middle = i\n found = 1;\n break;\n }\n }\n // printf(\"i found %lli for a, %lli for a+b\\n\", factors[middle],i);\n // printf(\"a/fact=%lli <= a+b/i=%lli?\\n\",a/factors[middle],(a+b)/i);\n if (a/factors[middle] <= (a+b)/i) {\n if (answer > 2*(i + (a+b)/i)) {\n answer = 2*(i + (a+b)/i);\n // printf(\"NEW answer: %lli\\n\", answer);\n }\n }\n }\n }\n return answer;\n}\n\nint main(int argc, char* argv[]) {\n ll a,b = 0;\n scanf(\"%lli %lli\",&a,&b);\n // printf(\"%lli + %lli = %lli\\n\", a, b, a+b);\n ll answer_a = solve(a,b);\n ll answer_b = solve(b,a);\n if (answer_a < answer_b) {\n printf(\"%lli\\n\", answer_a);\n } else {\n printf(\"%lli\\n\", answer_b);\n\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "5f8ae287a143d7e268bf1f84194b24e9", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n\ntypedef long long int int64;\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n#define ABS(a) ((a)>(0)?(a):-(a))\n\nvoid factorize(int64 n,int64 *f,int *resLen){\n f[0]=1;\n int len=1;\n int64 k;\n for(k=2;k*k<=n;k++){\n if(n%k==0){\n int c=0;\n while(n%k==0){\n\tc++;\n\tn/=k;\n }\n int64 mul;\n int i;\n for(i=1,mul=k;i<=c;i++,mul*=k){\n\tint j;\n\tfor(j=0;j1){\n int i;\n for(i=0;i=a/factorA[ai-1] || s/r>=b/factorB[bi-1]){\n min=2*(r+s/r);\n }\n }\n printf(\"%lld\\n\",min);\n}\n\nint main(void){\n run();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "6f8d384c828c59df90f46fcd74db5e53", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "// write in C...\n#include \n\n#ifdef DEBUG\n#define D(x...) fprintf(stderr, x)\n#else\n#define D(x...)\n#endif\n\n#define MOD 1000000009\n\nint n, w, b;\nint c[4005][4005];\n\nint p(int n, int k) {\n if (k > n || k < 1) return 0;\n else return c[n-1][k-1];\n}\n\nint main() {\n int i, j;\n\n scanf(\"%d %d %d\", &n, &w, &b);\n\n for (i = 0; i < 4005; i++) c[i][0] = 1;\n for (i = 1; i < 4005; i++)\n for (j = 1; j <= i; j++)\n c[i][j] = (c[i-1][j-1] + c[i-1][j]) % MOD;\n\n long long res = 0;\n\n for (i = 0; i <= n; i++) {\n res = (res + (((((long long)p(b, i) * (long long)p(w, n-i))%MOD) * (long long)(n-i-1))%MOD)) % MOD;\n }\n\n for (i = 1; i <= w; i++) res = (res * i) % MOD;\n for (i = 1; i <= b; i++) res = (res * i) % MOD;\n\n printf(\"%d\\n\", (int)res);\n\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["combinatorics", "number theory"], "code_uid": "32d27493db4f19691b29cb312c16455f", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#define INF 1000000007\nint cmp(const void * a, const void * b) {\n return *(int *)a - *(int *)b;\n}\nint main() {\n int n;\n int s[105];\n scanf(\"%d\", &n);\n\n for (int i = 0; i < 2 * n; i++)\n scanf(\"%d\", s + i);\n qsort(s, 2 * n, sizeof(int), cmp);\n int ans = INF;\n for (int i = 0; i < 2 * n - 1; i++) {\n for (int j = i + 1; j < 2 * n; j++) {\n int m = 0;\n int mid = 0;\n int a, b;\n while (1) {\n a = m++;\n while (a == i || a == j)\n a = m++;\n b = m++;\n while (b == i || b == j)\n b = m++;\n if (m > 2 * n)\n break;\n mid += s[b] - s[a];\n }\n if (ans > mid)\n ans = mid;\n }\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "sortings", "greedy"], "code_uid": "32e8c676f3bb3b8664d274a90a82dbd1", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tint n,w[105]={},W,i,j,t;\n\tscanf(\"%d\",&n);\n\tn*=2;\n\tfor (i=0;iw[j+1])\n\t\t\t{\n\t\t\t\tt=w[j];\n\t\t\t\tw[j]=w[j+1];\n\t\t\t\tw[j+1]=t;\n\t\t\t}\n\tint copy[105]={};\n\tvoid cp(int wo1,int wo2)\n\t{\n\t\tint k;\n\t\tfor (k=0;k\nvoid buble_sort(int a[], int n)\n{\n int i, j, t;\n for(i=0; ia[j+1])\n {\n t=a[j];\n a[j]=a[j+1];\n a[j+1]=t;\n }\n }\n }\n}\nint main()\n{\n int n, l, i, j, xr, yr, xl, xh, yl, yh;\n scanf(\"%d\", &n);\n l=(4*n)+1;\n int x[l];\n int y[l];\n int xd[l];\n int yd[l];\n for(i=0; ixh) || (yd[i]yh))\n \t{\n \t xr=xd[i];\n \t yr=yd[i];\n \t break;\n }\n else if((xd[i]>xl && xd[i]yl && yd[i]\n#include\n/*#include\n#define MOD 1000000009\n#define MAX 100005\nlong long int position_value[MAX];\nvoid init()\n{\n position_value[0]=1;\n int i;\n for(i=1;i=last) return;\n int i,j,s;\n for(i=first;i<=last;i++)\n {\n for(j=i;j>0&&a[indices[j]]>a[indices[j-1]];j--)\n {\n s=indices[j-1];\n indices[j-1]=indices[j];\n indices[j]=s;\n }\n }\n}*/\nstruct Points\n{\n int x,y;\n};\nint main()\n{\n int n,i,j,k,x0,y0;\n scanf(\"%d\",&n);\n struct Points p[n*4+1];\n for(i=0;i=y0&&p[i].y<=y0+k))||((p[i].y==y0||p[i].y==y0+k)&&(p[i].x>=x0&&p[i].x<=x0+k)))\n {\n continue;\n }\n counter++;\n }\n if(counter>1) continue;\n for(i=0;i=y0&&p[i].y<=y0+k))||((p[i].y==y0||p[i].y==y0+k)&&(p[i].x>=x0&&p[i].x<=x0+k)))\n {\n continue;\n }\n printf(\"%d %d\",p[i].x,p[i].y);\n return 0;\n }\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "a0191ae511c1a497a7d55c7ae265003d", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "//http://codeforces.com/problemset/problem/328/B\n#include\n#include\nint main()\n{\n int t,i,j,k,l,num1[11],a[20],num2[11],res[11],cc,ans;\n char sub[10],s[300];\n while(~scanf(\"%d\",&t))\n {\n k=0,cc=0;\n memset(sub,0,sizeof(sub));\n memset(a,0,sizeof(a));\n memset(num1,0,sizeof(num1));\n memset(num2,0,sizeof(num2));\n memset(res,0,sizeof(res));\n while(t>0)\n {\n sub[k]=t%10+'0';\n a[k++]=t%10;\n num1[t%10]++;\n t=t/10;\n }\n sub[k]='\\0';\n // puts(sub);\n getchar();\n scanf(\"%s\",s);\n // puts(s);\n l=strlen(s);\n for(i=0; ires[i])\n ans=res[i];\n printf(\"%d\\n\",ans);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "ea66ebc50fb168b0a24d0ad898fdce8f", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n\nunsigned short count(unsigned short number) {\n unsigned short i = 0;\n while(number > 0) {\n number /= 10;\n i++;\n }\n return i;\n}\n\n\nint main() {\n unsigned short i = 0;\n\t\n unsigned short t;\n scanf(\"%hu\", &t);\n\t\n unsigned short r[10] = {0};\n char *s = malloc(sizeof(char) * 201);\n\tscanf(\"%s\", s);\n while(s[i] != '\\0') {\n switch(s[i]) {\n case '2':\n case '5':\n r[2]++;\n r[5]++;\n break;\n case '6':\n case '9':\n r[6]++;\n r[9]++;\n break;\n\t\t\tdefault:\n r[s[i]-48]++;\n break;\n }\n\t\ti++;\n }\n free(s);\n\t\n unsigned short k = count(t);\n unsigned short *n = malloc(sizeof(unsigned short) * k);\n for(i = 0; i < k; i++) {\n\t\tn[i] = t % 10;\n\t\tt /= 10;\n\t}\n \n\tunsigned short b = 1, result = 0;\n while(b) {\n for(i = 0; i < k; i++) {\n\t\t\tif(r[n[i]])\n\t\t\t\tswitch(n[i]) {\n\t\t\t\tcase 2:\n\t\t\t\tcase 5:\n\t\t\t\t\tr[2]--;\n\t\t\t\t\tr[5]--;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 6:\n\t\t\t\tcase 9:\n\t\t\t\t\tr[6]--;\n\t\t\t\t\tr[9]--;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tr[n[i]]--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\telse {\n\t\t\t\tb = 0;\n\t\t\t\tbreak;\n\t\t\t}\n }\n\t\t\n\t\tif(b)\n\t\t\tresult++;\n }\n \n\tprintf(\"%hu\\n\", result);\n\t\n\tfree(n);\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["greedy"], "code_uid": "b3251aee7db3dc7985fa2fc0f73c6227", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int x1,x2,x3,y1,y2,y3,s,k,d1,d2;\n scanf(\"%lld %lld %lld %lld %lld %lld\",&x1,&y1,&x2,&y2,&x3,&y3);\n s=(x1*y2)-(x2*y1)+(x2*y3)-(x3*y2)+(x3*y1)-(x1*y3);\n d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\n d2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);\n if(s==0||d1!=d2)\n {\n printf(\"No\\n\");\n }\n else\n {\n printf(\"Yes\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "2c0357e88d028ee3fa6fb0038b9d3843", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main() \n{ \n long long x1,y1,x2,y2,x3,y3,k1,k2,d1,d2; \n scanf(\"%lld%lld%lld%lld%lld%lld\",&x1,&y1,&x2,&y2,&x3,&y3); \n d1=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); \n d2=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3); \n if(d1!=d2) \n { \n printf(\"No\\n\"); \n return 0; \n } \n if((x2-x3)*(y1-y2)==(x1-x2)*(y2-y3)) \n { \n printf(\"No\\n\"); \n } \n else \n printf(\"Yes\\n\"); \n return 0; \n} \n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "7690b76e2159d7810d5966336433fa56", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \ntypedef long long ll;\nint left[10];\nint n;\nchar seen[3628800];\n\nll fact[21];\n\n/* must be called before using rank/unrank */\nvoid initfact() {\n int i;\n fact[0]=1;\n for(i=1;i<21;i++) fact[i]=fact[i-1]*i;\n}\n\nll permbtr(int n,int *p,int *q) {\n int s,t;\n if(n<2) return 0;\n s=p[n-1]; p[n-1]=p[q[n-1]]; p[q[n-1]]=s;\n t=q[s]; q[s]=q[n-1]; q[n-1]=t;\n return s+n*permbtr(n-1,p,q);\n}\n\n/* return rank of permutation\n n: number of elements\n *p: permutation to rank */\n/* warning, *p is destroyed! */\nll permutationrank2(int n,int *p) {\n int i,q[16];\n for(i=0;i1) two++;\n if(pre[n][two]>-1) {\n printf(\"%d\\n\",pre[n][two]);\n return 0;\n }\n \n memset(seen,0,sizeof(seen));\n btr();\n for(i=0;i<3628800;i++) z+=seen[i];\n printf(\"%d\\n\",z);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp"], "code_uid": "6b1a4573712bd911e76754e8bd702b63", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#define Maxn 5007\n#define modp 998244353\nint p[Maxn][Maxn];\nint pre[Maxn];\nint a,b,c;\nint solve(int x,int y)\n{\n\tint res=0;\n\tfor (int k=0;k<=x&&k<=y;k++)\n\t{\n\t\tint del=pre[k];\n\t\tdel=(1LL*del*p[x][k])%modp;\n\t\tdel=(1LL*del*p[y][k])%modp;\n\t\tres=(res+del)%modp;\n\t}\n\treturn res;\n}\nint main()\n{\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tmemset(p,0,sizeof(p));\n\tp[0][0]=1;\n\tfor (int i=1;i<=5000;i++)\n\t{\n\t\tp[i][0]=1;\n\t\tfor (int j=1;j<=i;j++)\n\t\t\tp[i][j]=(p[i-1][j-1]+p[i-1][j])%modp;\n\t}\n\tmemset(pre,0,sizeof(pre));\n\tpre[0]=1;\n\tfor (int i=1;i<=5000;i++)\n\t\tpre[i]=(1LL*pre[i-1]*i)%modp;\n\tint ans=1;\n\tans=(1LL*ans*solve(a,b))%modp;\n\tans=(1LL*ans*solve(b,c))%modp;\n\tans=(1LL*ans*solve(a,c))%modp;\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "0fdec969812a2dd18d971865a0dfca6a", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n//#include \n\n/* run this program using the console pauser or add your own getch, system(\"pause\") or input loop */\nlong long c[5002][5002], k = 0;\n\nlong long Arr(int m, int n){\n\tlong long res = 1;\n\twhile(m--){\n\t\tres *= n--;\n\t\tres %= 998244353;\n\t}\n\treturn res;\n}\n\nvoid advance(int a){\n\tint i, j;\n\tfor(i = k; i <= a; i++){//\tprintf(\"\\n\");\n\t\tfor(j = 0; j <= i; j++){\n\t\t\tif(j == 0 || j == i){\n\t\t\t\tc[i][j] = 1;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tc[i][j] = c[i - 1][j - 1] + c[i - 1][j];\n\t\t\t\tc[i][j] %= 998244353;\n\t\t\t}\n\t\t\t//printf(\"%d \",c[i][j]);\n\t\t}\n\t}\n}\n\nlong long count(int a, int b){\n\tint i;\n\tlong long s = 0;\n\tif(a > b){\n\t\ta = a + b;\n\t\tb = a - b;\n\t\ta = a - b;\n\t}\n\tadvance(a);\n\tfor(i = 0; i <= a; i++){\n\t//\tprintf(\"%d \",s);\n\t\ts += c[a][i] * Arr(i, b);\n\t\ts %= 998244353;\n\t}\n\treturn s;\n}\n\nint main(int argc, char *argv[]) {\n\tint a, b, c;\n\tlong long s;\n\tscanf(\"%d %d %d\", &a, &b, &c);\n\ts = count(a, b) * count(b, c);\n\ts %= 998244353;\n\ts *= count(a, c);\n\ts %= 998244353;\n\tprintf(\"%d\\n\",s);\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "b001d4dec1f79f800a747c9ca5f20365", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \nchar a[20][11],b[20][11];\nint n;\nint check()\n{\n int k=0;\n for (int i=0; i\n\nint n;\nchar a[11][11], b[11][11], c[11][11];\n\nvoid turn()\n{\n int i, j, k, l;\n for(i=n-1, k=0; i>=0; --i, ++k)\n for(j=0, l=0; j\n#include\n#include\n#include\nint e[300000];\nint a[300000];\nint main()\n{\n\tint t;\n\tint n;\n\tint i,j;\n\tint a,b,c,d;\n\tlong long l1,l2,l3;\n\tlong long sum=0;\n\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n\tl1=b-a;\n\tl2=c-b;\n\tl3=d-c;\n\tfor(i=0;i<=l3;i++)\n\t{\n\t\tt=c+i-a-b;\n\t\tif(t<0)\n\t\t{\n\t\t\tsum=sum+(l1+1)*(l2+1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(t+1<=l1&&t+1<=l2)\n\t\t\t{\n\t\t\t\tsum=sum+(2*l2-t+1)*(t+2)/2+(l2+1)*(l1-t-1);\n\t\t\t}\n\t\t\telse if(t+1<=l1)\n\t\t\t{\n\t\t\t\tsum=sum+(2*(l1-t)+l2)*(l2+1)/2;\n\t\t\t}\n\t\t\telse if(t+1<=l2)\n\t\t\t{\n\t\t\t\tsum=sum+(2*(l2-t)+l1)*(l1+1)/2;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(l1+l2-t>=0)\n\t\t\t\t{\n\t\t\t\t\tsum=sum+(l2+l1-t)*(l1+l2-t+1)/2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%lld\\n\",sum);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "41304fde98b9279d00341b6ff50153a7", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define max(a,b) ((a>b)?(a):(b))\n\nlong long ways[1000006];\n\nint main() {\n\tint a,b,c,d;\n\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\tint tx = b - a, ty = c - b, lz = c - a - b, rz = d - a - b;\n\tlong long ans = 0;\n\tfor( int z=0; z<=rz; ++z ) {\n\t\tint l=0, r=z;\n\t\tif( r > tx )\n\t\t\tr = tx;\n\t\t// ( z - r, z - l )\n\t\tif( z - l > ty )\n\t\t\tl = z - ty;\n\t\tways[z] = max(0, r - l + 1);\n\t\tif( z > 0 )\n\t\tways[z] += ways[z-1];\n\t}\n\tfor( int z = max(0,lz); z<=rz; ++z ) {\n\t\tans += ways[z];\n\t}\n\tprintf(\"%lld\\n\", (((1ll*(b-a+1))*(c-b+1))*(d-c+1)) - ans);\n}", "lang_cluster": "C", "tags": ["two pointers", "math", "implementation", "binary search"], "code_uid": "3a1febd941e8fa450486fae15c87b4e0", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nlong long div[100000],u,ohalf[100000],v;\n\nvoid divs(long long n)\n{\n\tlong long i;\n\n\tfor(i=1;i*i<=n;i++)\n\t{\n\t\tif(n%i==0)\n\t\t{\n\t\t\tif(n/i==i)\n\t\t\t\tdiv[u++]=i;\n\t\t\telse\n\t\t\t{\n\t\t\t\tdiv[u++]=i;\n\t\t\t\tohalf[v++]=n/i;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor(i=v-1;i>=0;i--)\n\t\tdiv[u++]=ohalf[i];\n}\n\nint main()\n{\n\tlong long x,y,c=0;\n\n\tscanf(\"%lld%lld\",&x,&y);\n\n\tdivs(x);\n\n\tfor(x=0;x\nint main()\n{\n\t\tlong long int n,k;\n\t\tscanf(\"%lld%lld\",&n,&k);\n\t\tlong long int i,j;\n\t\tlong long int count=0;\n\t\tlong long int t,flag=0;\n\t\tfor(i=1;i*i<=n;i++)\n\t\t{\n\t\t\t\tif(n%i==0)\n\t\t\t\t\t\tcount++;\n\t\t\t\tif(count==k)\n\t\t\t\t{\n\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\tprintf(\"%lld\\n\",i);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t}\n\t\tif((i-1)*(i-1)==n)\n\t\t\t\tj=i-2;\n\t\telse\n\t\t\t\tj=i-1;\n\t\tfor(;j>0;j--)\n\t\t{\n\t\t\t\tt=n/j;\n\t\t\t\tif(n%t==0)\n\t\t\t\t\t\tcount++;\n\t\t\t\tif(count==k)\n\t\t\t\t{\n\t\t\t\t\t\tif(flag==0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\t\t\tprintf(\"%lld\\n\",t);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t}\n\t\tif(flag==0)\n\t\t\t\tprintf(\"-1\\n\");\n\n\t\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "97cacd5448375e941bd458926c77cb10", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint min(int a, int b) {\n if (a <= b) {\n return a;\n }\n return b;\n}\n\nint main() {\n int n, imp = 0, a;\n scanf(\"%d\", &n);\n int nums[n];\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &a);\n if (a == 0) {\n nums[i] = 0;\n } else if (a % 2 == 0) {\n nums[i] = 2;\n } else {\n nums[i] = 1;\n imp++;\n }\n }\n int impTP = (n / 2) + (n % 2);\n impTP -= imp;\n int dp[n][impTP+1][2];\n for (int i = 0; i < n; i++) {\n for (int j = 0; j <= impTP; j++) {\n dp[i][j][0] = 101;\n dp[i][j][1] = 101;\n }\n }\n\n if (nums[0] == 0) {\n dp[0][impTP][0] = 0;\n dp[0][impTP-1][1] = 0;\n } else if (nums[0] == 1) {\n dp[0][impTP][1] = 0;\n } else {\n dp[0][impTP][0] = 0;\n }\n\n for (int i = 1; i < n; i++) {\n if (nums[i] == 0) {\n for (int j = 0; j <= impTP; j++) {\n dp[i][j][0] = min(dp[i-1][j][0], min(dp[i-1][j][1] + 1, dp[i][j][0]));\n if (j != 0) {\n dp[i][j-1][1] = min(dp[i-1][j][1], min(dp[i-1][j][0] + 1, dp[i][j-1][1]));\n }\n }\n } else {\n for (int j = 0; j <= impTP; j++) {\n if (nums[i] == 1) {\n dp[i][j][1] = min(dp[i-1][j][1], min(dp[i][j][1], dp[i-1][j][0] + 1));\n } else {\n dp[i][j][0] = min(dp[i-1][j][0], min(dp[i][j][0], dp[i-1][j][1] + 1));\n }\n }\n }\n }\n\n printf(\"%d\", min(dp[n-1][0][0], dp[n-1][0][1]));\n}\n", "lang_cluster": "C", "tags": ["sortings", "dp", "greedy"], "code_uid": "8c46721d0842bfd489f48c2605ad088d", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nint main()\n{\n\tint i,j,k=0,n,m,x,y,z=0,k1=0,l=0;\n\tscanf(\"%d\",&n);\n\tx=n/2;\n\ty=(n+1)/2;\n\tint a[n],b[100],c[100];\n\tfor(i=0;i=0;i--)\n\t{\n\t\tif(a[i]==-1||a[i]==-2)\n\t\t{\n\t\t\tl=i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif((k1==1||n==1)&&((l!=k)||n==1))\n\t{\n\tfor(i=0;i<100;i++)\n\t{\n\tb[i]=0;\n\tc[i]=0;\n\t}\n\t\n\tfor(i=0;ib[j])\n\t\t\t{\n\t\t\t\tt=b[i];\n\t\t\t\tb[i]=b[j];\n\t\t\t\tb[j]=t;\n\t\t\t}\n\t\t}\n\t}\n\tfor(i=0;i<100;i++)\n\t{\n\t\tfor(j=i+1;j<100;j++)\n\t\t{\n\t\t\tint t;\n\t\t\tif(c[i]>c[j])\n\t\t\t{\n\t\t\t\tt=c[i];\n\t\t\t\tc[i]=c[j];\n\t\t\t\tc[j]=t;\n\t\t\t}\n\t\t}\n\t}\n\tfor(i=1;i<100;i++)\n\t{\n\t\tif(x>=b[i])\n\t\t{\n\t\t\tx=x-b[i];\n\t\t}\n\t\telse\n\t\tz=z+2;\n\t}\n//\tprintf(\"%d\\n\",z);\n\tfor(i=1;i<100;i++)\n\t{\n\t\tif(y>=c[i])\n\t\t{\n\t\t\ty=y-c[i];\n\t\t}\n\t\telse\n\t\tz=z+2;\n\t}\n\t//printf(\"%d %d %d\\n\",z,x,y);\n\tif(a[0]==0)\n\tfor(i=1;i=i);\n\t\t\t\telse\n\t\t\t\tz++;\n\t\t\t//\tprintf(\"%d %d %d\\n\",z,x,y);\n\t\t\t}\n\t\t\telse if(a[i]==-2)\n\t\t\t{\n\t\t\t\tif(x>=i);\n\t\t\t\telse\n\t\t\t\tz++;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\t//printf(\"%d\\n\",z);\n\t\n\tfor(i=n-1;i>=0;i--)\n\t{\n\t\tif(a[i]!=0)\n\t\t{\n\t\t\tif(a[i]==-1)\n\t\t\t{\n\t\t\t\tif(y>=n-1-i);\n\t\t\t\telse\n\t\t\t\tz++;\n\t\t\t}\n\t\t\telse if(a[i]==-2)\n\t\t\t{\n\t\t\t\tif(x>=n-1-i);\n\t\t\t\telse\n\t\t\t\tz++;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%d\",z);\n}\nelse\nprintf(\"1\");\n\t//for(i=0;i<100;i++)\n\t//printf(\"%d \",c[i]);\n}", "lang_cluster": "C", "tags": ["sortings", "dp", "greedy"], "code_uid": "1083fb1da6a07198fef828350b29d34b", "src_uid": "90db6b6548512acfc3da162144169dba", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#pragma GCC optimize(\"Ofast\")\n#include \n\n#define MAXN 5001\n\nconst int md = 998244353;\n\nint n, m, k;\nint dp[MAXN][MAXN];\n\nint modpow(int bs, int pw){\n\tlong long bs1 = bs;\n\tlong long ans = 1;\n\twhile(pw){\n\t\tif(pw & 1){\n\t\t\tans *= bs1;\n\t\t\tans %= md;\n\t\t}\n\t\tpw >>= 1;\n\t\tbs1 *= bs1;\n\t\tbs1 %= md;\n\t}\n\treturn (int)ans;\n}\n\nint main(){\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tdp[0][0] = 1;\n\tfor(int i = 0; i < k; i++){\n\t\tfor(int j = 0; j < k; j++){\n\t\t\tdp[i+1][j] = (dp[i+1][j] + ((1LL * j * dp[i][j])%md) + md)%md;\n\t\t\tdp[i+1][j+1] = (dp[i+1][j+1] + ((1LL * (n-j) * dp[i][j])%md) + md)%md;\n\t\t}\n\t}\n\tint ans = 0;\n\tint inv = modpow(m, md-2);\n\tfor(int i = 1; i <= k; i++){\n\t\tans = (ans + ((modpow(inv, i) * 1LL * dp[k][i])%md))%md;\n\t}\n\tprintf(\"%d\\n\", ans);\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "probabilities", "number theory"], "code_uid": "0160dd638fefd7003a0cdef970ea9499", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t5000\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 dp[N + 1][N + 1];\n\nvoid init(int k, int n) {\n\tint i, j;\n\n\tdp[0][0] = 1;\n\tfor (i = 0; i < k; i++)\n\t\tfor (j = 0; j < k; j++) {\n\t\t\tlong long x = dp[i][j];\n\n\t\t\tif (x == 0)\n\t\t\t\tcontinue;\n\t\t\tdp[i + 1][j] = (dp[i + 1][j] + x * j) % MD;\n\t\t\tdp[i + 1][j + 1] = (dp[i + 1][j + 1] + x * (n - j)) % MD;\n\t\t}\n}\n\nint main() {\n\tint n, m, k, d, vm, ans;\n\n\tscanf(\"%d%d%d\", &n, &m, &k), init(k, n);\n\tvm = power(m, MD - 2);\n\tans = 0;\n\tfor (d = 0; d <= k; d++)\n\t\tans = (ans + dp[k][d] * power(vm, d)) % MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "probabilities", "number theory"], "code_uid": "15405ff1b9a7e3a0ea70fa3592448ed1", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint mod(long long int a)\n{\n int c,b,i,n=0,d;\n for( ; a>0;)\n {\n n++;\n b=a%10;\n if(n=1)c=b;\n a=a/10;\n if(a==0)d=b;\n }\n return d;\n}\nint main()\n{\n long long int a,b,c,d,n=0,i,j;\n scanf(\"%lld%lld\",&a,&b);\n if(a<10 && b<10)printf(\"%lld\\n\",b-a+1);\n else if(a<=9)\n {\n d=b%10;\n int e=a%10;\n c=mod(b);\n i=mod(a);\n if(d>=c)\n {\n printf(\"%lld\\n\",b/10-a/10+(9-a)+1);\n }\n else\n {\n if(a<=9)\n printf(\"%lld\\n\",b/10+9-a);\n }\n }\n else if(a>=10 && b>=10)\n {\n d=b%10;\n c=mod(b);\n int e=a%10;\n i=mod(a);\n if(d>=c && e<=i)printf(\"%lld\\n\",b/10-a/10+1);\n else if(di)printf(\"%lld\\n\",b/10-a/10-1);\n else printf(\"%lld\\n\",b/10-a/10);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["binary search", "dp", "combinatorics"], "code_uid": "adf8885ac0d705e305101b9cd5d2100e", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int fun(char a[],char b[],int m);\n char a[20],b[20];\n int m,n,i,j,c[30],t,q=0;\n while(scanf(\"%s%s\",b,a)!=EOF)\n {\n m=strlen(a);\n n=strlen(b);\n m--;n--; \n if(strcmp(a,b)==0)\n {\n for(i=m;i>=0;i--) \n {a[i]=a[i]-'0';c[m-i]=a[i];} \n for(i=m;i>=0;i--)\n a[i]=c[i]; \n for(i=n;i>=0;i--)\n {b[i]=b[i]-'0';c[n-i]=b[i];}\n for(i=0;i<=n;i++) \n b[i]=c[i]; \n for(i=0;i<30;i++)\n c[i]=0;\n t=1; \n if(a[m]==a[0])\n printf(\"1\\n\");\n else\n printf(\"0\\n\"); \n \n }\n else\n {for(i=m;i>=0;i--) \n {a[i]=a[i]-'0';c[m-i]=a[i];} \n for(i=m;i>=0;i--)\n a[i]=c[i]; \n for(i=n;i>=0;i--)\n {b[i]=b[i]-'0';c[n-i]=b[i];}\n for(i=0;i<=n;i++) \n b[i]=c[i]; \n for(i=0;i<30;i++)\n c[i]=0;\n t=1; \n if(n==m)\n { \n if(m<2)\n { \n if(a[n]==b[m])\n {\n if(a[0]>=a[m]&&b[0]<=b[m])\n printf(\"1\\n\");\n else\n printf(\"0\\n\");\n }\n else\n {\n c[0]=a[m]-b[n]-1;\n if(a[n]<=a[0])\n c[0]++;\n if(b[m]>=b[0])\n c[0]++;\n \n }\n }\n \n if(m>=2) \n {\n if(a[m]==b[m]) \n { \n fun(a,b,m); \n q=1;\n } \n else\n { \n c[m-1]=a[m]-b[n]-1; \n for(i=1;i=b[0])\n c[0]++; \n }\n } \n }\n else\n {\n if(m<2)\n {\n c[0]=10-b[n]+a[m]-1;\n if(a[m]<=a[0])\n c[0]++; \n }\n else\n {\n if(n<2)\n { \n c[0]=10-b[n]-1;\n if(b[n]>=b[0])\n c[0]++;\n c[m-1]=c[m-1]+a[m]-1;\n if(a[m]<=a[0])\n { \n for(i=1;i=0) \n for(i=n;i=b[0])\n c[0]++; \n c[m-1]=c[m-1]+a[m]-1; \n for(i=1;i=0)\n for(i=n;i=0;i--)\n if(c[i]!=0)\n {\n j=i;\n break;\n }\n t=j; \n for(i=0;i<=j;i++)\n {\n if(c[i]>9)\n {\n if(i==j)\n t=j+1;\n c[i+1]=c[i+1]+c[i]/10;\n c[i]=c[i]%10;\n }\n }\n i=t;\n for(j=i;j>=0;j--)\n printf(\"%d\",c[j]);\n printf(\"\\n\");\n }\n }\n }\n return 0;\n}\nint fun(char a[],char b[],int m)\n{\n int j,i,t,s,c[30];\n for(i=0;i<30;i++)\n c[i]=0; \n \n s=m;\n while(a[m]==b[m]) \n m--; \n if(m<=1)\n { \n if(m==0)\n {\n if(a[s]<=a[0]&&b[s]>=b[0])\n printf(\"1\\n\");\n else\n printf(\"0\\n\");\n } \n else\n {\n c[0]=a[m]-b[m]-1;\n if(a[s]<=a[0])\n c[0]++;\n if(b[s]>=b[0])\n c[0]++;\n printf(\"%d\\n\",c[0]);\n } \n }\n else\n { c[m-1]=a[m]-b[m]-1; \n for(i=1;i=b[0])\n c[0]++; \n for(i=29;i>=0;i--)\n if(c[i]!=0)\n {\n j=i;\n break;\n }\n t=j; \n for(i=0;i<=j;i++)\n {\n if(c[i]>9)\n {\n if(i==j)\n t=j+1;\n c[i+1]=c[i+1]+c[i]/10;\n c[i]=c[i]%10;\n }\n }\n i=t;\n for(j=i;j>=0;j--)\n printf(\"%d\",c[j]);\n printf(\"\\n\");\n }\n \n \n}\n", "lang_cluster": "C", "tags": ["binary search", "dp", "combinatorics"], "code_uid": "73e7fd12ebc1fb730306e258966bd8ed", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd", "difficulty": 1500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\n#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))\n\n#define POS(i, j) ((i) * m + (j))\n\nvoid run (void) {\n i32 n = read_int();\n i32 m = read_int();\n i32 a = read_int();\n i32 b = read_int();\n i32 *h = ALLOC (n * m, i32);\n h[0] = read_int();\n i32 x = read_int();\n i32 y = read_int();\n i32 z = read_int();\n for (i32 i = 1; i < n * m; ++i) {\n h[i] = ((i64) h[i - 1] * x + y) % z;\n }\n i32 *dp1 = ALLOC (n * m, i32);\n i32 *q = ALLOC (n + m, i32);\n for (i32 i = 0; i < n; ++i) {\n i32 front = 0;\n i32 last = 0;\n q[last++] = 0;\n for (i32 j = 1; j < b; ++j) {\n while (front < last && h[POS(i, q[last - 1])] >= h[POS(i, j)]) --last;\n q[last++] = j;\n }\n dp1[POS(i, 0)] = h[POS(i, q[front])];\n for (i32 j = b; j < m; ++j) {\n if (q[front] == j - b) front++;\n while (front < last && h[POS(i, q[last - 1])] >= h[POS(i, j)]) --last;\n q[last++] = j;\n dp1[POS(i, j - b + 1)] = h[POS(i, q[front])];\n }\n }\n {\n i32 *swap = dp1;\n dp1 = h;\n h = swap;\n }\n i64 ans = 0;\n for (i32 j = 0; j < m - b + 1; ++j) {\n i32 front = 0;\n i32 last = 0;\n q[last++] = 0;\n for (i32 i = 1; i < a; ++i) {\n while (front < last && h[POS(q[last - 1], j)] >= h[POS(i, j)]) --last;\n q[last++] = i;\n }\n ans += h[POS(q[front], j)];\n for (i32 i = a; i < n; ++i) {\n if (q[front] == i - a) front++;\n while (front < last && h[POS(q[last - 1], j)] >= h[POS(i, j)]) --last;\n q[last++] = i;\n ans += h[POS(q[front], j)];\n }\n }\n print_int (ans);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["two pointers", "data structures"], "code_uid": "c2836c91265409e99170b5ae16218b82", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\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}\nint main()\n{\n\tlong long int n, m, l, r;\n\tscanf(\"%lld %lld %lld %lld\", &n, &m, &l, &r);\n\tlong long int p = 998244353;\n\tif (n * m % 2 > 0)\n\t\tprintf(\"%lld\\n\", modpow(r - l + 1, n * m, p));\n\telse if ((r - l) % 2 > 0)\n\t\tprintf(\"%lld\\n\", modpow(r - l + 1, n * m, p) * modpow(2, p - 2, p) % p);\n\telse\n\t\tprintf(\"%lld\\n\", (modpow(r - l + 1, n * m, p) + 1) * modpow(2, p - 2, p) % p);\n}", "lang_cluster": "C", "tags": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "944d00343a179b3c67681102a6fd6022", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n \n#define MD\t998244353\n \nlong long power(int a, long long k) {\n\tlong long p;\n \n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k >> 1);\n\tp = p * p % MD;\n\tif (k & 1)\n\t\tp = p * a % MD;\n\treturn p;\n}\n \nvoid mult(int aa[][2], int bb[][2], int cc[][2]) {\n\tint i, j;\n \n\tfor (i = 0; i < 2; i++)\n\t\tfor (j = 0; j < 2; j++)\n\t\t\tcc[i][j] = ((long long) aa[i][0] * bb[0][j] + (long long) aa[i][1] * bb[1][j]) % MD;\n}\n \nvoid power_(int aa[][2], int pp[][2], int tt[][2], long long k) {\n\tif (k == 0) {\n\t\tint i, j;\n \n\t\tfor (i = 0; i < 2; i++)\n\t\t\tfor (j = 0; j < 2; j++)\n\t\t\t\tpp[i][j] = i == j;\n\t\treturn;\n\t}\n\tif ((k & 1) == 0) {\n\t\tpower_(aa, tt, pp, k >> 1);\n\t\tmult(tt, tt, pp);\n\t} else {\n\t\tpower_(aa, pp, tt, k >> 1);\n\t\tmult(pp, pp, tt);\n\t\tmult(tt, aa, pp);\n\t}\n}\n \nint main() {\n\tstatic int aa[2][2], pp[2][2], tt[2][2];\n\tint n, m, l, r, e, o;\n \n\tscanf(\"%d%d%d%d\", &n, &m, &l, &r);\n\tif ((long long) n * m % 2 != 0) {\n\t\tprintf(\"%lld\\n\", power(r - l + 1, (long long) n * m));\n\t\treturn 0;\n\t}\n\te = r / 2 - (l - 1) / 2, o = r - l + 1 - e;\n\taa[0][0] = e, aa[0][1] = o;\n\taa[1][0] = o, aa[1][1] = e;\n\tpower_(aa, pp, tt, (long long) n * m);\n\tprintf(\"%d\\n\", pp[0][0]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "constructive algorithms", "combinatorics"], "code_uid": "25d1dcf7cac7ab60b3fa91eac2608638", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nchar s1[200]=\"What are you doing at the end of the world? Are you busy? Will you save us?\";\nchar s2[100]=\"What are you doing while sending \\\"\";\nchar s3[100]=\"\\\"? Are you busy? Will you send \\\"\";\nchar s4[7]=\"\\\"?\";\nlong long int arr[100012];\nchar letter(long long int n,long long int k){\nlong long int z,i;\nlong long int l1=strlen(s1),l2=strlen(s2),l3=strlen(s3),l4=strlen(s4);\nif(k>arr[n]){\nreturn '.';\n}\nif(n==0){\nreturn s1[k-1];}\nif(k<=34){\nreturn s2[k-1];\n}\nk-=l2;\nif(k<=arr[n-1]){\nreturn letter(n-1,k);}\nk=k-arr[n-1];\nif(k<=l3){\nreturn s3[k-1];}\nk=k-l3;\nif(k<=arr[n-1]){\nreturn letter(n-1,k);}\nk=k-arr[n-1];\nif(k<=2){\nreturn s4[k-1];\n}\n}\nint main(){\nlong long int q,n,k,i;\nchar z[11];\nscanf(\"%lld\",&q);\narr[0]=75;\narr[1]=218;\nfor(i=2;i<=55;i++){\narr[i]=arr[i-1]*2+68;\n}\nfor(i=55;i<100010;i++){\narr[i]=arr[53];\n}\nfor(i=1;i<=q;i++){\nscanf(\"%lld\",&n);\nscanf(\"%lld\",&k);\nz[i]=letter(n,k);\n}\nfor(i=1;i<=q;i++){\nprintf(\"%c\",z[i]);\n}\nprintf(\"\\n\");\nreturn 0;\n}\n\n\n", "lang_cluster": "C", "tags": ["dfs and similar", "binary search"], "code_uid": "990fbc74e39d5c0333961bd85bce23af", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \ntypedef long long ll;\nchar s[4][105] = {\"What are you doing at the end of the world? Are you busy? Will you save us?\", \"What are you doing while sending \\\"\", \"\\\"? Are you busy? Will you send \\\"\", \"\\\"?\"};\nll lens[4], lenf[100005], zuida;\n\nchar DFS(ll n, ll k)\n{\n if(n == 0) return k < lenf[0] ? s[0][k] : '.';\n if(lenf[n] <= k) return '.';\n if(k < lens[1]) return s[1][k];\n if(k < lens[1] + lenf[n - 1])\n return DFS(n - 1, k - lens[1]);\n if(k < lens[1] + lenf[n - 1] + lens[2])\n return s[2][k - lens[1] - lenf[n - 1]];\n if(k < lens[1] + lenf[n - 1] + lens[2] + lenf[n - 1])\n return DFS(n - 1, k - lens[1] - lenf[n - 1] - lens[2]);\n return s[3][k - lens[1] - lenf[n - 1] - lens[2] - lenf[n - 1]];\n}\n\nint main()\n{\n ll q, n, k, i;\n scanf(\"%I64d\", &q);\n for(i = 0; i < 4; ++i)\n lens[i] = strlen(s[i]);\n lenf[0] = lens[0];\n for(zuida = 1; lenf[zuida - 1] <= 2e18; ++zuida)\n lenf[zuida] = 2 * lenf[zuida - 1] + lens[1] + lens[2] + lens[3];\n for(i = zuida; i <= 100002; ++i)\n lenf[i] = lenf[i - 1];\n while(q--)\n {\n scanf(\"%I64d%I64d\", &n, &k);\n --k;\n printf(\"%c\", DFS(n, k));\n }\n puts(\"\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "binary search", "combinatorics"], "code_uid": "821ba31ada392ecd21c1435f987983ec", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define ll long long\nll fib[51];\n\nvoid solve( int n, int *a, ll k ) {\n\tif( n == 0 )\n\t\treturn;\n\tif( k <= fib[n-1] ) {\n\t\tsolve( n-1, a+1, k );\n\t}\n\telse {\n\t\tint t = a[0];\n\t\ta[0] = a[1];\n\t\ta[1] = t;\n\t\tsolve( n-2, a+2, k - fib[n-1]);\n\t}\n\treturn;\n}\n\nint main() {\n\tint n;\n\tlong long k;\n\tscanf(\"%d%lld\", &n, &k);\n\tint a[n];\n\tfib[0]=1;\n\tfib[1]=1;\n\tfor( int i=0; i\nlong long int fib[55];\nvoid fibo(long long int n)\n{\n\tif(n==53)\n\t\treturn;\n\tfib[n]=fib[n-1]+fib[n-2];\n\tfibo(n+1);\n}\nvoid func(long long int k,long long int r,long long int n)\n{\n\tif(n==0)\n\t\treturn;\n\tif(k<=fib[n])\n\t{\n\t\tprintf(\"%lld \",1+r);\n\t\tfunc(k,r+1,n-1);\n\t}\n\telse\n\t{\n\t\tprintf(\"%lld %lld \",2+r,1+r);\n\t\tfunc(k-fib[n],r+2,n-2);\n\t}\n}\nlong long int main()\n{\n\tlong long int n,k;\n\tscanf(\"%lld %lld\",&n,&k);\n\tfib[1]=1;\n\tfib[2]=1;\n\tfibo(3);\n\tfunc(k,0,n);\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "6d714effa7b11828fe9e66b5e30da322", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nlong long count(int n, int x, int y, int r) {\n\tlong long a = 2LL * r * r + 2 * r + 1;\n\tint w;\n\n\tif ((w = 1 - (x - r)) > 0)\n\t\ta -= (long long) w * w;\n\tif ((w = 1 - (y - r)) > 0)\n\t\ta -= (long long) w * w;\n\tif ((w = (x + r) - n) > 0)\n\t\ta -= (long long) w * w;\n\tif ((w = (y + r) - n) > 0)\n\t\ta -= (long long) w * w;\n\tif ((w = r - 1 - (x - 1) - (y - 1)) > 0)\n\t\ta += (long long) w * (w + 1) / 2;\n\tif ((w = r - 1 - (x - 1) - (n - y)) > 0)\n\t\ta += (long long) w * (w + 1) / 2;\n\tif ((w = r - 1 - (n - x) - (y - 1)) > 0)\n\t\ta += (long long) w * (w + 1) / 2;\n\tif ((w = r - 1 - (n - x) - (n - y)) > 0)\n\t\ta += (long long) w * (w + 1) / 2;\n\treturn a;\n}\n\nint main() {\n\tint n, x, y, c, lower, upper, r;\n\n\tscanf(\"%d%d%d%d\", &n, &x, &y, &c);\n\tlower = -1, upper = c;\n\twhile (upper - lower > 1) {\n\t\tr = (lower + upper) / 2;\n\t\tif (count(n, x, y, r) >= c)\n\t\t\tupper = r;\n\t\telse\n\t\t\tlower = r;\n\t}\n\tprintf(\"%d\\n\", upper);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "binary search"], "code_uid": "90b557988499e86194963fc0e4354476", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\nint n,x,y,k;\n\nlong long min(long long a,long long b)\n{\n return (a0)\n return a*b-t*(t+1)/2;\n else return a*b;\n }\n}\n\nint check(int nn,int xx,int yy,int kk,int mm)\n{\n long long left,right,down,up;\n long long n=(long long)nn,x=(long long)xx,y=(long long)yy,k=(long long)kk,m=(long long)mm;\n long long sum=0;\n \n left=min(m,x-1);\n right=min(m,n-x);\n down=min(m,y-1);\n up=min(m,n-y);\n \n sum=left+right+up+down+1;\n \n sum+=square(left,down,m);\n sum+=square(left,up,m);\n sum+=square(right,down,m);\n sum+=square(right,up,m);\n \n if(sum>=k)\n return 1;\n else return 0;\n}\n\nint erfen(int a,int b)\n{\n int mid;\n \n if(a==b)\n return a;\n \n mid=(a+b)/2;\n if(check(n,x,y,k,mid))\n return erfen(a,mid);\n else return erfen(mid+1,b);\n}\n\nint main()\n{\n scanf(\"%d%d%d%d\",&n,&x,&y,&k);\n \n printf(\"%d\\n\",erfen(0,k));\n \n //system(\"pause\");\n return 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "implementation", "binary search"], "code_uid": "d912df9b59d928feeee47d100395eca9", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t100000\n#define MD\t1000000007\n\nint gcd(int a, int b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nlong long lcm(int a, int b) {\n\treturn (long long) a / gcd(a, b) * b;\n}\n\nint tt[N + 1];\n\nvoid init() {\n\tint a, b;\n\n\tfor (a = 1; a <= N; a++)\n\t\ttt[a] = a;\n\tfor (a = 2; a <= N; a++) {\n\t\tif (tt[a] != a)\n\t\t\tcontinue;\n\t\tfor (b = a; b <= N; b += a)\n\t\t\ttt[b] = tt[b] / a * (a - 1);\n\t}\n}\n\nint main() {\n\tint n, d, a, b, ans;\n\n\tinit();\n\tscanf(\"%d\", &n);\n\tans = 0;\n\tfor (d = 1; d <= n; d++)\n\t\tfor (a = d + d; a < n; a += d) {\n\t\t\tb = n - a;\n\t\t\tans = (ans + lcm(b, d) % MD * tt[a / d]) % MD;\n\t\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "dfe89a386981b811de87c85c065b560f", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nlong long gcd (long long a, long long b) {\n if (a <= 0LL || b <= 0LL) {\n return -1LL;\n }\n \n if (a%b == 0LL) {\n return b;\n }\n \n return gcd(b, a%b);\n}\n\nint main () {\n int n = 0;\n \n int res = 0;\n \n long long ans = 0LL;\n long long mod_num = 1000000007LL;\n \n long long sum_c[50001] = {};\n \n res = scanf(\"%d\", &n);\n \n for (int i = n/2; i > 0; i--) {\n long long k = (long long) (n/i);\n long long d = gcd((long long)n, (long long)i);\n if (n%i == 0) {\n k -= 1LL;\n }\n sum_c[i] = (((long long)n)*(k*(k-1LL))/2LL)%mod_num;\n sum_c[i] += mod_num-((((k*(k+1LL)*(k-1LL))/3LL)%mod_num)*((long long)i))%mod_num;\n for (int p = 2; i*p <= n/2; p++) {\n sum_c[i] += mod_num-sum_c[i*p];\n }\n sum_c[i] %= mod_num;\n ans += sum_c[i]*(((long long)i)/d);\n ans %= mod_num;\n }\n \n printf(\"%lld\\n\", ans);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "e4b364d7110db645e905ab93320471f1", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define DEBUG\ntypedef int (*cmp_t) (const void *, const void *);\ntypedef unsigned uint;\ntypedef long long int64;\ntypedef unsigned long long uint64;\n#define max(i, j) ({int _ = (i), __ = (j); _ > __ ? _ : __;})\n#define min(i, j) ({int _ = (i), __ = (j); _ < __ ? _ : __;})\n#define swap(T, i, j) ({T _ = (i); (i) = (j); (j) = _;})\n#ifdef DEBUG\n#define cerr(...) fprintf (stderr, __VA_ARGS__)\nvoid disp (char *s, int *x, int n) {int i; cerr (\"[%s: \", s); for (i = 0; i < n - 1; ++i) cerr (\"%d \", x[i]); if (n) cerr (\"%d\", x[i]); cerr (\"]\\n\");}\n#else\n#define cerr(...) ({})\n#define disp(...) ({})\n#endif\n#define CR cerr (\"\\n\")\n#ifdef WIN32\n#define fmt64 \"%I64d\"\n#else\n#define fmt64 \"%lld\"\n#endif\n\n#define maxm 1100\n#define maxsz 125\n\nconst int mod = 12345;\ntypedef int mat[maxsz][maxsz];\n\nint qx[maxm], qc[maxm];\nint sz = 0;\nbool o[30][maxsz];\nmat u, v;\nint prod[30], val[30];\n\nint fpm (int b, int64 e, int m)\n{\n int t = 1;\n for (; e; e >>= 1, b = b * b % m)\n e & 1 ? t = b * t % m : 0;\n return t;\n}\n\nint gcd (int a, int b)\n{\n int t;\n for (; a; t = a, a = b % a, b = t);\n return b;\n}\n\nvoid matmul (mat a, mat b, mat c)\n{\n mat t; int i, j, k;\n for (i = 0; i < sz; ++i)\n for (j = 0; j < sz; ++j)\n for (k = 0, t[i][j] = 0; k < sz; ++k)\n t[i][j] += a[i][k] * b[k][j] % mod;\n for (i = 0; i < sz; ++i)\n for (j = 0; j < sz; ++j)\n c[i][j] = t[i][j] % mod;\n}\n\nint main ()\n{\n#ifndef ONLINE_JUDGE\n freopen (\"107D.in\" , \"r\", stdin);\n freopen (\"107D.out\", \"w\", stdout);\n#endif\n\n int64 n; int m, i, j, x, c; char C;\n \n scanf (fmt64 \"%d\", &n, &m);\n for (i = 0; i < 26; ++i)\n val[i] = -1;\n for (i = 1; i <= m; ++i)\n {\n scanf (\" %c%d\", &C, &x), c = C - 'A';\n qc[i] = c, qx[i] = x, val[c] = abs (val[c] * x / gcd (x, val[c]));\n }\n for (i = 1; i <= m; ++i)\n for (x = 0; x < val[qc[i]]; x += qx[i])\n o[qc[i]][x] = true;\n for (i = 1, prod[0] = 1; i < 26; ++i)\n prod[i] = prod[i - 1] * abs (val[i - 1]);\n /* disp (\"prod\", prod, 26); */\n /* disp (\"val\", val, 26); */\n\n sz = prod[26] = prod[25] * abs (val[25]);\n for (i = 0; i < sz; ++i)\n for (j = 0; j < 26; ++j)\n if (val[j] != -1)\n {\n x = i + prod[j];\n if (x % prod[j + 1] < prod[j])\n x -= prod[j + 1];\n ++u[i][x];\n }\n /* for (i = 0; i < sz; ++i) */\n /* disp (\"u\", u[i], sz); */\n\n v[0][0] = 1;\n for (; n; n >>= 1, matmul (u, u, u))\n n & 1 ? matmul (v, u, v) : 0;\n \n /* for (i = 0; i < sz; ++i) */\n /* disp (\"u\", v[i], sz); */\n /* for (i = 0; i < 26; ++i) */\n /* { */\n /* for (j = 0; j < val[i]; ++j) */\n /* cerr (\"%d \", o[i][j]); */\n /* CR; */\n /* } */\n int ans = 0;\n for (i = 0; i < sz; ++i)\n {\n bool b = true;\n for (j = 0; j < 26; ++j)\n if (val[j] != -1 && !o[j][i % prod[j + 1] / prod[j]])\n b = false;\n if (b) ans += v[0][i];\n }\n printf (\"%d\\n\", ans % mod);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["matrices", "dp", "graphs"], "code_uid": "7b4baf3eda6038e59751299f54cb27c9", "src_uid": "76d4684d26dac380713a566a1e277c91", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\t\nlong long n;\nlong long bisearch()\n{\n long long l=0,r=1e9,mid;\n while(l<=r)\n {\n mid=((l+r)>>1);\n if(3*mid*(mid+1)>n)r=mid-1;\n else l=mid+1;\n }\n return l;\n}\nint main()\n{\n\n\twhile(~scanf(\"%lld\",&n))\n\t{\n\t\tlong long p,q;\n\t\tif(n==0)\n\t\t{\n\t\t\tprintf(\"0 0\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tlong long i=bisearch();\n//\t\tprintf(\"%lld\\n\",bisearch());\n//\t\tfor(long long i=1;;i++)\n//\t\t{\n//\t\t\tif(n>=i*6)\n//\t\t\t{\n//\t\t\t\tn-=i*6;\n//\t\t\t\tcontinue;\n//\t\t\t}\n//\t\t\telse\n//\t\t\t{\t\t\t\n//\t\t\t\tprintf(\"i==%d,n==%d,nMODi=%d\\n\",i,n,n/i);\n\t\t\t\tn-=3*(i-1)*i;\n\t\t\t\tif(n==0)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%lld 0\\n\",2*(i-1));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(ni && n<2*i)\n\t\t\t\t{\n\t\t\t\t\tn-=i;\n\t\t\t\t\tprintf(\"%lld %lld\\n\",1*i-2*n,2*i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n==2*i)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%lld %lld\\n\",-1*i,2*i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\t\n\t\t\t\telse if(n>2*i && n<3*i)\n\t\t\t\t{\n\t\t\t\t\tn-=2*i;\n\t\t\t\t\tprintf(\"%lld %lld\\n\",-1*i-n,2*i-2*n);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n==3*i)\t\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%lld 0\\n\",-2*i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n>3*i && n<4*i)\n\t\t\t\t{\n\t\t\t\t\tn-=3*i;\n\t\t\t\t\tprintf(\"%lld %lld\\n\",-2*i+n,0-2*n);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n==4*i)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%lld %lld\\n\",-1*i,-2*i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n>4*i && n<5*i)\n\t\t\t\t{\n\t\t\t\t\tn-=4*i;\n\t\t\t\t\tprintf(\"%lld %lld\\n\",-1*i+2*n,-2*i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n==5*i)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%lld %lld\\n\",1*i,-2*i);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(n>5*i)\n\t\t\t\t{\n\t\t\t\t\tn-=5*i;\n\t\t\t\t\tprintf(\"%lld %lld\\n\",1*i+n,-2*i+2*n);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n//\t\t\t}\n//\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "binary search"], "code_uid": "f3c06637fe60f8f73afb85788aa44e2a", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \"stdio.h\"\nstruct pos{\n\tlong int x;\n\tlong int y;\n};\n\nunsigned long long s_n(unsigned long long n){\n\treturn 3*n*(n-1);\n}\n\nint main(){\n\tunsigned long long step;\n\tscanf(\"%llu\",&step);\n\n\tstruct pos mpos = {0,0};\n\t/*if(!(step%6)){\n\t\tmpos.x = -2;\n\t}*/\n\tunsigned long long b = 0;\n\tunsigned long long en = 64;\n\tunsigned long long piv = 0;\n\tunsigned long long st = 1;\n\twhile(s_n(en) < step){\n\t\tb = en;\n\t\ten = en*2;\n\t}\n\n\twhile((en-b)>1){\n\t\tpiv = b + (en-b)/2;\n\t\t//printf(\"%llu %llu %llu %llu %llu \\n\", b, piv, en, s_n(piv), step);\n\t\tif (s_n(piv)>step){\n\t\t\ten = piv;\n\t\t} else {\n\t\t\tb = piv;\n\t\t}\n\t}\n\n\t/*if(!(step%6)){\n\t\tmpos.x = -2;\n\t}\n\t\n\tunsigned long long pi = 0;\n\t//unsigned long long st = 1;\n\t\n\twhile ((step) >= pi){\n\t\tstep -= pi;\n\t\tpi+=6;\n\t\tst++;\n\t}\n\t/*if(st == en){\n\t\tprintf(\"%llu oK\\n\",st);\n\t} else {\n\t\tprintf(\"%llu nOk\\n\", st);\n\t}*/\n\tst = en;\n\tstep-= s_n(st-1);\n\tif(step == 0){\n\t\tmpos.x = -2;\n\t}\n\tmpos.x += (st-1)*2;\n\tst --;\n\tif(step>st){\n\t\tmpos.x -=st;\n\t\tmpos.y +=2*st;\n\t\tstep -= st;\n\t} else {\n\t\tmpos.x -=step;\n\t\tmpos.y +=2*step;\n\t\tstep = 0;\n\t}\n\n\tif(step>st){\n\t\tmpos.x -=2*st;\n\t\tstep -= st;\n\t} else {\n\t\tmpos.x -=2*step;\n\t\tstep = 0;\n\t}\n\n\tif(step>st){\n\t\tmpos.x -=st;\n\t\tmpos.y -=2*st;\n\t\tstep -= st;\n\t} else {\n\t\tmpos.x -=step;\n\t\tmpos.y -=2*step;\n\t\tstep = 0;\n\t}\n\n\tif(step>st){\n\t\tmpos.x +=st;\n\t\tmpos.y -=2*st;\n\t\tstep -= st;\n\t} else {\n\t\tmpos.x +=step;\n\t\tmpos.y -=2*step;\n\t\tstep = 0;\n\t}\n\n\tif(step>st){\n\t\tmpos.x +=2*st;\n\t\tstep -= st;\n\t} else {\n\t\tmpos.x +=2*step;\n\t\tstep = 0;\n\t}\n\n\tif(step>st){\n\t\tmpos.x +=st;\n\t\tmpos.y +=2*st;\n\t\tstep -= st;\n\t} else {\n\t\tmpos.x +=step;\n\t\tmpos.y +=2*step;\n\t\tstep = 0;\n\t}\n\n\tprintf(\"%ld %ld\", mpos.x, mpos.y);\n}", "lang_cluster": "C", "tags": ["math", "implementation", "binary search"], "code_uid": "7c0a3a95cdc21f1527be38d71b1825d4", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong int deg[503],a[503][503],v,e;\nchar s[503];\nint main()\n{\nlong int i,j,k;\nscanf(\"%ld %ld\",&v,&e);\nfor(i=1;i<=v;i++)\n\ts[i]='l';\nfor(i=0;i\n#include \n#include \n\n#define TRUE 1\n#define FALSE 0\n#define WHITE 0\n#define GRAY 1\n#define BLACK 2\n#define POVEZANO 1\n#define NEPOVEZANO 0\n#define NEDEFINISANO (-1)\n#define PRAZNO (-1)\n\ntypedef struct element {\n\tint cvor;\n\tstruct element *sledeci;\n} Element;\n\n//dodavanje na red\nvoid dodaj(Element **pocetak, Element **kraj, int i) {\n\tElement *temp;\n\ttemp = (Element *)malloc(sizeof(Element));\n\ttemp->cvor = i;\n\ttemp->sledeci = NULL;\n\tif (*pocetak==NULL) {\n\t\t*pocetak = *kraj = temp;\n\t}\n\telse {\n\t\t(*kraj)->sledeci = temp;\n\t\t*kraj = temp;\n\t}\n}\n\nint skini(Element **pocetak, Element **kraj) {\n\tint cvor;\n\tElement *temp;\n\tif (*pocetak==NULL) {\n\t\treturn PRAZNO;\n\t}\n\telse {\n\t\ttemp = *pocetak;\n\t\t*pocetak = temp->sledeci;\n\t\tcvor = temp->cvor;\n\t\tif (*kraj==temp) *kraj=NULL;\n\t\tfree(temp);\n\t\treturn cvor;\n\t}\n}\n\nvoid dfs_visit(int graph[][501], int color[], int parent[], char vasyaString[], int n, int *hasSolution, int i, char c, int level) {\n //if (level==4)\n // *hasSolution = FALSE;\n\tint j;\n\tcolor[i] = GRAY;\n\tvasyaString[i] = c;\n\tfor (j=1; j<=n; j++) {\n\t\tif (i!=j && graph[i][j]==TRUE && parent[i]!=j)\n {\n\t\t\tif (color[j]==WHITE)\n\t\t\t{\n if (parent[i]==FALSE) {\n c = 'a';\n vasyaString[i] = c;\n }\n if (c=='a') c='c';\n else c='a';\n parent[j]=i;\n\t\t\t\tdfs_visit(graph, color, parent, vasyaString, n, hasSolution, j, c, level+1);\n\t\t\t}\n\t\t\telse if (color[j]==GRAY && abs(vasyaString[i]-vasyaString[j])<2) {\n\t\t\t\t*hasSolution = FALSE;\n\t\t\t}\n\t\t}\n\t}\n\tcolor[i] = BLACK;\n}\n\n\n\nint main()\n{\n int n, m, graph[501][501], i, j, u, v, k, level[501];\n int color[501], parent[501];\n int hasSolution = TRUE;\n char vasyaString[501], c;\n Element *pocetak=NULL, *kraj=NULL;\n int problemi=0, problemj=0;\n\n scanf(\"%d%d\", &n, &m);\n for (i=1; i<=n; i++)\n {\n color[i]=WHITE;\n parent[i]=FALSE;\n vasyaString[i]='b';\n for (j=1; j<=n; j++)\n graph[i][j] = FALSE;\n }\n\n for (i=0; i3)\n {\n hasSolution = FALSE;\n }\n dodaj(&pocetak, &kraj, j);\n }\n else if (abs(vasyaString[i]-vasyaString[j])==0) {\n hasSolution = FALSE;\n problemi = i;\n problemj = j;\n }\n }\n if (!hasSolution)\n {\n break;\n }\n }\n if (!hasSolution)\n {\n break;\n }\n }\n\t\t}\n\t\tif (!hasSolution)\n {\n break;\n }\n\t}\n\n\tif (hasSolution)\n {\n for (i=1; i<=n; i++)\n {\n for (j=1; j<=n; j++)\n {\n if (graph[i][j]==TRUE && abs(vasyaString[i]-vasyaString[j])==2)\n {\n hasSolution=FALSE;\n }\n }\n }\n }\n\n if (hasSolution)\n {\n printf(\"Yes\\n\");\n for (i=1; i<=n; i++)\n printf(\"%c\",vasyaString[i]);\n printf(\"\\n\");\n }\n else\n {\n printf(\"No\\n\");\n if (n==15 && m==95)\n {\n for (i=1; i<=n; i++)\n printf(\"%c\",vasyaString[i]);\n printf(\"%d %d\\n\", problemi, problemj);\n for (i=1; i<=n; i++)\n {\n for (j=1; j<=n; j++)\n printf(\"%d\",graph[i][j]);\n printf(\"\\n\");\n }\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "graphs"], "code_uid": "2435f4941bcb3214510bf6da0cf492c6", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define uLL unsigned long long\n#define LL long long\nuLL exgcd64(uLL a,uLL b,uLL *x,uLL *y)\n{\n\tstatic uLL gcd;\n\tif (a==0)\n\t{\n\t\t*x=0;*y=1;\n\t\treturn b;\n\t}\n\telse\n\t{\n\t\tgcd=exgcd64(b%a,a,y,x);\n\t\t*x-=(b/a)*(*y)+b;\n\t\t*y+=a;\n\t\treturn gcd;\n\t}\n}\nint main()\n{\n//\tfreopen(\"in.in\",\"r\",stdin);\n\tLL i,j,k,n,m,a,b,c,d,x,y,vx,vy,e;\n\tscanf(\"%lld%lld%lld%lld%lld%lld\",&n,&m,&x,&y,&vx,&vy);\n\tif ((vx==0)||(vy==0))\n\t{\n\t\tif (vx==0)\n\t\t{\n\t\t\tif ((x==0)||(x==n))\n\t\t\t{\n\t\t\t\tif (vy<0) {printf(\"%lld 0\\n\",x);}\n\t\t\t\telse {printf(\"%lld %lld\\n\",x,m);}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t}\n\t\t}\n\t\tif (vy==0)\n\t\t{\n\t\t\tif ((y==0)||(y==m))\n\t\t\t{\n\t\t\t\tif (vx<0) {printf(\"0 %lld\\n\",y);}\n\t\t\t\telse {printf(\"%lld %lld\\n\",n,y);}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (vx<0)\n\t\t{\n\t\t\tx=n-x;\n\t\t}\n\t\tif (vy<0)\n\t\t{\n\t\t\ty=m-y;\n\t\t}\n\t\t//printf(\"%lld %lld %lld %lld\\n\",n,m,x,y);\n\t\tc=exgcd64(m,n,&a,&b);\n\t\te=c;\n\t\td=x-y;\n\t\tif (d<0) {d=(d%m+m)%m;}\n\t\tif (d%c!=0) {printf(\"-1\\n\");}\n\t\telse\n\t\t{\n\t\t\t//printf(\"%lld %lld %lld\\n\",b%c,d,((d/c)*(b/1)%(m/c)*n)%m);\n\t\t\td=(d/c)*(b)%(m/c);\n\t\t\tif (d==0) {d+=m/c;}\n\t\t\tc=d;\n\t\t\td=(c*n-(x-y))/m;\n/*\t\t\tif (d<0)\n\t\t\t{\n\t\t\t\ta=(-d)/c+1;\n\t\t\t\tc+=a*(m/e);\n\t\t\t\td+=a*(n/e);\n\t\t\t}*/\n\t\t\t//printf(\"%lld %lld %lld %lld\\n\",c,d*m,(c*n-(x-y))%m,x-y);\n\t\t\tc=c&1;d=d&1;\n\t\t\tif (vx<0) {c=c^1;}\n\t\t\tif (vy<0) {d=d^1;}\n\t\t\tc=c*n;d=d*m;\n\t\t\tprintf(\"%lld %lld\\n\",c,d);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["geometry", "number theory"], "code_uid": "63da19135cd55642d99554c6f37ba897", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define uLL unsigned long long\n#define LL long long\nuLL exgcd64(uLL a,uLL b,uLL *x,uLL *y)\n{\n\tstatic uLL gcd;\n\tif (a==0)\n\t{\n\t\t*x=0;*y=1;\n\t\treturn b;\n\t}\n\telse\n\t{\n\t\tgcd=exgcd64(b%a,a,y,x);\n\t\t*x-=(b/a)*(*y)+b;\n\t\t*y+=a;\n\t\treturn gcd;\n\t}\n}\nint main()\n{\n//\tfreopen(\"in.in\",\"r\",stdin);\n\tLL i,j,k,n,m,a,b,c,d,x,y,vx,vy,e;\n\tscanf(\"%lld%lld%lld%lld%lld%lld\",&n,&m,&x,&y,&vx,&vy);\n\tif ((vx==0)||(vy==0))\n\t{\n\t\tif (vx==0)\n\t\t{\n\t\t\tif ((x==0)||(x==n))\n\t\t\t{\n\t\t\t\tif (vy<0) {printf(\"%lld 0\\n\",x);}\n\t\t\t\telse {printf(\"%lld %lld\\n\",x,m);}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t}\n\t\t}\n\t\tif (vy==0)\n\t\t{\n\t\t\tif ((y==0)||(y==m))\n\t\t\t{\n\t\t\t\tif (vx<0) {printf(\"0 %lld\\n\",y);}\n\t\t\t\telse {printf(\"%lld %lld\\n\",n,y);}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (vx<0)\n\t\t{\n\t\t\tx=n-x;\n\t\t}\n\t\tif (vy<0)\n\t\t{\n\t\t\ty=m-y;\n\t\t}\n\t\t//printf(\"%lld %lld %lld %lld\\n\",n,m,x,y);\n\t\tc=exgcd64(m,n,&a,&b);\n\t\te=c;\n\t\td=x-y;\n\t\tif (d<0) {d=(d%m+m)%m;}\n\t\tif (d%c!=0) {printf(\"-1\\n\");}\n\t\telse\n\t\t{\n\t\t\t//printf(\"%lld %lld %lld\\n\",b%c,d,((d/c)*(b/1)%(m/c)*n)%m);\n\t\t\td=(d/c)*(b)%(m/c);\n\t\t\tif (d==0) {d+=m/c;}\n\t\t\tc=d;\n\t\t\td=(c*n-(x-y))/m;\n\t\t\tif (d<0)\n\t\t\t{\n\t\t\t\ta=(-d)/c+1;\n\t\t\t\tc+=a*(m/e);\n\t\t\t\td+=a*(n/e);\n\t\t\t}\n\t\t\t//printf(\"%lld %lld %lld %lld\\n\",c,d*m,(c*n-(x-y))%m,x-y);\n\t\t\tc=c&1;d=d&1;\n\t\t\tif (vx<0) {c=c^1;}\n\t\t\tif (vy<0) {d=d^1;}\n\t\t\tc=c*n;d=d*m;\n\t\t\tprintf(\"%lld %lld\\n\",c,d);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["geometry", "number theory"], "code_uid": "958d6f3d377b8b84528449b9bd092eb2", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint good(int a, int b) {\n\treturn a == 0 ? 1 : b == 0 ? 0 : good(a % 10 == b % 10 ? a / 10 : a, b / 10);\n}\n\nint count(int n) {\n\treturn n == 0 ? 0 : count(n / 10) + 1;\n}\n\nint main() {\n\tint n, x, k, ans;\n\n\tscanf(\"%d\", &n);\n\tk = count(n);\n\tans = 0;\n\tfor (x = 1; x * x <= n; x++) {\n\t\tint cnt;\n\n\t\tcnt = count(x * x);\n\t\tif (good(x * x, n) && ans < cnt)\n\t\t\tans = cnt;\n\t}\n\tprintf(\"%d\\n\", ans == 0 ? -1 : k - ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "53244c41b13af238b7d6cac3c64d6c81", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main(void)\n{\n long long n, i, s, nc, nop, min_nop;\n\n scanf(\"%lld\", &n);\n min_nop = LLONG_MAX;\n\n for (i = 1; i * i <= n; i++) {\n s = i * i;\n nc = n;\n nop = 0;\n\n while (nc && s) {\n if (nc % 10 == s % 10) {\n s /= 10;\n } else {\n nop++;\n }\n\n nc /= 10;\n }\n\n if (s == 0) {\n while (nc) {\n nop++;\n nc /= 10;\n }\n\n if (nop < min_nop) {\n min_nop = nop;\n }\n }\n }\n\n printf(\"%lld\\n\", min_nop == LLONG_MAX ? -1 : min_nop);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation"], "code_uid": "3a424d29fd5ede75cf1266537cd4bd33", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t13\n#define Q\t1010\n#define MD1\t998244353\n#define MD\t1000000007\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\n\nlong long pp[N + 1], qq[N + 1];\n\nvoid init() {\n\tint i;\n\n\tpp[0] = qq[0] = 1;\n\tfor (i = 1; i <= N; i++) {\n\t\tpp[i] = pp[i - 1] * 10;\n\t\tqq[i] = qq[i - 1] + pp[i];\n\t}\n}\n\nlong long idx(long long a, long long b) {\n\tstatic int aa[N], bb[N];\n\tstatic long long aa_[N];\n\tlong long cnt;\n\tint n, m, i, j, c;\n\n\tn = 0;\n\twhile (a > 0)\n\t\taa[n++] = a % 10, a /= 10;\n\tm = 0;\n\twhile (b > 0)\n\t\tbb[m++] = b % 10, b /= 10;\n\tfor (i = 0; i < n; i++)\n\t\taa_[i] = (i == 0 ? 0 : aa_[i - 1]) + aa[i] * pp[i];\n\tcnt = m;\n\tfor (i = n - 1, j = m - 1, c = 0; j >= 0; i--, j--)\n\t\tif (c < 0)\n\t\t\tcnt += qq[n - 1 - (m - 1 - j)] * (bb[j] - (j == m - 1 ? 1 : 0));\n\t\telse if (c > 0)\n\t\t\tcnt += (n - 1 - (m - 1 - j) == 0 ? 0 : qq[n - 2 - (m - 1 - j)]) * (bb[j] - (j == m - 1 ? 1 : 0));\n\t\telse {\n\t\t\tif (bb[j] <= aa[i]) {\n\t\t\t\tif (bb[j] < aa[i])\n\t\t\t\t\tc = -1;\n\t\t\t\tcnt += qq[n - 1 - (m - 1 - j)] * (bb[j] - (j == m - 1 ? 1 : 0));\n\t\t\t} else {\n\t\t\t\tc = 1;\n\t\t\t\tcnt += qq[n - 1 - (m - 1 - j)] * (aa[i] - (j == m - 1 ? 1 : 0));\n\t\t\t\tcnt += (n - 1 - (m - 1 - j) == 0 ? 0 : qq[n - 2 - (m - 1 - j)]) * (bb[j] - aa[i]) + (i == 0 ? 0 : aa_[i - 1]) + 1;\n\t\t\t}\n\t\t}\n\treturn cnt;\n}\n\nint aa[N], bb[N];\n\nlong long count_(long long a, long long d) {\n\tlong long b, cnt;\n\n\tcnt = 0;\n\tfor (b = 1; b <= a; b++)\n\t\tif (idx(a, b) - b >= d)\n\t\t\tcnt++;\n\treturn cnt;\n}\n\nlong long count(long long a, long long d) {\n\tint m;\n\tlong long cnt;\n\n\tcnt = 0;\n\tfor (m = 1; pp[m - 1] - 1 <= a; m++) {\n\t\tlong long lower = pp[m - 1] - 1, upper = min(pp[m], a + 1);\n\n\t\twhile (upper - lower > 1) {\n\t\t\tlong long b = (lower + upper) / 2;\n\n\t\t\tif (idx(a, b) - b >= d)\n\t\t\t\tupper = b;\n\t\t\telse\n\t\t\t\tlower = b;\n\t\t}\n\t\tcnt += min(pp[m], a + 1) - upper;\n\t}\n\treturn cnt;\n}\n\nint main() {\n\tlong long a, q, ans;\n\n\tinit();\n\tscanf(\"%lld\", &a);\n\tans = Q * a % MD;\n\tfor (q = -Q + 1; q <= Q; q++)\n\t\tans = (ans - count(a, q * MD1)) % MD;\n\tans = ans * MD1 % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "math", "meet-in-the-middle", "binary search"], "code_uid": "ec09604eab4de5b049bf2ad37c7cdca9", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define HELL 1000000007\nchar fast_char_var;\n#define\tfast_unsigned_dtype\tunsigned long\nfast_unsigned_dtype fast_unsigned_var;\nfast_unsigned_dtype fast_unsigned()\n{\n\tfast_char_var=getchar();\n\twhile(fast_char_var<48||fast_char_var>57)\n\t\tfast_char_var=getchar();\n\tfast_unsigned_var=0;\n\twhile(fast_char_var>47&&fast_char_var<58)\n\t{\n\t\tfast_unsigned_var=(fast_unsigned_var<<1)+(fast_unsigned_var<<3)+fast_char_var-48;\n\t\tfast_char_var=getchar();\n\t}\n\treturn fast_unsigned_var;\n}\nint main()\n{\n\tstatic unsigned long long ans2,ans,i,j,a[4010],b[4010],n;\n\tn=fast_unsigned();\n\tn++;\n\ta[0]=1;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tb[0]=a[i-1];\n\t\tfor(j=1;j<=i;j++)\n\t\t\tb[j]=(a[j-1]+b[j-1])%HELL;\n\t\t\n\t\tfor(j=0;j<=i;j++)\n\t\t\ta[j]=b[j];\n\t}\n\tans=b[n]+HELL-b[n-1];\n\tans%=HELL;\n\ta[0]=1;\n\tn--;\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tb[0]=a[i-1];\n\t\tfor(j=1;j<=i;j++)\n\t\t\tb[j]=(a[j-1]+b[j-1])%HELL;\n\t\t\n\t\tfor(j=0;j<=i;j++)\n\t\t\ta[j]=b[j];\n\t}\n\tans2=b[n]+HELL-b[n-1];\n\tans2%=HELL;\n\tans=ans+HELL-ans2;\n\tans%=HELL;\n\tprintf(\"%llu\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "54caff56f0d25d450b189511211b82d8", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MAX 4010\n#define MOD 1000000007\n\nint S[4010][4010];\n\nvoid Generate(){\n int i, j;\n\n S[0][0] = 1;\n for (i = 1; i < MAX; i++){\n S[i][0] = 0;\n for (j = 1; j <= i; j++){\n S[i][j] = ( ((long long)S[i - 1][j] * j) + S[i - 1][j - 1]) % MOD;\n }\n }\n}\n\nint F(int n){\n int k;\n long long x, res = 0;\n for (k = 1; k <= n; k++){\n x = S[n][k];\n res = (res + (x * k)) % MOD;\n }\n return res;\n}\n\nint main(){\n Generate();\n int n;\n while (scanf(\"%d\", &n) != EOF){\n printf(\"%d\\n\", F(n));\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "31f6b4c9e913bb80199a73cee4288faf", "src_uid": "aa2c3e94a44053a0d86f61da06681023", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define maxn 1000\n\nlong p[maxn+1][5],xl[maxn+1][maxn+1][5],point[maxn+1],count=0;\n__int64 value[maxn+1][maxn+1];\nbool vis[maxn+1];\n\n long n,i,j,k,l;\n __int64 v1,v2;\n\n\nvoid work()\n{\n for (j=1;j0\n // +\n if ((v1>0 && v2>0) || (v1<0 && v2<0))\n {\n vis[i]=false;\n return;\n }\n }\n vis[i]=true;\n}\n\nint main()\n{\n scanf(\"%ld\",&n);\n for (i=1;i<=n;i++)\n for (j=0;j<5;j++)\n scanf(\"%ld\",&p[i][j]);\n for (i=1;i<=n;i++)\n for (j=1;j<=n;j++)\n {\n value[i][j]=0;\n for (k=0;k<5;k++)\n {\n xl[i][j][k]=p[j][k]-p[i][k];\n value[i][j]+=xl[i][j][k]*xl[i][j][k];\n }\n }\n\n// for (i=1;i<=n;i++)\n// vis[i]=true;\n for (i=1;i<=n;i++)\n work();\n for (i=1;i<=n;i++)\n if (vis[i]==true)\n {\n count++;\n point[count]=i;\n }\n printf(\"%ld\\n\",count);\n for (i=1;i<=count;i++)\n printf(\"%ld\\n\",point[i]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "78af259845bf062c1c4283d5d602df31", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define N\t1000\n\nint main() {\n\tstatic int aa[N], bb[N], cc[N], dd[N], ee[N], ii[N];\n\tint n, h, i, j, k, cnt;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d%d%d%d%d\", &aa[i], &bb[i], &cc[i], &dd[i], &ee[i]);\n\tcnt = 0;\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\tif (j != i && k != i && j != k && (aa[j] - aa[i]) * (aa[k] - aa[i]) + (bb[j] - bb[i]) * (bb[k] - bb[i]) + (cc[j] - cc[i]) * (cc[k] - cc[i]) + (dd[j] - dd[i]) * (dd[k] - dd[i]) + (ee[j] - ee[i]) * (ee[k] - ee[i]) > 0)\n\t\t\t\t\tgoto out;\n\t\tii[cnt++] = i;\nout:\n\t\t;\n\t}\n\tprintf(\"%d\\n\", cnt);\n\tfor (h = 0; h < cnt; h++)\n\t\tprintf(\"%d\\n\", ii[h] + 1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "geometry"], "code_uid": "48fb93d3a6bee521c89886f7cd5016e2", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong long int n,x;\nlong long int f(long long int a)\n{\n\tif(a<2)\n\t\treturn a+1;\n \tx=f(a/2);\n\tx *= x;\n\tif(a & 1) x *= 2;\n\tx %= 1000000007;\n\treturn x;\n}\nint main()\n{\n\tscanf(\"%lld\",&n);\n\tlong long int a=f(n);\n\tprintf(\"%lld\",(a*(a+1)/2)%1000000007);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "matrices", "dp", "number theory"], "code_uid": "d83aaa7e754b6427f51e487e5a359975", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#define getchar getchar//_unlocked\n#define M 1000000007\n\nint getint ()\n{\n int n=0;\n char ch=getchar();\n\n while(ch<'0' || ch>'9')\n ch=getchar();\n\n while(ch>='0' && ch<='9')\n {\n n=n*10+ch-'0';\n ch=getchar();\n }\n\n return n;\n\n}\n\n\nunsigned long long gcd(unsigned long long a, unsigned long long b)\n{\n\n\n unsigned long long div=a,did=b,rem;\n\n while((rem=did%div)!=0)\n {\n did=div;\n div=rem;\n\n }\n\n return div;\n\n\n}\n\nlong long getlonglong ()\n{\n long long n=0;\n char ch=getchar();\n\n while(ch<'0' || ch>'9')\n ch=getchar();\n\n while(ch>='0' && ch<='9')\n {\n n=n*10+ch-'0';\n ch=getchar();\n }\n\n return n;\n\n}\n\n\nvoid sort(int a[] ,int start1 ,int end1 ,int start2 ,int end2)\n{\n\n int temp[end1-start1 +1 + end2-start2+1 ];\n int i=start1,j=start2,count=0;\n\n while(i<=end1 && j<=end2)\n {\n if(a[i]>=a[j])\n temp[count++]=a[i++];\n else\n temp[count++]=a[j++];\n\n\n }\n\n for(;i<=end1;++i)\n temp[count++]=a[i];\n\n for(;j<=end2;++j)\n temp[count++]=a[j];\n\n for(i=0;i\n#include \n\nlong long int power(int x, int y, int m)\n{\n\tif (y==1) return x % m;\n\tif (y==0) return 1;\n\tlong long int t = power(x, y / 2, m);\n\tif (y & 1)\n\t\treturn (((t*t) % m) * x) % m;\n\telse return (t*t) % m;\n}\n\nint main()\n{\n\tint i,j,x,y,n,m;\n\tscanf(\"%d %d\", &n, &m);\n\t\n\tlong long int res = (power(3, n, m) - 1 + m) % m;\n\tprintf(\"%I64d\\n\", res);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math"], "code_uid": "6d855904a79078b425a55fa7448d46cc", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint n,m;\n\nint modpow(int d,int x,int M){\n long long res=1,temp=d;\n while(x){\n if(x&1){res*=temp; res%=M;}\n temp=(temp*temp)%M;\n x>>=1;\n }\n return (int)res;\n}\n\nmain(){\n scanf(\"%d%d\",&n,&m);\n int ans = (modpow(3,n,m)+m-1)%m;\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "4f3919d23b2f49af29cc504942983faa", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c", "difficulty": 1400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint buy[12][105],v[12][105],money[105],sale[12][105],space[105];\nint main()\n{\n int n,m,s,max=0,x,y,t,k,sum,total,i,j;\n char str[105];\n scanf(\"%d%d%d\",&n,&m,&s);\n for(i=0;ibuy[i][k])\n money[k]=sale[j][k]-buy[i][k];\n else\n money[k]=0;\n space[k]=v[i][k];\n }\n for(x=0;x=total)\n {\n sum+=money[k]*total;\n break;\n }\n else\n {\n sum+=money[k]*space[k];\n total-=space[k];\n }\n }\n if(sum>max)\n max=sum;\n }\n }\n printf(\"%d\\n\",max);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "games", "graph matchings"], "code_uid": "529f4091786c1158250332582367f756", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nlong long gcd(long long a, long long b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nint main() {\n\tstatic char cc[1048576], *s = cc;\n\tlong long x, y;\n\n\tscanf(\"%lld%lld\", &x, &y);\n\tif (gcd(x, y) != 1) {\n\t\tprintf(\"Impossible\\n\");\n\t\treturn 0;\n\t}\n\twhile (x > 1 || y > 1) {\n\t\tlong long k;\n\t\tchar c;\n\n\t\tif (x > y) {\n\t\t\tk = x / y;\n\t\t\tif (y == 1)\n\t\t\t\tk--;\n\t\t\tx %= y;\n\t\t\tc = 'A';\n\t\t} else {\n\t\t\tk = y / x;\n\t\t\tif (x == 1)\n\t\t\t\tk--;\n\t\t\ty %= x;\n\t\t\tc = 'B';\n\t\t}\n\t\ts += sprintf(s, \"%lld%c\", k, c);\n\t}\n\tprintf(\"%s\\n\", cc);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["number theory"], "code_uid": "e7cb9d74e3b47da12969eb0cc386657e", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/*\nID: Sfiction\nOJ: CF128 Div2\nPROB: D\n*/\n#include \nint main()\n{\n double a,b,m,vx,vy,vz;\n double x,z,t;\n scanf(\"%lf%lf%lf\",&a,&b,&m);\n scanf(\"%lf%lf%lf\",&vx,&vy,&vz);\n t=-m/vy;\n x=a/2+t*vx;\n z=t*vz;\n while (x<0||x>a)\n if (x>a) x=2*a-x;\n else x=-x;\n while (z<0||z>b)\n if (z>b) z=2*b-z;\n else z=-z;\n printf(\"%.10lf %.10lf\",x,z);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry", "implementation"], "code_uid": "88adc4d1489e22376aa3cd5c92b42089", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main ()\n{\n\tint a, b, m, vx, vy, vz, i;\n\tdouble x, y, z, t, T;\n\tscanf (\"%d%d%d\", &a, &b, &m);\n\tscanf (\"%d%d%d\", &vx, &vy, &vz);\n\tx = (double)a/2; y = m; z = 0;\n\twhile (y>0.000001)\n\t{\n\t\t//printf (\"%lf %lf %lf %d %d\\n\", x, y, z, vx, vz);\n\t\tT = -1*y/vy;\n\t\tt = -1*x/vx;\n\t\tif (t > 0.000001 && t < T)\n\t\t\tT = t;\n\t\tt = (a-x)/vx;\n\t\tif (t > 0 && t < T)\n\t\t\tT = t;\n\t\tt = -1*z/vz;\n\t\tif (t > 0 && t < T)\n\t\t\tT = t;\n\t\tt = (b-z)/vz;\n\t\tif (t > 0 && t < T)\n\t\t\tT = t;\n\t\tx += vx*T;\n\t\ty += vy*T;\n\t\tz += vz*T;\n\t\tif (x > -0.000001 && x < 0.000001)\n\t\t{\n\t\t\tvx *= -1;\n\t\t\tx = 0;\n\t\t}\n\t\tif (x-a > -0.000001 && x-a < 0.000001)\n\t\t{\n\t\t\tvx *= -1;\n\t\t\tx = a;\n\t\t}\n\t\tif (z > -0.000001 && z < 0.000001)\n\t\t{\n\t\t\tvz *= -1;\n\t\t\tz = 0;\n\t\t}\n\t\tif (z-b > -0.000001 && z-b < 0.000001)\n\t\t{\n\t\t\tvz *= -1;\n\t\t\tz = b;\n\t\t}\n\t}\n\tprintf (\"%lf %lf\\n\", x, z);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "geometry", "implementation"], "code_uid": "e438e97e3bded3d311d756746d4e7573", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n\tlong long int x;\n\t\n\tscanf(\"%lld\", &x);\n\t\n\tif(x<=3 || x%2==0)\n\t{\n\t\tprintf(\"NO\");\n\t}\n\telse\n\t{\n\t\tprintf(\"1 %lld\", (x-3)/2);\n\t}\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "4ea5386843106209ece771175e270877", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n long long int r, x = 1, y;\n scanf(\"%lld\", &r);\n if(r % 2 == 0 || r < 5)\n printf(\"NO\\n\");\n else{\n y = (r - 3) / 2;\n printf(\"%lld %lld\\n\", x, y);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "number theory"], "code_uid": "6ba63044a18b94feb7ea69d341836a09", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba", "difficulty": 1200.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;ik);if(i>=j)break;t=d[i];d[i]=d[j];d[j]=t;}intSort(d,i);intSort(d+j+1,s-j-1);}\nvoid intReverse(int d[],int size){int a=0,b=size-1,t;while(a=0;k--)if(d[k]d[k])break;j=d[i],d[i]=d[k],d[k]=j;intReverse(d+k+1,size-k-1);return 1;}\n\nint main(){\n int i,j,k,l,m,n;\n int res;\n char tmp[10];\n int in[10], go[10];\n ull hs, mx;\n\n dieInit();\n while(scanf(\"%s\",tmp)==1){\n ullHashClear();\n res = 0;\n\n rep(i,6) in[i] = tmp[i];\n intSort(in,6);\n\n do{\n mx = 0;\n rep(i,24){\n rep(k,6) go[k] = in[die[i][k]];\n hs = 0;\n rep(k,6) hs = hs * 1007 + go[k];\n if(mx < hs) mx = hs;\n }\n if( ullHashIncrease(mx)==1 ) res++;\n }while(intNextPermutation(in,6));\n\n printf(\"%d\\n\",res);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "implementation"], "code_uid": "9c957bc47b0e3c36bc0de280e5689e6c", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int a[6] = {0}, b[7] = {0};\n char s[7];\n int i;\n\n scanf(\"%s\", s);\n\n for (i = 0; i < 6; i++) {\n\tswitch (s[i]) {\n\tcase 'R' : a[0]++; break;\n\tcase 'O' : a[1]++; break;\n\tcase 'Y' : a[2]++; break;\n\tcase 'G' : a[3]++; break;\n\tcase 'B' : a[4]++; break;\n\tcase 'V' : a[5]++; break;\n\t}\n }\n\n for (i = 0; i < 6; i++) b[a[i]]++;\n\n if (b[6] == 1 || b[5] == 1) {\n\tputs(\"1\");\n } else if (b[4] == 1 || b[3] == 2) {\n\tputs(\"2\");\n } else if (b[3] == 1) {\n\tif (b[2] == 1) {\n\t puts(\"3\");\n\t} else {\n\t puts(\"5\");\n\t}\n } else if (b[2] == 3) {\n\tputs(\"6\");\n } else if (b[2] == 2) {\n\tputs(\"8\");\n } else if (b[2] == 1) {\n\tputs(\"15\");\n } else {\n\tputs(\"30\");\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force"], "code_uid": "f8806101e1d61988426c38e43e5870e6", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nconst long long MOD = 1e9 + 7;\nstruct A{int first; int second;};\nstruct A fibp(long long n) {\n long long a = 1, b = 0;\n long long s = 0, r = 1;\n for ( ; n; n >>= 1) {\n if (n & 1) {\n long long na = (a*s + b*r) % MOD;\n long long nb = (a*r + b*s + b*r) % MOD;\n a = na;\n b = nb;\n }\n long long ns = (s*s + r*r) % MOD;\n long long nr = (2*s*r + r*r) % MOD;\n s = ns;\n r = nr;\n }\n struct A res;\n res.first = a;\n res.second = b;\n return res;\n}\n\nint powmod(long long a, long long b) {\n long long r = 1;\n for (a %= MOD; b; b >>= 1) {\n if (b & 1) {\n r *= a;\n r %= MOD;\n }\n a *= a;\n a %= MOD;\n }\n return r;\n}\n\nint f(long long n, int k) {\n static int A[2001];\n for (int i = 0; i <= k; ++i) {\n A[i] = powmod(n + i, k);\n }\n struct A ab = fibp(n + 1);\n int a = ab.first, b = ab.second;\n int r = 0;\n for (int lA = k + 1; lA; --lA) {\n a += b; if (a >= MOD) {a -= MOD;}\n b += a; if (b >= MOD) {b -= MOD;}\n r += (long long)A[0] * a % MOD; if (r >= MOD) {r -= MOD;}\n for (int i = 0; i < lA - 1; ++i) {\n A[i] -= A[i + 1]; if (A[i] < 0) {A[i] += MOD;}\n }\n }\n return r;\n}\n\nint main(void) {\n long long n;\n int k;\n scanf(\"%lld%d\", &n, &k);\n int ans = f(n + 1, k) - f(1, k); if (ans < 0) {ans += MOD;}\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "matrices", "combinatorics"], "code_uid": "44061d2e0f017091a4b6241641c770d3", "src_uid": "14f50a111db268182e5927839a993118", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \nconst long long MOD = 1e9 + 7;\nstruct A{int first; int second;};\nstruct A fibp(long long n) {\n long long a = 1, b = 0;\n long long s = 0, r = 1;\n for ( ; n; n >>= 1) {\n if (n & 1) {\n long long na = (a*s + b*r) % MOD;\n long long nb = (a*r + b*s + b*r) % MOD;\n a = na;\n b = nb;\n }\n long long ns = (s*s + r*r) % MOD;\n long long nr = (2*s*r + r*r) % MOD;\n s = ns;\n r = nr;\n }\n struct A res;\n res.first = a;\n res.second = b;\n return res;\n}\n\nint powmod(long long a, long long b) {\n long long r = 1;\n for (a %= MOD; b; b >>= 1) {\n if (b & 1) {\n r *= a;\n r %= MOD;\n }\n a *= a;\n a %= MOD;\n }\n return r;\n}\n\nint f(long long n, int k) {\n int A[50];\n for (int i = 0; i <= k; ++i) {\n A[i] = powmod(n + i, k);\n }\n struct A ab = fibp(n + 1);\n int a = ab.first, b = ab.second;\n int r = 0;\n for (int lA = k + 1; lA; --lA) {\n a += b; if (a >= MOD) {a -= MOD;}\n b += a; if (b >= MOD) {b -= MOD;}\n r += (long long)A[0] * a % MOD; if (r >= MOD) {r -= MOD;}\n for (int i = 0; i < lA - 1; ++i) {\n A[i] -= A[i + 1]; if (A[i] < 0) {A[i] += MOD;}\n }\n }\n return r;\n}\n\nint main(void) {\n long long n;\n int k;\n scanf(\"%lld%d\", &n, &k);\n int ans = f(n + 1, k) - f(1, k); if (ans < 0) {ans += MOD;}\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["math", "matrices", "combinatorics"], "code_uid": "3d2617dd40a2a1a7ecb696315aaf8cf7", "src_uid": "14f50a111db268182e5927839a993118", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i=n){\n if(now[n-1] < 0) return;\n if(now[n-1] == res && cost > res_cost) res++;\n if(now[n-1] < res) res = now[n-1], res_cost = cost;\n return;\n }\n\n if(b>=n){\n if(aa!=0 && aa!=n-1 && now[aa]) return;\n solve(a+1,a+2,cost);\n return;\n }\n\n REP(i,-mx[aa][bb],mx[aa][bb]+1){\n if(-mi[aa][bb]\n#define M 510\n#define ll long long int\nll mod=1000000007;\nll f[M][M];\nll pp[1000000];\nll ans;\nint n,k;\nvoid prepare(){\n ll cnt;\n int i,j;\n pp[0]=1;\n for(i=1;i<1000000;i++)pp[i]=(pp[i-1]*2)%mod;\n for(i=0;i<=500;i++)f[i][0]=1;\n for(n=1;n<=500;n++)for(k=1;k<=n;k++){\n for(j=k;j<=n;j++){\n cnt=(pp[j*(n-j+1)]-pp[(j-1)*(n-j+1)]+mod)%mod;\n cnt=(f[j-1][k-1]*cnt)%mod;\n f[n][k]=(f[n][k]+cnt);\n }\n f[n][k]%=mod;\n }\n}\nint main(){\n int i,j;\n prepare();\n scanf(\"%d %d\",&n,&k);\n printf(\"%lld\\n\",f[n][k]);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "aaa6628268686afb5529c13147193123", "src_uid": "111673158df2e37ac6c019bb99225ccb", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define MD 1000000007\n\nint f[11][10], g[11][10];\n\nint a[10];\n\nint calc(int m, int n) {\n\tif (!n) return 1;\n\tint i, t = 0;\n\tfor (i = 0; i < m; ++i) {\n\t\tif (g[0][i] <= 0) continue;\n\t\t--g[0][i];\n\t\tt += (long long)(g[0][i] + 1) * calc(m - i, n - 1) % MD;\n\t\tif (t >= MD) t -= MD;\n\t\t++g[0][i];\n\t}\n\treturn t;\n}\n\nint main() {\n\tint i, j, k, l;\n\tscanf(\"%d\", &j);\n\tfor (i = 0; i < 10; ++i, j /= 10) a[i] = j % 10;\n\n\tmemset(f, 0, sizeof f), f[10][0] = 1;\n\tmemset(g, 0, sizeof g);\n\tfor (i = 9; i >= 0; --i) {\n\t\t// f -> f =\n\t\t// f -> g <\n\t\t// g -> g (any)\n\t\tk = a[i] == 4 || a[i] == 7;\n\t\tfor (j = k; j <= 9; ++j) f[i][j] = f[i + 1][j - k];\n\n\t\tfor (k = 0; k < a[i]; ++k) {\n\t\t\tl = k == 4 || k == 7;\n\t\t\tfor (j = l; j <= 9; ++j) g[i][j] += f[i + 1][j - l];\n\t\t}\n\n\t\tfor (k = 0; k <= 9; ++k) {\n\t\t\tl = k == 4 || k == 7;\n\t\t\tfor (j = l; j <= 9; ++j) g[i][j] += g[i + 1][j - l];\n\t\t}\n\t}\n\t--g[0][0]; // 0\u4e0d\u5408\u6cd5\n\n\tk = 0;\n\tfor (i = 0; i <= 9; ++i) {\n\t\tg[0][i] += f[0][i];\n\t\tk += (long long)g[0][i] * calc(i, 6) % MD;\n\t\tif (k >= MD) k -= MD;\n\t}\n\tprintf(\"%d\", k);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "bfd8c38293c08a7189fe0c8d60caf79a", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nconst int mod = (int)1e9 + 7;\n\nlong long power(long long a, int b) {\n long long ret = 1;\n while (b > 0) {\n if (b % 2) {\n ret *= a;\n ret %= mod;\n }\n a = (a * a) % mod;\n b /= 2;\n }\n return ret;\n}\n\nlong long inverse_mod(long long n) {\n return power(n, mod - 2);\n}\n\nlong long choose(long long n, int k) {\n if (k > n) {\n return 0;\n }\n \n int q = 1;\n for (int i = 1; i <= k; i++) {\n q *= i;\n q %= mod;\n }\n \n long long p = 1;\n for (long long i = n; i > n - k; i--) {\n p *= i;\n p %= mod;\n }\n \n return p * inverse_mod(q) % mod;\n}\n\nint main(void) {\n int m;\n scanf(\"%i\", &m);\n \n char s[50];\n sprintf(s, \"%i\", m);\n \n int len = strlen(s);\n long long f[len+1][len+1][2];\n \n memset(f, 0, sizeof(f));\n \n f[0][0][1] = 1;\n for (int i = 0; i < len; i++) {\n for (int j = 0; j <= len; j++) {\n for (int eq = 0; eq <= 1; eq++) {\n long long cur = f[i][j][eq];\n for (char d = '0'; d <= '9'; d++) {\n if (eq && d > s[i]) {\n continue;\n } \n int n_eq = eq && (d == s[i]);\n int is_lucky = (d == '4' || d == '7') ? 1 : 0;\n f[i+1][j+is_lucky][n_eq] += cur;\n f[i+1][j+is_lucky][n_eq] %= mod;\n }\n }\n }\n }\n \n long long counts[len+1];\n for (int i = 0; i <= len; i++) {\n counts[i] = f[len][i][0] + f[len][i][1];\n counts[i] %= mod;\n }\n counts[0] = (counts[0] + mod - 1) % mod;\n \n long long dp[len+2][50*len+1][10];\n memset(dp, 0, sizeof(dp));\n \n dp[0][0][6] = 1;\n for (int i = 0; i <= len; i++) {\n for (int s = 0; s <= 7*len; s++) {\n for (int r = 0; r <= 6; r++) {\n long long cur = dp[i][s][r];\n if (!cur) continue;\n for (int j = 0; j <= r; j++) {\n if (s+j*i <= 7 * len && r - j >= 0) {\n dp[i+1][s+j*i][r-j] += cur * choose(counts[i], j) % mod;\n dp[i+1][s+j*i][r-j] %= mod;\n }\n }\n }\n } \n }\n \n const int six_fact = 720; \n \n long long take[len+1];\n for (int i = 0; i <= len; i++) {\n take[i] = dp[len+1][i][0] * six_fact % mod;\n }\n \n long long ans = 0;\n for (int c = 1; c <= len; c++) {\n for (int i = 0; i < c; i++) {\n ans += take[i] * counts[c] % mod;\n ans %= mod;\n }\n }\n \n printf(\"%lld\\n\", ans);\n \n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "dp", "combinatorics"], "code_uid": "048c2af60ea0f470d3659208229f748f", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n\n#define MIN(x,y) (((x)<(y))?(x):(y))\n\nstruct{\n short com;\n short flg[3];\n short num;\n short bef[199];\n}game[200]={{0}};\n\nint chk_clear(int k,int f);\n\nint main(void){\n int i,j,k,in,n,room;\n int count[3]={0},cleard[3]={0};\n\n scanf(\"%d%*c\",&n);\n for(i=0;i\n#include\n#define maxn 210\n\nint p[maxn], num[maxn], bef[maxn][maxn], vis[maxn], an[4];\n\nint min(int a, int b, int c){\n\ta = a < b ? a : b;\n\treturn a < c ? a : c;\n}\n\nint gao(int start, int n){\n\tint finish = 0, ans = 0, f = 0, now, flag = 0, i, j;\n\tmemset(vis, 0, sizeof(vis));\n\twhile(finish != n){\n\t\tfor(now = 1; now <= 3; now++){\n\t\t\tif(now == start){\n\t\t\t\tflag = 1;\n\t\t\t}\n\t\t\tif(flag == 1){\n\t\t\t\tfor(i = 1; i <= n; i++){\n\t\t\t\t\tif(p[i] == now){\n\t\t\t\t\t\tif(!num[i] && !vis[i]){\n\t\t\t\t\t\t\tans++; \n\t\t\t\t\t\t\t//printf(\"+\");//\n\t\t\t\t\t\t\tvis[i] = 1;\n\t\t\t\t\t\t\tfinish++;\n\t\t\t\t\t\t\t//printf(\"%d \", i);//\n\t\t\t\t\t\t\ti = 0;\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tf = 0;\n\t\t\t\t\t\t\tfor(j = 1; j <= num[i]; j++){ \n\t\t\t\t\t\t\t\tif(!vis[bef[i][j]]){\n\t\t\t\t\t\t\t\t\tf = 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(f == 0 && !vis[i]){\n\t\t\t\t\t\t\t\tans++;\n\t\t\t\t\t\t\t\t//printf(\"+\");// \n\t\t\t\t\t\t\t\tvis[i] = 1;\n\t\t\t\t\t\t\t\tfinish++;\n\t\t\t\t\t\t\t\t//printf(\"%d \", i);//\n\t\t\t\t\t\t\t\ti = 0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\t\t\n\t\t\t}\n\t\t\tif(flag == 1 && finish != n){\n\t\t\t\tans++;\n\t\t\t\t//printf(\"(+)\");//\n\t\t\t}\n\t\t}\t\t\n\t}\n\t//printf(\"\\n\");//\n\treturn ans;\n}\n\nint main(void){\n\tint n, i, j, ans;\n\tscanf(\"%d\", &n);\n\tfor(i = 1; i <= n; i++){\n\t\tscanf(\"%d\", &p[i]);\n\t}\n\tfor(i = 1; i <= n; i++){\n\t\tscanf(\"%d\", &num[i]);\n\t\tfor(j = 1; j <= num[i]; j++){\n\t\t\tscanf(\"%d\", &bef[i][j]);\n\t\t}\n\t}\n\t\n\tfor(i = 1; i <= 3; i++){\n\t\tan[i] = gao(i, n);\n\t\t//printf(\"%d\\n\", an[i]);//\n\t}\n\tans = min(an[1], an[2], an[3]);\n\tprintf(\"%d\", ans);\n\treturn 0;\n} \n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "27308a172ea156d95cc01ebfb6d32128", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n\tlong long int t,n,l,k,d[200],a[200],flag,i,tmr,temp;\n\tscanf(\"%lld\",&t);\n\twhile(t--)\n\t{\n\t\tscanf(\"%lld %lld %lld\",&n,&k,&l);\n\t\tfor(i=0;il)\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t\t// printf(\"%d-%d\\n\",d[i],i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if(d[i]+k>l)\n\t\t\t{\n\t\t\t\tif(i==0 || tmr==1000)\n\t\t\t\t{\n\t\t\t\t\ta[i]=l;\n\t\t\t\t\ttmr=l-d[i];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(tmr>0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp=a[i-1]-d[i-1];\n\t\t\t\t\t\ta[i]=d[i]+tmr-1;\n\t\t\t\t\t\ttmr--;\n\t\t\t\t\t\tif(a[i]>l)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmr=tmr-(a[i]-l);\n\t\t\t\t\t\t\ta[i]=l;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ttmr=tmr-1;\n\t\t\t\t\t\tif(d[i]-tmr>l)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\t\t// printf(\"%d\\n\",i);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta[i]=d[i]-tmr;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// if(tmr==-k)\n\t\t\t\t\t\t// {\n\t\t\t\t\t\t// \ttmr=k;\n\t\t\t\t\t\t// }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(flag==1)\n\t\t{\n\t\t\tprintf(\"No\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"Yes\\n\");\n\t\t}\n\t}\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "dp"], "code_uid": "ac89c1b6b13a137499dff130f04ceda3", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n\nint main()\n{\n\tint t,n,l,k,d[200],a[200],flag,i,tmr,temp;\n\tscanf(\"%d\",&t);\n\twhile(t--)\n\t{\n\t\tscanf(\"%d %d %d\",&n,&k,&l);\n\t\tfor(i=0;il)\n\t\t\t{\n\t\t\t\tflag=1;\n\t\t\t\t// printf(\"%d-%d\\n\",d[i],i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if(d[i]+k>l)\n\t\t\t{\n\t\t\t\tif(i==0 || tmr==1000)\n\t\t\t\t{\n\t\t\t\t\ta[i]=l;\n\t\t\t\t\ttmr=l-d[i];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(tmr>0)\n\t\t\t\t\t{\n\t\t\t\t\t\ttemp=a[i-1]-d[i-1];\n\t\t\t\t\t\ta[i]=d[i]+tmr-1;\n\t\t\t\t\t\ttmr--;\n\t\t\t\t\t\twhile(a[i]>l)\n\t\t\t\t\t\t{\t\n\t\t\t\t\t\t\ta[i]--;\n\t\t\t\t\t\t\ttmr--;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\ttmr=tmr-1;\n\t\t\t\t\t\tif(d[i]-tmr>l)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tflag=1;\n\t\t\t\t\t\t\t// printf(\"%d\\n\",i);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta[i]=d[i]-tmr;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// if(tmr==-k)\n\t\t\t\t\t\t// {\n\t\t\t\t\t\t// \ttmr=k;\n\t\t\t\t\t\t// }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(flag==1)\n\t\t{\n\t\t\tprintf(\"No\\n\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"Yes\\n\");\n\t\t}\n\t}\n}", "lang_cluster": "C", "tags": ["brute force", "greedy", "dp"], "code_uid": "82fd26e5b0bc93413b9539417007c8a7", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nlong long xy[2];\n\nint gcdxy(int a, int b) {\n\tif (b == 0) {\n\t\txy[0] = 1, xy[1] = 0;\n\t\treturn a;\n\t} else {\n\t\tint g = gcdxy(b, a % b);\n\t\tint tmp;\n\n\t\ttmp = xy[0] - a / b * xy[1];\n\t\txy[0] = xy[1];\n\t\txy[1] = tmp;\n\t\treturn g;\n\t}\n}\n\nint main() {\n\tint a1, b1, a2, b2, l, r, g;\n\tlong long x, b, n, k_, l_, cnt, cnt1, cnt2;\n\n\tscanf(\"%d%d%d%d%d%d\", &a1, &b1, &a2, &b2, &l, &r);\n\t/* (a1k + b1 = a2l + b2) = (a1k - a2l = b2 - b1) */\n\tg = gcdxy(a1, -a2);\n\tb = (long long) b2 - b1;\n\tif (b % g != 0)\n\t\tprintf(\"0\\n\");\n\telse {\n\t\tk_ = xy[0] * b / g, l_ = xy[1] * b / g;\n\t\tif (g < 0)\n\t\t\tg = -g;\n\t\tcnt2 = a2 / g;\n\t\tcnt1 = a1 / g;\n\t\tcnt = (long long) a1 / g * a2;\n\t\tk_ = (k_ % cnt2 + cnt2) % cnt2;\n\t\tl_ = (l_ % cnt1 + cnt1) % cnt1;\n\t\tx = a1 * k_ + b1 > a2 * l_ + b2 ? a1 * k_ + b1 : a2 * l_ + b2;\n\t\tn = 0;\n\t\tif (x >= l && x <= r)\n\t\t\tn = (r - x + 1 + cnt - 1) / cnt;\n\t\telse if (x < l)\n\t\t\tn = (r - x + 1 + cnt - 1) / cnt - (l - 1 - x + 1 + cnt - 1) / cnt;\n\t\tprintf(\"%lld\\n\", n);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "4cb73a4ef76d900d8e42a50616765b2f", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define MAX(x, y) (((x) > (y)) ? (x) : (y))\nint main()\n{\n long long int a,b,c,d,move,move_p,move_v;\n scanf(\"%lld %lld %lld %lld\",&a,&b,&c,&d);\n if(ad)||(a>c&&b<=d)||(a>=c&&b>d)){\n move_p=a+b;\n move_v=MAX(c,d);\n if(move_p<=move_v)printf(\"Polycarp\");\n else printf(\"Vasiliy\");\n }\n else if(a==c&&b\n#include \n#include \n\n#define min(a,b) ((a)<(b) ? (a):(b))\n#define max(a,b) ((a)>(b) ? (a):(b))\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nint main(){\n int i, j, k, l, x, y, z, x1, y1, x2, y2;\n\n while (scanf(\"%d %d %d %d\", &x1, &y1, &x2, &y2) != EOF){\n if ((x1 + y1) <= max(x2, y2)) puts(\"Polycarp\");\n else if ((x1 + y1) == 1) puts(\"Polycarp\");\n else if (( (x1 - 1 + 1) == x2 && (y1 + 1) == y2)) puts(\"Polycarp\");\n else if (( (x1 + 1) == x2 && (y1 - 1 + 1) == y2)) puts(\"Polycarp\");\n else if (x1 <= x2 && y1 <= y2) puts(\"Polycarp\");\n else if (max(x2, y2) < (x1 + y1)) puts(\"Vasiliy\");\n else{\n puts(\"Polycarp\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "implementation", "games"], "code_uid": "793b1ee5a243fb769a8ce646884df325", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint max(int a, int b)\n{\n if (a > b) {\n\t return a;\n } else {\n\t return b;\n }\n}\n\nint min(int a, int b)\n{\n if (a < b) {\n\t return a;\n } else {\n\t return b;\n }\n}\n\nint main()\n{\n char s[4][3];\n int p, q, i, j, k;\n int a[8][8] = {0};\n int b[2][2];\n\n for (i = 0; i < 4; i++) scanf(\"%s\", s[i]);\n\n p = s[2][0] - 'a';\n q = s[2][1] - '1';\n\n for (i = p - 1; i <= p + 1; i++) {\n\t for (j = q - 1; j <= q + 1; j++) {\n\t if (i >= 0 && i < 8 && j >= 0 && j < 8) a[i][j] = 1;\n\t }\n }\n\n for (i = 0; i < 2; i++) {\n\t b[i][0] = s[i][0] - 'a';\n\t b[i][1] = s[i][1] - '1';\n\n\t for (j = b[i][0]; j >= 0; j--) {\n\t a[j][b[i][1]]++;\n\n\t if (j == p && b[i][1] == q) break;\n\t }\n\n\t for (j = b[i][0] + 1; j < 8; j++) {\n\t a[j][b[i][1]]++;\n\n\t if (j == p && b[i][1] == q) break;\n\t }\n\n\t for (j = b[i][1] - 1; j >= 0; j--) {\n\t a[b[i][0]][j]++;\n\n\t if (b[i][0] == p && j == q) break;\n\t }\n\n\t for (j = b[i][1] + 1; j < 8; j++) {\n\t a[b[i][0]][j]++;\n\n\t if (b[i][0] == p && j == q) break;\n\t }\n }\n\n p = s[3][0] - 'a';\n q = s[3][1] - '1';\n\n if (a[p][q] == 0) {\n\t puts(\"OTHER\");\n\n\t return 0;\n }\n\n for (i = p - 1; i <= p + 1; i++) {\n\t for (j = q - 1; j <= q + 1; j++) {\n\t if (i >= 0 && i < 8 && j >= 0 && j < 8) {\n\t\t if (a[i][j] == 0) {\n\t\t\t puts(\"OTHER\");\n\n\t\t\t return 0;\n\t\t }\n\n\t\t for (k = 0; k < 2; k++) {\n\t\t\t if (i == b[k][0] && j == b[k][1]) {\n\t\t\t if (a[i][j] == 1) {\n\t\t\t\t puts(\"OTHER\");\n\n\t\t\t\t return 0;\n\t\t\t }\n\t\t\t }\n\t\t }\n\t }\n\t }\n }\n\n puts(\"CHECKMATE\");\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "97b8675ad373124fd72ddf5d95742817", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#define REP(i,a,b) for(i=a;iin[k][0]&&in[k][0]>in[3][0]))) break;\n if(in[i][0]==in[3][0] && in[i][0]==in[k][0] && ((in[i][1]in[k][1]&&in[k][1]>in[3][1]))) break;\n }\n if(k==3) break;\n }\n }\n if(i<2) break;\n ok=1; break;\n }\n in[3][0] -= di; in[3][1] -= dj;\n }\n if(ok) puts(\"OTHER\"); else puts(\"CHECKMATE\");\n\n break;\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "fc394fb05e967fed69865ada9eba98b7", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n#define prime 1000000007\nint main()\n{\n\tlong long num,flag=0;\n\tscanf(\"%lli\",&num);\n\tif(num<0)\n\t{\n\t\tflag=1;\n\t\tnum=-1*num;\n\t}\n\tnum=num%360;\n\tif(flag==0)\n\t{\n\t\tif(num<=45)\n\t\t{\n\t\t\tprintf(\"0\\n\");\n\t\t}\n\t\telse if(num<=135)\n\t\t{\n\t\t\tprintf(\"1\\n\");\n\t\t}\n\t\telse if(num<=225)\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t}\n\t\telse if(num<315)\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t}\n\t\telse printf(\"0\\n\");\n\t}\n\telse if(flag==1)\n\t{\n\t\tif(num==135)\n\t\t\tprintf(\"2\\n\");\n\t\telse if(num==225)\n\t\t\tprintf(\"1\\n\");\n\t\telse if(num==315)\n\t\t\tprintf(\"0\\n\");\n\t\telse if(num<=45)\n\t\t{\n\t\t\tprintf(\"0\\n\");\n\t\t}\n\t\telse if(num<=135)\n\t\t{\n\t\t\tprintf(\"3\\n\");\n\t\t}\n\t\telse if(num<=225)\n\t\t{\n\t\t\tprintf(\"2\\n\");\n\t\t}\n\t\telse if(num<315)\n\t\t{\n\t\t\tprintf(\"1\\n\");\n\t\t}\n\t\telse printf(\"0\\n\");\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "5c00aa6ccbdc300ce3d96349dd901614", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint main()\n{\n\tlong long int n,a;\n\tscanf(\"%lld\",&n);\n\tif(n<0)\n\t{\n\t\ta=360+n%360;\n\t}\n\telse\n\t\ta=n%360;\n\tif(a>=0&&a<=45)\n\t\tprintf(\"0\");\n\telse if(a>=46&&a<=135)\n\t\tprintf(\"1\");\n\telse if(a>=136&&a<=225)\n\t\tprintf(\"2\");\n\telse if(a>=226&&a<=314)\n\t\tprintf(\"3\");\n\telse if(a>=315&&a<=360)\n\t\tprintf(\"0\");\n\n\treturn 0;\n\n}\n", "lang_cluster": "C", "tags": ["math", "geometry"], "code_uid": "ff4149719bf6fe7235f74722cfea0a57", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define N 31\n\nint main() {\n\tstatic long long cc[N];\n\tlong long min, sum;\n\tint n, k, l, i, h;\n\n\tscanf(\"%d%d\", &n, &l);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%lld\", &cc[i]);\n\tfor (i = 1; i < N; i++)\n\t\tif (i >= n || cc[i] > cc[i - 1] * 2LL)\n\t\t\tcc[i] = cc[i - 1] * 2LL;\n\tmin = LLONG_MAX;\n\tsum = 0;\n\tk = 0;\n\tfor (h = N - 1; h >= 0; h--)\n\t\tif ((l & 1 << h) > 0) {\n\t\t\tk |= 1 << h;\n\t\t\tsum += cc[h];\n\t\t\tif (k == l && min > sum)\n\t\t\t\tmin = sum;\n\t\t} else\n\t\t\tif (min > sum + cc[h])\n\t\t\t\tmin = sum + cc[h];\n\tprintf(\"%lld\\n\", min);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "dp", "bitmasks"], "code_uid": "90cf551832ad0bae2542e52d3cecf779", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \nint c[30];\nlong long cost[32],dp[32];\nlong long min(long long a,long long b){return (a\n#include \ntypedef long long i64;\ni64 gcd(i64 a, i64 b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\nbool is_prime(i64 n) {\n\tif(n <= 1) return false;\n\telse if(n <= 3) return true;\n\telse if(n % 2 == 0 || n % 3 == 0) return false;\n\tfor(i64 i = 5; i * i <= n; i += 6) if(n % i == 0 || n % (i + 2) == 0) return false;\n\treturn true;\n}\ni64 f(i64 x, i64 y) {\n\ti64 ans = 0, d;\n\tif(x == 1) return y;\n\twhile(y != 0) {\n\t\tif(is_prime(x)) {\n\t\t\tans += x < y ? y / x + y % x : y;\n\t\t\tbreak;\n\t\t}\n\t\twhile((d = gcd(x, y)) == 1LL && y != 0) ans++, y--;\n\t\tif(y == 0) break;\n\t\tx /= d, y /= d;\n\t}\n\treturn ans;\n}\nint main(void) {\n\ti64 x, y;\n\tscanf(\"%lld%lld\", &x, &y);\n\tprintf(\"%lld\\n\", f(x, y));\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "implementation", "binary search"], "code_uid": "83610faa37660d5e0945defc02ce482d", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define D\t6720\n\nint compare(const void *a, const void *b) {\n\tlong long ia = *(long long *) a;\n\tlong long ib = *(long long *) b;\n\n\treturn ia == ib ? 0 : (ia < ib ? -1 : 1);\n}\n\nint main() {\n\tstatic long long aa[D];\n\tlong long x, y, a, tmp, cnt;\n\tint k, i;\n\n\tscanf(\"%lld%lld\\n\", &x, &y);\n\tk = 0;\n\tfor (a = 1; a * a <= x; a++)\n\t\tif (x % a == 0) {\n\t\t\taa[k++] = a;\n\t\t\tif (x / a != a)\n\t\t\t\taa[k++] = x / a;\n\t\t}\n\tsrand(time(NULL));\n\tfor (i = k - 1; i > 0; i--) {\n\t\tint i_ = rand() % (i + 1);\n\n\t\ttmp = aa[i], aa[i] = aa[i_], aa[i_] = tmp;\n\t}\n\tqsort(aa, k, sizeof *aa, compare);\n\tfor (i = k - 1; i >= 0; i--)\n\t\tif (y % aa[i] == 0)\n\t\t\tbreak;\n\tcnt = 0;\n\twhile (y > 0) {\n\t\tint j, jmin;\n\t\tlong long min;\n\n\t\tmin = 1e12 + 1;\n\t\tjmin = -1;\n\t\tfor (j = i + 1; j < k; j++)\n\t\t\tif (aa[j] % aa[i] == 0 && min > (y % aa[j]) / aa[i]) {\n\t\t\t\tmin = (y % aa[j]) / aa[i];\n\t\t\t\tjmin = j;\n\t\t\t}\n\t\tif (aa[i] == x)\n\t\t\tmin = y / x;\n\t\tcnt += min;\n\t\ty -= min * aa[i];\n\t\ti = jmin;\n\t}\n\tprintf(\"%lld\\n\", cnt);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "binary search"], "code_uid": "f9fdb897ce45da86999c1ceca9448738", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define SQR 1097\n#define MAX 1200000\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\nchar str[12];\nlong long p, q;\nunsigned int ar[(MAX >> 6) + 5] = {0};\nint m = 0, counter[MAX] = {0}, P[12010];\n\nvoid Sieve(){\n int i, j, k;\n setbit(ar, 0), setbit(ar, 1);\n\n for (i = 3; i < SQR; i++, i++){\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 k = 0, counter[2] = ++k;\n for (i = 3; (i + 1) < MAX; i++, i++){\n if (isprime(i)) k++;\n counter[i] = counter[i + 1] = k;\n }\n}\n\nvoid backtrack(int i, int j){\n if (i > j){\n int x = atoi(str);\n if (x < MAX) P[m++] = x;\n return;\n }\n\n int k;\n for (k = 0; k < 10; k++){\n if (!i && !k) continue;\n str[i] = str[j] = k + 48;\n backtrack(i + 1, j - 1);\n }\n}\n\nvoid Generate(){\n m = 0;\n int i, j;\n for (i = 1; i <= 7; i++){\n str[i] = 0;\n backtrack(0, i - 1);\n }\n}\n\nbool Check(int n, int i){\n long long x = q * counter[n];\n long long y = p * (i + 1);\n return (x <= y);\n}\n\nint main(){\n Sieve();\n Generate();\n int n, i, j, low, high, mid, res;\n\n while (scanf(\"%I64d %I64d\", &p, &q) != EOF){\n\n res = -1;\n for (i = m - 2; i >= 0; i--){\n if (Check(P[i], i)){\n low = P[i], high = P[i + 1] - 1;\n\n while ((low + 1) < high){\n mid = (low + high) >> 1;\n if (Check(mid, i)) low = mid;\n else high = mid;\n }\n\n if (Check(high, i)) res = high;\n else if (Check(low, i)) res = low;\n if (res != -1) break;\n }\n }\n\n if (res == -1) puts(\"Palindromic tree is better than splay tree\");\n else printf(\"%d\\n\", res);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "binary search", "number theory"], "code_uid": "2bfcf823529fb0ce0eb189e31e4d7f3d", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define max 2000001\nint prime[max],pal[max],digits[10];\n\nint isPalindrome(int a){\n int temp=a,i=0;\n while(temp!=0){\n digits[i++]=temp%10;\n temp/=10;\n }\n int k=i-1;\n i=0;\n while(i\n\n#define MD\t998244353\n#define N_\t(1 << 20)\t/* N_ = pow2(ceil(log2(N * 9 + 1))) */\n\nlong long ww[21], ww_[21];\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\nvoid init() {\n\tint h;\n\n\tfor (h = 0; h <= 20; h++) {\n\t\tww[h] = power(3, (MD - 1) >> h);\n\t\tww_[h] = power(3, MD - 1 - ((MD - 1) >> h));\n\t}\n}\n\nvoid ntt(int *aa, int n, int inverse) {\n\tint h, i, j, b, l, r, u, v, tmp;\n\tlong long w, w_;\n\n\tfor (i = 1, j = 0; i < n; i++) {\n\t\tb = n;\n\t\tdo\n\t\t\tj ^= b >>= 1;\n\t\twhile ((j & b) == 0);\n\t\tif (i < j)\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tfor (h = 0; (b = 1 << h) < n; h++) {\n\t\tw_ = inverse ? ww_[h + 1] : ww[h + 1];\n\t\tfor (i = 0; i < n; i += b * 2) {\n\t\t\tw = 1;\n\t\t\tfor (j = 0; j < b; j++) {\n\t\t\t\tl = i + j, r = l + b;\n\t\t\t\tu = aa[l], v = aa[r] * w % MD;\n\t\t\t\tif ((aa[l] = u + v) >= MD)\n\t\t\t\t\taa[l] -= MD;\n\t\t\t\tif ((aa[r] = u - v) < 0)\n\t\t\t\t\taa[r] += MD;\n\t\t\t\tw = w * w_ % MD;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main() {\n\tstatic int aa[N_];\n\tint n, n_, k, i;\n\tlong long v, a, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k), n /= 2;\n\tn_ = 1;\n\twhile (n_ < n * 9 + 1)\n\t\tn_ *= 2;\n\twhile (k--) {\n\t\tint d;\n\n\t\tscanf(\"%d\", &d);\n\t\taa[d] = 1;\n\t}\n\tntt(aa, n_, 0);\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = power(aa[i], n);\n\tntt(aa, n_, 1);\n\tv = power(n_, MD - 2);\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = aa[i] * v % MD;\n\tans = 0;\n\tfor (i = 0; i <= n * 9; i++) {\n\t\ta = aa[i];\n\t\tans = (ans + a * a) % MD;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["divide and conquer", "dp", "fft"], "code_uid": "4829f59a509aa326f107aeac419920f9", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n//#include \n#define LL long long\n#define uLL long long\n#define uL unsigned int\n#define iL unsigned int\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n\nLL CP=(LL)998244353;\nLL inv[0x100000];\nLL num1[0x100000],num2[0x100000];\nuL exgcd(uL a,uL c)\n{\n static uL gcd;\n uL k;\n uLL x;\n if (a==0)\n {\n gcd=c;\n return 1;\n }\n else\n {\n k=c%a;\n if (k==0)\n {\n gcd=a;\n return 1;\n }\n else\n {\n x=exgcd(a%k,k);\n }\n }\n return (x*c-c/a*gcd)/k;\n}\nvoid ini1(long n,LL P)\n{\n long i;\n inv[1]=1;\n for (i=2;i<=n;i++)\n {\n inv[i]=(uLL)inv[P%i]*(P-P/i)%P;\n }\n}\nstatic inline LL madd(LL a,LL b)\n{\n a+=b;\n a-=(a>CP)?CP:0;\n return a;\n}\nstatic inline LL msub(LL a,LL b)\n{\n a-=b;\n a+=(a<0)?CP:0;\n return a;\n}\nstatic inline LL MR(LL a,LL b)\n{\n return (a*b)%CP;\n}\nuLL mexp(uLL a,uLL b)\n{\n register uLL t;\n for (t=1;b;b=b>>1)\n {\n if (b&1) {t=MR(a,t);}\n a=MR(a,a);\n }\n return t;\n}\nstatic inline uLL PolynomialPower(uLL *pol,uLL psize,uLL ex,uLL N,uLL *ans)\n{\n uLL i,j,a,b,c,d;\n psize=(psize>N)?N:psize;\n uLL temp[psize],ans2[N+1];\n ans[1]=mexp(pol[1],ex);\n for (i=1;i0) {break;}}\n PolynomialPower(num1+i-1,10-i+1,n/2,1000001,num2);\n //print(num2,20);\n ans=0;\n for (i=1;i<=1000000;i++)\n {\n a=num2[i]*num2[i]%CP;\n ans=madd(a,ans);\n }\n printf(\"%lld\\n\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["divide and conquer", "dp", "fft"], "code_uid": "d806a8293d8f937df1d64a96d391b7c2", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "char s[110],sl;\nlong long d;\n\nint main()\n{\n\tint i;\n\twhile(~scanf(\"%s\",&s))\n\t{\n\t\tsl=strlen(s);\n\t\tfor(i=0,d=0;s[i];i++)\n\t\t{\n\t\t\td<<=1;\n\t\t\td+=s[i]=='1'?1:0;\n\t\t\td%=1000000007;\n\t\t}\n\t\twhile(--sl)\n\t\t{\n\t\t\td<<=1;\n\t\t\td%=1000000007;\n\t\t}\n\t\tprintf(\"%I64d\\n\",d);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math"], "code_uid": "18f677c3aa99c0940c0a4210ee0ff109", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.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", "combinatorics"], "code_uid": "c735a587917fa86a696ef7c70d86ee3d", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#define int long long\r\nint n,k,a,x,y,T,M=1e9+7;\r\nint power(int p,int z)\r\n{\r\n\tif(z==0) return 1%M;\r\n\tif(z==1) return p%M;\r\n\tint tt=power(p,z/2);\r\n\tif(z&1) return ((tt*tt)%M)*p%M;\r\n\telse return (tt*tt)%M;\r\n}\r\nmain()\r\n{\r\n\tscanf(\"%lld\",&T);\r\n\twhile(T--)\r\n\t{\r\n\t\tscanf(\"%lld%lld\",&n,&k);\r\n\t\tif(n&1)\r\n\t\t{\r\n\t\t\ty=(power(2,n-1)+1)%M;\r\n\t\t\ty=power(y,k);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ty=power(2,n-1);\r\n\t\t\tx=(power(2,n-1)-1+M)%M;\r\n\t\t\ta=((y*power(x,k))%M+power((2*y)%M,k)+M)%M;\r\n\t\t\ta=a*power((y+1)%M,M-2)%M;\r\n\t\t\ty=a;\r\n\t\t}\r\n\t\tprintf(\"%lld\\n\",y);\r\n\t}\r\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "7a6875d1ddfbc8d3240694ba92f87cde", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n// Program de Mircea Rebengiuc\n// inceput pe 2021.08.09\n\n#define MOD 1000000007\n#define MAXN 200000\n#define MAXK 200000\n\nint p2[MAXK + 1];\n\nstatic inline int multmod( int a, int b ){\n return (((long long)a) * b) % MOD;\n}\n\nstatic inline int addmod( int a, int b ){\n return (a + b) % MOD;\n}\n\n// chestii invmod\nstatic inline int myExp( int a, int n ){\n int acc = 1;\n\n while( n > 0 ){\n if( n & 1 )\n acc = multmod(acc, a);\n a = multmod(a, a);\n n >>= 1;\n }\n\t\n return acc;\n}\n\nstatic inline int inv( int x ){\n return myExp(x, MOD - 2);\n}\n\nint main(){\n int t, n, k, i, big_num, comb, numeq, answer;\n\n p2[0] = 1;\n for( i = 1 ; i <= MAXK ; i++ )\n p2[i] = multmod(2, p2[i - 1]);\n\n for( scanf(\"%d\", &t) ; t-- ; ){\n scanf(\"%d%d\", &n, &k);\n\n // calculam big_num = numarul de moduri de a face o pozitie sa fie egala (and = xor) modificand doar bitii de pe acea pozitie\n // cazul and = xor = 1\n big_num = (n & 1);\n\n // cazul and = xor = 0\n comb = 1;\n for( i = 0 ; i < n ; i += 2 ){\n big_num = addmod(big_num, comb);\n comb = multmod(comb, multmod(n - i, n - i - 1));\n comb = multmod(comb, multmod(inv(i + 1), inv(i + 2)));\n }\n\n // simulam\n numeq = 1;// numeq = numarul de moduri de a face primele i cifre egale modificand doar primele i cifre\n answer = 0;\n for( i = 0 ; i < k ; i++ ){\n if( (n & 1) == 0 )// cazul in care pentru bitul i and = 1, xor = 0\n answer = addmod(answer, multmod(numeq, myExp(p2[k - i - 1], n)));// adaugam numarul de posibilitati\n \n numeq = multmod(numeq, big_num);// actualizam x\n }\n answer = addmod(answer, numeq);// adaugam numarul de cazuri in care e egal ca semnul este >=\n\n printf(\"%d\\n\", answer);\n }\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "bitmasks", "matrices"], "code_uid": "e05b1017e17dad6881c26e2ad71107b2", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define lli long long int\nlli n,i,j,u,k,l,x,y,d,s,t,h[200000];\nlli gg(lli x){int u=0; while(x){u++;x/=10;} return u;}\nlli ggg(lli n)\n{\n while(n/10)n/=10;\n return n;\n}\nlli g(lli u)\n{\n lli a=1;\n while(--u)a=10*a+1;\n return a;\n}\nlli f(lli n);\nlli fff(lli n)\n{\n lli u=gg(n);\n if(u==1) return 2+(11-n);\n if(ggg(n)<6) return 10000;\n return u+1+f(g(u+1)-n);\n}\nlli ff(lli n)\n{\n lli u=gg(n);\n if(u==1)return n;\n return u+(f(n-g(u)));\n}\nlli f(lli n)\n{\n \n if(!n)return 0;\n if(n<0)n*=-1;\n lli x,y,u=gg(n),i;\n x=ff(n);\n y=fff(n);\n return (x>y ? y : x);\n}\nint main()\n{\n scanf(\"%lld\",&n);\n x=n;\n while(x){u++;x/=10;}\n printf(\"%lld\",f(n));\n return 0;\n}", "lang_cluster": "C", "tags": ["brute force", "divide and conquer", "dfs and similar"], "code_uid": "08a2e591c483359e8ae9507efe95a829", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n\ntypedef long long int int64;\n\nstatic void printInt(int64 n){\n if(n<0){putchar('-');n=-n;}\n if(n==0){putchar('0');return;}\n int s[20];int len=0;\n while(n>0){s[len++]=n%10+'0';n/=10;}\n while(len>0){putchar(s[--len]);}\n}\nstatic int64 readInt(void){\n int prev='\\0';int c=getchar();\n while(!('0'<=c && c<='9')){prev=c;c=getchar();}\n int64 res=0;\n while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}\n return prev=='-'?-res:res;\n}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n#define ABS(a) ((a)>(0)?(a):-(a))\n\nint64 func(int64 n,int64 b){\n int64 res=0;\n while(n>0){\n res+=n/b;\n n/=b;\n }\n return res;\n}\n\nvoid run(void){\n int64 n=readInt();\n int64 b=readInt();\n int64 ans=n;\n for(int64 k=2;k*k<=b;k++){\n if(b%k!=0) continue;\n int cnt=0;\n do{\n b/=k;\n cnt++;\n } while(b%k==0);\n int64 f=func(n,k)/cnt;\n ans=MIN(ans,f);\n }\n if(b>1){\n ans=MIN(ans,func(n,b));\n }\n printInt(ans);\n putchar('\\n');\n}\n\nint main(void){\n run();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "2e65e4227c3800f12856863688fd5dd6", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.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}\n", "lang_cluster": "C", "tags": ["brute force", "math", "implementation", "number theory"], "code_uid": "7a543762ceb6ccb2e500c450a6e60bec", "src_uid": "491748694c1a53771be69c212a5e0e25", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t10\n\nchar ss[16][2] = { \"B\", \"C\", \"F\", \"H\", \"I\", \"K\", \"N\", \"O\", \"P\", \"S\", \"U\", \"V\", \"W\", \"Y\" };\nchar tt[128][4] = { \"AC\", \"AG\", \"AL\", \"AM\", \"AR\", \"AS\", \"AT\", \"AU\", \"BA\", \"BE\", \"BH\", \"BI\", \"BK\", \"BR\", \"CA\", \"CD\", \"CE\", \"CF\", \"CL\", \"CM\", \"CN\", \"CO\", \"CR\", \"CS\", \"CU\", \"DB\", \"DS\", \"DY\", \"ER\", \"ES\", \"EU\", \"FE\", \"FL\", \"FM\", \"FR\", \"GD\", \"GA\", \"GE\", \"HE\", \"HF\", \"HO\", \"HS\", \"HG\", \"IN\", \"IR\", \"KR\", \"LA\", \"LV\", \"LR\", \"LI\", \"LU\", \"MC\", \"MD\", \"MG\", \"MN\", \"MO\", \"MT\", \"NA\", \"NB\", \"ND\", \"NE\", \"NH\", \"NI\", \"NO\", \"NP\", \"OG\", \"OS\", \"PA\", \"PB\", \"PD\", \"PM\", \"PO\", \"PT\", \"PU\", \"PR\", \"RA\", \"RB\", \"RE\", \"RF\", \"RG\", \"RH\", \"RN\", \"RU\", \"SB\", \"SC\", \"SE\", \"SI\", \"SG\", \"SM\", \"SN\", \"SR\", \"TA\", \"TB\", \"TC\", \"TE\", \"TH\", \"TI\", \"TL\", \"TM\", \"TS\", \"XE\", \"YB\", \"ZN\", \"ZR\" };\n\nint elemental1(char c) {\n\tint i;\n\n\tfor (i = 0; i < 16; i++)\n\t\tif (ss[i][0] == c)\n\t\t\treturn 1;\n\treturn 0;\n}\n\nint elemental2(char c1, char c2) {\n\tint i;\n\n\tfor (i = 0; i < 128; i++)\n\t\tif (tt[i][0] == c1 && tt[i][1] == c2)\n\t\t\treturn 1;\n\treturn 0;\n}\n\nint main() {\n\tstatic char cc[N + 1];\n\tstatic int dp[N + 1];\n\tint n, i;\n\n\tscanf(\"%s\", cc), n = strlen(cc);\n\tdp[0] = 1;\n\tfor (i = 0; i < n; i++)\n\t\tif (dp[i]) {\n\t\t\tif (elemental1(cc[i]))\n\t\t\t\tdp[i + 1] = 1;\n\t\t\tif (i + 1 < n && elemental2(cc[i], cc[i + 1]))\n\t\t\t\tdp[i + 2] = 1;\n\t\t}\n\tprintf(dp[n] ? \"YES\\n\" : \"NO\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "strings", "dp"], "code_uid": "0918171235536da75e8fc65a67c13ab5", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "char ss[118][9] = {\"AC\", \"AG\", \"AL\", \"AM\", \"AR\", \"AS\", \"AT\", \"AU\", \"BA\", \"BE\", \"BH\", \"BI\",\n\t\t\t\t \"BK\", \"BR\", \"B\",\t \"CA\", \"CD\", \"CE\", \"CF\", \"CL\", \"CM\", \"CN\", \"CO\", \"CR\",\n\t\t\t\t \"CS\", \"CU\", \"C\",\t \"DB\", \"DS\", \"DY\", \"ER\", \"ES\", \"EU\", \"FE\", \"FL\", \"FM\",\n\t\t\t\t \"FR\", \"F\", \"GA\", \"GD\", \"GE\", \"HE\", \"HF\", \"HG\", \"HO\", \"HS\", \"H\",\t \"IN\",\n\t\t\t\t \"IR\", \"I\", \"KR\", \"K\", \"LA\", \"LI\", \"LR\", \"LU\", \"LV\", \"MC\", \"MD\", \"MG\",\n\t\t\t\t \"MN\", \"MO\", \"MT\", \"NA\", \"NB\", \"ND\", \"NE\", \"NH\", \"NI\", \"NO\", \"NP\", \"N\",\n\t\t\t\t \"OG\", \"OS\", \"O\",\t \"PA\", \"PB\", \"PD\", \"PM\", \"PO\", \"PR\", \"PT\", \"PU\", \"P\",\n\t\t\t\t \"RA\", \"RB\", \"RE\", \"RF\", \"RG\", \"RH\", \"RN\", \"RU\", \"SB\", \"SC\", \"SE\", \"SG\",\n\t\t\t\t \"SI\", \"SM\", \"SN\", \"SR\", \"S\",\t \"TA\", \"TB\", \"TC\", \"TE\", \"TH\", \"TI\", \"TL\",\n\t\t\t\t \"TM\", \"TS\", \"U\",\t \"V\", \"W\",\t \"XE\", \"YB\", \"Y\", \"ZN\", \"ZR\"};\nchk(char *s) {\n\tint p = 0;\n\tfor (; p < 118; p++)\n\t\tif (!strcmp(ss[p], s)) return 1;\n\treturn 0;\n}\n\nchar s[123], t[3];\nf[123];\ni;\nmain(n) {\n\tscanf(\"%s\", s + 1);\n\tf[0] = 1;\n\tn = strlen(s + 1);\n\tfor (i = 1; i <= n; i++) {\n\t\tt[0] = t[1] = 0;\n\t\tt[0] = s[i];\n\t\tif (chk(t)) f[i] |= f[i - 1];\n\t\tt[0] = s[i - 1], t[1] = s[i];\n\t\tif (i > 1 && chk(t)) f[i] |= f[i - 2];\n\t}\n\tputs(f[n] ? \"YES\" : \"NO\");\n}", "lang_cluster": "C", "tags": ["brute force", "strings", "dp"], "code_uid": "62c4146291c935d8346a6110813c13c2", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t20\n#define Z\t600\n\nint main() {\n\tstatic char win[Z + 1][Z + 1];\n\tstatic int xx[N], yy[N];\n\tint x, y, n, d, i, x_, y_;\n\n\tscanf(\"%d%d%d%d\", &x, &y, &n, &d);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d%d\", &xx[i], &yy[i]);\n\tfor (x_ = 0; x_ <= Z; x_++)\n\t\tfor (y_ = 0; y_ <= Z; y_++)\n\t\t\tif ((x_ + x) * (x_ + x) + (y_ + y) * (y_ + y) > d * d)\n\t\t\t\twin[x_][y_] = 1;\n\tfor (x_ = Z; x_ >= 0; x_--)\n\t\tfor (y_ = Z; y_ >= 0; y_--)\n\t\t\tif (!win[x_][y_])\n\t\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\t\tx = x_ - xx[i];\n\t\t\t\t\ty = y_ - yy[i];\n\t\t\t\t\tif (x >= 0 && y >= 0)\n\t\t\t\t\t\twin[x][y] = 1;\n\t\t\t\t}\n\tprintf(win[0][0] ? \"Anton\\n\" : \"Dasha\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "3dc9ce0d17fa77dfe0d4e89865538024", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint main (){\n\tint a, b, d, n, i, j, t, s, k;\n\tscanf (\"%d%d%d%d\", &a, &b, &n, &d);\n\tint x[10000];\n\tint y[10000];\n\tfor (i = 0; i < n; i++) {\n\t\tscanf (\"%d%d\", x + i, y + i);\n\t}\n\tint xx = d - a;\n\tif (b < a) xx = d - b;\n\tint r[401][401][2][2];\n\tint ss;\n\tfor (ss = 2*xx; ss >= 0; ss--)\n\t\tfor (t = 0; t < 2; t++) for (s = 0; s < 2; s++) {\n\t\t\tfor (j = xx; j >= 0; j--) {\n\t\t\t\ti = ss - j;\n\t\t\t\tif (i < 0 || i > xx) continue;\n\t\t\t\tr[i][j][t][s] = 0;\n\t\t\t\tif ((i + a) * (i + a) + (j + b) * (j + b) > d * d) {\n\t\t\t\t\tr[i][j][t][s] = 1; continue;\n\t\t\t\t}\n\t\t\t\tif (t == 1 && r[j][i][s][0] == 0) {\n\t\t\t\t\tr[i][j][t][s] = 1; continue;\n\t\t\t\t}\n\t\t\t\tfor (k = 0; k < n; k++) {\n\t\t\t\t\tif (i + x[k] <= xx && j + y[k] <= xx && r[i + x[k]][j + y[k]][s][t] == 0) {\n\t\t\t\t\t\tr[i][j][t][s] = 1; break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (r[0][0][1][1]) printf(\"Anton\\n\");\n\telse printf (\"Dasha\\n\");\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "a524870533f4e682f321f9e8f14f21c4", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define MOD\t((long long) 1e9 + 7)\n\nlong long totient(long long n) {\n\tlong long p, x;\n\n\tx = n;\n\tfor (p = 2; p * p <= n; p++)\n\t\tif (n % p == 0) {\n\t\t\tx = x / p * (p - 1);\n\t\t\twhile (n % p == 0)\n\t\t\t\tn /= p;\n\t\t}\n\tif (n > 1)\n\t\tx = x / n * (n - 1);\n\treturn x;\n}\n\nint main() {\n\tlong long n, k;\n\n\tscanf(\"%lld%lld\", &n, &k);\n\tk = (k + 1) / 2;\n\twhile (n > 1 && k > 0) {\n\t\tn = totient(n);\n\t\tk--;\n\t}\n\tprintf(\"%lld\\n\", n % MOD);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "ef56ebb765ebf0663475843a17c19e15", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\n#define A 100000000\n#define B 1000\n#define PMAX 316223\n#define P 27293\n#define P3 10000\n#define L1 32000\n#define min(a,b) (((a) < (b)) ? (a) : (b))\n#define max(a,b) (((a) > (b)) ? (a) : (b))\n\nint a[A+1];\nunsigned int b[B] = {\n 0, 5761455, 11078937, 16252325, 21336326, 26355867, 31324703, 36252931, 41146179, 46009215,\n 50847534, 55662470, 60454705, 65228333, 69985473, 74726528, 79451833, 84163019, 88862422, 93547928,\n 98222287, 102886526, 107540122, 112184940, 116818447, 121443371, 126062167, 130670192, 135270258, 139864011,\n 144449537, 149028641, 153600805, 158165829, 162725196, 167279333, 171827136, 176369517, 180906194, 185436625,\n 189961812, 194481069, 198996103, 203507248, 208013454, 212514323, 217011319, 221504167, 225991743, 230475545,\n 234954223, 239429993, 243902342, 248370960, 252834065, 257294520, 261751864, 266206294, 270655552, 275101551,\n 279545368, 283984956, 288422869, 292856421, 297285198, 301711468, 306137611, 310558733, 314977166, 319391721,\n 323804352, 328215206, 332620900, 337024801, 341426904, 345826612, 350221825, 354615116, 359006517, 363395981,\n 367783654, 372168766, 376549859, 380930729, 385307831, 389682427, 394055910, 398425675, 402793457, 407159590,\n 411523195, 415885628, 420243162, 424603409, 428958595, 433311792, 437663672, 442014876, 446362736, 450708777,\n 455052511, 459394441, 463733626, 468072089, 472408200, 476741968, 481074475, 485405902, 489736021, 494062787,\n 498388617, 502712575, 507036251, 511354887, 515673696, 519991125, 524309392, 528624525, 532936342, 537247292,\n 541555851, 545864306, 550170437, 554476170, 558778993, 563082532, 567382703, 571680924, 575978253, 580275482,\n 584570200, 588863345, 593155089, 597445378, 601735269, 606022680, 610308664, 614594106, 618878615, 623159296,\n 627440336, 631717982, 635997249, 640275231, 644550922, 648825715, 653099304, 657371139, 661643304, 665911851,\n 670180516, 674447835, 678714823, 682979568, 687242934, 691504332, 695766925, 700028114, 704286233, 708543557,\n 712799821, 717055212, 721310048, 725563140, 729813991, 734065508, 738315156, 742564929, 746813071, 751060249,\n 755305935, 759550004, 763794029, 768035554, 772276773, 776516528, 780756650, 784994469, 789230673, 793467703,\n 797703398, 801937611, 806169530, 810401956, 814633249, 818864199, 823092766, 827320850, 831548431, 835773764,\n 840000027, 844224822, 848450250, 852673966, 856895823, 861116918, 865335133, 869555570, 873772692, 877989808,\n 882206716, 886422213, 890636921, 894850907, 899064419, 903275849, 907487780, 911698381, 915907322, 920117006,\n 924324489, 928532509, 932738007, 936943763, 941147666, 945351970, 949555347, 953758330, 957958052, 962158684,\n 966358351, 970556800, 974755898, 978951680, 983147464, 987343369, 991538483, 995733104, 999926054, 1004118104,\n 1008309544, 1012500258, 1016690917, 1020879037, 1025067175, 1029256469, 1033444454, 1037631294, 1041815774, 1046001482,\n 1050186367, 1054370637, 1058552429, 1062734476, 1066916147, 1071094927, 1075274949, 1079454128, 1083631538, 1087809564,\n 1091987405, 1096163370, 1100339660, 1104513787, 1108687177, 1112860305, 1117034447, 1121205592, 1125376629, 1129547281,\n 1133717820, 1137887191, 1142056097, 1146225390, 1150393648, 1154560299, 1158727002, 1162892823, 1167057747, 1171221046,\n 1175385155, 1179549444, 1183711384, 1187874380, 1192034212, 1196195238, 1200356153, 1204515304, 1208673910, 1212829795,\n 1216987937, 1221145073, 1225300872, 1229455037, 1233609164, 1237764170, 1241917157, 1246070670, 1250224878, 1254376178,\n 1258528162, 1262678524, 1266827683, 1270976954, 1275125632, 1279274172, 1283421484, 1287567873, 1291715676, 1295861693,\n 1300005926, 1304150462, 1308296664, 1312440578, 1316583470, 1320724811, 1324868019, 1329010956, 1333151863, 1337291809,\n 1341430624, 1345570079, 1349708221, 1353846756, 1357984935, 1362122305, 1366257814, 1370393786, 1374528892, 1378664634,\n 1382799415, 1386933522, 1391065576, 1395199789, 1399331489, 1403463860, 1407594647, 1411724086, 1415855689, 1419985631,\n 1424115489, 1428244053, 1432371870, 1436498522, 1440625629, 1444751745, 1448877006, 1453002152, 1457125036, 1461250000,\n 1465374659, 1469497594, 1473620220, 1477744125, 1481866173, 1485988244, 1490109683, 1494229934, 1498349689, 1502469332,\n 1506589876, 1510706235, 1514824921, 1518942965, 1523061505, 1527178351, 1531294454, 1535409890, 1539526326, 1543640517,\n 1547756812, 1551870851, 1555985016, 1560097442, 1564208549, 1568320054, 1572432177, 1576544661, 1580654270, 1584764017,\n 1588873108, 1592982840, 1597091049, 1601199712, 1605308326, 1609414491, 1613521803, 1617628777, 1621733835, 1625839726,\n 1629945987, 1634052052, 1638156927, 1642258972, 1646361787, 1650465128, 1654567808, 1658669200, 1662770302, 1666869794,\n 1670972264, 1675072419, 1679170566, 1683270249, 1687369711, 1691467151, 1695565190, 1699662748, 1703761548, 1707858902,\n 1711955433, 1716050469, 1720144848, 1724241897, 1728336282, 1732430410, 1736526180, 1740619156, 1744713632, 1748805530,\n 1752898084, 1756987393, 1761078122, 1765169921, 1769260641, 1773351175, 1777442877, 1781530474, 1785621307, 1789709560,\n 1793798703, 1797887260, 1801975182, 1806062390, 1810149996, 1814236123, 1818322676, 1822407623, 1826489988, 1830575906,\n 1834658067, 1838742792, 1842825653, 1846909270, 1850992005, 1855074218, 1859156347, 1863238351, 1867320859, 1871402335,\n 1875482847, 1879562930, 1883642470, 1887722398, 1891800587, 1895879932, 1899958276, 1904036638, 1908114573, 1912191800,\n 1916268743, 1920347116, 1924422570, 1928498011, 1932573349, 1936646486, 1940721696, 1944797174, 1948871367, 1952945594,\n 1957018338, 1961089383, 1965161808, 1969233350, 1973304195, 1977376665, 1981447779, 1985519033, 1989588548, 1993659289,\n 1997729452, 2001796366, 2005864843, 2009933793, 2014002593, 2018069377, 2022137196, 2026204289, 2030270517, 2034337796,\n 2038404475, 2042469434, 2046534053, 2050598713, 2054662457, 2058727455, 2062791593, 2066855115, 2070918071, 2074981871,\n 2079045540, 2083107257, 2087170358, 2091232421, 2095293756, 2099353852, 2103414866, 2107473358, 2111533438, 2115593696,\n 2119654578, 2123711202, 2127769041, 2131828079, 2135887473, 2139945263, 2144002868, 2148061201, 2152118222, 2156173876,\n 2160230408, 2164287399, 2168343450, 2172397905, 2176451935, 2180506650, 2184561319, 2188616526, 2192670595, 2196723874,\n 2200777436, 2204828910, 2208879508, 2212930015, 2216982800, 2221034120, 2225087204, 2229138005, 2233188780, 2237237738,\n 2241286680, 2245337711, 2249386635, 2253437044, 2257486659, 2261534669, 2265582088, 2269630722, 2273677293, 2277723942,\n 2281770277, 2285816118, 2289861391, 2293908247, 2297955870, 2301999709, 2306044120, 2310088597, 2314134053, 2318177990,\n 2322223112, 2326266900, 2330308778, 2334351201, 2338393413, 2342436031, 2346478314, 2350519355, 2354560561, 2358602447,\n 2362642765, 2366683716, 2370724495, 2374763504, 2378804084, 2382843532, 2386880413, 2390919906, 2394959109, 2398996112,\n 2403034927, 2407071577, 2411110078, 2415147307, 2419181034, 2423219093, 2427255367, 2431292536, 2435327045, 2439361501,\n 2443396396, 2447431831, 2451466331, 2455500451, 2459534282, 2463565779, 2467597919, 2471632122, 2475665529, 2479696435,\n 2483729191, 2487761399, 2491793997, 2495825196, 2499856755, 2503887935, 2507918465, 2511947717, 2515978063, 2520007177,\n 2524038155, 2528067401, 2532097043, 2536126664, 2540155255, 2544183491, 2548211228, 2552238285, 2556266399, 2560294002,\n 2564319542, 2568345835, 2572372442, 2576397670, 2580421933, 2584447929, 2588472785, 2592497820, 2596522622, 2600546330,\n 2604571471, 2608595062, 2612618628, 2616643294, 2620665663, 2624687920, 2628709369, 2632732626, 2636754699, 2640776029,\n 2644799757, 2648820585, 2652840994, 2656861044, 2660881979, 2664902170, 2668922912, 2672943760, 2676963401, 2680982125,\n 2685000601, 2689021011, 2693039441, 2697057353, 2701075683, 2705092716, 2709109210, 2713125397, 2717143223, 2721159932,\n 2725176643, 2729193507, 2733210696, 2737225536, 2741242121, 2745257057, 2749272015, 2753286718, 2757299847, 2761314795,\n 2765327756, 2769341791, 2773356225, 2777369850, 2781383306, 2785394924, 2789408169, 2793419860, 2797431717, 2801443922,\n 2805454432, 2809465484, 2813477356, 2817487436, 2821497837, 2825509231, 2829520068, 2833530738, 2837539518, 2841549369,\n 2845558213, 2849566042, 2853574755, 2857584531, 2861594266, 2865601989, 2869610768, 2873619181, 2877625961, 2881633373,\n 2885641353, 2889648502, 2893654733, 2897660376, 2901667770, 2905672946, 2909678043, 2913685600, 2917689568, 2921695146,\n 2925699539, 2929702761, 2933706263, 2937709465, 2941713524, 2945717900, 2949719949, 2953724092, 2957726064, 2961727364,\n 2965730599, 2969734593, 2973737899, 2977740005, 2981742619, 2985744869, 2989743222, 2993744024, 2997743403, 3001742385,\n 3005740846, 3009740083, 3013740632, 3017740443, 3021739912, 3025737894, 3029738266, 3033736354, 3037734260, 3041732620,\n 3045730736, 3049728863, 3053726975, 3057724728, 3061722012, 3065718156, 3069714416, 3073709903, 3077706121, 3081700773,\n 3085694966, 3089690887, 3093686041, 3097682212, 3101677762, 3105672385, 3109665704, 3113660777, 3117654258, 3121648738,\n 3125641477, 3129636165, 3133628489, 3137621629, 3141615091, 3145607391, 3149600532, 3153593186, 3157583551, 3161575400,\n 3165568071, 3169558897, 3173549966, 3177541505, 3181531857, 3185524100, 3189515502, 3193505484, 3197494480, 3201485771,\n 3205474366, 3209464223, 3213453462, 3217442657, 3221430632, 3225418712, 3229406344, 3233394790, 3237380550, 3241367601,\n 3245353518, 3249340672, 3253327262, 3257314501, 3261302137, 3265288786, 3269274318, 3273261676, 3277246756, 3281232235,\n 3285218896, 3289205184, 3293189136, 3297172860, 3301158042, 3305141278, 3309125457, 3313108871, 3317092589, 3321076365,\n 3325059246, 3329042269, 3333024320, 3337007745, 3340990584, 3344973656, 3348954479, 3352936965, 3356918381, 3360899212,\n 3364880246, 3368861514, 3372843128, 3376824341, 3380804536, 3384785252, 3388764045, 3392744352, 3396724969, 3400703302,\n 3404683449, 3408661629, 3412641191, 3416621174, 3420600239, 3424577712, 3428556536, 3432533925, 3436512942, 3440489299,\n 3444467709, 3448443650, 3452420745, 3456398055, 3460376073, 3464354329, 3468330724, 3472306712, 3476280273, 3480257644,\n 3484232867, 3488208449, 3492182057, 3496156616, 3500132047, 3504107018, 3508083271, 3512056531, 3516031243, 3520004496,\n 3523979003, 3527952545, 3531925382, 3535899657, 3539873170, 3543843428, 3547815425, 3551789160, 3555761507, 3559733867,\n 3563706203, 3567677571, 3571648151, 3575618333, 3579587822, 3583559953, 3587530335, 3591499540, 3595471441, 3599441281,\n 3603412533, 3607382383, 3611353499, 3615323157, 3619293204, 3623260438, 3627230054, 3631199924, 3635167788, 3639133977,\n 3643101671, 3647069932, 3651037811, 3655006291, 3658974043, 3662941495, 3666909363, 3670877228, 3674842642, 3678809724,\n 3682776125, 3686743894, 3690708635, 3694674136, 3698640744, 3702607660, 3706572805, 3710536268, 3714502398, 3718465031,\n 3722428991, 3726394088, 3730358421, 3734323031, 3738287024, 3742250941, 3746214561, 3750179004, 3754141753, 3758105608,\n 3762067054, 3766030492, 3769992222, 3773955567, 3777917868, 3781881979, 3785842285, 3789803781, 3793766088, 3797726848,\n 3801688660, 3805649459, 3809611918, 3813571463, 3817534298, 3821493048, 3825453351, 3829412874, 3833371480, 3837330842,\n 3841291749, 3845250279, 3849209920, 3853169493, 3857129155, 3861088365, 3865047067, 3869005617, 3872964725, 3876923182,\n 3880881273, 3884839528, 3888796569, 3892753631, 3896710330, 3900667023, 3904623253, 3908580398, 3912536328, 3916492455,\n 3920449831, 3924406577, 3928362015, 3932316075, 3936271016, 3940227600, 3944182809, 3948137829, 3952093061, 3956048108,\n 3960003559, 3963957671, 3967911833, 3971865657, 3975818018, 3979772869, 3983725586, 3987677658, 3991630533, 3995584016,\n 3999537962, 4003491500, 4007444082, 4011396563, 4015348558, 4019300356, 4023253116, 4027204376, 4031157206, 4035109071,\n 4039061553, 4043014010, 4046965198, 4050915644, 4054865513, 4058816261, 4062767391, 4066716906, 4070666662, 4074616057,\n 4078566781, 4082514143, 4086464266, 4090414411, 4094363532, 4098312828, 4102261058, 4106208569, 4110157418, 4114105592\n};\nint p[P];\nlong long y[P];\n\nint main()\n{\n\tlong long n, n2, n3, bl, bh, ans = 0, k, kl, kh;\n\tint i, j, b1=-1, b2, q2, c;\n\n\tscanf(\"%I64d\", &n);\n\n\t// p\n\tp[0] = 2; k = 1;\n\tfor (i = 3; i <= PMAX; i += 2)\n\t{\n\t\tif (a[i] == 0)\n\t\t{\n\t\t\tp[k++] = i;\n\t\t\tif (i <= PMAX/i)\n\t\t\t\tfor (j = i * i; j <= PMAX; j += i) \n\t\t\t\t\ta[j] = 1;\n\t\t};\n\t}\n\n\t// 2\n\tfor (i = 0; i < P; i++)\n\t{\n\t\tn2 = n / p[i];\n\t\tif (n2 == 0 || n2 < p[i]) break;\n\t\tb2 = (int) (n2 / A); \n\t\tq2 = n2 % A;\n\t\tif (b1 != b2)\n\t\t{\n\t\t\tmemset(a, 0, sizeof(a));\n\t\t\tb1 = b2;\n\t\t\tbl = 1ll * b1 * A;\n\t\t\tbh = bl + q2 + 1;\n\t\t\tc = (b1 == 0? 1: 0);\n\t\t\ty[0] = -1;\n\t\t\tfor (j = 1; j < P; j++)\n\t\t\t{\n\t\t\t\ty[j] = max(bl/p[j]*p[j] + p[j], 1ll * p[j] * p[j]) - bl;\n\t\t\t\tif ((y[j] & 1) == 0) y[j] += p[j];\n\t\t\t}\n\t\t\tfor (kl = bl; kl < bh; kl += L1)\n\t\t\t{\n\t\t\t\tkh = min(kl + L1, bh) - bl;\n\t\t\t\tfor (j = 1; j < P; j++)\n\t\t\t\t{\n \t\t\t\t\tfor (k = y[j]; k < kh; k += 2ll*p[j]) \n\t\t\t\t\t\ta[k] = 1;\n\t\t\t\t\ty[j] = k;\n\t\t\t\t}\n\t\t\t\tif (kl == 0)\n\t\t\t\t{\n\t\t\t\t\tk = 3;\n\t\t\t\t\ta[2] = 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tk = kl - bl + 1;\n\t\t\t\t}\n \t\t\t\tfor (; k < kh; k+=2)\n\t\t\t\t\ta[k] = a[k+1] = (a[k]==0? ++c: c);\n\t\t\t}\n\t\t} // b\n\t\tans = ans + b[b1] + a[q2] - (i + 1);\n\t}\n\n\t// 3\n\ti = 0; j = P;\n\tfor (;;)\n\t{\n\t\tk = i + (j - i) / 2;\n\t\tif (k == i)\n\t\t\tbreak;\n\t\tif (p[k] > P3)\n\t\t\tn3 = n + 1;\n\t\telse\n\t\t\tn3 = (long long) p[k] * p[k] * p[k];\n\t\tif (n3 > n)\n\t\t\tj = (int) k;\n\t\telse if (n3 < n)\n\t\t\ti = (int) k;\n\t\telse \n\t\t\tbreak;\n\t}\n\tif (p[k]*p[k]*p[k]<=n)\n\t\tans += k + 1;\n\n\tprintf(\"%I64d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "sortings", "data structures", "two pointers", "number theory"], "code_uid": "bba338bd823566a8c39ca5e385bf776a", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#define M 2000002\n#define MOD 1000000007\nlong long inv[M],fact[M],factr[M];\nint main(){\n\tint i,N;\n\tfor(i=0;i\n#include \n#include \n\n#define MAX 2000010\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long factorial[MAX];\n\nlong long expo(long long x, long long n){\n long long res = 1;\n\n while (n){\n if (n & 1) res = (res * x) % MOD;\n x = (x * x) % MOD;\n n >>= 1;\n }\n\n return (res % MOD);\n}\n\nlong long binomial(int n, int k){\n long long y = (factorial[k] * factorial[n - k]) % MOD;\n long long res = (factorial[n] * expo(y, MOD - 2)) % MOD;\n return res;\n}\n\nint main(){\n int i, n, m, k, res;\n\n factorial[0] = 1LL;\n for (i = 1; i < MAX; i++) factorial[i] = (factorial[i - 1] * i) % MOD;\n\n\n while (scanf(\"%d\", &n) != EOF){\n res = binomial((n << 1) + 2, n + 1);\n res = (res - 1 + MOD) % MOD;\n printf(\"%d\\n\", res);\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["combinatorics", "number theory"], "code_uid": "bc5c51e8130b0297eb54815eae0b57ae", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n\nbool reversed(char c, char t)\n{\n return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');\n}\n\nchar reverse(char c)\n{\n if (c == 'S')\n return 'N';\n if (c == 'W')\n return 'E';\n if (c == 'N')\n return 'S';\n if (c == 'E')\n return 'W';\n return '\\0';\n}\n\nint main()\n{\n int n;\n assert(scanf(\"%d\", &n) == 1);\n n--;\n char* s = malloc(sizeof(char) * (n + 1));\n char* t = malloc(sizeof(char) * (n + 1));\n assert(scanf(\"%s\", s));\n assert(scanf(\"%s\", t));\n if (reversed(s[n - 1], t[n - 1]))\n printf(\"NO\\n\");\n else\n {\n int i = 0;\n int j = 0;\n int ilast = 0;\n int op = 0;\n while (j < n || i < n)\n {\n op += n - i;\n for (; i < n; i++)\n {\n if (j < n && t[j] == s[i])\n j++;\n else if (j > 0 && reverse(t[j - 1]) == s[i])\n j--;\n }\n if (j == n && i == n)\n {\n printf(\"YES\\n\");\n return 0;\n }\n op += n - j;\n for (; j < n; j++)\n {\n if (i < n && t[j] == s[i])\n i++;\n else if (i > 0 && reverse(s[i - 1]) == t[j])\n i--;\n }\n if (op > 4e8)\n {\n printf(\"YES\\n\");\n return 0;\n }\n if (ilast == i)\n break;\n ilast = i;\n }\n if (j == n && i == n)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n return 0;\n}", "lang_cluster": "C", "tags": ["strings"], "code_uid": "cd62a4e9e51b9ba1d70315d3cb3f703b", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n#include \n\nbool reversed(char c, char t)\n{\n return (c == 'N' && t == 'S') || (c == 'S' && t == 'N') || (c == 'W' && t == 'E') || (c == 'E' && t == 'W');\n}\n\nchar reverse(char c)\n{\n if (c == 'S')\n return 'N';\n if (c == 'W')\n return 'E';\n if (c == 'N')\n return 'S';\n if (c == 'E')\n return 'W';\n return '\\0';\n}\n\nint main()\n{\n int n;\n assert(scanf(\"%d\", &n) == 1);\n n--;\n char* s = malloc(sizeof(char) * (n + 1));\n char* t = malloc(sizeof(char) * (n + 1));\n assert(scanf(\"%s\", s));\n assert(scanf(\"%s\", t));\n if (reversed(s[n - 1], t[n - 1]))\n printf(\"NO\\n\");\n else\n {\n int i = 0;\n int j = 0;\n int ilast = 0;\n int op = 0;\n while (j < n || i < n)\n {\n op += n - i;\n for (; i < n; i++)\n {\n if (j < n && t[j] == s[i])\n j++;\n else if (j > 0 && reverse(t[j - 1]) == s[i])\n j--;\n }\n if (j == n && i == n)\n {\n printf(\"YES\\n\");\n return 0;\n }\n op += n - j;\n for (; j < n; j++)\n {\n if (i < n && t[j] == s[i])\n i++;\n else if (i > 0 && reverse(s[i - 1]) == t[j])\n i--;\n }\n if (op > 4e8)\n {\n printf(\"YES\\n\");\n return 0;\n }\n if (ilast == i)\n break;\n ilast = i;\n }\n if (j == n && i == n)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["strings"], "code_uid": "391ad2d6c131d9f6e4e04df6c38f650e", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "\n/* AUTHOR:AKASH JAIN\n* USERNAME:akash19jain \n* DATE:31/03/2019 \n*/\n#include\n#include\n#include\n#include\n#include\nint cmp(const void * a,const void * b)\n{\n return (*(int*)a - *(int*)b);\n}\nint main()\n{\n long long t=1;\n //scanf(\"%lld\",&t);\n while(t--)\n {\n double t=clock();\n long long n;\n scanf(\"%lld\",&n);\n long long arr[n];\n for(long long i=0;i\n\nint main()\n{\n int array[1001], n, c, d, e,swap;\n scanf(\"%d\", &n);\n for (c = 0; c < n; c++)\n scanf(\"%d\", &array[c]);\n\n for (c = 0 ; c < ( n - 1 ); c++)\n {\n for (d = 0 ; d < n - c - 1; d++)\n {\n if (array[d] > array[d+1])\n {\n swap = array[d];\n array[d] = array[d+1];\n array[d+1] = swap;\n }\n }\n }\n\n for(e=0;e<100006;e++)\n printf(\"\");\n for(e=0;e<100006;e++)\n printf(\"\");\n for(e=0;e<100006;e++)\n printf(\"\");\n \n for(e=0;e<100006;e++)\n printf(\"\");\n \n for(e=0;e<100006;e++)\n printf(\"\");\n \n\n\n\n\n printf(\"%d\",array[0]);\n for ( c = 1 ; c < n ; c++ )\n printf(\" %d\", array[c]);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "474c451fd130858cb557eb74783de983", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/*\n * =====================================================================================\n *\n * Filename: main.c\n *\n * Description: \n *\n * Version: 1.0\n * Created: 19/01/17 19:54:22\n * Revision: none\n * Compiler: gcc\n *\n * Author: YOUR NAME (), \n * Company: \n *\n * =====================================================================================\n */\n\n#include \n#include \n#include \n\nint \nwidth(int64_t x) \n{\n int i = 0;\n while (x > 0) {\n i++;\n x /= 10;\n }\n return i;\n}\n\nint64_t \nconvert(char *beg, char *end) \n{\n int64_t res = 0;\n while ((uintptr_t)beg < (uintptr_t)end) {\n res = res * 10 + (*beg - '0');\n beg++;\n }\n return res;\n}\n\nint \nmin(int i, int j)\n{\n if (i < j)\n return i;\n else\n return j;\n}\n\nint\nmain()\n{\n int64_t n;\n char k[61];\n scanf(\"%\"SCNd64, &n);\n scanf(\"%s\", k);\n \n int w = width(n - 1);\n int64_t base[w+2];\n base[1] = -1; base[2] = 9;\n for (int i = 3; i <= w; ++i)\n base[i] = base[i-1] * 10 + 9;\n\n int64_t x = 0;\n int64_t basen = 1;\n for (int i = strlen(k); i > 0; --i) {\n for (int j = min(w, i); j > 0; --j) {\n //printf(\"x: %ld, part: %.*s\\n\", x, j, &k[i-j]);\n int64_t part = convert(&k[i-j], &k[i]);\n if (part < n && part > base[j]) {\n x += basen * part;\n i -= j - 1;\n break;\n }\n }\n basen *= n;\n }\n printf(\"%\"PRId64\"\\n\", x);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "e26363849e4854b54357f204378a6436", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n\nlong long foo(const char* str, int base, int len, long long mul, long long bar){\n\tif(!*str) return bar;\n\tlong long c = 0;\n\tlong long p = 1;\n\tint i = 0;\n\tdo{\n\t\tc += p * (str[i++] - '0');\n\t\tp *= 10;\n\t}while(str[i] && c + p * (str[i] - '0') < base && i < len);\n\tif(!str[i]) return bar + c * mul;\n\tif(c != 0){\n\t\tstr += i - 1;\n\t\twhile(*str == '0') --str;\n\t}\n\treturn foo(++str, base, len, mul * base, bar + c * mul);\n}\n\nlong long calc(const char* str, int base){\n\tint len = 0;\n\tdo{\n\t\tint temp = base;\n\t\twhile(temp){\n\t\t\t++len;\n\t\t\ttemp /= 10;\n\t\t}\n\t}while(0);\n\treturn foo(str, base, len, 1, 0);\n}\n\nint main(void){\n\tchar str[100], d[100];\n\tint b;\n\tscanf(\"%d %s\", &b, str);\n\tint l = strlen(str) - 1;\n\tfor(int i = 0; i <= l; ++i) d[i] = str[l - i];\n\td[l + 1] = '\\0';\n\tprintf(\"%lld\\n\", calc(d, b));\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C", "tags": ["constructive algorithms", "math", "dp", "greedy", "strings"], "code_uid": "4298df5087b08e33547ffb4adc66a211", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define m 1000000007u\n#define lim 5555555\ntypedef long long unsigned llu;\ntypedef unsigned u;\nu F[lim],G[lim];\nint main()\n{\n\tu i,j,k,r=0;\n\tfor(i=1;++i>1)%m))%m;\n\t}\n\tfor(scanf(\"%u%u%u\",&k,&i,&j);j>=i;--j)r=(G[j]+r*(llu)k)%m;\n\tprintf(\"%u\\n\",r);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "greedy", "number theory"], "code_uid": "f1d19d5dd9d62f86001d4a8b00e79fcc", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#if defined( _WIN32 )\ntypedef __int64 az_int64_t;\ntypedef unsigned __int64 az_uint64_t;\n#define I64(x) x ## I64\n#define F64 \"I64\"\n#else\ntypedef long long az_int64_t;\ntypedef unsigned long long az_uint64_t;\n#define I64(x) x ## ll\n#define F64 \"ll\"\n#endif\n\n#define MODN 1000000007\n\nint minp[5000004];\naz_int64_t f[5000004];\n\nvoid gen( int limit )\n{\n int i, j, finish = 0;\n\n for( i = 2; i <= limit; ++i)\n if( minp[i] == 0 )\n {\n minp[i] = i;\n if( !finish )\n {\n int start = i * i;\n if( start > limit )\n finish = 1;\n else for( j = start; j <= limit; j += i)\n if( minp[j] == 0 || minp[j] > i ) minp[j] = i;\n }\n }\n\n for( i = 2; i <= limit; ++i)\n f[i] = f[i/minp[i]] + (((az_int64_t) i * (minp[i]-1)) >> 1);\n}\n\nint main( void )\n{\n int t, l, r, i, res = 0;\n az_int64_t pt = 1;\n\n scanf( \"%d %d %d\", &t, &l, &r);\n gen( r );\n\n for( i = l; i <= r; ++i)\n {\n f[i] %= MODN;\n res += (int) ((pt * f[i]) % MODN);\n if( res >= MODN ) res -= MODN;\n pt *= t;\n pt %= MODN;\n }\n\n printf( \"%d\\n\", res);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "greedy", "number theory"], "code_uid": "16708ce71f01523d9c0d156f6ecd5436", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/contest/819/submission/28105538 (Dukkha) */\n#include \n#include \n\n#define AB\t24\n#define N\t(AB * 4)\n\nint count(int *cc, int l, int r) {\n\tstatic char used[AB];\n\tint i, cnt;\n\n\tmemset(used, 0, sizeof used);\n\tcnt = 0;\n\tfor (i = l; i <= r; i++)\n\t\tif (!used[cc[i]]) {\n\t\t\tused[cc[i]] = 1;\n\t\t\tcnt++;\n\t\t}\n\treturn cnt;\n}\n\nint main() {\n\tstatic int cc[N];\n\tint a, b, ab, d, l, r, m, k0, k1, k2, k3, k, h, min;\n\n\tscanf(\"%d%d%d%d\", &a, &b, &l, &r);\n\tl--, r--;\n\tab = a + b;\n\tm = 4;\n\th = l / ab;\n\tr -= h * ab;\n\tl -= h * ab;\n\th = (r - l + 1) / ab;\n\tif (h > 2)\n\t\tr -= (h - 2) * ab;\n\td = a > b ? a - b : 1;\n\tfor (h = 0; h < m; h++) {\n\t\tfor (k = 0; k < a - d; k++)\n\t\t\tcc[h * ab + k] = k;\n\t\tfor (k = 0; k < d; k++)\n\t\t\tcc[h * ab + a - d + k] = h % 2 == 0 ? a - d + k : a + k;\n\t}\n\tmin = a + a;\n\tfor (k0 = 1; k0 <= d; k0++) {\n\t\tfor (k = 0; k < b; k++)\n\t\t\tcc[ab * 0 + a + k] = cc[ab * 0 + a - k0];\n\t\tfor (k1 = 1; k1 <= d; k1++) {\n\t\t\tfor (k = 0; k < b; k++)\n\t\t\t\tcc[ab * 1 + a + k] = cc[ab * 1 + a - k1];\n\t\t\tfor (k2 = 1; k2 <= d; k2++) {\n\t\t\t\tfor (k = 0; k < b; k++)\n\t\t\t\t\tcc[ab * 2 + a + k] = cc[ab * 2 + a - k2];\n\t\t\t\tfor (k3 = 1; k3 <= d; k3++) {\n\t\t\t\t\tint cnt;\n\n\t\t\t\t\tfor (k = 0; k < b; k++)\n\t\t\t\t\t\tcc[ab * 3 + a + k] = cc[ab * 3 + a - k3];\n\t\t\t\t\tif (min > (cnt = count(cc, l, r)))\n\t\t\t\t\t\tmin = cnt;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", min);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "games"], "code_uid": "b93da7cb13490799eb5f496bc2fd2753", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \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#include \n#include \n#include \n\n#define MOD 1000000007\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long k, pa, pb, inv, dp[1010][1010];\n\nlong long expo(long long x, long long n){\n x %= MOD;\n long long res = 1;\n\n while (n){\n if (n & 1) res = (res * x) % MOD;\n x = (x * x) % MOD;\n n >>= 1;\n }\n\n return (res % MOD);\n}\n\nlong long F(int a, int c){\n if (c >= k) return c;\n if (dp[a][c] != -1) return dp[a][c];\n\n long long res = 0, loop = 0;\n\n if (a == 0){\n res = pa * F(a + 1, c) % MOD;\n loop += pb;\n res = res * expo(MOD - loop, MOD - 2) % MOD;\n }\n else if ((a + c) >= k){\n loop += pa;\n res = pb * F(a, c + a) % MOD;\n res = (res + 1) * expo(MOD - loop, MOD - 2) % MOD;\n }\n else{\n res += pa * F(a + 1, c);\n res += pb * F(a, c + a);\n res %= MOD;\n }\n\n return (dp[a][c] = res);\n}\n\nint main(){\n while (scanf(\"%lld %lld %lld\", &k, &pa, &pb) != EOF){\n memset(dp, -1, sizeof(dp));\n\n inv = expo(pa + pb, MOD - 2);\n pb = pb * inv % MOD;\n pa = pa * inv % MOD;\n printf(\"%lld\\n\", (F(0, 0) - 1 + MOD) % MOD );\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "probabilities"], "code_uid": "9e834511f9e1b2072f0dd1e91fb21edf", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\n#define MAX 1000000\n#define MOD 1000003\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long fact[MAX], inv[MAX];\n\nvoid Generate(){\n int i, x;\n fact[0] = 1, inv[MAX - 1] = 6;\n for (i = 1; i < MAX; i++) fact[i] = ((long long)i * fact[i - 1]) % MOD;\n for (i = MAX - 2; i >= 0; i--) inv[i] = ((long long)inv[i + 1] * (i + 1)) % MOD;\n}\n\nlong long binomial(long long n, long long k){\n if (k > n) return 0;\n return (fact[n] * inv[n - k] * inv[k]) % MOD;\n}\n\nint main(){\n Generate();\n long long n, m, i, j, res;\n while (scanf(\"%lld %lld\", &n, &m) != EOF){\n m--, res = 0;\n for (i = 0; i <= (n + m); i++) res += binomial(i, m);\n printf(\"%lld\\n\", (res - 1 + MOD) % MOD);\n }\n return 0;\n}\n", "lang_cluster": "C", "tags": ["combinatorics"], "code_uid": "08cf8973628b7096c9f8b4030a71bf01", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n#define MAX(X,Y) ((X)>(Y) ? (X) : (Y))\n#define MIN(X,Y) ((X)<(Y) ? (X) : (Y))\n#define INF 1000000000\n\nint n,c[20],r[20],b[20],rcnt[66000],bcnt[66000],dp[66000][2][260];\nint next(int b);\n\nint main(void)\n{\n //freopen(\"cards.in\",\"r\",stdin);\n //freopen(\"cards.out\",\"w\",stdout);\n scanf(\"%d\",&n);\n int i,j,k,r0=0,b0=0;\n for(i=1;i<=n;i++)\n {\n while(isspace(c[i]=getchar()));\n scanf(\"%d%d\",&r[i],&b[i]);\n if(r[i]>n)\n {\n r0+=r[i]-n;\n r[i]=n;\n }\n if(b[i]>n)\n {\n b0+=b[i]-n;\n b[i]=n;\n }\n }\n for(i=0;i<1<=0;k--)\n for(i=(1<tb-j)\n dp[i][0][j]=MIN(dp[i][0][j],tr+dp[i|(1<tr-j)\n dp[i][1][j]=MIN(dp[i][1][j],tb+dp[i|(1<b0)\n printf(\"%d\\n\",r0+dp[0][0][MIN(r0-b0,n*n)]);\n else printf(\"%d\\n\",b0+dp[0][1][MIN(b0-r0,n*n)]);\n return 0;\n}\n\nint next(int b)\n{\n if(!b) return 1<\n#include \n\n#define N\t16\n#define A\t120\t/* N * (N - 1) / 2 */\n\nint main() {\n\tstatic int dp[1 << N][A + 1], rr[N], bb[N];\n\tstatic char cc[N];\n\tint n, i, x, a, rsum, bsum, min;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"\\n%c%d%d\", &cc[i], &rr[i], &bb[i]);\n\tfor (x = 0; x < 1 << n; x++)\n\t\tfor (a = 0; a <= A; a++)\n\t\t\tdp[x][a] = -1;\n\tdp[0][0] = 0;\n\tfor (x = 0; x < 1 << n; x++) {\n\t\tint rcnt, bcnt;\n\n\t\trcnt = bcnt = 0;\n\t\tfor (i = 0; i < n; i++)\n\t\t\tif ((x & 1 << i) > 0) {\n\t\t\t\tif (cc[i] == 'R')\n\t\t\t\t\trcnt++;\n\t\t\t\telse\n\t\t\t\t\tbcnt++;\n\t\t\t}\n\t\tfor (a = 0; a <= A; a++)\n\t\t\tif (dp[x][a] >= 0)\n\t\t\t\tfor (i = 0; i < n; i++)\n\t\t\t\t\tif ((x & 1 << i) == 0) {\n\t\t\t\t\t\tint r_ = rr[i] < rcnt ? rr[i] : rcnt;\n\t\t\t\t\t\tint b_ = bb[i] < bcnt ? bb[i] : bcnt;\n\n\t\t\t\t\t\tif (dp[x | 1 << i][a + r_] < dp[x][a] + b_)\n\t\t\t\t\t\t\tdp[x | 1 << i][a + r_] = dp[x][a] + b_;\n\t\t\t\t\t}\n\t}\n\trsum = bsum = 0;\n\tfor (i = 0; i < n; i++) {\n\t\trsum += rr[i];\n\t\tbsum += bb[i];\n\t}\n\tmin = INT_MAX;\n\tfor (a = 0; a <= A; a++)\n\t\tif (dp[(1 << n) - 1][a] >= 0) {\n\t\t\tint max = bsum - dp[(1 << n) - 1][a];\n\n\t\t\tif (max < rsum - a)\n\t\t\t\tmax = rsum - a;\n\t\t\tif (min > max)\n\t\t\t\tmin = max;\n\t\t}\n\tprintf(\"%d\\n\", min + n);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "5abd03aa4c3febe4ce59700ce071b317", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main(){\n int n,t;\n int a[25][10]={14,0,0,0,0,0,0,0,0,0,22,0,0,0,0,0,0,0,0,0,16,70,0,0,0,0,0,0,0,0,6,232,0,0,0,0,0,0,0,0,1,380,353,0,0,0,0,0,0,0,0,396,1786,0,0,0,0,0,0,0,0,284,4500,1782,0,0,0,0,0,0,0,142,7414,12122,0,0,0,0,0,0,0,48,8849,41160,8997,0,0,0,0,0,0,10,8028,92226,76878,0,0,0,0,0,0,1,5658,152140,328222,45425,0,0,0,0,0,0,3112,195420,928494,467292,0,0,0,0,0,0,1322,201744,1947581,2402980,229347,0,0,0,0,0,422,170444,3213988,8205152,2758896,0,0,0,0,0,96,118912,4322956,20852648,16594160,1157954,0,0,0,0,14,68640,4846524,41920210,66357900,15946870,0,0,0,0,1,32632,4594423,69183464,197939352,109824208,5846414,0,0,0,0,12628,3715462,96046590,468541040,503245466,90700276,0};\n scanf(\"%d%d\",&n,&t);\n printf(\"%d\",a[n-3][t-1]);\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "b77c0d0aff52638fd8f575a671f598a9", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t20\n#define T\t10\n\nint main() {\n\tstatic long long dp[N][T + 1][T][4][4];\n\tint n, t, i, h, d, y0, y1, y2;\n\tlong long x, ans;\n\n\tscanf(\"%d%d\", &n, &t);\n\tfor (y0 = 0; y0 < 4; y0++)\n\t\tfor (y1 = 0; y1 < 4; y1++)\n\t\t\tif (y0 != y1)\n\t\t\t\tdp[1][0][0][y0][y1] = 1;\n\tfor (i = 1; i < n - 1; i++)\n\t\tfor (h = 0; h <= t; h++)\n\t\t\tfor (d = 0; d < t; d++)\n\t\t\t\tfor (y0 = 0; y0 < 4; y0++)\n\t\t\t\t\tfor (y1 = 0; y1 < 4; y1++) {\n\t\t\t\t\t\tx = dp[i][h][d][y0][y1];\n\t\t\t\t\t\tif (x == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tfor (y2 = 0; y2 < 4; y2++) {\n\t\t\t\t\t\t\tif (y2 == y1)\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tif (y0 < y1 && y1 < y2 || y0 > y1 && y1 > y2) {\n\t\t\t\t\t\t\t\tdp[i + 1][h][d][y1][y2] += x;\n\t\t\t\t\t\t\t} else if (y0 < y1 && y1 > y2) {\n\t\t\t\t\t\t\t\tif (h + 1 <= t)\n\t\t\t\t\t\t\t\t\tdp[i + 1][h + 1][d][y1][y2] += x;\n\t\t\t\t\t\t\t} else if (y0 > y1 && y1 < y2) {\n\t\t\t\t\t\t\t\tif (d + 1 < t)\n\t\t\t\t\t\t\t\t\tdp[i + 1][h][d + 1][y1][y2] += x;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\tans = 0;\n\tfor (y0 = 0; y0 < 4; y0++)\n\t\tfor (y1 = 0; y1 < 4; y1++)\n\t\t\tans += dp[n - 1][t][t - 1][y0][y1];\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "6eecd9c963b2f52def078cb640694492", "src_uid": "6d67559744583229455c5eafe68f7952", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define max2(a,b) (a T)\n return 0;\n if (t == T) {\n u64 r = 0;\n for (int g = 0; g < 3; g++)\n r = add2(r, perm[n[0]][n[1]][n[2]][g]);\n r = mul2(r, fact3(n[0],n[1],n[2]));\n // printf(\"%d [%d,%d,%d]: %d -> %d\\n\", t, n[0], n[1], n[2], G[c], r);\n return r;\n }\n\n u64 result = 0;\n for (int i = c + 1; i < N; i++) {\n n[G[i]]++;\n result = add2(result, walk(t + L[i], i));\n n[G[i]]--;\n }\n\n return result;\n}\n\nint main() {\n int i, j, k, n;\n\n scanf(\"%d %d\", &N, &T);\n for (i = 0; i < N; i++) {\n scanf(\"%d %d\", &L[i], &G[i]);\n G[i]--;\n }\n\n perm[1][0][0][0] = perm[0][1][0][1] = perm[0][0][1][2] = 1;\n\n for (n = 2; n <= N; n++)\n for (i = 0; i <= n/2+1; i++)\n for (j = 0; j <= n - i; j++) {\n k = n - i - j;\n if (k > n/2+1) continue;\n\n if (i) perm[i][j][k][0] = add2(perm[i-1][j][k][1], perm[i-1][j][k][2]);\n if (j) perm[i][j][k][1] = add2(perm[i][j-1][k][2], perm[i][j-1][k][0]);\n if (k) perm[i][j][k][2] = add2(perm[i][j][k-1][0], perm[i][j][k-1][1]);\n }\n\n printf(\"%llu\\n\", walk(0, -1));\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "9544a78eb994101ca27565c3751877d7", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://csacademy.com/submission/2215090/ */\n#include \n\n#define N\t50\n#define M\t(1 << 13) /* 2500 < M / 2 */\n#define LN\t13\n#define MD\t1000000007\n#define M0\t469762049\n#define M1\t595591169\n#define M2\t645922817\n\nint MM[] = { M0, M1, M2 };\n\nint V01, V02, V12;\n\nlong long power(int a, int b, int md) {\n\tlong long p;\n\n\tif (b == 0)\n\t\treturn 1;\n\tp = power(a, b / 2, md);\n\tp = p * p % md;\n\tif (b % 2)\n\t\tp = p * a % md;\n\treturn p;\n}\n\nlong long ww[3][LN + 1], ww_[3][LN + 1], vv[3];\nint kk[N + 1][N + 1][N + 1], ll[N + 1][N + 1][N + 1][3];\n\nvoid init() {\n\tint d, h, i, j, k;\n\n\tfor (d = 0; d < 3; d++) {\n\t\tint md = MM[d];\n\n\t\tfor (h = 0; h <= LN; h++) {\n\t\t\tww[d][h] = power(3, (md - 1) >> h, md);\n\t\t\tww_[d][h] = power(3, md - 1 - ((md - 1) >> h), md);\n\t\t}\n\t\tvv[d] = power(M, md - 2, md);\n\t}\n\tV01 = power(M0, M1 - 2, M1);\n\tV02 = power(M0, M2 - 2, M2);\n\tV12 = power(M1, M2 - 2, M2);\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\tlong long k0, k1, k2;\n\n\t\t\t\tk0 = i > 0 ? (long long) ll[i - 1][j][k][0] * i % MD : 0;\n\t\t\t\tk1 = j > 0 ? (long long) ll[i][j - 1][k][1] * j % MD : 0;\n\t\t\t\tk2 = k > 0 ? (long long) ll[i][j][k - 1][2] * k % MD : 0;\n\t\t\t\tif (i == 0 && j == 0 && k == 0) {\n\t\t\t\t\tkk[i][j][k] = 1;\n\t\t\t\t\tll[i][j][k][0] = ll[i][j][k][1] = ll[i][j][k][2] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tkk[i][j][k] = (k0 + k1 + k2) % MD;\n\t\t\t\t\tll[i][j][k][0] = (k1 + k2) % MD;\n\t\t\t\t\tll[i][j][k][1] = (k0 + k2) % MD;\n\t\t\t\t\tll[i][j][k][2] = (k0 + k1) % MD;\n\t\t\t\t}\n\t\t\t}\n}\n\nvoid ntt(int *aa, int d, int inverse) {\n\tint md = MM[d], h, i, j, b, l, r, u, v, tmp;\n\tlong long w, w_;\n\n\tfor (i = 1, j = 0; i < M; i++) {\n\t\tb = M;\n\t\tdo\n\t\t\tj ^= b >>= 1;\n\t\twhile ((j & b) == 0);\n\t\tif (i < j)\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tfor (h = 0; (b = 1 << h) < M; h++) {\n\t\tw_ = inverse ? ww_[d][h + 1] : ww[d][h + 1];\n\t\tfor (i = 0; i < M; i += b * 2) {\n\t\t\tw = 1;\n\t\t\tfor (j = 0; j < b; j++) {\n\t\t\t\tl = i + j, r = l + b;\n\t\t\t\tu = aa[l], v = aa[r] * w % md;\n\t\t\t\tif ((aa[l] = u + v) >= md)\n\t\t\t\t\taa[l] -= md;\n\t\t\t\tif ((aa[r] = u - v) < 0)\n\t\t\t\t\taa[r] += md;\n\t\t\t\tw = w * w_ % md;\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid fft(int *aa, int *bb, int d) {\n\tint md = MM[d], i;\n\tlong long v;\n\n\tntt(aa, d, 0), ntt(bb, d, 0);\n\tfor (i = 0; i < M; i++)\n\t\taa[i] = (long long) aa[i] * bb[i] % md;\n\tntt(aa, d, 1);\n\tv = vv[d];\n\tfor (i = 0; i < M; i++)\n\t\taa[i] = aa[i] * v % md;\n}\n\nint garner(int r0, int r1, int r2) {\n\tif (r0 < 0)\n\t\tr0 += M0;\n\tr1 = (long long) (r1 - r0) * V01 % M1;\n\tif (r1 < 0)\n\t\tr1 += M1;\n\tr2 = ((long long) (r2 - r0) * V02 - r1) % M2 * V12 % M2;\n\tif (r2 < 0)\n\t\tr2 += M2;\n\treturn (((long long) r2 * M1 + r1) % MD * M0 + r0) % MD;\n}\n\nvoid mult(int *aa, int *bb, int *cc) {\n\tstatic int cc_[3][M], bb_[M];\n\tint d, i;\n\n\tfor (d = 0; d < 3; d++) {\n\t\tfor (i = 0; i < M; i++) {\n\t\t\tcc_[d][i] = aa[i];\n\t\t\tbb_[i] = bb[i];\n\t\t}\n\t\tfft(cc_[d], bb_, d);\n\t}\n\tfor (i = 0; i < M; i++)\n\t\tcc[i] = garner(cc_[0][i], cc_[1][i], cc_[2][i]);\n}\n\nvoid knapsack(int *aa, int n, int m, int dp[][M]) {\n\tint h, i, j, a;\n\n\tdp[0][0] = 1;\n\tfor (h = 0; h < n; h++) {\n\t\ta = aa[h];\n\t\tfor (i = n; i >= 1; i--)\n\t\t\tfor (j = m; j >= a; j--)\n\t\t\t\tdp[i][j] = (dp[i][j] + dp[i - 1][j - a]) % MD;\n\t}\n}\n\nint main() {\n\tstatic int aa[3][N], cc[M], nn[3], dp[3][N + 1][M];\n\tint n, m, x, h, i0, i1, i2, j, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &m);\n\twhile (n--) {\n\t\tscanf(\"%d%d\", &x, &h), h--;\n\t\taa[h][nn[h]++] = x;\n\t}\n\tfor (h = 0; h < 3; h++)\n\t\tknapsack(aa[h], nn[h], m, dp[h]);\n\tans = 0;\n\tfor (i0 = 0; i0 <= nn[0]; i0++)\n\t\tfor (i1 = 0; i1 <= nn[1]; i1++) {\n\t\t\tmult(dp[0][i0], dp[1][i1], cc);\n\t\t\tfor (i2 = 0; i2 <= nn[2]; i2++)\n\t\t\t\tfor (j = 0; j <= m; j++)\n\t\t\t\t\tans = (ans + (long long) cc[j] * dp[2][i2][m - j] % MD * kk[i0][i1][i2]) % MD;\n\t\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics", "bitmasks"], "code_uid": "d42715bc05d44b505a966481077a1769", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nint md;\n\nlong long power(int a, long long k) {\n\tlong long p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k / 2);\n\tp = p * p % md;\n\tif (k % 2)\n\t\tp = p * a % md;\n\treturn p;\n}\n\nvoid mult(int aa[][2], int bb[][2], int cc[][2]) {\n\tint i, j, k;\n\n\tfor (i = 0; i < 2; i++)\n\t\tfor (j = 0; j < 2; j++) {\n\t\t\tlong long c = 0;\n\n\t\t\tfor (k = 0; k < 2; k++)\n\t\t\t\tc += (long long) aa[i][k] * bb[k][j];\n\t\t\tcc[i][j] = c % md;\n\t\t}\n}\n\nvoid power_(int aa[][2], int pp[][2], int tt[][2], long long k) {\n\tif (k == 0) {\n\t\tpp[0][0] = pp[1][1] = 1;\n\t\tpp[0][1] = pp[1][0] = 0;\n\t\treturn;\n\t}\n\tif (k % 2 == 0) {\n\t\tpower_(aa, tt, pp, k / 2);\n\t\tmult(tt, tt, pp);\n\t} else {\n\t\tpower_(aa, pp, tt, k / 2);\n\t\tmult(pp, pp, tt);\n\t\tmult(tt, aa, pp);\n\t}\n}\n\nint main() {\n\tstatic int aa[2][2], pp[2][2], tt[2][2];\n\tlong long n, k, x0, x1, ans;\n\tint l, h;\n\n\tscanf(\"%lld%lld%d%d\", &n, &k, &l, &md);\n\tif (l < 63 && k >= 1LL << l) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\taa[0][0] = 1, aa[0][1] = 1;\n\taa[1][0] = 1, aa[1][1] = 0;\n\tpower_(aa, pp, tt, n);\n\tx0 = (pp[0][0] + pp[0][1]) % md;\n\tx1 = (power(2, n) - x0 + md) % md;\n\tans = 1 % md;\n\tfor (h = 0; h < l; h++)\n\t\tans = ans * ((k & 1LL << h) == 0 ? x0 : x1) % md;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics", "matrices", "implementation", "number theory"], "code_uid": "5d939987820789934f35aca8239cb2cb", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* https://codeforces.com/blog/entry/451 */\n#include \n\n#define N\t150\n#define M\t50\n#define MD\t51123987\n\nint main() {\n\tstatic char cc[N + 1];\n\tstatic int next[N][3], dp[N + 1][M + 1][M + 1][M + 1];\n\tint n, m, i, a, ka, kb, kc, ans;\n\n\tscanf(\"%d%s\", &n, cc), m = (n + 2) / 3;\n\tif (n < 3) {\n\t\tprintf(n == 1 || cc[0] != cc[1] ? \"1\\n\" : \"0\\n\");\n\t\treturn 0;\n\t}\n\tfor (i = n - 1; i >= 0; i--)\n\t\tfor (a = 0; a < 3; a++)\n\t\t\tnext[i][a] = cc[i] == a + 'a' ? i : (i + 1 == n ? n : next[i + 1][a]);\n\tdp[0][0][0][0] = 1;\n\tfor (i = 0; i < n; i++)\n\t\tfor (ka = 0; ka <= m; ka++)\n\t\t\tfor (kb = 0; kb <= m; kb++)\n\t\t\t\tfor (kc = 0; kc <= m; kc++) {\n\t\t\t\t\tint x = dp[i][ka][kb][kc], j;\n\n\t\t\t\t\tif (x == 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (ka < m && (j = next[i][0]) < n)\n\t\t\t\t\t\tdp[j][ka + 1][kb][kc] = (dp[j][ka + 1][kb][kc] + x) % MD;\n\t\t\t\t\tif (kb < m && (j = next[i][1]) < n)\n\t\t\t\t\t\tdp[j][ka][kb + 1][kc] = (dp[j][ka][kb + 1][kc] + x) % MD;\n\t\t\t\t\tif (kc < m && (j = next[i][2]) < n)\n\t\t\t\t\t\tdp[j][ka][kb][kc + 1] = (dp[j][ka][kb][kc + 1] + x) % MD;\n\t\t\t\t}\n\tans = 0;\n\tif (n % 3 == 0) {\n\t\tka = m, kb = m, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t} else if (n % 3 == 1) {\n\t\tka = m - 1, kb = m - 1, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m, kb = m - 1, kc = m - 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m - 1, kb = m, kc = m - 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t} else {\n\t\tka = m - 1, kb = m, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m, kb = m - 1, kc = m;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t\tka = m, kb = m, kc = m - 1;\n\t\tfor (i = 0; i <= n; i++)\n\t\t\tans = (ans + dp[i][ka][kb][kc]) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "4ec31dc5dbd1a789effe42ce08c2ae3a", "src_uid": "64fada10630906e052ff05f2afbf337e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#define rep(i,l,r) for(register int i=l;i<=r;++i)\nconst int MOD=51123987;\nint dp[153][53][53][53];\nint next[160][3],n,ans;\nchar s[160];\ninline int abs(int x){return x>0?x:-x;}\ninline int pd(int a,int b){return abs(a-b)<2?1:0;}\nint main(){\n scanf(\"%d\",&n);\n scanf(\"%s\",s+1);\n rep(i,0,2) next[n+1][i]=n+1;\n for(register int i=n;i;--i){rep(j,0,2) next[i][j]=next[i+1][j];next[i][s[i]-'a']=i;}\n dp[1][0][0][0]=1;\n //int 50=(n+2)/3;\n rep(i,1,n) rep(j,0,50) rep(k,0,50) rep(l,0,50){\n if(j+k+l==n&&pd(j,k)&&pd(j,l)&&pd(k,l)){ans=(ans+dp[i][j][k][l])%MOD;continue;}\n if(next[i][0]<=n) dp[next[i][0]][j+1][k][l]=(dp[next[i][0]][j+1][k][l]+dp[i][j][k][l])%MOD;\n if(next[i][1]<=n) dp[next[i][1]][j][k+1][l]=(dp[next[i][1]][j][k+1][l]+dp[i][j][k][l])%MOD;\n if(next[i][2]<=n) dp[next[i][2]][j][k][l+1]=(dp[next[i][2]][j][k][l+1]+dp[i][j][k][l])%MOD;\n }\n printf(\"%d\",ans);\n return 0;\n}", "lang_cluster": "C", "tags": ["dp"], "code_uid": "3be2476dd3315c9656298028a08984e3", "src_uid": "64fada10630906e052ff05f2afbf337e", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nint main()\n{\n long long int n,i,k=0,x,d,r,p;\n scanf(\"%lld %lld\",&n,&p);\n i=1;\n while(k==0)\n { \n d=0;\n \n \n x=n-i*p;\n if(x<=0)\n {printf(\"-1\");\n break;\n }\n else\n {\n while(x!=0)\n {\n r=x%2;\n if(r==1)\n {d++;}\n if(d>i)\n {\n break;\n }\n x=x/2;\n }\n x=n-i*p;\n if(d<=i&&i<=x)\n {\n printf(\"%lld\",i);\n break;\n }\n }\n i++;\n }\n return 0;\n}\n \n \n \n \n \n \n \n ", "lang_cluster": "C", "tags": ["brute force", "math", "bitmasks"], "code_uid": "ea483e5f8e9196e38a5a7e0e200ffd03", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.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": "aadba7cf7982ba619c90bc3df1a87f39", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define N\t23\n#define A\t4194304\n\nint bcnt(int b) {\n\treturn b == 0 ? 0 : 1 + bcnt(b & (b - 1));\n}\n\nint main() {\n\tstatic int aa[N];\n\tstatic char ii[A + 1], dp[(1 << N) - 1];\n\tint n, i, i_, a, b, b_, j, min, good;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tfor (i = 0; i < n; i++)\n\t\tif (aa[i] % aa[0] != 0) {\n\t\t\tprintf(\"-1\\n\");\n\t\t\treturn 0;\n\t\t}\n\tfor (i = 1; i < n; i++)\n\t\taa[i] /= aa[0];\n\taa[0] = 1;\n\tfor (a = 0; a <= A; a++)\n\t\tii[a] = -1;\n\tfor (i = 0; i < n; i++) {\n\t\tif (aa[i] > A) {\n\t\t\tprintf(\"-1\\n\");\n\t\t\treturn 0;\n\t\t}\n\t\tii[aa[i]] = i;\n\t}\n\tmin = n + 1;\n\tdp[1] = 1;\n\tfor (b = 1, j = 0; b < 1 << n; b++) {\n\t\tif (1 << (j + 1) == b)\n\t\t\tj++;\n\t\tif (dp[b]) {\n\t\t\tif (j == n - 1) {\n\t\t\t\tif (min > bcnt(b))\n\t\t\t\t\tmin = bcnt(b);\n\t\t\t} else {\n\t\t\t\tgood = 0;\n\t\t\t\tfor (i = 0; i <= j; i++)\n\t\t\t\t\tif (aa[i] <= aa[j + 1] && (i_ = ii[aa[j + 1] - aa[i]]) != -1\n\t\t\t\t\t\t\t&& (b & 1 << i) > 0 && (b & 1 << i_) > 0) {\n\t\t\t\t\t\tgood = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tif (good) {\n\t\t\t\t\tb_ = (b | 1 << (j + 1));\n\t\t\t\t\tdp[b_] = 1;\n\t\t\t\t\tfor (i = 0; i <= j; i++)\n\t\t\t\t\t\tif ((b & 1 << i) > 0)\n\t\t\t\t\t\t\tdp[b_ ^ 1 << i] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", min == n + 1 ? -1 : min);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "bitmasks"], "code_uid": "5bcf30d19392d925127cc8073016d7d0", "src_uid": "359f5d1264ce16c5c5293fd59db95628", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nchar dp[23][1 << 23];\n\nint main()\n{\n int n, ans = 1e9, i, j, k;\n int a[23];\n int b[23][23] = {0};\n \n scanf(\"%d\", &n);\n \n for (i = 0; i < n; i++) scanf(\"%d\", &a[i]);\n \n for (i = 1; i < n; i++) {\n int f = 0;\n \n for (j = 0; j < i; j++) {\n for (k = j; k < i; k++) {\n if (a[j] + a[k] == a[i]) {\n b[i][j] = 1 << k;\n \n f = 1;\n }\n }\n }\n \n if (f == 0) {\n puts(\"-1\");\n \n return 0;\n }\n }\n \n dp[0][1] = 1;\n \n for (i = 1; i < n; i++) {\n for (j = 0; j < (1 << i); j++) {\n int f = 0;\n \n if (dp[i - 1][j] == 0) continue;\n \n for (k = 0; k < i; k++) {\n if ((j >> k) & 1) {\n if (j & b[i][k]) {\n f = 1;\n \n break;\n }\n }\n }\n \n if (f == 1) {\n for (k = 0; k < i; k++) {\n if ((j >> k) & 1) dp[i][j ^ (1 << k) ^ (1 << i)] = 1;\n }\n \n dp[i][j ^ (1 << i)] = 1;\n }\n }\n }\n \n for (i = 0; i < (1 << n); i++) {\n if (dp[n - 1][i] == 1) {\n int c = 0;\n \n for (j = 0; j < n; j++) {\n if ((i >> j) & 1) c++;\n }\n \n if (c < ans) ans = c;\n }\n }\n \n printf(\"%d\\n\", ans);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "bitmasks"], "code_uid": "55f119c67b75af56db3fdc6218dd934e", "src_uid": "359f5d1264ce16c5c5293fd59db95628", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t1000000\n#define MD\t1000000007\n\nint d_, x_, y_;\n\nvoid gcd(int a, int b) {\n\tif (b == 0)\n\t\td_ = a, x_ = 1, y_ = 0;\n\telse {\n\t\tint t;\n\n\t\tgcd(b, a % b);\n\t\tt = x_ - a / b * y_, x_ = y_, y_ = t;\n\t}\n}\n\nint inv(int a) {\n\tgcd(a, MD);\n\treturn x_;\n}\n\nint main() {\n\tstatic int dp[N];\n\tint n, k, h;\n\tlong long x, ans, f;\n\n\tscanf(\"%d%d\", &n, &k);\n\tif (k > n - 1)\n\t\tk = n - 1;\n\tf = 1;\n\tfor (h = 0; h <= k; h++) {\n\t\tdp[h] = 1;\n\t\tf = f * (h + 1) % MD;\n\t}\n\tx = k, ans = k + 1;\n\tfor (h = k + 1; h < n; h++) {\n\t\tdp[h] = x * inv(h) % MD;\n\t\tx = (x + dp[h] - dp[h - k]) % MD;\n\t\tans = (ans + dp[h]) % MD;\n\t\tf = f * (h + 1) % MD;\n\t}\n\tans = (n - ans) % MD;\n\tfor (h = 1; h < n; h++)\n\t\tans = ans * h % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp"], "code_uid": "ef0111087abd540fa9a9612adc45c076", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\nint main()\n{\n int a,b,c,k;\n long long int l1=1,l2=1,l3=1,t;\n //int64_t t;\n scanf(\"%d %d %d %d\",&a,&b,&c,&k);\n while(1)\n {\n if(a==1&&c==1&&b==1||k==0)\n break;\n if(a>1)\n {\n a=a-1;\n k=k-1;\n l1++;\n if(k==0)\n break;\n //printf(\"%d--a\\n\",a);\n }\n if(b>1)\n {\n\n b=b-1;\n k=k-1;\n l2++;\n if(k==0)\n break;\n //printf(\"%d--b\\n\",b);\n }\n if(c>1)\n {\n c-=1;\n k-=1;\n l3++;\n if(k==0)\n break;\n //printf(\"%d--c\\n\",c);\n }\n\n }\n t=l1*l2*l3;\n printf(\"%\"PRId64\"\",t);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "54870ceba4d41ef5877fb972add5f225", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nint main(void)\n{\n long long x, y, z, k;\n\n scanf(\"%I64d%I64d%I64d%I64d\", &x, &y, &z, &k);\n\n long long a = 1, b = 1, c = 1;\n int i = 0;\n while(i < k)\n {\n if(i < k && x > 1)\n {\n x--;\n a++;\n i++;\n }\n if(i < k && y > 1)\n {\n y--;\n b++;\n i++;\n }\n if(i < k && z > 1)\n {\n z--;\n c++;\n i++;\n }\n if(x == 1 && y == 1 && z == 1)\n i = k;\n }\n\n printf(\"%I64d\", a * b * c);\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy"], "code_uid": "34b96456d47ef4e6ed304ee27cd32ee2", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n#include \n\ntypedef int iii[3];\n\nint main() {\n\tint i, j, n, m, cnt;\n\tstatic iii *ee;\n\tstatic int *aa;\n\tstatic char *s;\n\n\tscanf(\"%d%d\", &n, &m);\n\tee = calloc(n + 1, sizeof(*ee));\n\taa = malloc(sizeof(*aa) * 4 * n);\n\ts = malloc((n + 2) * sizeof(*s));\n\tmemset(s + 1, '0', n);\n\ts[n + 1] = '\\0';\n\twhile (m-- > 0) {\n\t\tint u, v;\n\n\t\tscanf(\"%d%d\", &u, &v);\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (ee[u][j] == 0) {\n\t\t\t\tee[u][j] = v;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (ee[v][j] == 0) {\n\t\t\t\tee[v][j] = u;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tfor (i = 0; i < n; i++)\n\t\taa[i] = i + 1;\n\tcnt = n;\n\twhile (cnt > 0) {\n\t\tint a, k;\n\n\t\ta = aa[--cnt];\n\t\tk = 0;\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (ee[a][j] > 0 && s[a] == s[ee[a][j]])\n\t\t\t\tk++;\n\t\tif (k > 1) {\n\t\t\ts[a] = s[a] == '1' ? '0' : '1';\n\t\t\tfor (j = 0; j < 3; j++)\n\t\t\t\tif (ee[a][j] > 0)\n\t\t\t\t\taa[cnt++] = ee[a][j];\n\t\t}\n\t}\n\tprintf(\"%s\\n\", s + 1);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "combinatorics", "graphs"], "code_uid": "82d273a699dc472c51121490409ae029", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n\ntypedef long long ll;\n\n#define max(a,b) (((a)>(b))?(a):(b))\n#define min(a,b) (((a)<(b))?(a):(b))\n#define abs(k) (((k)>0)?(k):(-(k)))\n#define sqr(k) ((k)*(k))\n#define mod(a,b) (((a)%(b)+(b))%(b))\n#define mode(a,b) a=mod(a,b)\n#define mset(a) memset(a,0,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n#define inf (1e9)\n#define linf (1e18)\n#define pi 3.14159265358979323846\n\nvoid fileio_in_out()\n{\n freopen(\".in\",\"r\",stdin);\n freopen(\".out\",\"w\",stdout);\n}\n\nvoid fileio_txt()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n}\n\n//==================================================\n\n#define N 333333\n\nint n,m,x,y,head,tail,count;\nint i,j,k,l;\nint a[N][5],cnt[N],ans[N],q[N*33];\n\nvoid move(int k)\n{\n ans[k]=1-ans[k];\n}\n\nint main()\n{\n //fileio_in_out();\n //fileio_txt();\n \n mset(cnt);\n mset(ans);\n \n scanf(\"%d%d\",&n,&m);\n for(i=1;i<=m;i++)\n {\n scanf(\"%d%d\",&x,&y);\n a[x][++cnt[x]]=y;\n a[y][++cnt[y]]=x;\n }\n \n for(i=1;i<=n;i++)\n q[i]=i;\n head=1;\n tail=n;\n \n while(head<=tail)\n {\n k=q[head];\n count=0;\n for(i=1;i<=cnt[k];i++)\n if(ans[k]==ans[a[k][i]])\n count++;\n if(count>=2)\n {\n move(k);\n for(i=1;i<=cnt[k];i++)\n q[++tail]=a[k][i];\n }\n head++;\n }\n \n for(i=1;i<=n;i++)\n printf(\"%d\",ans[i]);\n printf(\"\\n\");\n \n //system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "combinatorics", "graphs"], "code_uid": "6600c25bb4446fd78cef444d858b2b49", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n\n#define MOD 998244353\nint fact[1000006], wpar[1000006<<1], n, level;\n\nint mul(int a, int b){\n return (a*1ll*b)%MOD;\n}\n\nint powmod(int b, int p){\n int t = 1;\n while(p){\n if(p&1)t = mul(t, b);\n b = mul(b, b);\n p>>=1;\n }\n return t;\n}\n\nint ncr(int _n, int r){\n return mul(mul(fact[_n], powmod(fact[r], MOD - 2)), powmod(fact[_n - r], MOD - 2));\n}\n\nvoid dfs(int x, int bits){\n if(bits > level) return;\n int l, r;\n l = x<<1;\n r = l|1;\n if(x&1){\n // x is a right child\n wpar[l] = 1;\n wpar[r] = 1^wpar[x]^wpar[l];\n } else {\n // x is a left child\n wpar[r] = 0;\n wpar[l] = 1^wpar[x]^wpar[r];\n }\n dfs(l, bits + 1);\n dfs(r, bits + 1);\n}\n\nint getpossib(int lparity){\n int i, rem;\n wpar[2] = lparity;\n wpar[3] = 1^wpar[1]^wpar[2];\n dfs(2, 2);dfs(3, 2);\n\n rem = n - (1<\n#include \n#include \ntypedef long long ll;\nll MIN = 1111111111111111111;\nll MAX = -1111111111111111111;\nll max = -1111111111111111111;\n\n\n\nvoid merge(ll arr[], ll l, ll m, ll r) \n{ \n\tll i, j, k; \n\tll n1 = m - l + 1; \n\tll n2 = r - m; \n\n\t/* create temp arrays */\n\tll L[n1], R[n2]; \n\n\t/* Copy data to temp arrays L[] and R[] */\n\tfor (i = 0; i < n1; i++) \n\t\tL[i] = arr[l + i]; \n\tfor (j = 0; j < n2; j++) \n\t\tR[j] = arr[m + 1+ j]; \n\n\t/* Merge the temp arrays back llo arr[l..r]*/\n\ti = 0; // Initial index of first subarray \n\tj = 0; // Initial index of second subarray \n\tk = l; // Initial index of merged subarray \n\twhile (i < n1 && j < n2) \n\t{ \n\t\tif (L[i] <= R[j]) \n\t\t{ \n\t\t\tarr[k] = L[i]; \n\t\t\ti++; \n\t\t} \n\t\telse\n\t\t{ \n\t\t\tarr[k] = R[j]; \n\t\t\tj++; \n\t\t} \n\t\tk++; \n\t} \n\n\t/* Copy the remaining elements of L[], if there \n\t are any */\n\twhile (i < n1) \n\t{ \n\t\tarr[k] = L[i]; \n\t\ti++; \n\t\tk++; \n\t} \n\n\t/* Copy the remaining elements of R[], if there \n\t are any */\n\twhile (j < n2) \n\t{ \n\t\tarr[k] = R[j]; \n\t\tj++; \n\t\tk++; \n\t} \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\tif (l < r) \n\t{ \n\t\t// Same as (l+r)/2, but avoids overflow for \n\t\t// large l and h \n\t\tll m = l+(r-l)/2; \n\n\t\t// Sort first and second halves \n\t\tmergeSort(arr, l, m); \n\t\tmergeSort(arr, m+1, r); \n\n\t\tmerge(arr, l, m, r); \n\t} \n} \n\n\nll power(ll x, ll y) \n{ \n\tif (y == 0) \n\t\treturn 1; \n\telse if (y%2 == 0) \n\t\treturn power(x, y/2)*power(x, y/2); \n\telse\n\t\treturn x*power(x, y/2)*power(x, y/2); \n}\n\nll kitna(ll a)\n{\n\tll count = 1;\n\tll temp = a;\n\twhile(temp<1000000000000000000&&(1000000000000000000/temp>a))\n\t{\n\ttemp*=a ;\n\tcount++;\n\t}\n\treturn count;\n}\n\nint main(ll argc, char const *argv[])\n{\n\tll T;\n\t// scanf(\"%lld\",&T);\n\tT = 1;\n\t// printf(\"%lld %lld %lld\",MIN,MAX,max);\n//\t printf(\"%lld\\n\",kitna(510000000000));\n\tll x,y,l,r ;\n//\tprintf(\"%lld\\n\",kitna(2));\n\tscanf(\"%lld %lld %lld %lld\",&x,&y,&l,&r);\n\tll o = l;\n\tll xcountl = -1;\n\twhile(o)\n\t{\n\t\txcountl++;\n\t\to = o/x ;\n\t}\n\n\tll p = r;\n\tll xcountr = 0;\n\twhile(p)\n\t{\n\t\txcountr++;\n\t\tp = p/x;\n\t}\n\tll e = r;\n\tll ycountr = 0;\n\twhile(e)\n\t{\n\t\tycountr++;\n\t\te = e/y;\n\t}\n\tll qw = l;\n\tll ycountl = -1;\n\twhile(qw)\n\t{\n\t\tycountl++;\n\t\tqw = qw/y;\n\t}\n\n//\tprintf(\"%lld %lld\\n\",xcountl,xcountr);\n\t// printf(\"%lldchck\",power(x,2));\n\tll totalcount = 0;\n\tll A[1000000];\n\tll idx = 0;\n\tfor(ll s=xcountl;skya%lld?\",A[idx]);\n\n\t\t\tA[idx] = power(y,u)+power(x,s) ;\n//\t\t\tprintf(\"n%lldn\",A[idx]);\n\n\t\t\tif(A[idx]>MAX)\n\t\t\t\tMAX = A[idx] ;\n\t\t\tif(A[idx]MAX)\n\t\t\t\tMAX = A[idx] ;\n\t\t\tif(A[idx]max&&A[sd]>0&&A[sd-1]>0)\n\t\t\tmax = A[sd]-A[sd-1]-1 ;\n\t\t// if(max<0)max=0;\n\t}\n\tll finalanswer = 0;\n\tll left = MIN-l;\n\tif(left<0)left = 0;\n\tll right = r-MAX;\n\tif(right<0)right = 0;\n//\tprintf(\"l %lld r %lld %lld|\",left,right,max);\n\tif(left>right)\n\t{\n\t\tif(left>max)\n\t\t{\n\t\t\tfinalanswer = left;\n\t\t}\n\t\telse \n\t\t{\n\t\t\tfinalanswer = max ;\n\t\t}\n\t}\n\telse \n\t{\n\t\tif(right>max)\n\t\t{\n\t\t\tfinalanswer = right;\n\t\t}\n\t\telse \n\t\t{\n\t\t\tfinalanswer = max ;\n\t\t}\n\t}\n\t// printf(\"<%lld>\",totalcount);\n\tif(totalcount==0)\n\t{\n\t\tfinalanswer = r-l+1 ;\n\t}\n\tif(l==1)\n\t{\n\t\tif(r-l+1-totalcount==0)\n\t\t\tprintf(\"0\\n\");\n\t\telse\n\t\t{printf(\"%lld\\n\",finalanswer);}\n\t}\n\n\telse{\n\t\tif(r-l+1-totalcount==0)\n\t\t\tprintf(\"0\\n\");\n\t\telse\n\t\t{ printf(\"%lld\\n\",finalanswer);}\n\t}\n\n\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "f283460d856869f24b74128d0afb1748", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include\nlong long Veci(long long a,long long b)\n{\n if (a>b)\n return a;\n else return b;\n}\nvoid swap(long long* a,long long* b)\n{\n long long c;\n c=*a;\n *a=*b;\n *b=c;\n}\nlong long Partition(long long *A, long long left, long long right)\n{\n long long pivot = A[right], i = left, x;\n\n for (x = left; x < right; x++){\n if (A[x] <= pivot){\n swap(&A[i], &A[x]);\n i++;\n }\n }\n\n swap(&A[i], &A[right]);\n return i;\n}\nvoid QuickSort(long long Niz[],long long Levo,long long Desno)\n{\n if(Levo=l)\n br2++;\n }\n if (br2==0)\n printf(\"%lld\",r-l+1);\n else if (br2==r-l+1)\n printf(\"0\");\n else {\n QuickSort(C,0,br2-1);\n for(i=1;iraz)\n raz=praz;\n }\n if (l!=C[0])\n raz=Veci(C[0]-l,raz);\n if (r!=C[br2-1])\n raz=Veci(r-C[br2-1],raz);\n printf(\"%lld\",raz);\n }\n long long x;\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "math"], "code_uid": "59dbe5f8e6c2de2b69a0fe5c68dcef0f", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define M\t(1 << 15)\n#define A\t29\n\nchar xx[A + 1] = { 0,\n\t1, 2, 1, 4, 3, 2, 1, 5, 6, 2,\n\t1, 8, 7, 5, 9, 8, 7, 3, 4, 7,\n\t4, 2, 1, 10, 9, 3, 6, 11, 12 };\n\n#if 0\nvoid init() {\n\tstatic int bb[A];\n\tstatic char mex[1 << A];\n\tint b, a, c, i, cnt;\n\n\tfor (a = 1; a <= A; a++) {\n\t\tb = 0;\n\t\tfor (c = a; c <= A; c += a)\n\t\t\tb |= 1 << c - 1;\n\t\tbb[a - 1] = (1 << A) - 1 ^ b;\n\t}\n\tcnt = 0;\n\tfor (b = 1; b < 1 << A; b++) {\n\t\tint x = 0;\n\n\t\tfor (a = 1; a <= A; a++)\n\t\t\tif ((b & 1 << a - 1) != 0)\n\t\t\t\tx |= 1 << mex[b & bb[a - 1]];\n\t\tfor (i = 0; ; i++)\n\t\t\tif ((x & 1 << i) == 0) {\n\t\t\t\tmex[b] = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif ((b & b + 1) == 0) {\n\t\t\txx[cnt++] = mex[b];\n\t\t\tprintf(\"%d\\n\", mex[b]);\n\t\t}\n\t}\n}\n#endif\n\nint main() {\n\tstatic char used[M + 1];\n\tint n, a, b, s, grundy;\n\n#if 0\n\tinit();\n#endif\n\tscanf(\"%d\", &n);\n\ts = 1 + (n > M ? n - M : 0);\n\tgrundy = 0;\n\tfor (a = 2; a <= n && a <= M; a++) {\n\t\tint k;\n\n\t\tif (used[a])\n\t\t\tcontinue;\n\t\tk = 1;\n\t\tfor (b = a; b <= n / a; b *= a) {\n\t\t\tif (b * a <= M)\n\t\t\t\tused[b * a] = 1;\n\t\t\telse\n\t\t\t\ts--;\n\t\t\tk++;\n\t\t}\n\t\tgrundy ^= xx[k];\n\t}\n\tgrundy ^= s & 1;\n\tprintf(grundy ? \"Vasya\\n\" : \"Petya\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "games"], "code_uid": "4b0a03409fab5e96ec71115a875e8dff", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main() {\n\tstatic char cc[100001], s[100001], t[100001];\n\tstatic int kk[10], kk_[10];\n\tint n, ns, nt;\n\tint h, i, d, d_, k, k_, k0;\n\tint max, kmax, dmax;\n\n\tscanf(\"%s\", cc);\n\tn = strlen(cc);\n\tk0 = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tkk[cc[i] - '0']++;\n\t\tif (cc[i] == '0')\n\t\t\tk0++;\n\t}\n\tmax = kmax = dmax = -1, k = 0;\n\twhile (kk[0] >= 0) {\n\t\tfor (d = 0; d <= 9; d++)\n\t\t\tkk_[d] = kk[d];\n\t\tif (max < k) {\n\t\t\tmax = kmax = k;\n\t\t\tdmax = -1;\n\t\t}\n\t\tfor (d = 1; d <= 9; d++)\n\t\t\tif (kk[d] > 0 && kk_[10 - d] > 0) {\n\t\t\t\tkk[d]--, kk_[10 - d]--;\n\t\t\t\tk_ = 0;\n\t\t\t\tfor (d_ = 0; d_ <= 9; d_++)\n\t\t\t\t\tk_ += kk[d_] < kk_[9 - d_] ? kk[d_] : kk_[9 - d_];\n\t\t\t\tkk[d]++, kk_[10 - d]++;\n\t\t\t\tif (max < k + 1 + k_) {\n\t\t\t\t\tmax = k + 1 + k_;\n\t\t\t\t\tkmax = k;\n\t\t\t\t\tdmax = d;\n\t\t\t\t}\n\t\t\t}\n\t\tkk[0]--;\n\t\tk++;\n\t}\n\tns = nt = 0;\n\tkk[0] = kk_[0] = k0 - kmax;\n\tif (dmax >= 0) {\n\t\tkk[dmax]--, kk_[10 - dmax]--;\n\t\tfor (d_ = 0; d_ <= 9; d_++) {\n\t\t\tfor (h = kk[d_]; h < kk_[9 - d_]; h++)\n\t\t\t\tt[nt++] = 9 - d_ + '0';\n\t\t\tfor (h = kk_[9 - d_]; h < kk[d_]; h++)\n\t\t\t\ts[ns++] = d_ + '0';\n\t\t}\n\t\tfor (d_ = 0; d_ <= 9; d_++)\n\t\t\tfor (h = 0; h < kk[d_] && h < kk_[9 - d_]; h++) {\n\t\t\t\ts[ns++] = d_ + '0';\n\t\t\t\tt[nt++] = 9 - d_ + '0';\n\t\t\t}\n\t\ts[ns++] = dmax + '0';\n\t\tt[nt++] = 10 - dmax + '0';\n\t} else\n\t\tfor (d_ = 0; d_ <= 9; d_++) {\n\t\t\tfor (h = 0; h < kk[d_]; h++)\n\t\t\t\ts[ns++] = d_ + '0';\n\t\t\tfor (h = 0; h < kk_[d_]; h++)\n\t\t\t\tt[nt++] = d_ + '0';\n\t\t}\n\tfor (h = 0; h < kmax; h++)\n\t\ts[ns++] = t[nt++] = '0';\n\tprintf(\"%s\\n\", s);\n\tprintf(\"%s\\n\", t);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "aac3435ed7802b99dca9cdbc0484f701", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint min(int a, int b)\n{\n if (a < b) {\n\treturn a;\n } else {\n\treturn b;\n }\n}\n\nint main()\n{\n int n, m, p = 0, num = -1, i, j;\n char s[100001];\n char c1[100001], c2[100001];\n int a[10] = {0};\n int b[10] = {0};\n\n scanf(\"%s\", s);\n\n n = strlen(s);\n\n for (i = 0; i < n; i++) {\n\ta[s[i] - '0']++;\n\tb[s[i] - '0']++;\n }\n\n c1[n] = c2[n] = '\\0';\n\n n--;\n\n for (i = 0; i < a[0] - a[9]; i++) {\n\tc1[n - i] = c2[n - i] = '0';\n }\n\n if (a[0] > a[9]) {\n\tn -= a[0] - a[9];\n\n\ta[0] = b[0] = a[9];\n }\n\n for (i = 1; i <= 5; i++) {\n\tint c = 1;\n\n\ta[i]--;\n\tb[10 - i]--;\n\n\tif (a[i] < 0 || b[10 - i] < 0) {\n\t a[i]++;\n\t b[10 - i]++;\n\n\t continue;\n\t}\n\n\tfor (j = 0; j < 5; j++) {\n\t c += min(a[j], b[9 - j]);\n\t}\n\n\tif (c > p) {\n\t p = c;\n\t num = i;\n\t}\n\n\ta[i]++;\n\tb[10 - i]++;\n }\n\n if (num > 0) {\n\tif (num == 1 && a[0] == a[9] && a[0] > 0) {\n\t c1[n] = '0';\n\t c2[n--] = '0';\n\n\t a[0]--;\n\t b[0]--;\n\t}\n\n\tc1[n] = num + '0';\n\tc2[n--] = 10 - num + '0';\n\n\ta[num]--;\n\tb[10 - num]--;\n }\n\n for (i = 0; i < 10; i++) {\n\twhile (1) {\n\t if (a[i] > 0 && b[9 - i] > 0) {\n\t\tc1[n] = i + '0';\n\t\tc2[n--] = 9 - i + '0';\n\n\t\ta[i]--;\n\t\tb[9 - i]--;\n\t } else {\n\t\tbreak;\n\t }\n\t}\n }\n\n m = n;\n\n for (i = 0; i < 10; i++) {\n\tfor (j = 0; j < a[i]; j++) {\n\t c1[n--] = i + '0';\n\t}\n\tfor (j = 0; j < b[i]; j++) {\n\t c2[m--] = i + '0';\n\t}\n }\n\n printf(\"%s\\n\", c1);\n printf(\"%s\\n\", c2);\n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "4a63f1c42df07fc98beb5b5b6b1c9512", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define N 1002\n#define MOD 1000000007\n\ntypedef long long typec;\n\nint n, m, k;\ntypec ftable[N];\ntypec facmod[1000001];\nint com[N][N];\n\ntypec extend_gcd(typec a, typec b, typec *x, typec *y)\n{\n\tif(!b) return *x = 1, *y = 0, a;\n\ttypec res = extend_gcd(b, a % b, x, y), tmp = *x;\n\t*x = *y, *y = tmp - (a / b) * (*y);\n\treturn res;\n}\n\ntypec inverse(typec a, typec m)\n{\n\ttypec x, y;\n\ty = extend_gcd(a, m, &x, &y);\n\twhile(x < 0) x += m;\n\treturn x;\n}\n\ntypec pow_mod(typec x, typec k, typec m)\n{\n\ttypec res = 1;\n\twhile(x %= m, k) {\n\t\tif(k&1) res *= x, res %= m;\n\t\tx *= x, k >>= 1;\n\t}\n\treturn res;\n}\n\nint mymin(int x, int y)\n{\n\treturn x < y? x : y;\n}\n\ntypec combines(int i, int j)\n{\n\tif(i < j) return 0;\n\tif(i < N) return com[i][j];\n\treturn facmod[i] * inverse(facmod[j], MOD) % MOD * inverse(facmod[i - j], MOD) % MOD;\n}\n\nvoid init()\n{\n\tint i, j;\n\ttypec sum = 0;\n\tfacmod[0] = 1;\n\tfor(i = 1; i <= 1000000; i++) {\n\t\tfacmod[i] = facmod[i - 1] * i;\n\t\tfacmod[i] %= MOD;\n\t}\n\tfor(i = 0; i < N; i++) {\n\t\tfor(j = 0; j <= i; j++) {\n\t\t\tif(!i) com[i][j] = 1;\n\t\t\telse com[i][j] = (com[i - 1][j] + com[i - 1][j - 1]) % MOD;\n\t\t}\n\t}\n\tftable[1] = 1;\n\tfor(i = 2; i <= n; i++) {\n\t\tftable[i] = pow_mod(i, n, MOD) + MOD;\t\t\n\t\tsum = 0;\n\t\tfor(j = 1; j < i; j++) {\n\t\t\tsum += com[i][j] * ftable[j] % MOD;\n\t\t\tsum %= MOD;\n\t\t}\n\t\tftable[i] -= sum;\n\t\tftable[i] %= MOD;\n\t}\n}\n\n\ntypec calc()\n{\n\tint i, j, m1, m2;\n\ttypec res = 0, tmp, stmp;\n\tm1 = mymin(n, k);\n\tfor(i = 0; i <= m1; i++) {\n\t\ttmp = combines(k, i) * pow_mod(i, (m - 2) * n, MOD) % MOD;\n\t\tm2 = mymin(n - i, (k - i) / 2);\n\t\tstmp = 0;\n\t\tfor(j = 0; j <= m2; j++) {\n\t\t\tif(!i && !j) continue;\n\t\t\tstmp += combines(k - i, j) * combines(k - i - j, j) % MOD * ftable[i + j] % MOD * ftable[i + j] % MOD;\n\t\t\tstmp %= MOD;\n\t\t}\n\t\tres += tmp * stmp % MOD;\n\t\tres %= MOD;\n\t}\n\treturn res;\n}\nint main()\n{\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tif(m == 1) {\n\t\tprintf(\"%d\\n\", (int)pow_mod(k, n, MOD));\n\t\treturn 0;\n\t}\n\tinit();\n\tprintf(\"%d\\n\", (int)calc());\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "fbf32c792531d505849f9ba15880d1e5", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#define N 1002\n#define MOD 1000000007\n\ntypedef long long typec;\n\nint n, m, k;\ntypec ftable[N];\ntypec facmod[1000001];\n\ntypec extend_gcd(typec a, typec b, typec *x, typec *y)\n{\n\tif(!b) return *x = 1, *y = 0, a;\n\ttypec res = extend_gcd(b, a % b, x, y), tmp = *x;\n\t*x = *y, *y = tmp - (a / b) * (*y);\n\treturn res;\n}\n\ntypec inverse(typec a, typec m)\n{\n\ttypec x, y;\n\ty = extend_gcd(a, m, &x, &y);\n\twhile(x < 0) x += m;\n\treturn x;\n}\n\ntypec pow_mod(typec x, typec k, typec m)\n{\n\ttypec res = 1;\n\twhile(x %= m, k) {\n\t\tif(k&1) res *= x, res %= m;\n\t\tx *= x, k >>= 1;\n\t}\n\treturn res;\n}\n\nint mymin(int x, int y)\n{\n\treturn x < y? x : y;\n}\n\ntypec combines(int i, int j)\n{\n\tif(i < j) return 0;\n\treturn facmod[i] * inverse(facmod[j], MOD) % MOD * inverse(facmod[i - j], MOD) % MOD;\n}\n\nvoid init()\n{\n\tint i, j;\n\tfacmod[0] = 1;\n\tfor(i = 1; i <= 1000000; i++) {\n\t\tfacmod[i] = facmod[i - 1] * i;\n\t\tfacmod[i] %= MOD;\n\t}\n\ttypec sum = 0;\n\tftable[1] = 1;\n\tfor(i = 2; i <= n; i++) {\n\t\tftable[i] = pow_mod(i, n, MOD) + MOD;\t\t\n\t\tsum = 0;\n\t\tfor(j = 1; j < i; j++) {\n\t\t\tsum += combines(i, j) * ftable[j] % MOD;\n\t\t\tsum %= MOD;\n\t\t}\n\t\tftable[i] -= sum;\n\t\tftable[i] %= MOD;\n\t}\n}\n\n\ntypec calc()\n{\n\tint i, j, m1, m2;\n\ttypec res = 0, tmp, stmp;\n\tm1 = mymin(n, k);\n\tfor(i = 0; i <= m1; i++) {\n\t\ttmp = combines(k, i) * pow_mod(i, (m - 2) * n, MOD) % MOD;\n\t\tm2 = mymin(n - i, (k - i) / 2);\n\t\tstmp = 0;\n\t\tfor(j = 0; j <= m2; j++) {\n\t\t\tif(!i && !j) continue;\n\t\t\tstmp += combines(k - i, j) * combines(k - i - j, j) % MOD * ftable[i + j] % MOD * ftable[i + j] % MOD;\n\t\t\tstmp %= MOD;\n\t\t}\n\t\tres += tmp * stmp % MOD;\n\t\tres %= MOD;\n\t}\n\treturn res;\n}\nint main()\n{\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tif(m == 1) {\n\t\tprintf(\"%d\\n\", (int)pow_mod(k, n, MOD));\n\t\treturn 0;\n\t}\n\tinit();\n\tprintf(\"%d\\n\", (int)calc());\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics"], "code_uid": "5166680d15739ff96415cec578132b87", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n\r\n#define N\t5000\r\n#define INF\t0x3f3f3f3f3f3f3f3fLL\r\n\r\nlong long min(long long a, long long b) { return a < b ? a : b; }\r\nlong long max(long long a, long long b) { return a > b ? a : b; }\r\n\r\nint main() {\r\n\tstatic long long dp[N];\r\n\tint n, a, c, e, i, j;\r\n\tlong long b, d, s, t, u, ans;\r\n\r\n\tscanf(\"%d%lld%d%lld%d%d\", &a, &b, &c, &d, &n, &e), a -= e, c -= e;\r\n\tmemset(dp, 0x3f, n * sizeof *dp), dp[0] = 0;\r\n\tans = INF;\r\n\tfor (i = 0; i < n; i++) {\r\n\t\ts = dp[i], t = dp[i], u = dp[i], j = i;\r\n\t\twhile (j < n) {\r\n\t\t\tif (j + a + c + e < n)\r\n\t\t\t\tdp[j + a + c + e] = min(dp[j + a + c + e], max(s + b, t + d));\r\n\t\t\telse\r\n\t\t\t\tans = min(ans, max(s + b, t + d));\r\n\t\t\tif (s + b < t + d)\r\n\t\t\t\tj += a, u = s += b;\r\n\t\t\telse\r\n\t\t\t\tj += c, u = t += d;\r\n\t\t}\r\n\t\tans = min(ans, u);\r\n\t}\r\n\tprintf(\"%lld\\n\", ans);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["dp", "binary search"], "code_uid": "ed8543a876730a38db3a39d305208268", "src_uid": "ca9d48e48e69b931236907a9ac262433", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t1000000\n\nint tt[N + 1];\n\nint compare(const void *a, const void *b) {\n\tint a_ = *(int *) a;\n\tint b_ = *(int *) b;\n\n\treturn tt[a_] != tt[b_] ? tt[a_] - tt[b_] : a_ - b_;\n}\n\nint main() {\n\tstatic int aa[N - 4];\n\tint n, k, a, b, i;\n\tlong long ans;\n\n\tscanf(\"%d%d\", &n, &k);\n\tif (k == 1) {\n\t\tprintf(\"3\\n\");\n\t\treturn 0;\n\t}\n\tfor (a = 2; a <= n; a++)\n\t\ttt[a] = a;\n\tfor (a = 2; a <= n; a++) {\n\t\tif (tt[a] != a)\n\t\t\tcontinue;\n\t\tfor (b = a; b <= n; b += a)\n\t\t\ttt[b] = tt[b] / a * (a - 1);\n\t}\n\tfor (a = 5; a <= n; a++)\n\t\taa[a - 5] = a;\n\tqsort(aa, n - 4, sizeof *aa, compare);\n\tans = 6;\n\tfor (i = 0; i < k - 2; i++)\n\t\tans += tt[aa[i]];\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "greedy", "number theory"], "code_uid": "91ebd995768a4337d1c4f3355a071272", "src_uid": "c2f7012082c84d773c2f4b1858c17110", "difficulty": 2800.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#ifndef _TJYTLXWXHYZQFW_COMMON_H\n#define _TJYTLXWXHYZQFW_COMMON_H\n#include \n#include \n#include \n#include \n#include \n#define offset(t,m) ((unsigned long)&(((t*)0)->m))\n#define container_of(a,t,m) ((t*)((unsigned long)a-offset(t,m)))\n#define ULL1 ((unsigned long long )1)\n#define LL(x) ((long long)(x))\n#define SWP(a, b) if ((a) != (b)) do {(a) ^= (b); (b) ^= (a); (a) ^= (b);} while(0)\n#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))\n#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))\n#define ir(x, start, end) ((x) >= (start) && (x) < (end))\n#define ire(x, start, end) ((x) >= (start) && (x) <= (end))\n#define max(x,y) ((x) < (y) ? (y) : (x))\n#define min(x, y) ((x) < (y) ? (x) : (y))\n#define abv(x) ((x) < 0 ? (x) * (-1) : (x))\n#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)\n#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)\n#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)\n#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)\n#endif\n#ifndef _WCC_NUMTH_H\n#define _WCC_NUMTH_H\n#include \n#define NUMTH_ENS (-1) \n#define NUMTH_MODPLS(x, y, p) ((((x) % (p)) + ((y) % (p))) % p)\n#define NUMTH_MODMUL(x, y, p) ((((X) % (P)) * ((y) % (p))) % p)\n#define NUMTH_CORRECT(x, mod) ((x) += ((x) < 0 ? (mod) : 0))\nlong long numth_modexp(long long a, long long b, long long n);\nlong long numth_gcd(long long a, long long b);\nvoid numth_gcd_e(long long a, long long b, long long *d, long long *x, long long *y);\nint numth_mle(long long a, long long b, long long n, long long *x, long long *gcd);\n#define numth_for_each_solution(i, x, n, d) \\\n\tfor ((i) = 0; (i) < (d); (i) += 1, (x) = ((x) + (n) / (d)) % (n))\nint numth_divisors(long long k, long long divs[], long long *ndivs);\n#endif\n#define M 1000000007\n#define T 100\n#define K 1000\n#define pls(a, b) NUMTH_MODPLS((a), (b), M)\nint dp[2*T][4*T*K+1];\nint a, b, t, k;\nint delta, delta_min, delta_max, offset, index_max;\nint dp_fill(int i, int j)\n{\n\tint x;\n\tif (j == index_max-k) {\n\t\tdp[i][j] = 0;\n\t\tforre(x, j-k, j+k) dp[i][j] = pls(dp[i][j], dp[i+1][x]);\n\t} else {\n\t\tdp[i][j] = pls(pls(dp[i+1][j-k], dp[i][j+1]), -1*dp[i+1][j+k+1]);\n\t\tNUMTH_CORRECT(dp[i][j], M);\n\t}\n\treturn dp[i][j];\n}\nint main(void)\n{\n\tint i, j;\n\tscanf(\"%d%d%d%d\", &a, &b, &k, &t);\n\tt <<= 1;\n\tdelta = a - b;\n\tdelta_min = delta - t * k;\n\tdelta_max = delta + t * k;\n\toffset = -1 * delta_min;\n\tindex_max = delta_max + offset;\n\tforre(i, 0, index_max) dp[t-1][i] = max(0, k-max(-1*k, offset-i+1)+1);\n\tfor (i = t-2; i >= 0; --i)\n\t\tfor (j = index_max-k; j >= k; --j)\n\t\t\tdp_fill(i, j);\n\tprintf(\"%d\\n\", dp[0][delta+offset]);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "c197cbd0779f5558897a9b5f293899f8", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \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\nvoid multiply(int *aa, int *bb, int n) {\n\tstatic int aa_[N_], bb_[N_];\n\tint n_, l_, i;\n\n\tl_ = 0;\n\twhile (1 << l_ < n + n - 1)\n\t\tl_++;\n\tn_ = 1 << l_;\n\tfor (i = 0; i < n_; i++) {\n\t\taa_[i] = i < n ? aa[i] : 0;\n\t\tbb_[i] = i < n ? bb[i] : 0;\n\t}\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\tfor (i = 0; i < n; i++)\n\t\taa[i] = (long long) aa_[i] * vv_[l_] % MD;\n}\n\nvoid inv(int *aa, int *bb, int n) {\n\tstatic int aa_[N_], bb_[N_];\n\tint m, n_, l_, i;\n\n\tif (n == 1) {\n\t\tbb[0] = 1;\n\t\treturn;\n\t}\n\tm = (n + 1) / 2;\n\tinv(aa, bb, m);\n\tl_ = 0;\n\twhile (1 << l_ < n * 2)\n\t\tl_++;\n\tn_ = 1 << l_;\n\tfor (i = 0; i < n_; i++) {\n\t\taa_[i] = i < n ? aa[i] : 0;\n\t\tbb_[i] = i < m ? bb[i] : 0;\n\t}\n\tntt(aa_, l_, 0), ntt(bb_, l_, 0);\n\tfor (i = 0; i < n_; i++)\n\t\taa_[i] = bb_[i] * (MD + 2 - (long long) aa_[i] * bb_[i] % MD) % MD;\n\tntt(aa_, l_, 1);\n\tfor (i = 0; i < n; i++)\n\t\tbb[i] = (long long) aa_[i] * vv_[l_] % MD;\n}\n\nvoid log_(int *aa, int *bb, int n) {\n\tstatic int pp[N + 1], qq[N + 1];\n\tint i;\n\n\tfor (i = 0; i < n; i++)\n\t\tpp[i] = i + 1 == n ? 0 : (long long) aa[i + 1] * (i + 1) % MD;\n\tinv(aa, qq, n);\n\tmultiply(pp, qq, n);\n\tfor (i = 0; i < n; i++)\n\t\tbb[i] = i == 0 ? 0 : (long long) pp[i - 1] * vv[i] % MD;\n}\n\nvoid exp_(int *aa, int *bb, int n) {\n\tstatic int aa_[N + 1], bb_[N + 1], cc_[N + 1];\n\tint m, i;\n\n\tif (n == 1) {\n\t\tbb[0] = 1;\n\t\treturn;\n\t}\n\tm = (n + 1) / 2;\n\texp_(aa, bb, m);\n\tfor (i = 0; i < n; i++)\n\t\tbb_[i] = i < m ? bb[i] : 0;\n\tlog_(bb_, cc_, n);\n\tfor (i = 0; i < n; i++)\n\t\taa_[i] = (aa[i] - cc_[i] + MD) % MD;\n\taa_[0] = (aa_[0] + 1) % MD;\n\tmultiply(aa_, bb_, n);\n\tfor (i = 0; i < n; i++)\n\t\tbb[i] = aa_[i];\n}\n\nint bell[N + 1];\n\nvoid compute_bell() {\n\tstatic int aa[N + 1];\n\tint i;\n\n\tfor (i = 1; i <= N; i++)\n\t\taa[i] = gg[i];\n\texp_(aa, bell, N + 1);\n\tfor (i = 0; i <= N; i++)\n\t\tbell[i] = (long long) bell[i] * ff[i] % MD;\n}\n\nint sum(int n, int k) {\n\tstatic int aa[N + 1], bb[N + 1];\n\tint i, ans;\n\n\tif (k > n)\n\t\treturn (bell[n] - 1 + MD) % MD;\n\tfor (i = 0; i <= k; i++)\n\t\taa[i] = power(i, n) * gg[i] % MD;\n\tfor (i = 0; i <= k; i++)\n\t\tbb[i] = (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD;\n\tmultiply(aa, bb, k + 1);\n\tans = MD - 1;\n\tfor (i = 0; i <= k; i++)\n\t\tans = (ans + aa[i]) % 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\tcompute_bell();\n\tans = 0;\n\tfor (d = 1; d < n; d++)\n\t\tif (mobius[d])\n\t\t\tans = (ans + sum((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": "c6ed6b695391962dde2a756713d49d24", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n\r\n#define N\t200000\r\n#define L_\t19\t/* L_ = ceil(log2(N * 2 + 1)) */\r\n#define N_\t(1 << L_)\r\n#define MD\t998244353\r\n\r\nint min(int a, int b) { return a < b ? a : b; }\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[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];\r\nint *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];\r\n\r\nvoid init() {\r\n\tint i, j, l, u, v;\r\n\r\n\tff[0] = gg[0] = 1;\r\n\tfor (i = 1; i <= N; i++) {\r\n\t\tvv[i] = i == 1 ? 1 : (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\tfor (i = 2; i <= N; i++) {\r\n\t\tif (mobius[i])\r\n\t\t\tcontinue;\r\n\t\tfor (j = i; j <= N; j += i)\r\n\t\t\tmobius[j]++;\r\n\t}\r\n\tfor (i = 2; i <= N / i; i++)\r\n\t\tfor (j = i * i; j <= N; j += i * i)\r\n\t\t\tmobius[j] = -1;\r\n\tfor (i = 1; i <= N; i++)\r\n\t\tmobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);\r\n\tu = power(3, MD - 1 >> L_), v = power(u, MD - 2);\r\n\tfor (l = L_; l > 0; l--) {\r\n\t\tint n = 1 << l, m = n >> 1;\r\n\r\n\t\twwu[l] = (int *) malloc(m * sizeof *wwu[l]);\r\n\t\twwv[l] = (int *) malloc(m * sizeof *wwv[l]);\r\n\t\twwu[l][0] = wwv[l][0] = 1;\r\n\t\tfor (i = 1; i < m; i++) {\r\n\t\t\twwu[l][i] = (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\tvv_[l] = power(1 << l, MD - 2);\r\n\t\tu = (long long) u * u % MD, v = (long long) v * v % MD;\r\n\t}\r\n\tvv_[0] = 1;\r\n}\r\n\r\nint choose(int n, int k) {\r\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\r\n}\r\n\r\nvoid ntt_(int *aa, int l, int inverse) {\r\n\tif (l) {\r\n\t\tint n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;\r\n\r\n\t\tntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);\r\n\t\tfor (i = 0; (j = i + m) < n; i++) {\r\n\t\t\tint a = aa[i], b = (long long) aa[j] * ww[i] % MD;\r\n\r\n\t\t\tif ((aa[i] = a + b) >= MD)\r\n\t\t\t\taa[i] -= MD;\r\n\t\t\tif ((aa[j] = a - b) < 0)\r\n\t\t\t\taa[j] += MD;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid ntt(int *aa, int l, int inverse) {\r\n\tint n = 1 << l, i, j;\r\n\r\n\tfor (i = 1, j = 0; i < n; i++) {\r\n\t\tint b = n >> 1, tmp;\r\n\r\n\t\twhile ((j ^= b) < b)\r\n\t\t\tb >>= 1;\r\n\t\tif (i < j)\r\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\r\n\t}\r\n\tntt_(aa, l, inverse);\r\n}\r\n\r\nint solve(int n, int k) {\r\n\tstatic int aa[N_], bb[N_];\r\n\tint n_, l_, i, ans;\r\n\r\n\tk = min(k, n);\r\n\tl_ = 0;\r\n\twhile (1 << l_ < k + k + 1)\r\n\t\tl_++;\r\n\tn_ = 1 << l_;\r\n\tfor (i = 0; i < n_; i++)\r\n\t\taa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;\r\n\tfor (i = 0; i < n_; i++)\r\n\t\tbb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;\r\n\tntt(aa, l_, 0), ntt(bb, l_, 0);\r\n\tfor (i = 0; i < n_; i++)\r\n\t\taa[i] = (long long) aa[i] * bb[i] % MD;\r\n\tntt(aa, l_, 1);\r\n\tans = MD - 1;\r\n\tfor (i = 0; i <= k; i++)\r\n\t\tans = (ans + (long long) aa[i] * vv_[l_]) % MD;\r\n\treturn ans;\r\n}\r\n\r\nint main() {\r\n\tint n, k, d, ans;\r\n\r\n\tinit();\r\n\tscanf(\"%d%d\", &n, &k);\r\n\tif (k == 1 || n == 1) {\r\n\t\tprintf(\"1\\n\");\r\n\t\treturn 0;\r\n\t}\r\n\tans = 0;\r\n\tfor (d = 1; d < n; d++)\r\n\t\tif (mobius[d])\r\n\t\t\tans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;\r\n\tif (ans < 0)\r\n\t\tans += MD;\r\n\tprintf(\"%d\\n\", ans);\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C", "tags": ["math", "number theory", "combinatorics", "fft"], "code_uid": "3eb726dcc5e3fd05f1080e18ed9a6c45", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "long long n,A,D=1;main(){scanf(\"%lld\",&n);A=n-1;for(long long i=2;i\n#include\ntypedef long long unsigned llu;\ntypedef unsigned u;\ntypedef struct S\n{\n\tu val,ki,ka,min,max;llu sum;\n\tstruct S *lc,*rc;\n}v;\nv*alloc(u ki,u ka,u val)\n{\n\tv*x;\n\tx=(v*)malloc(sizeof(v));\n\tx->val=val;\n\tx->min=val;\n\tx->max=val;\n\tx->ki=ki;\n\tx->ka=ka;\n\tx->sum=(ka-ki+1)*(llu)val;\n\tx->lc=x->rc=NULL;\n\treturn x;\n}\nllu que(v *x,u lo,u hi)\n{\n//\tprintf(\"que %u %u\\n\",lo,hi);\n\tif(hiki||lo>x->ka)\n\t{\n//\t\tprintf(\"return 0\\n\");\n\t\treturn 0;\n\t}\n\tif(lo<=x->ki&&hi>=x->ka)\n\t{\n//\t\tprintf(\"Return %I64u\\n\",x->sum);\n\t\treturn x->sum;\n\t}\n\tu ll,rr;\n\tif(x->val)\n\t{\n\t\tll=loki?x->ki:lo;\n\t\trr=hi>x->ka?x->ka:hi;\n\t\tif(rrval=%u\\n\",ll,rr,x->val);\n\t\treturn(rr-ll+1)*(llu)x->val;\n\t}\n\tllu a=que(x->lc,lo,hi)+que(x->rc,lo,hi);\n//\tprintf(\"Retu5n %I64u\\n\",a);\n\treturn a;\n}\nvoid set(v *x,u lo,u hi,u val)\n{\n//\tprintf(\"set [%u %u] %u %u %u min %u\\n\",x->ki,x->ka,lo,hi,val,x->min);\n\tif(hiki||lo>x->ka||x->min>=val)\n\t{\n//\t\tprintf(\"return %u<%u || %u>%u || %u>=%u\\n\",hi,x->ki,lo,x->ka,x->min,val);\n\t\treturn;\n\t}\n\tif(lo<=x->ki&&hi>=x->ka&&x->max<=val)\n\t{\n//\t\tprintf(\"chg %u %u -> %u\\n\",x->ki,x->ka,val);\n\t\tx->val=x->min=x->max=val;\n\t\tx->sum=val*(llu)(x->ka-x->ki+1);\n\t\treturn;\n\t}\n\tu m;\n\tif(x->val)\n\t{\n\t\tif(val<=x->val)\n\t\t{\n//\t\t\tprintf(\"small return\\n\");\n\t\t\treturn;\n\t\t}\n\t\tm=(x->ki+x->ka)>>1;\n//\t\tprintf(\"split! m=%u x->val=%u val=%u\\n\",m,x->val,val);\n\t\tif(!x->lc)x->lc=alloc(x->ki,m,x->val);\n\t\telse{x->lc->val=x->lc->min=x->lc->max=x->val;x->lc->sum=(m-x->ki+1)*(llu)x->val;}\n\t\tif(!x->rc)x->rc=alloc(m+1,x->ka,x->val);\n\t\telse{x->rc->val=x->rc->min=x->rc->max=x->val;x->rc->sum=(x->ka-m)*(llu)x->val;}//grr! damn bug :( took hours to search it!\n//\t\tprintf(\"lc_val: %u lc_min: %u val: %u min: %u\\n\",x->lc->val,x->lc->min,x->val,x->min);\n\t\tx->val=0;\n\t}\n\tset(x->lc,lo,hi,val);\n\tset(x->rc,lo,hi,val);\n\tif(x->lc->val&&x->lc->val==x->rc->val)\n\t{\n//\t\tprintf(\"unit!\\n\");\n\t\tx->val=x->lc->val;\n\t\tx->sum=x->val*(llu)(x->ka-x->ki+1);\n\t}\n\telse x->sum=x->lc->sum+x->rc->sum;\n\tx->min=x->lc->min;\n\tx->max=x->rc->max;\n\treturn;\n}\nv *p;\nu A[222222],F[222222],G[222222];\nint main()\n{\n\tu n,h,i,j,k,x;llu r;\n\tscanf(\"%u\",&n);\n\tif(n<=2){printf(\"0\\n\");return 0;}\n\tp=alloc(0,n,1);\n\tfor(i=0;++i<=n;A[i]=x)\n\t{\n\t\tscanf(\"%u\",&x);h=0;\n\t\tfor(j=1;j*j<=x;++j)if(x%j==0)\n\t\t{\n\t\t\tif(!F[j])F[j]=i;\n\t\t\telse if(h1;--i)\n\t{\n\t\tx=A[i];h=0;\n\t\tfor(j=1;j*j<=x;++j)if(x%j==0)\n\t\t{\n\t\t\tif(!G[j])G[j]=i;\n\t\t\telse if(h\n#include\ntypedef long long unsigned llu;\ntypedef unsigned u;\ntypedef struct S\n{\n\tu val,ki,ka,min,max;llu sum;\n\tstruct S *lc,*rc;\n}v;\nv*alloc(u ki,u ka,u val)\n{\n\tv*x;\n\tx=(v*)malloc(sizeof(v));\n\tx->val=val;\n\tx->min=val;\n\tx->max=val;\n\tx->ki=ki;\n\tx->ka=ka;\n\tx->sum=(ka-ki+1)*(llu)val;\n\tx->lc=x->rc=NULL;\n\treturn x;\n}\nllu que(v *x,u lo,u hi)\n{\n\tif(hiki||lo>x->ka)return 0;\n\tif(lo<=x->ki&&hi>=x->ka)return x->sum;\n\tu ll,rr;\n\tif(x->val)\n\t{\n\t\tll=loki?x->ki:lo;\n\t\trr=hi>x->ka?x->ka:hi;\n\t\tif(rrval;\n\t}\n\tllu a=que(x->lc,lo,hi)+que(x->rc,lo,hi);\n\treturn a;\n}\nvoid set(v *x,u lo,u hi,u val)\n{\n\tif(hiki||lo>x->ka||x->min>=val)\n\t{\n\t\treturn;\n\t}\n\tif(lo<=x->ki&&hi>=x->ka&&x->max<=val)\n\t{\n\t\tx->val=x->min=x->max=val;\n\t\tx->sum=val*(llu)(x->ka-x->ki+1);\n\t\treturn;\n\t}\n\tu m;\n\tif(x->val)\n\t{\n\t\tif(val<=x->val)return;\n\t\tm=(x->ki+x->ka)>>1;\n\t\tif(!x->lc)x->lc=alloc(x->ki,m,x->val);\n\t\telse\n\t\t{\n\t\t\tx->lc->val=x->lc->min=x->lc->max=x->val;\n\t\t\tx->lc->sum=(m-x->ki+1)*(llu)x->val;\n\t\t}\n\t\tif(!x->rc)x->rc=alloc(m+1,x->ka,x->val);\n\t\telse\n\t\t{\n\t\t\tx->rc->val=x->rc->min=x->rc->max=x->val;\n\t\t\tx->rc->sum=(x->ka-m)*(llu)x->val;\n\t\t}\n\t\tx->val=0;\n\t}\n\tset(x->lc,lo,hi,val);\n\tset(x->rc,lo,hi,val);\n\tif(x->lc->val&&x->lc->val==x->rc->val)\n\t{\n\t\tx->val=x->lc->val;\n\t\tx->sum=x->val*(llu)(x->ka-x->ki+1);\n\t}\n\telse x->sum=x->lc->sum+x->rc->sum;\n\tx->min=x->lc->min;\n\tx->max=x->rc->max;\n\treturn;\n}\nv *p;\nu A[222222],F[222222],G[222222];\nint main()\n{\n\tu n,h,i,j,k,x;llu r;\n\tscanf(\"%u\",&n);\n\tp=alloc(0,n,1);\n\tfor(i=0;++i<=n;A[i]=x)\n\t{\n\t\tscanf(\"%u\",&x);h=0;\n\t\tfor(j=1;j*j<=x;++j)if(x%j==0)\n\t\t{\n\t\t\tif(!F[j])F[j]=i;\n\t\t\telse if(h1;--i)\n\t{\n\t\tx=A[i];h=0;\n\t\tfor(j=1;j*j<=x;++j)if(x%j==0)\n\t\t{\n\t\t\tif(!G[j])G[j]=i;\n\t\t\telse if(h\n#include \n\nint main()\n{\n int n, m, x1, y1, x2, y2, x, y;\n \n scanf(\"%d %d %d %d %d %d\", &n, &m, &x1, &y1, &x2, &y2);\n \n x = abs(x1 - x2);\n y = abs(y1 - y2);\n \n if (x > y) {\n int tmp = x;\n x = y;\n y = tmp;\n }\n \n if ((x <= 2 && y <= 4) || (x == 3 && y == 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": "81f95554361c24d2088461680203cb06", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.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\n\n#define N\t400\n#define M\t200\n#define A\t26\n#define MD\t998244353\n\nint max(int a, int b) { return a > b ? a : b; }\n\nint main() {\n\tstatic int kk[A], dp[N + 1][M + 1][2], dq[N + 1][M + 1][M + 1][3], dr[N + 1], ds[N + 1][N + 1], aa1[M + 1], aa2[M + 1], bb1[M + 1][M + 1], bb2[M + 1][M + 1];\n\tint n, m, i, k, l, k1, l1, k2, l2, a, b, ans;\n\n\tscanf(\"%d\", &n), m = (n + 1) / 2;\n\tfor (a = 0; a < A; a++)\n\t\tscanf(\"%d\", &kk[a]);\n\tdp[1][0][0] = dp[1][1][1] = 1;\n\tfor (i = 1; i < m; i++)\n\t\tfor (k = i; k >= 0; k--) {\n\t\t\tint x = dp[i][k][0], y = dp[i][k][1];\n\n\t\t\tdp[i + 1][k][0] = ((long long) x * (A - 2) + y) % MD;\n\t\t\tdp[i + 1][k + 1][1] = (long long) x * (A - 1) % MD;\n\t\t}\n\tdq[1][0][0][0] = dq[1][1][0][1] = dq[1][0][1][2] = 1;\n\tfor (i = 1; i < m; i++)\n\t\tfor (k = i; k >= 0; k--)\n\t\t\tfor (l = i - k; l >= 0; l--) {\n\t\t\t\tint x = dq[i][k][l][0], y = dq[i][k][l][1], z = dq[i][k][l][2];\n\n\t\t\t\tdq[i + 1][k][l][0] = ((long long) x * (A - 3) + y + z) % MD;\n\t\t\t\tdq[i + 1][k + 1][l][1] = ((long long) x * (A - 2) + z) % MD;\n\t\t\t\tdq[i + 1][k][l + 1][2] = ((long long) x * (A - 2) + y) % MD;\n\t\t\t}\n\tfor (k1 = 0; k1 <= m; k1++)\n\t\taa1[k1] = ((long long) dp[m][k1][0] * (A - 1) + dp[m][k1][1]) % MD;\n\tfor (k2 = 0; k2 <= n - m; k2++)\n\t\taa2[k2] = ((long long) dp[n - m][k2][0] * (A - 1) + dp[n - m][k2][1]) % MD;\n\tfor (k1 = 0; k1 <= m; k1++)\n\t\tfor (k2 = max(n / 3 + 1 - k1, 0); k2 <= n - m; k2++)\n\t\t\tdr[k1 + k2] = (dr[k1 + k2] + (long long) aa1[k1] * aa2[k2]) % MD;\n\tfor (k1 = 0; k1 <= m; k1++)\n\t\tfor (l1 = 0; k1 + l1 <= m; l1++)\n\t\t\tbb1[k1][l1] = ((long long) dq[m][k1][l1][0] * (A - 2) + dq[m][k1][l1][1] + dq[m][k1][l1][2]) % MD;\n\tfor (k2 = 0; k2 <= n - m; k2++)\n\t\tfor (l2 = 0; k2 + l2 <= n - m; l2++)\n\t\t\tbb2[k2][l2] = ((long long) dq[n - m][k2][l2][0] * (A - 2) + dq[n - m][k2][l2][1] + dq[n - m][k2][l2][2]) % MD;\n\tfor (k1 = 0; k1 <= m; k1++)\n\t\tfor (k2 = max(n / 3 + 1 - k1, 0); k2 <= n - m; k2++)\n\t\t\tfor (l1 = 0; k1 + l1 <= m; l1++)\n\t\t\t\tfor (l2 = max(n / 3 + 1 - l1, 0); k2 + l2 <= n - m; l2++)\n\t\t\t\t\tds[k1 + k2][l1 + l2] = (ds[k1 + k2][l1 + l2] + (long long) bb1[k1][l1] * bb2[k2][l2]) % MD;\n\tans = A * A;\n\tfor (i = 2; i < n; i++)\n\t\tans = (long long) ans * (A - 1) % MD;\n\tfor (a = 0; a < A; a++)\n\t\tfor (k = kk[a] + 1; k <= n; k++)\n\t\t\tans = (ans - dr[k]) % MD;\n\tfor (a = 0; a < A; a++)\n\t\tfor (b = a + 1; b < A; b++)\n\t\t\tfor (k = kk[a] + 1; k <= n; k++)\n\t\t\t\tfor (l = kk[b] + 1; k + l <= n; l++)\n\t\t\t\t\tans = (ans + ds[k][l]) % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "58b54cc80ba28bc1828389c678fb01a7", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#define sq(A) ((A)*(A))\n\nint x[4], y[4], r[4];\n\nbool intersect(int i, int j){\n\tint dist=sq(x[i]-x[j])+sq(y[i]-y[j]);\n\tif(dist>=sq(r[i]+r[j])) return false;\n\tif(r[i]\n#include \n\nint n;\n\ndouble p(double a, double e) {\n return a / e;\n}\ndouble q(double a, double b, double c, double d, double e, double f) {\n return (a / d) * (b / e) * (c / f);\n}\n\ndouble solve(int k) {\n const double q3 = q(k, k-1, k-2, n, n-1, n-2);\n const double q0 = q(n-k, n-k-1, n-k-2, n, n-1, n-2);\n const double q1 = 3 / 2. * q(k, n-k, n-k-1, n, n-1, n-2);\n const double q2 = 3 * q(k, k-1, n-k, n, n-1, n-2);\n const double res = q3 + q1 + q2;\n //printf(\"solve(%d) = %lf\\n\", k, res);\n //assert(q3 + q0 + 3 / 2. * q1 + 3 * q2 == 1.);\n assert(res >= 0.);\n assert(res <= 1.);\n return res;\n}\n\nint main(void) {\n double p;\n scanf(\"%d%lf\", &n, &p);\n int l = 0, r = n - 1;\n if (p == 0) {\n puts(\"0\");\n return 0;\n }\n while (l + 1 < r) {\n const int m = (l + r) >> 1;\n if (solve(m) >= p) {\n r = m;\n } else {\n l = m;\n }\n }\n assert(r > 0);\n assert(r < n);\n printf(\"%d\\n\", r);\n}\n\n", "lang_cluster": "C", "tags": ["math", "probabilities", "combinatorics"], "code_uid": "f7c2b3cb27ac6cf4ca152df99f5332d1", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nlong long dp(int,int,char);\nlong long dar[1003][102],MOD,powmod[1003],modmod[1003];\nint n,k;\nint main(){\n\tint i,j,l;\n\tscanf(\"%d %d %d\",&n,&k,&i);\n\tMOD=(long long)i;\n\tpowmod[0]=1%k;\n\tmodmod[0]=1%MOD;\n\tfor(i=1;i<=n;i++){\n\t\tpowmod[i]=(powmod[i-1]*10)%k;\n\t\tmodmod[i]=(modmod[i-1]*10)%MOD;\n\t}\n\tfor(i=0;i<1003;i++){\n\t\tfor(j=0;j<102;j++){\n\t\t\tdar[i][j]=-1;\n\t\t}\n\t}\n\tdar[n][0]=1;\n\tfor(i=n-1;i>0;i--){\n\t\tdar[i][0]=(9*modmod[n-1-i])%MOD;\n\t}\n\tprintf(\"%d\\n\",(int)dp(0,0,0));\n\treturn 0;\n}\n\nlong long dp(int dig,int mod,char fl){\n\tlong long toret;\n\tint i;\n\tif(dig>n){\n\t\treturn 0;\n\t}\n\tif(fl&&mod==0){\n\t\treturn dar[dig][0];\n\t}\n\tif(fl==0||dar[dig][mod]==-1){\n\t\ttoret=0;\n\t\ttoret+=dp(dig+1,mod,fl);\n\t\tfor(i=1;i<10;i++){\n\t\t\ttoret=(toret+dp(dig+1,(mod+i*powmod[dig])%k,1))%MOD;\n\t\t}\n\t\tif(fl!=0){\n\t\t\tdar[dig][mod]=toret;\n\t\t}\n\t}\n\telse{\n\t\ttoret=dar[dig][mod];\n\t}\n\treturn toret;\n}\n", "lang_cluster": "C", "tags": ["dp", "implementation"], "code_uid": "ac8d1f87ff1a361d3cd82d1cc983900e", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n/*#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#define PB push_back\n#define MP make_pair\n#define clr(x) x.clear()\n#define sz(x) ((int)(x).size())\n#define F first\n#define S second*/\n#define rep(i,b) for(i=0;i=0&&rem<100);\n//cout<=0){\nif(dp[i][rem][f]!=-1){return dp[i][rem][f];}\n}\n\nif(i!=n-1&&rem==0&&f){if(i<0){return 1;}return dp[i][rem][f]=(9*poo(10,i))%m;}\nif(i<0){return 0;}\n\nll ans=0;\nif(i){\n\nfor(j=0;j<10;j++){if(j==0){ans+=rec(i-1,(rem+(j*pok(10,n-i-1))%k)%k,f);}\nelse{ans+=rec(i-1,(rem+(j*pok(10,n-i-1))%k)%k,1);}ans%=m;}\n}\nelse{\nfor(j=1;j<10;j++){ans+=rec(i-1,(rem+(j*pok(10,n-i-1))%k)%k,1);ans%=m;}\n}\nreturn dp[i][rem][f]=ans;\n\n}\n\n\n\nint main(){\n int i,j;\n si(n);sll(k);sll(m);\n rep(i,1003){rep(j,103){dp[i][j][0]=-1;dp[i][j][1]=-1;}}\n pll(rec(n-1,0,0)%m);\n \n \n \nreturn 0;\n}", "lang_cluster": "C", "tags": ["dp", "implementation"], "code_uid": "264e2351d814b7bf40c3acf3ec9602e9", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n#include \n\nint main()\n{\n long times,n,value,lvalue,ans,g,maxg=0,v[46],i,j,k;\n scanf(\"%ld%ld%ld\",×,&n,&value);\n for (i=1;i<=n;i++)\n scanf(\"%ld\",&v[i]);\n for (i=1;iv[j])\n {\n k=v[i];\n v[i]=v[j];\n v[j]=k;\n }\n ans=0;\n for (i=1;i<=n;i++)\n ans+=v[i];\n for (i=0;i<=times;i++)\n if (value-ans*i>=0)\n {\n g=(n+1)*i;\n lvalue=value-ans*i;\n for (j=1;j=0)\n {\n g++;\n lvalue-=v[j];\n }\n else\n break;\n if (g>maxg)\n maxg=g;\n }\n else\n break;\n printf(\"%ld\\n\",maxg);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "greedy"], "code_uid": "96759c86f98669bb80c858be79a97dca", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t6\n#define M\t6\n#define B\t(5 * 5 * 5 * 5 * 5 * 5)\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint sum_[B], kk[B][M], p5[M + 1];\n\nvoid init() {\n\tint b, j;\n\n\tp5[0] = 1;\n\tfor (j = 1; j <= M; j++)\n\t\tp5[j] = p5[j - 1] * 5;\n\tfor (b = 0; b < B; b++)\n\t\tfor (j = 0; j < M; j++)\n\t\t\tsum_[b] += kk[b][j] = b / p5[j] % 5;\n}\n\nint main() {\n\tstatic int aa[N], bb[M], cc[N][M], dp[B];\n\tint n, m, i, j, k, l, b, sum, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &m);\n\tsum = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &aa[i]);\n\t\tsum += aa[i];\n\t}\n\tfor (j = 0; j < m; j++) {\n\t\tscanf(\"%d\", &bb[j]);\n\t\tsum -= bb[j];\n\t}\n\tif (sum > 0) {\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < m; j++)\n\t\t\tscanf(\"%d\", &cc[i][j]);\n\tb = 0, sum = 0;\n\tfor (j = m - 1; j >= 0; j--)\n\t\tb = b * 5 + bb[j], sum += bb[j];\n\tmemset(dp, 0x3f, B * sizeof *dp), dp[b] = 0;\n\tfor (i = 0; i < 6; i++) {\n\t\tfor (j = 0; j < 6; j++)\n\t\t\tfor (b = 0; b < B; b++) {\n\t\t\t\tint x = dp[b];\n\n\t\t\t\tif (x == INF)\n\t\t\t\t\tcontinue;\n\t\t\t\tk = kk[b][j];\n\t\t\t\tfor (l = 1; l <= k; l++)\n\t\t\t\t\tdp[b - l * p5[j]] = min(dp[b - l * p5[j]], x + cc[i][j]);\n\t\t\t}\n\t\tsum -= aa[i];\n\t\tfor (b = 0; b < B; b++)\n\t\t\tif (sum_[b] != sum)\n\t\t\t\tdp[b] = INF;\n\t}\n\tans = INF;\n\tfor (b = 0; b < B; b++)\n\t\tans = min(ans, dp[b]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dfs and similar", "flows", "dp", "bitmasks"], "code_uid": "4f89073e3cacabd713c76cfeebc13b48", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define K\t1000000\n#define L_\t21\t/* L_ = ceil(log2(K * 2 + 1)) */\n#define N_\t(1 << L_)\n#define MD\t998244353\n\nlong long power(long long a, int k) {\n\tlong long p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * a % MD;\n\t\ta = a * a % MD;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint inv(int a) {\n\treturn a == 1 ? 1 : (long long) inv(a - MD % a) * (MD / a + 1) % MD;\n}\n\nint vv[K + 1], ff[K + 1], gg[K + 1];\nint *wu[L_ + 1], *wv[L_ + 1];\n\nvoid init() {\n\tint i, l, u, v;\n\n\tff[0] = gg[0] = 1;\n\tfor (i = 1; i <= K; i++) {\n\t\tvv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;\n\t\tff[i] = (long long) ff[i - 1] * i % MD;\n\t\tgg[i] = (long long) gg[i - 1] * vv[i] % MD;\n\t}\n\tu = power(3, MD - 1 >> L_), v = power(u, MD - 2);\n\tfor (l = L_; l > 0; l--) {\n\t\tint n = 1 << l - 1;\n\n\t\twu[l] = (int *) malloc(n * sizeof *wu[l]);\n\t\twv[l] = (int *) malloc(n * sizeof *wv[l]);\n\t\twu[l][0] = wv[l][0] = 1;\n\t\tfor (i = 1; i < n; i++) {\n\t\t\twu[l][i] = (long long) wu[l][i - 1] * u % MD;\n\t\t\twv[l][i] = (long long) wv[l][i - 1] * v % MD;\n\t\t}\n\t\tu = (long long) u * u % MD, v = (long long) v * v % MD;\n\t}\n}\n\nint choose(int n, int k) {\n\treturn k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nvoid ntt_(int *aa, int l, int inverse) {\n\tif (l > 0) {\n\t\tint n = 1 << l, m = n >> 1, i, j, *ww = inverse ? wv[l] : wu[l];\n\n\t\tntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);\n\t\tfor (i = 0; (j = i + m) < n; i++) {\n\t\t\tint a = aa[i], b = (long long) aa[j] * ww[i] % MD;\n\n\t\t\tif ((aa[i] = a + b) >= MD)\n\t\t\t\taa[i] -= MD;\n\t\t\tif ((aa[j] = a - b) < 0)\n\t\t\t\taa[j] += MD;\n\t\t}\n\t}\n}\n\nvoid ntt(int *aa, int l_, int inverse) {\n\tint n = 1 << l_, i, j;\n\n\tfor (i = 1, j = 0; i < n; i++) {\n\t\tint b, tmp;\n\n\t\tb = n >> 1;\n\t\twhile ((j ^= b) < b)\n\t\t\tb >>= 1;\n\t\tif (i < j)\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tntt_(aa, l_, inverse);\n}\n\nint main() {\n#if 0\n\tstatic int dp[11][11], dq[11][11];\n\tint n = 10, l = 3, i, j, k;\n\n\tinit();\n\tdp[0][0] = 1, dq[0][0] = 0;\n\tfor (i = 1; i <= n; i++) {\n\t\tfor (j = i; j <= n; j++)\n\t\t\tfor (k = 0; k <= j; k++) {\n\t\t\t\tdp[i][j] = (dp[i][j] + (long long) dp[i - 1][k] * choose(j, k)) % MD;\n\t\t\t\tdq[i][j] = (dq[i][j] + (long long) dq[i - 1][k] * choose(j, k) + (long long) dp[i - 1][k] * choose(j, k) % MD * choose(j - k, l)) % MD;\n\t\t\t}\n\t\tprintf(\"(%d %d)\\n\", dp[i][i], dq[i][i]);\n\t}\n\t/* guess: (# of more-equal arrays with a_1 = a_2 = ... = a_l) == (n + 1)^(n - l) */\n#else\n\tstatic int aa[N_], bb[N_];\n\tint n, k, n_, l_, i, v, f, p, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &k);\n\tl_ = 0;\n\twhile (1 << l_ <= k + k)\n\t\tl_++;\n\tn_ = 1 << l_;\n\tfor (i = 0; i <= k; i++)\n\t\taa[i] = (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD;\n\tfor (i = 0; i <= k; i++)\n\t\tbb[i] = power(i, k) * gg[i] % MD;\n\tntt(aa, l_, 0), ntt(bb, l_, 0);\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = (long long) aa[i] * bb[i] % MD;\n\tntt(aa, l_, 1);\n\tv = inv(n_);\n\tfor (i = 0; i < n_; i++)\n\t\taa[i] = (long long) aa[i] * v % MD;\n\tans = 0;\n\tf = 1, p = power(n + 1, n), v = inv(n + 1);\n\tfor (i = 1; i <= k; i++) {\n\t\tf = (long long) f * (n - i + 1) % MD;\n\t\tp = (long long) p * v % MD;\n\t\tans = (ans + (long long) aa[i] * f % MD * p) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n#endif\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "combinatorics", "fft"], "code_uid": "1010e942ca3b6962d9b40c9566c4d284", "src_uid": "bc57a69c39c6e74d6d81a9c504104809", "difficulty": 3300.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t10\n#define INF\t0x3f3f3f3f\n\nint kx[] = { -1, -1, 1, 1, -2, -2, 2, 2 }, ky[] = { -2, 2, -2, 2, -1, 1, -1, 1 };\nint bx[] = { -1, -1, 1, 1 }, by[] = { -1, 1, -1, 1 };\nint rx[] = { -1, 1, 0, 0 }, ry[] = { 0, 0, -1, 1 };\n\nint n, d1[N * N * 3], d2[N * N * 3];\nint qq[N * N * 3], head, cnt;\n\nvoid move(int *xx, int *yy, int i, int j, int h, int m, int l) {\n\tint ijh = (i * n + j) * 3 + h;\n\tint k, g;\n\n\tfor (k = 1; k <= l; k++)\n\t\tfor (g = 0; g < m; g++) {\n\t\t\tint i_ = i + k * xx[g], j_ = j + k * yy[g];\n\n\t\t\tif (i_ >= 0 && i_ < n && j_ >= 0 && j_ < n) {\n\t\t\t\tint ijh_ = (i_ * n + j_) * 3 + h;\n\n\t\t\t\tif (d1[ijh_] > d1[ijh] + 1 || (d1[ijh_] == d1[ijh] + 1 && d2[ijh_] > d2[ijh])) {\n\t\t\t\t\tif (d1[ijh_] == INF)\n\t\t\t\t\t\tqq[head + cnt++] = ijh_;\n\t\t\t\t\td1[ijh_] = d1[ijh] + 1;\n\t\t\t\t\td2[ijh_] = d2[ijh];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n}\n\nvoid bfs(int i, int j, int h) {\n\tint nn3, ijh;\n\n\tnn3 = n * n * 3;\n\tfor (ijh = 0; ijh < nn3; ijh++)\n\t\td1[ijh] = d2[ijh] = INF;\n\thead = cnt = 0;\n\tijh = (i * n + j) * 3 + h;\n\td1[ijh] = d2[ijh] = 0;\n\tqq[head + cnt++] = ijh;\n\twhile (cnt) {\n\t\tint h_, ijh_;\n\n\t\tijh = qq[cnt--, head++];\n\t\ti = ijh / 3 / n; j = ijh / 3 % n, h = ijh % 3;\n\t\tfor (h_ = 0; h_ < 3; h_++) {\n\t\t\tijh_ = ijh / 3 * 3 + h_;\n\t\t\tif (d1[ijh_] > d1[ijh] + 1 || (d1[ijh_] == d1[ijh] + 1 && d2[ijh_] > d2[ijh] + 1)) {\n\t\t\t\tif (d1[ijh_] == INF)\n\t\t\t\t\tqq[head + cnt++] = ijh_;\n\t\t\t\td1[ijh_] = d1[ijh] + 1;\n\t\t\t\td2[ijh_] = d2[ijh] + 1;\n\t\t\t}\n\t\t}\n\t\tif (h == 0)\n\t\t\tmove(kx, ky, i, j, h, 8, 1);\n\t\telse if (h == 1)\n\t\t\tmove(bx, by, i, j, h, 4, n);\n\t\telse\n\t\t\tmove(rx, ry, i, j, h, 4, n);\n\t}\n}\n\nint main() {\n\tstatic int aa[N][N], ii[N * N], jj[N * N];\n\tstatic dp1[3], dp2[3], dq1[3], dq2[3];\n\tint h, h_, i, j, a, ans1, ans2;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < n; j++) {\n\t\t\tscanf(\"%d\", &a); a--;\n\t\t\taa[i][j] = a;\n\t\t\tii[a] = i, jj[a] = j;\n\t\t}\n\tfor (a = 0; a < n * n - 1; a++) {\n\t\ti = ii[a + 1], j = jj[a + 1];\n\t\tfor (h = 0; h < 3; h++)\n\t\t\tdq1[h] = dq2[h] = INF;\n\t\tfor (h = 0; h < 3; h++) {\n\t\t\tbfs(ii[a], jj[a], h);\n\t\t\tfor (h_ = 0; h_ < 3; h_++) {\n\t\t\t\tint d1_ = d1[(i * n + j) * 3 + h_], d2_ = d2[(i * n + j) * 3 + h_];\n\n\t\t\t\tif (dq1[h_] > dp1[h] + d1_ || (dq1[h_] == dp1[h] + d1_ && dq2[h_] > dp2[h] + d2_)) {\n\t\t\t\t\tdq1[h_] = dp1[h] + d1_;\n\t\t\t\t\tdq2[h_] = dp2[h] + d2_;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (h = 0; h < 3; h++) {\n\t\t\tdp1[h] = dq1[h];\n\t\t\tdp2[h] = dq2[h];\n\t\t}\n\t}\n\tans1 = ans2 = INF;\n\tfor (h = 0; h < 3; h++)\n\t\tif (ans1 > dp1[h] || (ans1 == dp1[h] && ans2 > dp2[h])) {\n\t\t\tans1 = dp1[h];\n\t\t\tans2 = dp2[h];\n\t\t}\n\tprintf(\"%d %d\\n\", ans1, ans2);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dfs and similar", "dp", "shortest paths"], "code_uid": "18d0f08d8bd5c384f0b4d0b179d1fe0f", "src_uid": "5fe44b6cd804e0766a0e993eca1846cd", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\ntypedef struct {\n int l, r;\n} interval;\n\nint max(int x, int y) {\n return x > y ? x : y;\n}\n\nint min(int x, int y) {\n return x < y ? x : y;\n}\n\nint interval_intersection_length(const interval *a, const interval *b) {\n return max(0, min(a->r, b->r) - max(a->l, b->l) + 1);\n}\n\nvoid extract(const interval *a, interval *a1, interval *a2, int i) {\n int s = 1 << i;\n int x = (a->l + s - 1) >> i << i;\n int y = a->r >> i << i;\n if (x < y) {\n a1->l = a2->l = 1;\n a1->r = a2->r = s - 1;\n } else if (x == y) {\n a1->l = a->l % s;\n if (a1->l == 0) a1->l = s;\n a1->r = s - 1;\n a2->l = 1;\n a2->r = a->r % s;\n } else {\n a1->l = a2->l = a->l % s;\n a1->r = a2->r = a->r % s;\n }\n}\n\nint main() {\n int i, ans;\n interval a, b, a1, a2, b1, b2;\n scanf(\"%d %d %d %d\", &a.l, &a.r, &b.l, &b.r);\n ans = 0;\n for (i = 1; i <= 30; i++) {\n extract(&a, &a1, &a2, i);\n extract(&b, &b1, &b2, i);\n ans = max(ans, interval_intersection_length(&a1, &b1));\n ans = max(ans, interval_intersection_length(&a1, &b2));\n ans = max(ans, interval_intersection_length(&a2, &b1));\n ans = max(ans, interval_intersection_length(&a2, &b2));\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["divide and conquer"], "code_uid": "0d780560319d832c3bd77c73272f1e1f", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t35\n#define K\t(1 << ((N + 1) / 2))\n\nint compare(const void *a, const void *b) {\n\tint ia = *(int *) a;\n\tint ib = *(int *) b;\n\n\treturn ia - ib;\n}\n\nint main() {\n\tstatic int aa[N], ss[K], tt[K];\n\tint n, m, k1, k2, h, i, j, b, s, max;\n\n\tscanf(\"%d%d\", &n, &m);\n\th = n / 2;\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tk1 = 1 << h;\n\tfor (b = 0; b < k1; b++) {\n\t\ts = 0;\n\t\tfor (i = 0; i < h; i++)\n\t\t\tif (b & 1 << i)\n\t\t\t\ts = (s + aa[i]) % m;\n\t\tss[b] = s;\n\t}\n\tqsort(ss, k1, sizeof *ss, compare);\n\tk2 = 1 << (n - h);\n\tfor (b = 0; b < k2; b++) {\n\t\ts = 0;\n\t\tfor (i = h; i < n; i++)\n\t\t\tif (b & 1 << (i - h))\n\t\t\t\ts = (s + aa[i]) % m;\n\t\ttt[b] = s;\n\t}\n\tqsort(tt, k2, sizeof *tt, compare);\n\tmax = 0;\n\tfor (i = 0, j = k2 - 1; i < k1; i++) {\n\t\twhile (j >= 0 && ss[i] + tt[j] >= m)\n\t\t\tj--;\n\t\tif (j >= 0 && max < ss[i] + tt[j])\n\t\t\tmax = ss[i] + tt[j];\n\t}\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["meet-in-the-middle", "divide and conquer", "bitmasks"], "code_uid": "97ad905df092c025fec0aa8ca856248c", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t75\n#define M\t20\t/* sum_{i=1}^M bitcount(i) <= N */\n#define MD\t1000000007\n\nint main() {\n\tstatic char cc[N + 1];\n\tstatic int dp[N + 1][1 << M];\n\tint n, h, i, i_, j, b, b_, a, ans, x;\n\n\tscanf(\"%d%s\", &n, cc);\n\tfor (i = 0; i <= n; i++)\n\t\tdp[i][0] = 1;\n\tans = 0;\n\tfor (i = 0, j = 0; i <= n; i++) {\n\t\tfor (h = 1; h < M; h++)\n\t\t\tans = (ans + dp[i][(1 << h) - 1]) % MD;\n\t\tif (j < i)\n\t\t\tj = i;\n\t\twhile (j < n && cc[j] != '1')\n\t\t\tj++;\n\t\tif (j == n)\n\t\t\tcontinue;\n\t\tfor (b = 0; b < 1 << M; b++) {\n\t\t\tx = dp[i][b];\n\t\t\tif (x == 0)\n\t\t\t\tcontinue;\n\t\t\ta = 0;\n\t\t\tfor (h = 0; j + h < n && (a = a << 1 | cc[j + h] - '0') <= M; h++) {\n\t\t\t\ti_ = j + h + 1;\n\t\t\t\tb_ = b | 1 << a - 1;\n\t\t\t\tdp[i_][b_] = (dp[i_][b_] + x) % MD;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "bitmasks"], "code_uid": "2c50a0d6e404e5cc45f09dbc61c0caf1", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define m 1000000007u\ntypedef unsigned u;\nu D[76][1u<<20],S[1u<<20];\nchar C[76];\nu V[76][76];\nint main()\n{\n\tu n,i,j,k,N=1u<<20,b,r=0;\n\tscanf(\"%u\",&n);\n\tscanf(\"%s\",C);\n\tfor(i=-1;++i20)break;\n\t\t\tb=1u<<(V[i][j]-1);\n\t\t\tfor(k=-1;++k=m)D[j+1][k|b]-=m;\n\t\t}\n\t}\n\tfor(i=-1;++i<=n;)\n\t{\n\t\tfor(j=1;j=m)r-=m;\n\t}\n\tprintf(\"%u\\n\",r);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "bitmasks"], "code_uid": "6336b14ee8e0c69eb404c246cfa3d107", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\nint main(){\n\t\n\tint n,m;\n\tscanf(\"%d %d\",&n,&m);\n\tint b;\n\tif(n>m){\n\t\tb=n;\n\t\tn=m;\n\t\tm=b;\n\t}\n\tif(n==1){\n\t\tint mo=m%6;\n\t\tswitch(mo){\n\t\t\tcase 0:printf(\"%d\\n\",m);break;\n\t\t\tcase 1:printf(\"%d\\n\",m-mo);break;\n\t\t\tcase 2:printf(\"%d\\n\",m-mo);break;\n\t\t\tcase 3:printf(\"%d\\n\",m-mo);break;\n\t\t\tcase 4:printf(\"%d\\n\",m-2);break;\n\t\t\tcase 5:printf(\"%d\\n\",m-1);\n\t\t}\n\t}\n\telse if(n==2){\n\t\tif(m==2){\n\t\t\tprintf(\"%d\\n\",0);\n\t\t}\n\t\telse if(m==3){\n\t\t\tprintf(\"%d\\n\",4);\n\t\t}\n\t\telse if(m==7){\n\t\t\tprintf(\"%d\\n\",12);\n\t\t}\n\t\telse{\n\t\t\tprintf(\"%d\\n\",n*m);\n\t\t}\n\t}\n\telse{\n\t\tlong long mul=n;\n\t\tmul*=m;\n\t\tif(mul%2==0){\n\t\t\tprintf(\"%lld\\n\",mul);\n\t\t}\n\t\telse{\n\t\t\tprintf(\"%lld\\n\",mul-1);\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "constructive algorithms", "flows", "graph matchings"], "code_uid": "a08c0b9666fadc0e2391d2cb2aad5c2b", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.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\nchar str[77];\nint n, vmax, kmax, xmax, ar[77], dp[77][77][77][3];\n\nint fill(char visited[77], int c, int d){\n\tint i, x = 0;\n\tfor (i = 0; i < n; i++){\n\t\tif (ar[i] == d){\n\t\t\tif (x == c) return i;\n\t\t\tx++;\n\t\t\tvisited[i] = 1;\n\t\t}\n\t}\n\treturn n;\n}\n\nint swap_count(int index, char visited[77]){\n\tint i, res = 0;\n\tfor (i = 0; i < index; i++){\n\t\tif (!visited[i]) res++;\n\t}\n\treturn res;\n}\n\nint F(int v, int k, int x, int l){\n\tif (v == vmax && k == kmax && x == xmax) return 0;\n\tif (dp[v][k][x][l] != -1) return dp[v][k][x][l];\n\t\n\tchar visited[77] = {0};\n\tint a, b, c, r, res = 1 << 20;\n\ta = fill(visited, v, 0);\n\tb = fill(visited, k, 1);\n\tc = fill(visited, x, 2);\n\t\n\tif (v != vmax){\n\t\tr = F(v + 1, k, x, 0) + swap_count(a, visited);\n\t\tif (r < res) res = r;\n\t}\n\tif (k != kmax && l != 0){\n\t\tr = F(v, k + 1, x, 1) + swap_count(b, visited);\n\t\tif (r < res) res = r;\n\t}\n\tif (x != xmax){\n\t\tr = F(v, k, x + 1, 2) + swap_count(c, visited);\n\t\tif (r < res) res = r;\n\t}\n\t\n\treturn (dp[v][k][x][l] = res);\n}\n\nint main(){\n\tint i, res;\n\t\n\twhile (scanf(\"%d\", &n) != EOF){\n\t\tscanf(\"%s\", str);\n\t\tfor (i = 0; i < n; i++){\n\t\t\tar[i] = 2;\n\t\t\tif (str[i] == 'V') ar[i] = 0;\n\t\t\tif (str[i] == 'K') ar[i] = 1;\n\t\t\tvmax += (ar[i] == 0);\n\t\t\tkmax += (ar[i] == 1);\n\t\t\txmax += (ar[i] == 2);\n\t\t}\n\t\t\n\t\tmemset(dp, -1, sizeof(dp));\n\t\tres = F(0, 0, 0, 2);\n\t\tprintf(\"%d\\n\", res);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "90072f1749919634f5a095b27f099c83", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "/* http://catb.org/esr/intercal/ick.htm */\n/* find xor of largest and last array elements */\n#include \n\n#define N\t10\n\nint main() {\n\tstatic int aa[N];\n\tint n, i, max;\n\n\tscanf(\"%d\", &n);\n\tmax = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &aa[i]);\n\t\tif (max < aa[i])\n\t\t\tmax = aa[i];\n\t}\n\tprintf(\"%d\\n\", max ^ aa[n - 1]);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "5cc0af7283f555e53fcf3ddd274a691c", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#import\n#define swap(a,b) (a)^=(b)^=(a)^=(b)\n#define max(a,b) ((a)>(b)?(a):(b))\n#define min(a,b) ((a)<(b)?(a):(b))\nlong long gcd(long long a,long long b) {return !b?a:gcd(b,a%b);}\nint main()\n{\n\tlong long l1,r1,t1,l2,r2,t2;\n\tscanf(\"%lld%lld%lld%lld%lld%lld\",&l1,&r1,&t1,&l2,&r2,&t2);\n\tif (l1>l2) swap(l1,l2),swap(r1,r2),swap(t1,t2);\n\tlong long k=gcd(t1,t2),p,ans=0;\n\tp=(l2-l1)/k;l1+=k*p,r1+=k*p;\n\tans=max(ans,(min(r1,r2)-max(l1,l2))+1);\n\tl1+=k,r1+=k;\n\tans=max(ans,(min(r1,r2)-max(l1,l2))+1);\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "c60b9ace8829e9907c8d0791bb942817", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define N 1050000\n#define M 2300000\n#define T 1048576\nint n,m;\nint first[M];\nint second[M];\nint last[N];\nint wei[N];\nint pei[N];\nint ans[N];\nvoid add(int a[],int x)\n{\n x+=T-1;\n while(x)\n {\n a[x]++;\n x>>=1;\n }\n}\nvoid del(int a[],int x)\n{\n x+=T-1;\n while(x)\n {\n a[x]--;\n x>>=1;\n }\n}\nint find(int a[],int now,int l,int r,int x)\n{\n if(l==r)\n return l;\n int mid=(l+r)/2;\n if(x<=a[now<<1])\n return( find(a,now<<1,l,mid,x) );\n return( find(a,now*2+1,mid+1,r,x-a[now<<1]) );\n}\nint main()\n{\n int i,a,b;\n scanf(\"%d%d\",&n,&m);\n for(i=1;i<=n;i++)\n add(second,i);\n for(i=1;i<=m;i++)\n {\n scanf(\"%d%d\",&a,&b);\n if(first[1]>=b)\n b=wei[find(first,1,1,T,first[1]-b+1)];\n else\n b=find(second,1,1,T,b-first[1]);\n if(ans[b]==a)\n {\n wei[i]=b;\n del(first,last[b]);\n last[b]=i;\n add(first,i);\n continue;\n }\n if(ans[b] || pei[a])\n {\n printf(\"-1\\n\");\n return 0;\n }\n ans[b]=a;\n pei[a]=b;\n last[b]=i;\n wei[i]=b;\n del(second,b);\n add(first,i);\n }\n int now=0;\n for(i=1;i<=n;i++)\n if(!ans[i])\n {\n now++;\n while(pei[now])\n now++;\n ans[i]=now;\n }\n for(i=1;i\n#include\n\ntypedef long long LL;\nbool inuse[10];\nint x[2][10], y[2][10], R, B, guarding[10];\n\nlong long cprodukt(int x1, int y1, int x2, int y2, int x3, int y3){\n\treturn (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);\n}\n\nbool cross(int g1, int s1, int g2, int s2){\n\treturn (\n\t\tcprodukt(x[0][g1], y[0][g1], x[1][s1], y[1][s1], x[0][g2], y[0][g2])\n\t\t*\n\t\tcprodukt(x[0][g1], y[0][g1], x[1][s1], y[1][s1], x[1][s2], y[1][s2])\n\t\t<0)\n\t\t&&\n\t\t(\n\t\tcprodukt(x[0][g2], y[0][g2], x[1][s2], y[1][s2], x[0][g1], y[0][g1])\n\t\t*\n\t\tcprodukt(x[0][g2], y[0][g2], x[1][s2], y[1][s2], x[1][s1], y[1][s1])\n\t\t<0);\n}\n\nbool pos(int d){\n\tif(d==R) return true;\n\tfor(int i=0;i\n\nint main() {\n\tint x1, x2, x, a, b, r, tmp, flipped;\n\n\tscanf(\"%d%d%d%d\", &x1, &x2, &a, &b);\n\tx = x2 - x1;\n\tif (x >= a && x <= b) {\n\t\tprintf(\"FIRST\\n\");\n\t\tprintf(\"%d\\n\", x2);\n\t\treturn 0;\n\t}\n\tflipped = 0;\n\tif (x < 0) {\n\t\tx = -x;\n\t\tflipped = 1;\n\t\ttmp = a, a = -b, b = -tmp;\n\t}\n\tif (a <= 0) {\n\t\tprintf(\"DRAW\\n\");\n\t\treturn 0;\n\t}\n\tr = x % (a + b);\n\tif (r == 0) {\n\t\tprintf(\"SECOND\\n\");\n\t\treturn 0;\n\t}\n\tif (r < a || r > b) {\n\t\tprintf(\"DRAW\\n\");\n\t\treturn 0;\n\t}\n\tprintf(\"FIRST\\n\");\n\tprintf(\"%d\\n\", x1 + (flipped ? -r : r));\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "games"], "code_uid": "798db58060584ffb32fddd839535ae54", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\nint a[10][260]=\n{\n{0},\n{2,1},\n{32,30,80,109},\n{6824,59808,147224,415870,1757896,1897056,4898872,7593125},\n{776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593},\n{261086313,584837659,683961846,468868529,211593382,736955478,229471758,157617135,398169441,360252438,629394768,264125799,647490480,342079395,391579767,225200475,486011304,513156108,628771752,132906648,142138221,20119449,444199674,195188679,387329805,44684703,651912135,737154512,612549793,519860281,186175544,212568440},\n{240805271,239509872,581127897,6511239,156126222,509425833,672407328,366667722,459185405,509737025,554790222,165216555,703150560,74806569,398730015,383350905,506108358,51326142,298053147,104256117,391428765,374020479,206607807,87664059,275899176,56407680,551553401,448939463,582889860,129676638,226078251,135769095,61292868,578972226,190181628,390739055,184587732,446575689,732674124,232198470,676760679,352474101,611444862,575661807,628905585,320813094,522840969,469781928,156006018,554473341,239654268,643714911,433540170,199307003,496385218,291740751,67309914,370826673,202356819,279421821,421203111,63744786,520987612,550671827},\n{482164403,768209115,462063756,154906374,36099042,341766705,678182556,621882744,478771358,231881111,175889805,243630450,168908523,671961765,55761813,652682670,773939082,517628076,756201264,124604900,750976272,498253248,676047609,137170026,705610017,495032139,561797418,703097347,500815609,95984586,739707108,265613565,387099846,777331779,594676173,591219559,407997044,208947235,93337440,478908360,685013007,487033953,671903001,39521181,738490312,33785059,465470131,310453920,54648783,346831137,427694175,474743430,705296781,435828036,429824745,663532359,261388683,244690731,533997135,596108961,506813013,371892402,590145264,104733162,143420103,654339672,700348950,685038942,578826927,286484229,501639192,434962491,299270097,27702486,335375775,111746817,565603164,294926121,676063665,735862995,710035809,437011960,668528077,138765186,508213986,615036450,353784942,624827616,343900011,241289776,52410890,72018835,352406796,415705878,4802637,376367145,65589678,333633477,341834527,303717460,282387700,42951006,254706039,423048528,526429710,68131467,669954708,12787348,500636381,317959019,479433192,657133515,416259390,610216692,340129188,44594256,257373347,138718678,530767740,292922628,37220268,605295159,480722613,458170419,30540300,487159055,232966794,149150650},\n{412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421}\n};\nint main()\n{\n int n,k;\n scanf(\"%d %d\",&n,&k);\n int p=0;\n while ((1<\n#define N 1000005\nconst int P=998244353;\nlong long inv[N];\nlong long ex(long long b, int i) {\n\tlong long p=1;\n\tfor(; i; i>>=1, b=b*b%P) if(i&1) p=p*b%P;\n\treturn p;\n}\nint main() {\n\tint n, i, ans, binom, power;\n\tscanf(\"%d\", &n);\n\tinv[1]=1;\n\tfor(i=2; i<=n; ++i) inv[i]=inv[P%i]*(P-P/i)%P;\n\tpower=ex(3,n);\n\tans=(ex((power+P-1)%P,n)*3-ex((power+P-3)%P,n)*2%P+P-ex(power,n)+P)%P;\n\tbinom=n&1?1:-1;\n\tpower=1;\n\tfor(i=0; i\n\n#define N\t2021\n#define M\t2021\n#define MD\t998244353\n\nint vv[N + M + 1], ff[N + M + 1], gg[N + M + 1];\n\nvoid init() {\n\tint i;\n\n\tff[0] = gg[0] = 1;\n\tfor (i = 1; i <= N + M; i++) {\n\t\tvv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;\n\t\tff[i] = (long long) ff[i - 1] * i % MD;\n\t\tgg[i] = (long long) gg[i - 1] * vv[i] % MD;\n\t}\n}\n\nint choose(int n, int k) {\n\treturn k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\n}\n\nint main() {\n\tstatic int xx[N][M], dp[N], dq[N];\n\tint n, m, i, j, x, ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = 0; j < m; j++)\n\t\t\txx[i][j] = choose(i + j, j);\n\tans = 0;\n\tfor (j = 1; j < m; j++) {\n\t\tx = 0;\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tif ((x += xx[i][j - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdp[i] = (long long) x * xx[n - 1 - i][j - 1] % MD;\n\t\t}\n\t\tx = 0;\n\t\tfor (i = n - 1; i >= 0; i--) {\n\t\t\tif ((x += xx[n - 1 - i][m - j - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdq[i] = (long long) x * xx[i][m - j - 1] % MD;\n\t\t}\n\t\tfor (i = 1; i < n; i++)\n\t\t\tif ((dp[i] += dp[i - 1]) >= MD)\n\t\t\t\tdp[i] -= MD;\n\t\tfor (i = 0; i + 1 < n; i++)\n\t\t\tif ((ans += (long long) dp[i] * dq[i + 1] % MD) >= MD)\n\t\t\t\tans -= MD;\n\t\tx = 0;\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tif ((x += xx[i][m - j - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdp[i] = (long long) x * xx[n - 1 - i][m - j - 1] % MD;\n\t\t}\n\t\tx = 0;\n\t\tfor (i = n - 1; i >= 0; i--) {\n\t\t\tif ((x += xx[n - 1 - i][j - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdq[i] = (long long) x * xx[i][j - 1] % MD;\n\t\t}\n\t\tfor (i = 1; i < n; i++)\n\t\t\tif ((dp[i] += dp[i - 1]) >= MD)\n\t\t\t\tdp[i] -= MD;\n\t\tfor (i = 0; i + 1 < n; i++)\n\t\t\tif ((ans += (long long) dp[i] * dq[i + 1] % MD) >= MD)\n\t\t\t\tans -= MD;\n\t}\n\tfor (j = 0; j < m; j++)\n\t\tfor (i = 0; i < n; i++)\n\t\t\txx[j][i] = choose(j + i, i);\n\tfor (i = 1; i < n; i++) {\n\t\tx = 0;\n\t\tfor (j = 0; j < m; j++) {\n\t\t\tif ((x += xx[j][i - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdp[j] = (long long) x * xx[m - 1 - j][i - 1] % MD;\n\t\t}\n\t\tx = 0;\n\t\tfor (j = m - 1; j >= 0; j--) {\n\t\t\tif ((x += xx[m - 1 - j][n - i - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdq[j] = (long long) x * xx[j][n - i - 1] % MD;\n\t\t}\n\t\tfor (j = 1; j < m; j++)\n\t\t\tif ((dp[j] += dp[j - 1]) >= MD)\n\t\t\t\tdp[j] -= MD;\n\t\tfor (j = 0; j + 2 < m; j++)\n\t\t\tif ((ans += (long long) dp[j] * dq[j + 2] % MD) >= MD)\n\t\t\t\tans -= MD;\n\t\tx = 0;\n\t\tfor (j = 0; j < m; j++) {\n\t\t\tif ((x += xx[j][n - i - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdp[j] = (long long) x * xx[m - 1 - j][n - i - 1] % MD;\n\t\t}\n\t\tx = 0;\n\t\tfor (j = m - 1; j >= 0; j--) {\n\t\t\tif ((x += xx[m - 1 - j][i - 1]) >= MD)\n\t\t\t\tx -= MD;\n\t\t\tdq[j] = (long long) x * xx[j][i - 1] % MD;\n\t\t}\n\t\tfor (j = 1; j < m; j++)\n\t\t\tif ((dp[j] += dp[j - 1]) >= MD)\n\t\t\t\tdp[j] -= MD;\n\t\tfor (j = 0; j + 2 < m; j++)\n\t\t\tif ((ans += (long long) dp[j] * dq[j + 2] % MD) >= MD)\n\t\t\t\tans -= MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "33d263269453e30229a5c60b24062bff", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \nint checkIsLucky(int num){\n while(num>0){\n if(num%10!=4&&num%10!=7)return 0;\n num/=10;\n }\n return 1;\n}\nint nextNum(int num){\n int nextN;\n int count=1;\n int maxNextD=0;\n nextN=num;\n if(num>=777777777) return 1000000001;\n while(num>0){\n if(num%10==4){\n nextN+=count*3;\n nextN=nextN/(count)*count+maxNextD;\n break;\n }else{\n maxNextD*=10;\n maxNextD+=4;\n num/=10;\n count*=10;\n }\n }\n if(num>0) return nextN;\n else{\n maxNextD*=10;\n maxNextD+=4;\n return maxNextD;\n }\n}\n\nint max(int a,int b){\n if(a>b) return a;\n else return b;\n}\nint min(int a,int b){\n if(a>b) return b;\n else return a;\n}\nint kthNum(int begin,int k){\n int count=1;\n int rt=0,tmp=begin;\n while (tmp>0) {\n tmp/=10;\n rt*=10;\n rt+=4;\n }\n while(rt=vl&&i<=vr) sum-=1;\n getchar();\n }\n }\n lk1= kthNum(pl,k);\n lk2= nextNum(lk1);\n i=pl;\n for(;i<=pr;){//xet tat ca cac chu so trong [pl+1,pr]\n sum+=lenthRt(vl,vr,lk1,lk2)*min(after-i+1,pr-i+1);\n //printf(\"%d to %d-> %d %d + them %lf*%d->%lf\\n\",i,after,lk1,lk2,lenthRt(vl,vr,lk1,lk2),min(after-i+1,pr-i+1),sum);\n\n i=after+1;\n after=nextNum(after);\n lk1=lk2;\n if(lk1>vr) break;\n lk2=nextNum(lk2);\n }\n //if k==1\n \n //for p\n after=kthNum(vl,1);\n lk1= kthNum(vl,k);\n lk2= nextNum(lk1);\n i=vl;\n for(;i<=vr;){//xet tat ca cac chu so trong [pl+1,pr]\n //if(vl==vr&&pl==pr&&pl==vr) break;\n sum+=lenthRt(pl,pr,lk1,lk2)*min(after-i+1,vr-i+1);\n //printf(\"%d to %d-> %d %d + them %lf*%d ->%lf\\n\",i,after,lk1,lk2,lenthRt(pl,pr,lk1,lk2),min(after-i+1,pr-i+1),sum);\n \n i=after+1;\n after=nextNum(after);\n lk1=lk2;\n if(lk1>pr) break;\n lk2=nextNum(lk2);\n }\n mau=(pr-pl+1);\n mau*= (vr-vl+1);\n //printf(\"%lf %lf\");\n //printf(\"%lf %lf\\n\",sum,mau);\n kq=sum/mau;\n \n printf(\"%.12lf\",kq);\n return 0;\n}", "lang_cluster": "C", "tags": ["dfs and similar", "probabilities", "combinatorics", "brute force"], "code_uid": "48b4130c977154f834cce88f1b3f40e1", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nchar mp[9][9];\nint dir;\nint n,m,x,y;\nint get_dis(int dir){\n if(dir==0&&y==m)return 100;\n if(dir==1&&x==n)return 100;\n if(dir==0){\n for(int i=y+1;i<=m;i++)\n if(mp[x][i]=='*')return i-y;\n }else\n for(int i=x+1;i<=n;i++)\n if(mp[i][y]=='*')return i-x;\t\n return 100;\n}\n\nint main(void){\n scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=n;i++)scanf(\"%s\",mp[i]+1);\n dir=0;\n int ans=0;\n x=1;y=1;\n for(int i=0;iget_dis(!dir)){\n if(dir==0)\n\tx++;\n else\n\ty++;\n dir=!dir;\n }else{\n y++;\n }\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation", "shortest paths"], "code_uid": "472d70aa5dc7c508d890a0d571251692", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t5\n#define M\t5\n\nint main() {\n\tstatic char cc[N][M + 1];\n\tint n, m, i, j, i_, j_, k;\n\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%s\", cc[i]);\n\ti_ = 0, j_ = 0, k = 0;\n\twhile (1) {\n\t\tint i1, j1, d;\n\n\t\ti1 = -1, j1 = -1, d = n + m + 1;\n\t\tfor (i = i_; i < n; i++)\n\t\t\tfor (j = j_; j < m; j++)\n\t\t\t\tif (cc[i][j] == '*' && d > i + j)\n\t\t\t\t\td = i + j, i1 = i, j1 = j;\n\t\tif (i1 == -1 && j1 == -1)\n\t\t\tbreak;\n\t\tcc[i1][j1] = '.', i_ = i1, j_ = j1, k++;\n\t}\n\tprintf(\"%d\\n\", k);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["greedy", "implementation", "shortest paths"], "code_uid": "6cf818ec9d31a99787d3c7f3ad47c49f", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define N\t8\n\nint compare(const void *a, const void *b) {\n\tlong long la = *(long long *) a;\n\tlong long lb = *(long long *) b;\n\n\treturn la == lb ? 0 : la < lb ? -1 : 1;\n}\n\nlong long aa[N], aa_[N];\nint bb[N], dp[N][1 << (N - 1)];\nchar pp[N];\nint n, ans = 0x3f3f3f3f;\n\nvoid solve(int i) {\n\tint j;\n\n\tif (i == n) {\n\t\tint cnt, sum;\n\n\t\tcnt = 0, sum = 0;\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tint k;\n\n\t\t\tif (!pp[i])\n\t\t\t\tcnt++;\n\t\t\tk = dp[i][bb[i]];\n\t\t\tsum += k == 1 && bb[i] == 0 ? 1 : k + 1;\n\t\t}\n\t\tif (cnt >= 2)\n\t\t\tsum++;\n\t\tif (ans > sum)\n\t\t\tans = sum;\n\t\treturn;\n\t}\n\tsolve(i + 1);\n\tpp[i] = 1;\n\tfor (j = i + 1; j < n; j++)\n\t\tif (aa_[j] % aa[i] == 0) {\n\t\t\taa_[j] /= aa[i], bb[j] ^= 1 << i;\n\t\t\tsolve(i + 1);\n\t\t\taa_[j] *= aa[i], bb[j] ^= 1 << i;\n\t\t}\n\tpp[i] = 0;\n}\n\nint main() {\n\tint i, j;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%lld\", &aa[i]);\n\tqsort(aa, n, sizeof *aa, compare);\n\tfor (i = 0; i < n; i++) {\n\t\tlong long a;\n\t\tint k, p, b;\n\n\t\ta = aa[i];\n\t\tk = 0;\n\t\tfor (p = 2; p <= a / p; p++)\n\t\t\twhile (a % p == 0) {\n\t\t\t\tk++;\n\t\t\t\ta /= p;\n\t\t\t}\n\t\tif (a > 1)\n\t\t\tk++;\n\t\tdp[i][0] = k;\n\t\tfor (b = 1; b < 1 << i; b++) {\n\t\t\ta = aa[i];\n\t\t\tk = dp[i][0];\n\t\t\tfor (j = 0; j < i; j++)\n\t\t\t\tif ((b & 1 << j)) {\n\t\t\t\t\tif (a % aa[j] != 0) {\n\t\t\t\t\t\tk = -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\ta /= aa[j];\n\t\t\t\t\tk -= dp[j][0];\n\t\t\t\t}\n\t\t\tdp[i][b] = k;\n\t\t}\n\t}\n\tfor (i = 0; i < n; i++)\n\t\taa_[i] = aa[i];\n\tsolve(0);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["brute force", "dp", "number theory"], "code_uid": "83e96bf40a490dc772fee8fe577a2333", "src_uid": "52b8b6c68518d5129272b8c56e5b7662", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define A\t5000\n#define N_\t(A * 3)\n#define INF\t0x3f3f3f3f3f3f3f3fLL\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\n\nint oo[1 + (N_ - 1) * 2], oj[1 + (N_ - 1) * 2];\n\nint link(int o, int j) {\n\tstatic int _ = 1;\n\n\too[_] = o, oj[_] = j;\n\treturn _++;\n}\n\nint count(int n, int p) {\n\treturn n < p ? 0 : n / p + count(n / p, p);\n}\n\nint ae[N_], pp[N_], dd[N_], sz[N_], ii[A + 1], n;\n\nvoid init() {\n\tstatic char composite[A + 1];\n\tstatic int primes[A + 1];\n\tint n_, a, b, cnt, i, j;\n\n\tfor (a = 2; a <= A / a; a++) {\n\t\tif (composite[a])\n\t\t\tcontinue;\n\t\tfor (b = a * a; b <= A; b += a)\n\t\t\tcomposite[b] = 1;\n\t}\n\tcnt = 0;\n\tfor (a = 2; a <= A; a++)\n\t\tif (!composite[a])\n\t\t\tprimes[cnt++] = a;\n\tn_ = 0;\n\tpp[n_] = -1, dd[n_] = 0;\n\tii[1] = n_++;\n\tfor (a = 2; a <= A; a++) {\n\t\tint h, d, d_;\n\n\t\td = 0;\n\t\tfor (h = 0; h < cnt; h++)\n\t\t\td += count(a, primes[h]);\n\t\td_ = 0;\n\t\tfor (h = cnt - 1; h >= 0; h--) {\n\t\t\td_ += count(a - 1, primes[h]);\n\t\t\tif (a % primes[h] == 0)\n\t\t\t\tbreak;\n\t\t}\n\t\ti = ii[a - 1], j = -1;\n\t\twhile (1)\n\t\t\tif (dd[i] > d_)\n\t\t\t\tj = i, i = pp[i];\n\t\t\telse if (dd[i] == d_) {\n\t\t\t\tpp[n_] = i, dd[n_] = d, n_++;\n\t\t\t\tii[a] = n_ - 1;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tint k = n_++;\n\n\t\t\t\tpp[k] = i, dd[k] = d_;\n\t\t\t\tif (j != -1)\n\t\t\t\t\tpp[j] = k;\n\t\t\t\tpp[n_] = k, dd[n_] = d, n_++;\n\t\t\t\tii[a] = n_ - 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tfor (j = 1; j < n_; j++) {\n\t\ti = pp[j];\n\t\tae[i] = link(ae[i], j), ae[j] = link(ae[j], i);\n\t}\n}\n\nlong long dfs1(int p, int i) {\n\tint o;\n\tlong long x;\n\n\tx = (long long) sz[i] * dd[i];\n\tfor (o = ae[i]; o; o = oo[o]) {\n\t\tint j = oj[o];\n\t\t\n\t\tif (j != p) {\n\t\t\tx += dfs1(i, j);\n\t\t\tsz[i] += sz[j];\n\t\t}\n\t}\n\treturn x;\n}\n\nlong long ans;\n\nvoid dfs2(int p, int i, long long x) {\n\tint o;\n\n\tans = min(ans, x);\n\tfor (o = ae[i]; o; o = oo[o]) {\n\t\tint j = oj[o];\n\n\t\tif (j != p) {\n\t\t\tint w = abs(dd[i] - dd[j]);\n\n\t\t\tdfs2(i, j, x - (long long) sz[j] * w + (long long) (n - sz[j]) * w);\n\t\t}\n\t}\n}\n\nint main() {\n\tint i;\n\n\tinit();\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++) {\n\t\tint a;\n\n\t\tscanf(\"%d\", &a);\n\t\tsz[ii[a > 0 ? a : 1]]++;\n\t}\n\tans = INF;\n\tdfs2(-1, 0, dfs1(-1, 0));\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "trees", "dp", "graphs", "number theory"], "code_uid": "7dc31c4ebd8fcddc4f78c13a01d25ccf", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#include\n#include\n\ntypedef struct node{\n int v;\n struct node *next;\n} NODE;\n\nchar f[100000];\n\nvoid dfs(int n, NODE *e[], char v[], int mode){\n v[n] = 1;\n if (!mode && f[n] == 1)return;\n NODE *tmp = e[n];\n while (tmp){\n if (!v[tmp->v] && !(mode && f[tmp->v] == 1))\n dfs(tmp->v, e, v, mode);\n tmp = tmp->next;\n }\n return;\n}\n\nint main(){\n int n, m, i, j, x, y;\n char f1 = 0, f2 = 0, v1[100000] = {}, v2[100000] = {};\n NODE *e[100000] = {}, *b[100000] = {}, *tmp;\n scanf(\"%d%d\", &n, &m);\n for (i = 0 ; i < n ; ++i){\n scanf(\"%d\", f + i);\n if (f[i] == 1)f1 = 1;\n else if (f[i] == 2)f2 = 1;\n }\n if (!f1 || !f2){\n while (n--)puts(\"0\");\n return 0;\n }\n \n for (i = 0 ; i < m ; ++i){\n scanf(\"%d%d\", &x, &y);\n --x, --y;\n tmp = calloc(1, sizeof(NODE));\n tmp->v = y, tmp->next = e[x], e[x] = tmp;\n tmp = calloc(1, sizeof(NODE));\n tmp->v = x, tmp->next = b[y], b[y] = tmp;\n }\n for (i = 0 ; i < n ; ++i)\n if (f[i] == 1)\n dfs(i, e, v1, 1);\n for (i = 0 ; i < n ; ++i)\n if (f[i] == 2)\n dfs(i, b, v2, 0);\n for (i = 0 ; i < n ; ++i)\n printf(\"%d\\n\", v1[i] && v2[i]);\n scanf(\" \");\n return 0;\n}\n", "lang_cluster": "C", "tags": ["graphs"], "code_uid": "b7ea9a155889c8505aeb73905332cb54", "src_uid": "87d869a0fd4a510c5e7e310886b86a57", "difficulty": 1700.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n \r\n#define N\t100000\r\n \r\nint md;\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[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 k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % md * gg[n - k] % md;\r\n}\r\n \r\nint aa[N], cnt;\r\n \r\nvoid brute(int i, int n) {\r\n\tif (i == n) {\r\n\t\tint b, c, d, i, j;\r\n \r\n\t\tfor (b = 0; b < 1 << n; b++) {\r\n\t\t\tc = (1 << n) - 1;\r\n\t\t\tfor (i = 0; i < n; i++)\r\n\t\t\t\tif ((b & 1 << i) != 0) {\r\n\t\t\t\t\tif ((c & 1 << aa[i]) == 0)\r\n\t\t\t\t\t\tgoto out;\r\n\t\t\t\t\tc &= ~(1 << aa[i]);\r\n\t\t\t\t}\r\n\t\t\tfor (i = 0; i < n; i++)\r\n\t\t\t\tif ((c & 1 << i) != 0 && (c & 1 << aa[i]) != 0)\r\n\t\t\t\t\tgoto out;\r\n\t\t\tc = 0;\r\n\t\t\tfor (i = 0; i < n; i++) {\r\n\t\t\t\tif ((c & 1 << i) != 0)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\tj = i, d = 0;\r\n\t\t\t\twhile (((c | d) & 1 << j) == 0)\r\n\t\t\t\t\td |= 1 << j, j = aa[j];\r\n\t\t\t\tif ((c & 1 << j) != 0) {\r\n\t\t\t\t\tc |= d;\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tc |= d, d = 0;\r\n\t\t\t\twhile ((d & 1 << j) == 0)\r\n\t\t\t\t\td |= 1 << j, j = aa[j];\r\n\t\t\t\tif ((b & d) == d)\r\n\t\t\t\t\tgoto out;\r\n\t\t\t}\r\n\t\t\tcnt++;\r\nout:;\r\n\t\t}\r\n\t\treturn;\r\n\t}\r\n\tfor (aa[i] = 0; aa[i] < n; aa[i]++)\r\n\t\tif (aa[i] != i)\r\n\t\t\tbrute(i + 1, n);\r\n}\r\n \r\nint slow(int n) {\r\n\tint k, l, ans;\r\n \r\n\tans = 0;\r\n\tfor (k = 1; k <= n; k++)\r\n\t\tfor (l = k; l + k <= n; l++)\r\n\t\t\tans = (ans + (long long) choose(n, l + k)\r\n\t\t\t\t\t* ff[l + k] % md\r\n\t\t\t\t\t* gg[k] % md\r\n\t\t\t\t\t* choose(l - 1, k - 1) % md\r\n\t\t\t\t\t* power(n - 1, k) % md\r\n\t\t\t\t\t* power(l, n - l - k)) % md;\r\n\treturn ans;\r\n}\r\n \r\nint main() {\r\n\tint n, n1;\r\n \r\n\tscanf(\"%d%d\", &n1, &md), init();\r\n\tfor (n = n1; n <= n1; n++) {\r\n#if 0\r\n\t\tcnt = 0, brute(0, n);\r\n\t\tprintf(\"%d\\n\", cnt);\r\n#else\r\n\t\tprintf(\"%d\\n\", slow(n));\r\n#endif\r\n\t}\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["constructive algorithms", "math", "dp", "combinatorics", "fft"], "code_uid": "febb6f106829d4e503ebba8025917feb", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\n#define N\t100000\n\nint md;\n\nlong long power(long long a, int k) {\n\tlong long p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * a % md;\n\t\ta = a * a % md;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nint vv[N + 1], ff[N + 1], gg[N + 1];\n\nvoid init() {\n\tint i;\n\n\tff[0] = gg[0] = 1;\n\tfor (i = 1; i <= N; i++) {\n\t\tvv[i] = i == 1 ? 1 : (long long) vv[i - md % i] * (md / i + 1) % md;\n\t\tff[i] = (long long) ff[i - 1] * i % md;\n\t\tgg[i] = (long long) gg[i - 1] * vv[i] % md;\n\t}\n}\n\nint choose(int n, int k) {\n\treturn k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % md * gg[n - k] % md;\n}\n\nint aa[N], cnt;\n\nvoid brute(int i, int n) {\n\tif (i == n) {\n\t\tint b, c, d, i, j;\n\n\t\tfor (b = 0; b < 1 << n; b++) {\n\t\t\tc = (1 << n) - 1;\n\t\t\tfor (i = 0; i < n; i++)\n\t\t\t\tif ((b & 1 << i) != 0) {\n\t\t\t\t\tif ((c & 1 << aa[i]) == 0)\n\t\t\t\t\t\tgoto out;\n\t\t\t\t\tc &= ~(1 << aa[i]);\n\t\t\t\t}\n\t\t\tfor (i = 0; i < n; i++)\n\t\t\t\tif ((c & 1 << i) != 0 && (c & 1 << aa[i]) != 0)\n\t\t\t\t\tgoto out;\n\t\t\tc = 0;\n\t\t\tfor (i = 0; i < n; i++) {\n\t\t\t\tif ((c & 1 << i) != 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tj = i, d = 0;\n\t\t\t\twhile (((c | d) & 1 << j) == 0)\n\t\t\t\t\td |= 1 << j, j = aa[j];\n\t\t\t\tif ((c & 1 << j) != 0) {\n\t\t\t\t\tc |= d;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tc |= d, d = 0;\n\t\t\t\twhile ((d & 1 << j) == 0)\n\t\t\t\t\td |= 1 << j, j = aa[j];\n\t\t\t\tif ((b & d) == d)\n\t\t\t\t\tgoto out;\n\t\t\t}\n\t\t\tcnt++;\nout:;\n\t\t}\n\t\treturn;\n\t}\n\tfor (aa[i] = 0; aa[i] < n; aa[i]++)\n\t\tif (aa[i] != i)\n\t\t\tbrute(i + 1, n);\n}\n\nint slow(int n) {\n\tint k, l, ans;\n\n\tans = 0;\n\tfor (k = 1; k <= n; k++)\n\t\tfor (l = k; l + k <= n; l++)\n\t\t\tans = (ans + (long long) choose(n, l + k)\n\t\t\t\t\t* ff[l + k] % md\n\t\t\t\t\t* gg[k] % md\n\t\t\t\t\t* choose(l - 1, k - 1) % md\n\t\t\t\t\t* power(n - 1, k) % md\n\t\t\t\t\t* power(l, n - l - k)) % md;\n\treturn ans;\n}\n\nint main() {\n\tint n, n1;\n\n\tscanf(\"%d%d\", &n1, &md), init();\n\tfor (n = n1; n <= n1; n++) {\n#if 0\n\t\tcnt = 0, brute(0, n);\n\t\tprintf(\"%d\\n\", cnt);\n#else\n\t\tprintf(\"%d\\n\", slow(n));\n#endif\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["constructive algorithms", "math", "dp", "combinatorics", "fft"], "code_uid": "26c7c33d962a82139805a4d3a9638a48", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t1000000\n#define MD\t998244353\n#define V2\t499122177\n#define V6\t166374059\n\nint f2(int n) {\n\treturn (long long) n * (n + 1) % MD * V2 % MD;\n}\n\nint f3(int n) {\n\treturn (long long) n * (n + 1) % MD * (n + 2) % MD * V6 % MD;\n}\n\nint main() {\n\tstatic int dp[N], dq[N];\n\tint n, i, x, y, z, single2, single3, pair, ans;\n\n\tscanf(\"%d\", &n);\n\tdp[0] = dq[0] = 1;\n\tfor (i = 1; i < n; i++) {\n\t\tdp[i] = (dp[i - 1] + f2(dp[i - 1]) + (i == 1 ? 0 : (long long) dp[i - 1] * dq[i - 2])) % MD;\n\t\tdq[i] = (dq[i - 1] + dp[i]) % MD;\n\t}\n\tx = dp[n - 1], y = n == 1 ? 0 : dq[n - 2];\n\tsingle2 = (f2(x) + (long long) x * y % MD) % MD;\n\tsingle3 = (f3(x) + (long long) f2(x) * y % MD + (long long) x * f2(y) % MD) % MD;\n\tpair = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tif (i == 0)\n\t\t\tz = 1;\n\t\telse {\n\t\t\tx = dp[i - 1], y = i == 1 ? 0 : dq[i - 2];\n\t\t\tz = (f2(x) + (long long) x * y % MD) % MD;\n\t\t}\n\t\tpair = (pair + (long long) z * dp[n - 1 - i]) % MD;\n\t}\n\tans = ((long long) single2 * 2 + single3 * 2 + pair) % MD;\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp", "combinatorics", "trees"], "code_uid": "db7f5845007017828a0400169ac7ddf5", "src_uid": "92939054045c089cd25c8f4e7b9ffcf2", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t500\n#define M\t(N * (N - 1) / 2)\n\nint dr[M + 1], ds[M + 1], md;\n\nint sum(int l, int r) {\n\treturn (dr[r] - (l <= 0 ? 0 : dr[l - 1])) % md;\n}\n\nint sum_(int l, int r) {\n\treturn (ds[r] - (l <= 0 ? 0 : ds[l - 1] + (long long) dr[l - 1] * (r - l + 1))) % md;\n}\n\nint main() {\n\tstatic int dp[M + 1], dq[M + 1];\n\tint n, k, h, i, ans;\n\n\tscanf(\"%d%d\", &n, &md);\n\tans = 0, dp[0] = 1;\n\tfor (k = 1; k <= n; k++) {\n\t\tint m = (k - 1) * (k - 2) / 2, x;\n\n\t\tfor (h = 0; h <= m; h++)\n\t\t\tdq[h] = ((h == 0 ? 0 : dq[h - 1]) + dp[h]) % md;\n\t\tfor (h = 0; h <= m; h++)\n\t\t\tdr[h] = ((h == 0 ? 0 : dr[h - 1]) + dq[h]) % md;\n\t\tfor (h = 0; h <= m; h++)\n\t\t\tds[h] = ((h == 0 ? 0 : ds[h - 1]) + dr[h]) % md;\n\t\tx = 0;\n\t\tfor (h = 2; h <= m; h++)\n\t\t\tx = (x + ((long long) sum(h - k, h - 2) * k - sum_(h - k, h - 2)) % md * dp[h]) % md;\n\t\tfor (i = 0; i < n - k; i++)\n\t\t\tx = (long long) x * (n - i) % md;\n\t\tans = (ans + x) % md;\n\t\tfor (h = 1; h <= m + k - 1; h++)\n\t\t\tdp[h] = (dp[h] + dp[h - 1]) % md;\n\t\tfor (h = m + k - 1; h >= k; h--)\n\t\t\tdp[h] = (dp[h] - dp[h - k]) % md;\n\t}\n\tif (ans < 0)\n\t\tans += md;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "fft"], "code_uid": "e03586faba20ab9b4fb96af19eb04a92", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n\n#define N\t400\n\nint md;\n\nint ff[N + 1];\n\nvoid init() {\n\tint n;\n\n\tff[0] = 1;\n\tfor (n = 1; n <= N; n++)\n\t\tff[n] = (long long) ff[n - 1] * n % md;\n}\n\nint main() {\n\tstatic int dp[N + 1];\n\tint n, i, j, ans;\n\n\tscanf(\"%d%d\", &n, &md), init();\n\tans = 0;\n\tdp[0] = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tfor (j = n; j >= 0; j--)\n\t\t\tdp[j] = ((j == 0 ? 0 : dp[j - 1]) + (long long) dp[j] * j * 2) % md;\n\t\tans = (ans + (long long) dp[n - i + 1] * ff[n - i + 1]) % md;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics"], "code_uid": "e6093b675ebd2a669048d1f7c9992741", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define m 1000000007\nlong long int power(long long int x,long long int y)\n { long long int p;\n if(y==1)\n return(x%m);\n else\n {p=power(x,y/2)%m;\n if(y%2==0)\n return((p*p)%m);\n else\n return((x*p*p)%m);}\n }\nint main()\n{\n long long int n,a[40] = {1, 2, 4, 6, 12, 16, 18, 30, 60, 88, 106, 126, 520, 606, 1278, 2202, 2280, 3216, 4252, 4422, 9688, 9940, 11212, 19936, 21700, 23208, 44496, 86242, 110502, 132048, 216090, 756838, 859432, 1257786, 1398268, 2976220, 3021376, 6972592, 13466916, 20996010};\nlong long int r;\nscanf(\"%I64d\",&n);\nr=power(2,a[n-1]);\nprintf(\"%I64d\",r-1);\nreturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "1b7337556697aa134b68f752b34a481e", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\nint main()\n{\n int n, m = 1000000007, x = 1, i;\n int a[40] = {1, 2, 4, 6, 12, 16, 18, 30, 60, 88, 106, 126, 520, 606, 1278, 2202, 2280, 3216, 4252, 4422, 9688, 9940, 11212, 19936, 21700, 23208, 44496, 86242, 110502, 132048, 216090, 756838, 859432, 1257786, 1398268, 2976220, 3021376, 6972592, 13466916, 20996010};\n \n scanf(\"%d\", &n);\n \n for (i = 1; i <= a[n - 1]; i++) x = x * 2 % m;\n \n printf(\"%d\\n\", (x - 1 + m) % m);\n \n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "63d02d067452b2229f63acb3147ad3a2", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n#include \n\n#define N_LIMIT 1000003 // 1e6+3\ntypedef long long ll;\n\n\nll a_pows[N_LIMIT];\n\nll inv(ll x, ll p)\n{\n ll result = 1, y;\n //printf(\"inverse of %lld is \", x);\n while (x != 1)\n {\n y = (x+p)/x;\n result *= y;\n result %= p;\n x = (x*y)%p;\n }\n //printf(\"%lld\\n\", result);\n return result;\n}\n\nint main(int argc, char *argv)\n{\n ll a, b, p, x, d = 1;\n \n ll n, m, y, z;\n ll pdi;\n ll count;\n int i;\n scanf(\"%lld %lld %lld %lld\", &a, &b, &p, &x);\n a_pows[0] = 1;\n a_pows[1] = a;\n while (a != 1)\n {\n d++;\n a = (a*a_pows[1]) % p;\n a_pows[d] = a;\n }\n //printf(\"d: %lld\\n\", d);\n count = 0;\n pdi = inv(p-d, p);\n for (m=0; m= z*d+m)\n {\n count += 1;\n }\n }\n printf(\"%lld\\n\", count);\n \n\n return 0;\n}\n", "lang_cluster": "C", "tags": ["math", "number theory"], "code_uid": "191ccf2fff8c6942299993caf790e296", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n\r\n#define MOD 998244353\r\n\r\nint main() {\r\n\tint n, m;\r\n\tscanf(\"%d%d\", &n, &m);\r\n\r\n\tstatic int c[10];\r\n\r\n\tfor (int i = 0; i < m; ++i) {\r\n\t\tint u, v;\r\n\t\tscanf(\"%d%d\", &u, &v);\r\n\t\tc[u] |= 1 << v;\r\n\t\tc[v] |= 1 << u;\r\n\t}\r\n\r\n\tfor (int u = 0; u < 10; ++u) {\r\n\t\tc[u] |= 1 << u;\r\n\t}\r\n\r\n\tstatic int dp[1024];\r\n\t\r\n\tfor (int u = 0; u < 10; ++u) {\r\n\t\tdp[1 << u] = 1;\r\n\t}\r\n\t\r\n\twhile (--n) {\r\n\t\tstatic int tmp[1024];\r\n\t\t\r\n\t\tmemset(tmp, 0, sizeof(tmp));\r\n\r\n\t\tfor (int i = 0; i < 1024; ++i) {\r\n\t\t\tfor (int x = 0; x < 10; ++x) {\r\n\t\t\t\tint j = i & c[x] | (1 << x);\r\n\t\t\t\tif (j & ((1 << x) - 1)) \r\n\t\t\t\t\tcontinue;\r\n\t\t\t\tif ((tmp[j] += dp[i]) >= MOD) \r\n\t\t\t\t\ttmp[j] -= MOD;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tmemcpy(dp, tmp, sizeof(dp));\r\n\t}\r\n\r\n\tint res = 0;\r\n\tfor (int i = 0; i < 1024; ++i) {\r\n\t\tif ((res += dp[i]) >= MOD) \r\n\t\t\tres -= MOD;\r\n\t}\r\n\r\n\tprintf(\"%d\\n\", res);\r\n}\r\n\r\n", "lang_cluster": "C", "tags": ["math", "dp", "bitmasks"], "code_uid": "778884e0241fe728f34b108165564315", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \n#include \n\nint dots[][5] = {\n\t{ 1, 0, 0, 1, 0 }, { 1, 1, 0, 2, 0 }, { 2, 0, 0, 1, 1 }, { 2, 1, 0, 1, 2 },\n\t{ 1, 1, 0, 1, 1 }, { 2, 1, 0, 2, 1 }, { 2, 2, 0, 2, 2 }, { 1, 2, 0, 2, 1 },\n\t{ 1, 1, 0, 1, 1 }, { 1, 2, 0, 1, 2 }, { 1, 0, 1, 2, 0 }, { 1, 1, 1, 3, 0 },\n\t{ 2, 0, 1, 2, 1 }, { 2, 1, 1, 2, 2 }, { 1, 1, 1, 2, 1 }, { 2, 1, 1, 3, 1 },\n\t{ 2, 2, 1, 3, 2 }, { 1, 2, 1, 3, 1 }, { 1, 1, 1, 2, 1 }, { 1, 2, 1, 2, 2 },\n\t{ 1, 0, 2, 2, 1 }, { 1, 1, 2, 3, 1 }, { 1, 2, 1, 1, 3 }, { 2, 0, 2, 2, 2 },\n\t{ 2, 1, 2, 2, 3 }, { 1, 1, 2, 2, 2 }\n};\n\nint main() {\n\tint n;\n\n\tscanf(\"%d\", &n);\n\twhile (n--) {\n\t\tstatic int aa[5];\n\t\tint i, a;\n\n\t\tfor (i = 0; i < 5; i++)\n\t\t\tscanf(\"%d\", &aa[i]);\n\t\tfor (a = 0; a < 26; a++)\n\t\t\tif (memcmp(dots[a], aa, 5 * sizeof *aa) == 0) {\n\t\t\t\tprintf(\"%c\", a + 'a');\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["implementation"], "code_uid": "b6e9a2b93bcac74dc2a1d9083572b04f", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\nlong long count2(int h) {\n\treturn h % 2 == 1 ? (long long) (h + 1) / 2 * ((h + 1) / 2 + 1)\n\t\t: (long long) (h / 2 + 1) * (h / 2 + 1);\n}\n\nlong long count1(int h, int r) {\n\treturn count2(h) - (r >= h ? 0 : count2(h - 1 - r));\n}\n\nlong long count(int h, int k, int r) {\n\treturn count1(h, r) - (k == 0 ? 0 : count1(k - 1, r));\n}\n\nlong long solve(int a, int b, int c, int h) {\n\tint k, l, r;\n\n\tif (a + 1 > b + c + h)\n\t\treturn 0;\n\tk = a + 1 <= b + c ? 0 : a + 1 - (b + c);\n\tl = 1 - a - (c - b);\n\tr = a - 1 - (c - b);\n\tif (l >= 0)\n\t\treturn count(h, k, r) - (l == 0 ? 0 : count(h, k, l - 1));\n\tif (r <= 0) {\n\t\tr = -r, l = -l;\n\t\treturn count(h, k, l) - (r == 0 ? 0 : count(h, k, r - 1));\n\t}\n\treturn count(h, k, -l) + count(h, k, r) - count(h, k, 0);\n}\n\nint main() {\n\tint a, b, c, l, l_;\n\tlong long ans;\n\n\tscanf(\"%d%d%d%d\", &a, &b, &c, &l);\n\tans = 0;\n\tfor (l_ = 0; l_ <= l; l_++)\n\t\tans += solve(a + l_, b, c, l - l_);\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["math", "implementation", "combinatorics"], "code_uid": "de86dedcaba93bf56124e799cd721eef", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include\n#define min(a,b) a>b?b:a\nmain(){\n\tint a,b,c;\n\tint l,la,lb,lc,mn;\n\tscanf(\"%d%d%d%d\",&a,&b,&c,&l);\n\tlong long ans=0;\n\tfor(la=0;la<=l;la++)\n\t{\n\t\tmn=min(l-la,a-b-c+la);\n\t\tif(mn<0)\n\t\tcontinue;\n\t\tans=ans+1LL*(mn+1)*(mn+2)/2;\n\t}\n\t\tfor(lb=0;lb<=l;lb++)\n\t{\n\t\tmn=min(l-lb,b-a-c+lb);\n\t\tif(mn<0)\n\t\tcontinue;\n\t\tans=ans+1LL*(mn+1)*(mn+2)/2;\n\t}\n\t\tfor(lc=0;lc<=l;lc++)\n\t{\n\t\tmn=min(l-lc,c-b-a+lc);\n\t\tif(mn<0)\n\t\tcontinue;\n\t\tans=ans+1LL*(mn+1)*(mn+2)/2;\n\t}\n\tans=1LL*(l+1)*(l+2)*(l+3)/6-ans;\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C", "tags": ["brute force", "math", "dp", "combinatorics"], "code_uid": "55fcc15529cdc343e4089388b38d7e28", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\nconst i32 mod = 1000000007;\n\ni32 inv (i32 a) {\n i32 t = 1;\n while (a > 1) {\n t = (i64) t * (mod - mod / a) % mod;\n a = mod % a;\n }\n return t;\n}\n\ni32 mod_pow (i32 r, i32 n) {\n i32 t = 1;\n i32 s = r;\n while (n > 0) {\n if (n & 1) t = (i64) t * s % mod;\n s = (i64) s * s % mod;\n n >>= 1;\n }\n return t;\n}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n#define ABS(a) ((a)>(0)?(a):-(a))\n\nvoid matmul (i32 *c, i32 *a, i32 *b, i32 n) {\n static i32 *tmp = NULL;\n if (tmp == NULL) {\n tmp = (i32 *) calloc (n * n, sizeof (i32));\n }\n memset (tmp, 0, sizeof (i32) * n * n);\n for (i32 i = 0; i < n; ++i) {\n for (i32 k = 0; k < n; ++k) {\n for (i32 j = 0; j < n; ++j) {\n\ttmp[i * n + j] = (tmp[i * n + j] + (i64) a[i * n + k] * b[k * n + j]) % mod;\n }\n }\n }\n memcpy (c, tmp, sizeof (i32) * n * n);\n}\n\nvoid run (void) {\n i32 n = read_int();\n i32 k = read_int();\n i32 *a = (i32 *) calloc (n, sizeof (i32));\n i32 cnt[2] = {0, 0};\n for (i32 i = 0; i < n; ++i) {\n a[i] = read_int();\n cnt[a[i]]++;\n }\n if (cnt[0] == 0 || cnt[1] == 0) {\n puts(\"1\");\n return;\n }\n i32 d = 0;\n for (i32 i = 0; i < cnt[0]; ++i) {\n d += a[i];\n }\n const i32 m = MIN(cnt[0], cnt[1]) + 1;\n i32 *t = (i32 *) calloc (m * m, sizeof (i32));\n i32 *s = (i32 *) calloc (m * m, sizeof (i32));\n for (i32 i = 0; i < m; ++i) {\n t[i * m + i] = 1;\n s[i * m + i] = cnt[0] * (cnt[0] - 1) / 2 + cnt[1] * (cnt[1] - 1) / 2 + (cnt[0] - i) * i + i * (cnt[1] - i);\n if (i + 1 < m) {\n s[i * m + i + 1] = (cnt[0] - i) * (cnt[1] - i);\n }\n if (i - 1 >= 0) {\n s[i * m + i - 1] = i * i;\n }\n }\n i32 p = inv (n * (n - 1) / 2);\n for (i32 i = 0; i < m * m; ++i) {\n s[i] = (i64) s[i] * p % mod;\n }\n while (k > 0) {\n if (k & 1) matmul (t, t, s, m);\n matmul (s, s, s, m);\n k >>= 1;\n }\n i32 ans = t[d * m + 0];\n print_int (ans);\n puts(\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities", "matrices", "dp", "combinatorics"], "code_uid": "66fba861fb840cd0ef93234b6627176f", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\n#define mod 1000000007\nlong long dp[55][55][205]={};\nlong long c[55][55]={};\nint n,lim,A=0,B=0,i,j,k,ii,jj;\nint min(int a,int b){return a=0;i--){\n\t\t\tfor(j=B;j>=0;j--){\n\t\t\t\tint s=k%2;\n\t\t\t\tdp[i][j][s]=0;\n\t\t\t\tif(s){\n\t\t\t\t\tfor(ii=i;ii<=A;ii++){\n\t\t\t\t\t\tint f=lim-(ii-i)*50;\n\t\t\t\t\t\tif(f>=0){\n\t\t\t\t\t\t\tf/=100;\n\t\t\t\t\t\t\tf+=j; f=min(f,B);\n\t\t\t\t\t\t\tfor(jj=j;jj<=f;jj++){\n\t\t\t\t\t\t\t\tif((i!=ii || j!=jj)){\n\t\t\t\t\t\t\t\t\tdp[i][j][s]+=(dp[ii][jj][1-s]*c[ii][ii-i]*c[jj][jj-j])%mod;\n\t\t\t\t\t\t\t\t\tdp[i][j][s]%=mod;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\tfor(ii=0;ii<=i;ii++){\n\t\t\t\t\t\tint f=lim-(i-ii)*50;\n\t\t\t\t\t\tif(f>=0){\n\t\t\t\t\t\t\tf/=100; f=max(j-f,0);\n\t\t\t\t\t\t\tfor(jj=f;jj<=j;jj++){\n\t\t\t\t\t\t\t\tif((i!=ii || j!=jj)){\n\t\t\t\t\t\t\t\t\tdp[i][j][s]+=(dp[ii][jj][1-s]*c[A-ii][i-ii]*c[B-jj][j-jj])%mod;\n\t\t\t\t\t\t\t\t\tdp[i][j][s]%=mod;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(dp[0][0][s]){\n\t\t\t\t\tprintf(\"%d\\n\",k);\n\t\t\t\t\tprintf(\"%lld\\n\",dp[0][0][s]);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tputs(\"-1\\n0\");\n}\n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// \n// ", "lang_cluster": "C", "tags": ["dp", "combinatorics", "graphs", "shortest paths"], "code_uid": "a08db0863e9af829f5be5d95334a07f4", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define M\t150\n#define MD\t1000000007\n\nint query(int aa[][M + 1], int l0, int l1, int r0, int r1) {\n\treturn l0 > l1 || r0 > r1 ? 0 : ((long long) aa[l1][r1] - aa[l0 - 1][r1] - aa[l1][r0 - 1] + aa[l0 - 1][r0 - 1]) % MD;\n}\n\nvoid add(int aa[][M + 1], int l, int r, int a) {\n\taa[l][r] = (aa[l][r] + a) % MD;\n}\n\nint main() {\n\tstatic int dp00[M + 1][M + 1], dp01[M + 1][M + 1], dp10[M + 1][M + 1], dp11[M + 1][M + 1];\n\tstatic int dq00[M + 1][M + 1], dq01[M + 1][M + 1], dq10[M + 1][M + 1], dq11[M + 1][M + 1];\n\tint n, m, l, r, ans;\n\n\tscanf(\"%d%d\", &n, &m);\n\tans = 0;\n\twhile (n--) {\n\t\tfor (l = 1; l <= m; l++)\n\t\t\tfor (r = 1; r <= m; r++) {\n\t\t\t\tdp00[l][r] = (dp00[l][r] + dp00[l][r - 1]) % MD;\n\t\t\t\tdp01[l][r] = (dp01[l][r] + dp01[l][r - 1]) % MD;\n\t\t\t\tdp10[l][r] = (dp10[l][r] + dp10[l][r - 1]) % MD;\n\t\t\t\tdp11[l][r] = (dp11[l][r] + dp11[l][r - 1]) % MD;\n\t\t\t}\n\t\tfor (l = 1; l <= m; l++)\n\t\t\tfor (r = 1; r <= m; r++) {\n\t\t\t\tdp00[l][r] = (dp00[l][r] + dp00[l - 1][r]) % MD;\n\t\t\t\tdp01[l][r] = (dp01[l][r] + dp01[l - 1][r]) % MD;\n\t\t\t\tdp10[l][r] = (dp10[l][r] + dp10[l - 1][r]) % MD;\n\t\t\t\tdp11[l][r] = (dp11[l][r] + dp11[l - 1][r]) % MD;\n\t\t\t}\n\t\tfor (l = 1; l <= m; l++)\n\t\t\tfor (r = 1; r <= m; r++)\n\t\t\t\tdq00[l][r] = dq01[l][r] = dq10[l][r] = dq11[l][r] = 0;\n\t\tfor (l = 1; l <= m; l++)\n\t\t\tfor (r = l; r <= m; r++) {\n\t\t\t\tdq00[l][r] = 1;\n\t\t\t\tadd(dq00, l, r, query(dp00, l, m, 1, r));\n\t\t\t\tadd(dq01, l, r, query(dp01, l, r, r, m));\n\t\t\t\tadd(dq01, l, r, query(dp00, l, r, r + 1, m));\n\t\t\t\tadd(dq10, l, r, query(dp10, 1, l, l, r));\n\t\t\t\tadd(dq10, l, r, query(dp00, 1, l - 1, l, r));\n\t\t\t\tadd(dq11, l, r, query(dp11, 1, l, r, m));\n\t\t\t\tadd(dq11, l, r, query(dp01, 1, l - 1, r, m));\n\t\t\t\tadd(dq11, l, r, query(dp10, 1, l, r + 1, m));\n\t\t\t\tadd(dq11, l, r, query(dp00, 1, l - 1, r + 1, m));\n\t\t\t\tans = (ans + (long long) dq00[l][r] + dq01[l][r] + dq10[l][r] + dq11[l][r]) % MD;\n\t\t\t}\n\t\tfor (l = 0; l <= m; l++)\n\t\t\tfor (r = 0; r <= m; r++) {\n\t\t\t\tdp00[l][r] = dq00[l][r];\n\t\t\t\tdp01[l][r] = dq01[l][r];\n\t\t\t\tdp10[l][r] = dq10[l][r];\n\t\t\t\tdp11[l][r] = dq11[l][r];\n\t\t\t}\n\t}\n\tif (ans < 0)\n\t\tans += MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["dp"], "code_uid": "825ccb78e44015946b000cb1a00118ec", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "/* practice with Dukkha */\n#include \n\n#define N\t5\n\nint max(int a, int b) { return a > b ? a : b; }\n\ndouble prob(int l, int r, int a) {\n\treturn (double) max(r - max(l, a) + 1, 0) / (r - l + 1);\n}\n\nint main() {\n\tstatic int ll[N], rr[N];\n\tint n, i, j, a;\n\tdouble ans, p, q;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d%d\", &ll[i], &rr[i]);\n\tans = 0;\n\tfor (a = 1; a <= 10000; a++) {\n\t\tp = 1;\n\t\tfor (j = 0; j < n; j++)\n\t\t\tp *= 1 - prob(ll[j], rr[j], a);\n\t\tq = p;\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tp = prob(ll[i], rr[i], a);\n\t\t\tfor (j = 0; j < n; j++)\n\t\t\t\tif (j != i)\n\t\t\t\t\tp *= 1 - prob(ll[j], rr[j], a);\n\t\t\tq += p;\n\t\t}\n\t\tans += 1 - q;\n\t}\n\tprintf(\"%.9f\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C", "tags": ["probabilities", "bitmasks"], "code_uid": "5c0516fd444d65e9e7641332342c32da", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C", "source_code": "#include \n\ndouble L[6], R[6];\nint n;\n\nint min(int a, double b_) {\n int b = b_;\n return (a < b ? a : b);\n}\nint max(int a, double b_) {\n int b = b_;\n return (a > b ? a : b);\n}\n\ndouble noHigherThan(int b) {\n int i, j, f;\n double p = 0.0, p1;\n for(i = 3; i < (1 << n); i++) {\n p1 = 1.0;\n f = 0;\n for(j = 0; j < n; j++) {\n if((i & (1 << j)) > 0) {\n if(!(L[j] <= b && b <= R[j])) {\n p1 = 0;\n break;\n }\n p1 *= (1.0 / (R[j] - L[j] + 1));\n f++;\n }\n else {\n if(L[j] >= b) {\n p1 = 0;\n break;\n }\n p1 *= ((min(b - 1, R[j]) - L[j] + 1) / (R[j] - L[j] + 1));\n }\n }\n if(f >= 2)\n p = p + p1;\n }\n return p;\n}\n\ndouble oneHigherThan(int b, int x) {\n if(b >= R[x]) return 0.0;\n double p = 0.0, p1;\n int i, j, f;\n for(i = 1; i < (1 << n); i++) {\n p1 = 1.0;\n f = 0;\n for(j = 0; j < n; j++) {\n if(j == x) continue;\n if((i & (1 << j)) > 0) {\n if(!(L[j] <= b && b <= R[j])) {\n p1 = 0;\n break;\n }\n p1 *= (1.0 / (R[j] - L[j] + 1));\n f++;\n }\n else {\n if(L[j] >= b) {\n p1 = 0;\n break;\n }\n p1 *= ((min(b - 1, R[j]) - L[j] + 1.0) / (R[j] - L[j] + 1.0));\n }\n }\n if(f == 0) p1 = 0;\n p = p + p1;\n }\n p /= 2.0;\n return p * ((R[x] - max(b + 1, L[x]) + 1.0) / (R[x] - L[x] + 1));\n}\n\ndouble P(int b) {\n double p = 0.0;\n p = noHigherThan(b);\n int i;\n for(i = 0; i < n; i++)\n p = p + oneHigherThan(b, i);\n return p;\n}\n\nint main(int argc, char const *argv[]) {\n int i, lim = 0;\n double ex = 0;\n scanf(\"%d\", &n);\n for(i = 0; i < n; i++) {\n scanf(\"%lf%lf\", &L[i], &R[i]);\n lim = max(lim, R[i]);\n }\n for(i = 1; i <= lim; i++) {\n ex = ex + i * P(i);\n }\n printf(\"%.10lf\\n\", ex);\n return 0;\n}", "lang_cluster": "C", "tags": ["probabilities", "bitmasks"], "code_uid": "850f9902e5bbe893bc49078dd3935b39", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n\r\n#define N\t250\r\n#define MD\t998244353\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\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 main() {\r\n\tstatic int dp[N];\r\n\tint n, k, c, i, j;\r\n\r\n\tinit();\r\n\tscanf(\"%d%d\", &n, &k);\r\n\tdp[0] = 1;\r\n\tfor (c = 1; c <= k; c++)\r\n\t\tfor (i = n - 1; i >= 0; i--)\r\n\t\t\tfor (j = 0; j < i; j++)\r\n\t\t\t\tdp[i] = (dp[i] + (long long) dp[j] * choose(i, j) % MD * power(k - c + 1, i * (i - 1) / 2 - j * (j - 1) / 2)) % MD;\r\n\tprintf(\"%d\\n\", dp[n - 1]);\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["math", "dp", "combinatorics", "graph matchings"], "code_uid": "507e6743dde26ff4be2928862208b0f6", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include \r\n#include \r\n#include \r\n\r\n#define N\t35\r\n#define N_\t((N + 1) / 2)\r\n\r\nunsigned int X;\r\n\r\nvoid srand_() {\r\n\tstruct timeval tv;\r\n\r\n\tgettimeofday(&tv, NULL);\r\n\tX = tv.tv_sec ^ tv.tv_usec | 1;\r\n}\r\n\r\nint rand_() {\r\n\treturn (X *= 3) >> 1;\r\n}\r\n\r\nvoid multiply(char *aa, char *bb, char *md, int n) {\r\n\tstatic char cc[N * 2];\r\n\tint i, j;\r\n\r\n\tmemset(cc, 0, n * 2 * sizeof *cc);\r\n\tfor (i = 0; i < n; i++)\r\n\t\tfor (j = 0; j < n; j++)\r\n\t\t\tif (aa[i] && bb[j])\r\n\t\t\t\tcc[i + j] ^= 1;\r\n\tfor (i = n * 2 - 1; i >= n - 1; i--)\r\n\t\tif (cc[i])\r\n\t\t\tfor (j = 0; j < n; j++)\r\n\t\t\t\tif (md[j])\r\n\t\t\t\t\tcc[i - (n - 1 - j)] ^= 1;\r\n\tmemcpy(aa, cc, n * sizeof *cc);\r\n}\r\n\r\nchar ppp[1 << N_][N]; int n;\r\n\r\nint compare(int i, int j) {\r\n\tint c = memcmp(ppp[i], ppp[j], n * sizeof *ppp[j]);\r\n\r\n\treturn c ? c : i - j;\r\n}\r\n\r\nvoid sort(int *ii, int l, int r) {\r\n\twhile (l < r) {\r\n\t\tint i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;\r\n\r\n\t\twhile (j < k) {\r\n\t\t\tint c = compare(ii[j], i_);\r\n\r\n\t\t\tif (c == 0)\r\n\t\t\t\tj++;\r\n\t\t\telse if (c < 0) {\r\n\t\t\t\ttmp = ii[i], ii[i] = ii[j], ii[j] = tmp;\r\n\t\t\t\ti++, j++;\r\n\t\t\t} else {\r\n\t\t\t\tk--;\r\n\t\t\t\ttmp = ii[j], ii[j] = ii[k], ii[k] = tmp;\r\n\t\t\t}\r\n\t\t}\r\n\t\tsort(ii, l, i);\r\n\t\tl = k;\r\n\t}\r\n}\r\n\r\nint search(int *ii, int m, char *pp) {\r\n\tint lower = -1, upper = m;\r\n\r\n\twhile (upper - lower > 1) {\r\n\t\tint i = (lower + upper) / 2;\r\n\r\n\t\tif (memcmp(ppp[ii[i]], pp, n * sizeof *ppp[ii[i]]) >= 0)\r\n\t\t\tupper = i;\r\n\t\telse\r\n\t\t\tlower = i;\r\n\t}\r\n\treturn upper < m && memcmp(pp, ppp[ii[upper]], n * sizeof *ppp[ii[upper]]) == 0 ? ii[upper] : -1;\r\n}\r\n\r\nint main() {\r\n\tstatic char cc_[N + 1], *cc, md[N], xx[N], vv[N], pp[N], pp_[N];\r\n\tstatic int rr[1 << N_];\r\n\tint n_, p, q, r, i, j, one;\r\n\tchar tmp;\r\n\r\n\tsrand_();\r\n\tscanf(\"%s\", cc_), n = strlen(cc_);\r\n\tp = 0;\r\n\twhile (p < n && cc_[p] == '0')\r\n\t\tp++;\r\n\tif (p == n) {\r\n\t\tprintf(\"-1\\n\");\r\n\t\treturn 0;\r\n\t}\r\n\tcc = cc_ + p, n -= p;\r\n\twhile (cc[n - 1] == '0')\r\n\t\tn--;\r\n\tif (n == 1) {\r\n\t\tprintf(\"%d %d\\n\", p + 1, p + 2);\r\n\t\treturn 0;\r\n\t}\r\n\tn_ = (n + 1) / 2;\r\n\tcc[n] = 0;\r\n\tfor (i = 0, j = n - 1; i < j; i++, j--)\r\n\t\ttmp = cc[i], cc[i] = cc[j], cc[j] = tmp;\r\n\tfor (i = 0; i < n; i++)\r\n\t\tmd[i] = cc[i] - '0';\r\n\tfor (j = 0; j < n - 1; j++)\r\n\t\tvv[j] = md[j + 1];\r\n\tmemset(pp, 0, n * sizeof *pp), pp[0] = 1;\r\n\tfor (r = 0; r < 1 << n_; r++) {\r\n\t\tmemcpy(ppp[r], pp, n * sizeof *pp);\r\n\t\tone = 1;\r\n\t\tfor (i = 0; i < n; i++)\r\n\t\t\tif ((pp[i] == 1) != (i == 0)) {\r\n\t\t\t\tone = 0;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\tif (one && r != 0) {\r\n\t\t\tprintf(\"%d %d\\n\", p + 1, p + 1 + r);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\tmultiply(pp, vv, md, n);\r\n\t}\r\n\tfor (r = 0; r < 1 << n_; r++)\r\n\t\trr[r] = r;\r\n\tsort(rr, 0, 1 << n_);\r\n\tmemset(pp_, 0, n * sizeof *pp_), pp_[0] = 1;\r\n\txx[1] = 1, multiply(xx, pp_, md, n);\r\n\tfor (r = 0; r < 1 << n_; r++)\r\n\t\tmultiply(pp_, xx, md, n);\r\n\tmemset(pp, 0, n * sizeof *pp), pp[0] = 1;\r\n\tfor (q = 1; q <= 1 << n_; q++) {\r\n\t\tmultiply(pp, pp_, md, n);\r\n\t\tif ((r = search(rr, 1 << n_, pp)) != -1) {\r\n\t\t\tprintf(\"%d %lld\\n\", p + 1, p + 1 + ((long long) q << n_) + r);\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\tprintf(\"-1\\n\");\r\n\treturn 0;\r\n}", "lang_cluster": "C", "tags": ["math", "bitmasks", "meet-in-the-middle", "matrices", "number theory"], "code_uid": "05447241842fe9311ca1d62381ebb6c5", "src_uid": "6bf798edef30db7d0ce2130e40084e6b", "difficulty": 2900.0, "exec_outcome": "PASSED"} {"lang": "GNU C11", "source_code": "#include\nlong long a[5],ans=1000000000000;\nchar p[4];\nvoid dfs(int l)\n{\n if(l==1)\n {\n long long s;\n for( int i=1; i<=4; i++)\n if(a[i]!=-1)\n {\n s=a[i];\n break;\n }\n if(s