{"source_code": "#include \n\n#define N\t500\n#define A\t500\n#define M\t512\n#define MD\t998244353\n\nint main() {\n\tstatic int dp[N + 1][A + 1], pp[M][M], ch[M][M];\n\tint n, a_, i, j, k, k_, a;\n\n\tscanf(\"%d%d\", &n, &a_);\n\tfor (a = 1; a < M; a++) {\n\t\tpp[a][0] = 1;\n\t\tfor (k = 1; k < M; k++)\n\t\t\tpp[a][k] = (long long) pp[a][k - 1] * a % MD;\n\t}\n\tch[0][0] = 1;\n\tfor (i = 1; i < M; i++) {\n\t\tch[i][0] = 1;\n\t\tfor (j = 1; j < M; j++)\n\t\t\tch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;\n\t}\n\tfor (a = 1; a <= a_; a++)\n\t\tdp[0][a] = 1;\n\tfor (k = 2; k <= n; k++)\n\t\tfor (a = 1; a <= a_; a++)\n\t\t\tif (a <= k - 1)\n\t\t\t\tdp[k][a] = pp[a][k];\n\t\t\telse\n\t\t\t\tfor (k_ = 0; k_ <= k; k_++) \n\t\t\t\t\tdp[k][a] = (dp[k][a] + (long long) dp[k - k_][a - (k - 1)] % MD * ch[k][k_] % MD * pp[k - 1][k_]) % MD;\n\tprintf(\"%d\\n\", dp[n][a_]);\n\treturn 0;\n}\n", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f"} {"source_code": "#include\nint main()\n{\n\tint i,a,b,c,k;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tfor(i=1;i<=b;i++)\n\t{\n\t\tk=(a*10)/b;\n\t\ta=(a*10)-(k*b);\n\t\tif(k==c)\n\t\t{\n\t printf(\"%d\",i);\t\n\t break;}\n\t else\n\t continue;\n}\nif( i==b+1 )\nprintf(\"-1\");\nelse\nreturn 0;\n}", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910"} {"source_code": "#include\nint main()\n{\nlong long int n, d,sum=0;\nscanf(\"%lld\",&n);\nscanf(\"%lld\",&d);\nprintf(\"\\n\");\nint i,t[100];\nfor(i=0;id)//uske gaane aur resting time ka sum smaller than total time\nprintf(\"-1\");\nelse\nprintf(\"%d\",(d-sum)/5);\n\nreturn 0;\n}\n", "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea"} {"source_code": "#include\nint isPrime(int n);\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int i;\n for(i=1; ; i++)\n {\n int s;\n s = ((n*i)+1);\n if(isPrime(s)==0)\n {\n printf(\"%d\\n\",i);\n break;\n }\n }\n return 0;\n}\nint isPrime(int n)\n{\n int i;\n for(i=2; i*i<=n; i++)\n {\n if(n%i==0)\n return 0;\n }\n return 1;\n}", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97"} {"source_code": "#include\nint main()\n{\n int i,k,max=0,n,arr[1000],str[1000]={};\n scanf(\"%d\",&n);\n for(i=0;imax)\n max=str[i];\n }\n printf(\"%d\\n\",max);\n return 0;\n}\n", "src_uid": "f30329023e84b4c50b1b118dc98ae73c"} {"source_code": "int n,m=1;\nint main()\n{\n scanf(\"%i\",&n);\n if(n)while(--n)m=(m*3)%1000003;\n printf(\"%i\",m);\n return 0;\n}\n", "src_uid": "1a335a9638523ca0315282a67e18eec7"} {"source_code": "#include \n\nint main(void)\n{\n unsigned box[5][5];\n int i,j,k,l,m;\n for(i=0;i<5;i++)\n for(j=0;j<5;j++)\n scanf(\"%u\",&box[i][j]);\n\n unsigned sum = 0, max =0;\n for(i=0;i<5;i++)\n for(j=0;j<5;j++)\n {\n\tif(j==i) continue;\n\tfor(k=0;k<5;k++)\n\t {\n\t if(k == j || k ==i) continue;\n\t for(l=0;l<5;l++)\n\t {\n\t\tif(l == j || l == k || l== i) continue;\n\t\tfor(m=0;m<5;m++)\n\t\t {\n\t\t if(m==j || m==l || m==k || m==i) continue;\n\t\t sum += box[i][j] + box[j][i] + box[j][k] + box[k][j] + ((box[k][l] + box[l][k] + box[l][m] + box[m][l])<<1);\n\t\t if(sum > max) max = sum;\n\t\t sum = 0;\n\t\t }\n\t }\n\t }\n }\n printf (\"%u\\n\",max);\n return 0;\n}\n", "src_uid": "be6d4df20e9a48d183dd8f34531df246"} {"source_code": "#include\n#include\nint main(){\nint a,b,c;\nscanf(\"%d %d %d\",&a,&b,&c);\nint x = sqrt( a * b / c );\nint z = b / x;\nint y = c / z;\nint s = 4 * (x + y + z);\nprintf(\"%d\",s);\nreturn 0;\n}", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc"} {"source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nint ball[128], n, ans;\nvoid merge(int l, int r, int c)\n{\n\tans++;\n\tfor ( ; l>=0 && ball[l]==c; l--)\n\t\tans++;\n\tfor ( ; r1\n\t&& ball[l]==ball[l-1] && ball[l]==ball[l-2])\n\t\tmerge(l-2, l, ball[l]);\n\telse if (l>0 && ball[l]==ball[r] && ball[l-1]==ball[r])\n\t\tmerge(l-1, r, ball[l]);\n\telse if (r max)\n\t\t\t\tmax = ans;\n\t\t}\n\tprintf(\"%d\\n\", max);\n\n\treturn 0;\n}\n", "src_uid": "d73d9610e3800817a3109314b1e6f88c"} {"source_code": "#include \n\nint main(){\n int n;\n scanf(\"%d\",&n);\n int arr[n];\n for (int i=0; i\nshort main(){\nchar a[102];\nint n,d,i=0,jumb=0,j=0,conf=0;\nscanf(\"%d \",&n);\nscanf(\"%d \",&d);\nfgets( a,102,stdin);\nwhile(1){\n conf=0;\n if(a[i+d]-48==1){jumb++;i+=d;conf=1;}\n else {\n for(j=d+i-1;j>i;j--)\n if(a[j]-48==1){jumb++;i+=(j-i);conf=1;break;}\n }\n\n if(conf==0)break;\n if(i==n-1)break;\n}\n\n printf(\"%d\",(conf==0)? -1:jumb);\n\n\treturn 0;\n}", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e"} {"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 ", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8"} {"source_code": "#include\nint main()\n{\n int i=1,n,v=2;\n scanf(\"%d\",&n);\n while(1)\n {\n if(i==n)\n {\n printf(\"YES\");\n break;\n }\n else if(i>n)\n {\n printf(\"NO\");\n break;\n }\n else\n {\n i=i+v;\n v++;\n }\n }\n \n \n return 0;\n}\n", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301"} {"source_code": "#include \n#include \n#include \nint main(void)\n{\n int s, x1, x2, p, d1, t1, t2, ans = 0;\n scanf(\"%d%d%d%d%d%d%d\", &s, &x1, &x2, &t1, &t2, &p, &d1);\n int t_ig = abs(x1 - x2) * t2;\n int t_tr;\n\n if (d1 > 0 && p > x1 && p <= x2)\n t_tr = (2*s - p + x2)*t1;\n if (d1 < 0 && p < x1 && p >= x2 )\n t_tr = (2*s - x2 + p)*t1;\n\n if (p <= x1 && x1 <= x2 && d1 > 0 || x2 <= x1 && x1 <= p && d1 < 0)\n t_tr = abs(p - x2) * t1;\n\n if ( p <= x2 && d1 < 0)\n t_tr = (p + x2) * t1;\n\n if (p >= x2 && d1 > 0)\n t_tr = (2*s - p - x2) * t1;\n\n if (p <= x2 && x2 <= x1){\n if (d1 > 0)\n t_tr = (s - p + s - x2) * t1;\n else\n t_tr = (s + p + s - x2) * t1;\n }\n if (p >= x2 && x2 >= x1){\n if (d1 < 0)\n t_tr = (p + x2) * t1;\n else\n t_tr = (s + x2 + s - p) * t1;\n }\n\n if (t_tr >= t_ig)\n ans = t_ig;\n else\n ans = t_tr;\n printf(\"%d\", ans);\n return 0;\n}\n", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821"} {"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 \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", "src_uid": "91e8dbe94273e255182aca0f94117bb9"} {"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", "src_uid": "40002052843ca0357dbd3158b16d59f4"} {"source_code": "#include\n#include\nint main()\n{\n int l,i,t=0;\n char a[100];\n scanf(\"%s\",a);\n l=strlen(a);\n for(i=1;i=65 && a[i]<=90){\n t++;\n }\n }\n if(t==l-1){\n for(i=0;i=97 && a[i]<=122) a[i]-=32;\n else if(a[i]>=65 && a[i]<=90) a[i]+=32; \n }\n printf(\"%s\",a);\n }\n else printf(\"%s\",a);\n return 0;\n}", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf"} {"source_code": "#include\n#define min(a,b) (a\nint main()\n{\n __int64 a,b,T=0;\n scanf(\"%I64d%I64d\",&a,&b);\n while (a!=b)\n {\n if (a==0) break;\n if (a0) T++;\n printf(\"%I64d\\n\",T);\n return 0;\n}\n", "src_uid": "792efb147f3668a84c866048361970f8"} {"source_code": "#include\n\n char num[120];\n int main () \n{int n,i,n8=0;\nscanf(\"%d\",&n);\n\n\nscanf(\"%s\",num);\n\nfor(i=0;i=11)&&(n8>=1))\n{n=n-11;\nn8=n8-1;\nnb=nb+1;\n}\n\nprintf(\"%d\",nb);\n\n}", "src_uid": "259d01b81bef5536b969247ff2c2d776"} {"source_code": "#include \n#include \n#define ll long long\n#define MAX 162 // = 9*18\nll x,s,y,Upper_limit,Lower_limit,occ[MAX+2],ans,i;\nint isBig(ll a){ll sum=0, tmp=a;\n while(tmp) sum+=tmp%10, tmp/=10;\n return llabs(a-sum)>=s;\n}\nint main(){\n scanf(\"%I64d%I64d\",&x,&s);\n for(i=1;i<=MAX&&i<=x;i++)\n if(isBig(i)) occ[i]=1;\n Upper_limit = s+MAX;\n Lower_limit = s+1;\n if(x>Upper_limit) ans+=x-Upper_limit;\n for(i=Lower_limit;i<=Upper_limit&&i<=x;i++)\n if(isBig(i))\n if(i<=MAX) occ[i]=1;\n else ans++;\n for(i=1;i<=MAX&&i<=x;i++)\n if(occ[i]) ans++;\n printf(\"%I64d\\n\", ans);\n}", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b"} {"source_code": "#include\nint main()\n{\n long long int n,m,x;\n scanf(\"%lld %lld\",&n,&m);\n x=m-n;\n if(x>=10){\n printf(\"0\\n\");\n }\n else{\n long int temp,total=1,a[x+1];\n for(int i=0;i\n#include \n\nint main()\n{\n int k, i, arr[26], start[26], idx = 0, sum = 0, idx2 = 1;\n char q[105];\n scanf(\"%d\", &k);\n scanf(\"%s\", &q);\n memset(arr, 0x00, sizeof(arr));\n memset(start, 0x00, sizeof(start));\n for (i = 0; i < strlen(q); i++){\n if (!arr[q[i] - 'a']) {\n arr[q[i] - 'a']++; sum++;\n start[idx++] = i;\n }\n }\n if (sum < k) printf(\"NO\");\n else {\n printf(\"YES\\n\");\n idx = 0;\n while (k--){\n if (k){\n int j = start[idx2++];\n for (i = idx; i < j; i++) printf(\"%c\", q[i]);\n }\n else {\n for (i = idx; i < strlen(q); i++) printf(\"%c\", q[i]);\n }\n idx = i;\n printf(\"\\n\");\n }\n }\n printf(\"\\n\");\n return 0;\n}\n", "src_uid": "c1b071f09ef375f19031ce99d10e90ab"} {"source_code": "#include\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i b){\n puts(\"DRAW\");\n continue;\n }\n\n if(stone > b && fgg){\n puts(\"DRAW\");\n continue;\n }\n\n stone -= mod;\n puts(\"FIRST\");\n if(fg==0) printf(\"%d\\n\",x2-stone);\n else printf(\"%d\\n\",x2+stone);\n }\n\n return 0;\n}\n", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6"} {"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}", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70"} {"source_code": "#include \n#include \n\nint main()\n{\n int a, n;\n while(scanf(\"%d%d\", &n, &a) > 0)\n { \n int c[n+1];\n int i = 1;\n int num = 0;\n while(i < n + 1)\n { \n scanf(\"%d\", &c[i++]);\n }\n i = 1;\n while(i < n + 1)\n {\n if (c[i])\n {\n num++;\n if (a - abs(a-i) > 0 && a + abs(a-i) <= n && (c[a - abs(a-i)] + c[a + abs(a-i)]) == 1)\n { \n num--;\n }\n }\n i++;\n }\n printf(\"%d\\n\", num);\n }\n}\n", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5"} {"source_code": "#include\n#include\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef unsigned int uint;\ntypedef unsigned long ulong;\n\nlong long int sort(long long int a[] , int n){\n long long int tmp = 0;\n for(ll i = 1 ; i < n ; i++)\n {\n for(ll j = i ; j < n ; j++){\n if(a[i] > a[j]){\n tmp = a[j];\n a[j] = a[i];\n a[i] = tmp;\n }\n }\n\n }\n}\n\nlong long int min(long long int a , long long int b){\n if(a > b)\n return b;\n return a;\n}\n#define For(i, n) for(i=0;i<(n);++i)\n#define ForL(i, m, n) for(i=(m);i<(n);++i)\n\n#define Clear(X) memset( (X), 0, sizeof( (X) ) )\n#define Fill(X) memset( (X), -1, sizeof( (X) ) )\n\n#define ArraySize(X) (sizeof(X)/sizeof(X[0]))\n\n\n\nvoid _main();\n\nint main() {\n // COUNTER CODE STARTS HERE\n _main();\n // COUNTER CODE ENDS HERE\n\n return 0;\n}\n\n// ACTUAL CODE STARTS BELOW\n\nll a, b, c, l;\nll ans = 0;\n\nll exclude(ll a, ll b, ll c, ll r) {\n if (a < b + c) return 0;\n ll v = min(r, a - b - c);\n return ((v + 1) * (v + 2)) >> 1;\n\n}\n\nvoid _main() {\n scanf(\"%d %d %d %d\", &a , &b , &c , &l);\n for (ll i = 0; i <= l; ++i) {\n ans += (((i + 1) * (i + 2)) >> 1);\n }\n\n for (ll i = 0; i <= l; ++i) {\n ans -= exclude(a + i, b, c, l - i);\n ans -= exclude(b + i, a, c, l - i);\n ans -= exclude(c + i, b, a, l - i);\n }\n printf(\"%I64d\\n\", ans);\n}\n\n", "src_uid": "185ff90a8b0ae0e2b75605f772589410"} {"source_code": "#include\n#include\nint main()\n{\n char s[105]; int i;\n gets(s);\n for(i=(strlen(s)-1);i>=0;i--)\n {\n if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))\n {\n if(s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U' || s[i] == 'Y' ||\n s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u' || s[i] == 'y') {\n printf(\"YES\");\n return 0;\n }\n else\n {\n printf(\"NO\"); return 0;\n }\n }\n else continue;\n }\n\n return 0;\n}\n", "src_uid": "dea7eb04e086a4c1b3924eff255b9648"} {"source_code": "#include\n#include\n#include\nchar a[105];\nint judge(int );\nint max(int ,int );\nint max(int x,int y)\n{\n return (x>y)?x:y;\n}\nint judge(int n)\n{\n int i,p=1;\n for(i=0;i\n#include \n\nint ***sol;\nint N, K;\nconst int kInvalidSol = -10000;\nvoid new_sol() {\n\tsol = (int***)malloc(sizeof(int**) * (N + 1));\n\tfor (int n = 0; n <= N; ++n) {\n\t\tsol[n] = (int**)malloc(sizeof(int*) * (K + 1));\n\t\tfor (int k = 0; k <= K; ++k) {\n\t\t\tsol[n][k] = (int*)malloc(sizeof(int) * (N + 1));\n\t\t\tfor (int i = 0; i <= N; ++i) {\n\t\t\t\tsol[n][k][i] = kInvalidSol;\n\t\t\t}\n\t\t}\n\t}\n}\nvoid free_sol() {\n\tfor (int i = 0; i <= N; ++i) {\n\t\tfor (int j = 0; j <= K; ++j) {\n\t\t\tfree(sol[i][j]);\n\t\t}\n\t\tfree(sol[i]);\n\t}\n\tfree(sol);\n}\nvoid try_update_sol(int n, int k, int i, int value) {\n\tif (value >= 0 && sol[n][k][i] < value) {\n\t\tsol[n][k][i] = value;\n\t}\n}\nint main() {\n\tchar s[201], t[3];\n\tscanf(\"%d%d\\n%s\\n%s\", &N, &K, s, t);\n\t\n\tif (t[0] == t[1]) {\n\t\tint cc = 0;\n\t\tfor (int i = 0; i < N; ++i) {\n\t\t\tif (s[i] == t[0]) {\n\t\t\t\t++cc;\n\t\t\t}\n\t\t}\n\t\tcc += K;\n\t\tif (cc > N) {\n\t\t\tcc = N;\n\t\t}\n\t\tprintf(\"%d\\n\", cc * (cc - 1) / 2);\n\t\treturn 0;\n\t} \n\tnew_sol();\n\tint t0 = 0;\n\tsol[0][0][0] = 0;\n\tfor (int n = 1; n <= N; ++n) {\n\t\tif (s[n - 1] == t[0]) {\n\t\t\t++t0;\n\t\t\tif (t0 == 1) {\n\t\t\t\tsol[n][0][1] = 0;\n\t\t\t} else {\n\t\t\t\ttry_update_sol(n, 0, t0, sol[n - 1][0][t0 - 1]);\n\t\t\t}\n\t\t} else if (s[n - 1] == t[1]) {\n\t\t\ttry_update_sol(n, 0, t0, sol[n - 1][0][t0] + t0);\n\t\t} else {\n\t\t\ttry_update_sol(n, 0, t0, sol[n - 1][0][t0]);\n\t\t}\n\t\t// for (int k = cc; k <= K; ++k) {\n\t\t// \ttry_update_sol(n, k, 0, 0);\n\t\t// }\n\t}\n\tfor (int k = 1; k <= K; ++k) {\n\t\ttry_update_sol(1, k, 1, 0);\n\t\tfor (int n = 2; n <= N; ++n) {\n\t\t\tfor (int i = 1; i <= n; ++i) {\n\t\t\t\ttry_update_sol(n, k, i, sol[n][k - 1][i]);\n\t\t\t\tif (s[n - 1] == t[0]) {\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k][i - 1]);\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);\n\t\t\t\t} else if (s[n - 1] == t[1]) {\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k][i] + i);\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);\n\t\t\t\t} else {\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);\n\t\t\t\t\ttry_update_sol(n, k, i, sol[n - 1][k][i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\t\t\n\tint max = 0;\n\tfor (int i = 1; i <= N; ++i) {\n\t\tif (sol[N][K][i] > max) {\n\t\t\tmax = sol[N][K][i];\n\t\t}\n\t}\n\tprintf(\"%d\\n\", max);\n\tfree_sol();\n\treturn 0;\n}", "src_uid": "9c700390ac13942cbde7c3428965b18a"} {"source_code": "#include\n#include\n\n#define MAX_STRING_LEN 100000\n\nint main() \n{\n \n char S[MAX_STRING_LEN];\n int l, i,b=0,c,d=0;\n scanf(\"%d%s\",&i,&S);\n for(c=0;c\n#include \n\nint f[80][80][80][2];\nint posV[80], posK[80], posX[80];\nint cntV[80], cntK[80], cntX[80];\nint NewDist(int pos, int nV, int nK, int nX) {\n\tint newPos;\n\tnewPos = 0;\n\tnewPos += nV > cntV[pos - 1] ? nV : cntV[pos - 1];\n\tnewPos += nK > cntK[pos - 1] ? nK : cntK[pos - 1];\n\tnewPos += nX > cntX[pos - 1] ? nX : cntX[pos - 1];\n\treturn newPos - (nV + nK + nX);\n}\n\n\nint main(int argc, char *argv[]) {\n\tint n, nV, nK, nX, i, j, k, t;\n\tchar str[80];\n\tscanf(\"%d\\n%s\", &n, str + 1);\n\tfor (i = 1, nV = nK = nX = 0; i <= n; ++i) {\n\t\tcntV[i] = cntV[i - 1];\n\t\tcntK[i] = cntK[i - 1];\n\t\tcntX[i] = cntX[i - 1];\n\t\tif (str[i] == 'V') ++cntV[posV[++nV] = i];\n\t\telse if (str[i] == 'K') ++cntK[posK[++nK] = i];\n\t\telse ++cntX[posX[++nX] = i];\n\t}\n\tmemset(f, 0x70, sizeof(f));\n\tf[0][0][0][0] = 0;\n\tfor (i = 0; i <= nV; ++i)\n\t\tfor (j = 0; j <= nK; ++j)\n\t\t\tfor (k = 0; k <= nX; ++k) {\n\t\t\t\tif (i) {\n\t\t\t\t\tt = f[i - 1][j][k][0] + NewDist(posV[i], i - 1, j, k);\n\t\t\t\t\tif (t < f[i][j][k][1]) f[i][j][k][1] = t;\n\t\t\t\t\tt = f[i - 1][j][k][1] + NewDist(posV[i], i - 1, j, k);\n\t\t\t\t\tif (t < f[i][j][k][1]) f[i][j][k][1] = t;\n\t\t\t\t}\n\t\t\t\tif (j) {\n\t\t\t\t\tt = f[i][j - 1][k][0] + NewDist(posK[j], i, j - 1, k);\n\t\t\t\t\tif (t < f[i][j][k][0]) f[i][j][k][0] = t;\n\t\t\t\t}\n\t\t\t\tif (k) {\n\t\t\t\t\tt = f[i][j][k - 1][0] + NewDist(posX[k], i, j, k - 1);\n\t\t\t\t\tif (t < f[i][j][k][0]) f[i][j][k][0] = t;\n\t\t\t\t\tt = f[i][j][k - 1][1] + NewDist(posX[k], i, j, k - 1);\n\t\t\t\t\tif (t < f[i][j][k][0]) f[i][j][k][0] = t;\n\t\t\t\t}\n\t\t\t}\n\tif (f[nV][nK][nX][0] < f[nV][nK][nX][1]) printf(\"%d\\n\", f[nV][nK][nX][0]);\n\telse printf(\"%d\\n\", f[nV][nK][nX][1]);\n\treturn 0;\n}", "src_uid": "08444f9ab1718270b5ade46852b155d7"} {"source_code": "#include\nint main()\n{\n int a,b,c=0,i;\n char s[1000];\n scanf(\"%s\",s);\n if(strlen(s)>=5)\n {\n c++;\n }\n for(i=0; i='a'&&s[i]<='z')\n {\n c++;\n break;\n }\n }\n for(i=0; i='A'&&s[i]<='Z')\n {\n c++;\n break;\n }\n }\n for(i=0; i='0'&&s[i]<='9')\n {\n c++;\n break;\n }\n }\n if(c>=4)\n {\n printf(\"Correct\");\n }\n else\n {\n printf(\"Too weak\");\n }\n}\n", "src_uid": "42a964b01e269491975965860ec92be7"} {"source_code": "/*\n Sachin Chandani\n IIIT Hyderabad\n */\n\n#include\n#include\n#include\n#include\n#include\n#include\ntypedef long long int ll;\n#define INF INT_MAX\nint min(int a,int b);\nvoid swap(int *a,int *b);\nvoid swap(int *a,int *b)\n{\n\tint temp=*a;\n\t*a=*b;\n\t*b=temp;\n}\nint cmp(const void *a,const void *b)\n{\n\treturn(*(int*)a-*(int*)b);\n\n}\nint min(int a,int b)\n{\n\treturn(a>b?b:a);\n}\n\nint main()\n{\n\tint A,B;\n\tscanf(\"%d%d\",&A,&B);\n\tint a2=0,b2=0,a3=0,b3=0,a5=0,b5=0;\n\tbool flag=false;\n\twhile(flag==false)\n\t{\n\t\tif(A%2==0)\n\t\t{\n\t\t\tA/=2;\n\t\t\ta2++;\n\t\t}\n\t\tif(A%3==0)\n\t\t{\n\t\t\tA/=3;\n\t\t\ta3++;\n\t\t}\n\t\tif(A%5==0)\n\t\t{\n\t\t\tA/=5;\n\t\t\ta5++;\n\t\t}\n\t\tif(B%2==0)\n\t\t{\n\t\t\tB/=2;\n\t\t\tb2++;\n\t\t}\n\t\tif(B%3==0)\n\t\t{\n\t\t\tB/=3;\n\t\t\tb3++;\n\t\t}\n\t\tif(B%5==0)\n\t\t{\n\t\t\tB/=5;\n\t\t\tb5++;\n\t\t}\n\t\tif(A%2!=0 && B%2!=0 && A%3!=0 && B%3!=0 && A%5!=0 && B%5!=0)\n\t\t{\n\t\t\tflag=true;\n\t\t}\n\n\t}\n\tprintf(\"%d\",(A!=B?-1:(abs(a2-b2)+abs(a3-b3)+abs(a5-b5))));\n\n\n\n\treturn 0;\n}\n\n", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49"} {"source_code": "#include\nint main()\n{\n\tint i,n,a[12][12],b[12][12]={0},t=0,m,j,count=0;;\n\tscanf(\"%d%d\",&n,&m);\n\tgetchar();\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tfor(j=1;j<=m;j++)\n\t\t{\n\t\t\ta[i][j]=getchar();\n\t\t\tif(a[i][j]=='P')\n\t\t\t\tb[i][j]=1;\n\t\t\tif(a[i][j]=='W')\n\t\t\t\tb[i][j]=2;\n\t\t}\n\t\tgetchar();\n\t}\n\tfor(i=1;i<=n;i++)\n\t\tfor(j=1;j<=m;j++)\n\t\t\tif(b[i][j]==2)\n\t\t\t{\n\t\t\t\tif(b[i-1][j]==1)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tb[i-1][j]=0;\n\t\t\t\t}\n\t\t\t\telse if(b[i][j-1]==1)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tb[i][j-1]=0;\n\t\t\t\t}\n\t\t\t\telse if(b[i+1][j]==1)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tb[i+1][j]=0;\n\t\t\t\t}\n\t\t\t\telse if(b[i][j+1]==1)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tb[i][j+1]=0;\n\t\t\t\t}\n\t\t\t}\n\n\tprintf(\"%d\\n\",count);\n\treturn 0;\n}\n \t\t \t \t\t \t\t \t\t\t \t\t\t\t", "src_uid": "969b24ed98d916184821b2b2f8fd3aac"} {"source_code": "#include \n\nint main()\n{\n int n,k,i,t[100];\n int j=0;\n scanf(\"%d\",&n);\n scanf(\"%d\",&k);\n\n\n\n for(i=0; i\n\nmain()\n{\n int i=0, j=0;\n char a[103];\n scanf(\"%s\", a);\n for(int g=0; a[g]!='\\0'; g++)\n {\n if(a[g]=='o')\n i++;\n else \n j++;\n }\n if(i==0 || (j>=i && j%i==0) || j==0)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n}", "src_uid": "6e006ae3df3bcd24755358a5f584ec03"} {"source_code": "#include \n#include \n#define MAX(a, b) ((a) < (b) ? (b) : (a))\n\nstatic int n;\nstatic int B;\nstatic int A[100];\n// D[c][b] = best number of cuts with last cut being at position y and while\n// spending x bitcoins. Cut at position 0 = dummy base\nstatic int D[100][101];\nstatic int neven[101];\n\nint main(void)\n{\n int i, j, k;\n scanf(\"%d %d\\n\", &n, &B);\n\n for (i = 0; i < n; i++)\n scanf(\"%d\", &A[i]);\n\n neven[0] = 0;\n for (i = 1; i <= n; i++)\n neven[i] = neven[i-1] + !(A[i-1] & 1);\n\n\n D[0][0] = 0;\n for (i = 1; i < n; i++) { // for cut position\n int b = abs(A[i] - A[i-1]); // cost of cut\n for (j = 0; j < i; j++) { // for last cut position\n if (neven[i] - neven[j] != \n i - j - (neven[i] - neven[j]))\n continue;\n\n for (k = 0; k <= B - b; k++)\n D[i][k+b] = MAX(D[i][k+b], D[j][k] + 1);\n }\n }\n\n int best = 0;\n for (i = 0; i < n; i++) {\n /*\n printf(\"Maybe %d? n=%d, neven[n] - neven[i] = %d\\n\",\n i, n, neven[n] - neven[i]);\n */\n if (neven[n] - neven[i] != n - i - (neven[n] - neven[i]))\n continue;\n /*\n printf(\"HERE: %d\\n\", D[i][k]);\n */\n for (k = 0; k <= B; k++)\n best = MAX(best, D[i][k]);\n }\n\n printf(\"%d\\n\", best);\n\n return 0;\n}\n", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e"} {"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\nint main()\n{\n\nchar c[101];\nint i,onedig[8][1],twodig[8][2],l,r,j,r1,k,t;\n//printf(\"kous\");\n\n//for(t=0;t<10;t++)\n//{\nfor(i=0;i<8;i++)\n{\n onedig[i][0]=-1;\n twodig[i][0]=-1;\n twodig[i][1]=-1;\n}\nscanf(\"%s\",c);\nl=strlen(c);\n\nstrrev(c);\n\nfor(i=0;i=i)\n continue;\n r1=(r+j)%8;\n if(twodig[r1][0]!=-1)\n continue;\n twodig[r1][0]=onedig[j][0];\n twodig[r1][1]=i;\n\n }\n}\n\n\n\nfor(i=2;i=i)\n continue;\n\n r1=(r+j)%8;\n if(r1==0)\n break;\n\n\n\n }\n\n if(j<8)\n break;\n\n\n}\n\nif(i==l||l<3)\n{\n\n if(twodig[0][0]!=-1)\n {\n printf(\"YES\\n\");\n printf(\"%d\\n\",(c[twodig[0][1]]-'0')*10+c[twodig[0][0]]-'0');\n return 0 ;\n }\n if(onedig[0][0]!=-1)\n {\n printf(\"YES\\n\");\n printf(\"%d\\n\",c[onedig[0][0]]-'0');\n //continue ;\n return 0;\n }\n\n printf(\"NO\\n\");\n}\nelse\n{\n\n\n printf(\"YES\\n\");\n for(k=l-1;k>=i;k--)\n\n //if(k==i)\n\n printf(\"%c\",c[k]);\n // break;\n //}\n for(;k>twodig[j][1];k--){}\n printf(\"%c\",c[k]);\n\n for(;k>twodig[j][0];k--){}\n printf(\"%c\",c[k]);\n\nprintf(\"\\n\");\n\n\n}\n//}\nreturn 0;\n}\n", "src_uid": "0a2a5927d24c70aca24fc17aa686499e"} {"source_code": "/*\nID: mohamma73\nLANG: C\nTASK: crypt1\n*/\n\n#include\"stdio.h\"\n#include\"stdlib.h\"\n#include\"ctype.h\"\n#include\"math.h\"\n#include\"string.h\"\nstruct element{\n\tint val;\n\tint indx;\n};\nstruct person{\n\tint id;\n\tint n;\n\tint op[100];\n};\nstruct farmer{\n\tint p;\n\tint c;\n};\nvoid inc(int *a,int n){\n\tint i;\n\tif(a[0]!=2){\n\t\ta[0]++;\n\t\treturn;\n\t}\n\tfor(i=0;it[j])\n\t\treturn 1;\n\telse if(s[i]0 && a[j]l){\n\t\tint q=(l+n)/2;\n\t\tmergesort(a,l,q);\n\t\tmergesort(a,q+1,n);\n\t\tmerge(a,l,q,n);\n\t}\n}\nint isOkay(int a,int *s , int n){\n\tif(a<100 || a>=1000)\n\t\treturn 0;\n\tint c,i;\n\twhile(a/10>0){\n\t\tc=0;\n\t\tfor(i=0;i=10000)\n\t\treturn 0;\n\tint c,i;\n\twhile(a/10>0){\n\t\tc=0;\n\t\tfor(i=0;i0 && a[j-1]>a[j];j--){\n\t\t\t\ttemp=a[j];\n\t\t\t\ta[j]=a[j-1];\n\t\t\t\ta[j-1]=temp;\n\t\t\t\n\t\t}\n}\nvoid fun(int n,char *s){\n\tint i=0;\n\tfor(i=0;n/10!=0;i++,n/=10)\n\t\ts[i]=n%10+'0';\n\ts[i++]=n+'0';\n\ts[i]='\\0';\n}\nvoid sortIn(int *a,int *indx,int n){\n\tint t1;\n\tint i,j;\n\tfor(i=1;i0 && a[j-1]>a[j];j--){\n\t\t\tt1=a[j-1];\n\t\t\ta[j-1]=a[j];\n\t\t\ta[j]=t1;\n\t\t\tt1=indx[j-1];\n\t\t\tindx[j-1]=indx[j];\n\t\t\tindx[j]=t1;\n\t\t}\n}\nint valid(int *a,int l,int r,int n){\n\tint f=0;\n\tif(l>0 && a[l-1]>a[r])\n\t\tf=1;\n\tif(a[l+1]a[l])\n\t\tf=1;\n\tif(r=d)\n\t\t\tbreak;\n\t}\n\tif(i==0){\n\t\tprintf(\"%I64d\",p);\n\t\treturn 0;\n\t}else if(max>=i){\n\t\tprintf(\"%I64d\",p);\n\t\treturn 0;\n\t}\n\tp-=(a/10);\n\tif(p/(a/10)>0)\n\t\tprintf(\"%I64d\",p/(a/10));\n\tfor(;i>0;i--)\n\t\tprintf(\"%d\",9);\n\treturn 0;\n}\n", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a"} {"source_code": "#include\nint main()\n{\n\tlong int x,y,x1,x2,y1,y2,i,j;\n\tscanf(\"%ld%ld\",&x,&y);\n\tif(x>0&&y>0)\n\t{\n\t\tprintf(\"%ld %ld %ld %ld\\n\",0,x+y,x+y,0);\n\t}\n\telse if(x<0&&y<0)\n\t{\n\t\tprintf(\"%ld %ld %ld %ld\\n\",x+y,0,0,x+y);\n\t}\n\telse if(x>0&&y<0)\n\t{\n\t\tprintf(\"%ld %ld %ld %ld\\n\",0,y-x,x-y,0);\n\t}\n\telse\n\t{\n\t\tprintf(\"%ld %ld %ld %ld\\n\",x-y,0,0,y-x);\n\t}\n\treturn 0;\n}\n", "src_uid": "e2f15a9d9593eec2e19be3140a847712"} {"source_code": "#include\n#include\nint main()\n{\n double ax,ay,bx,by,cx,cy;\n double d1,d2;\n scanf(\"%lf%lf%lf%lf%lf%lf\",&ax,&ay,&bx,&by,&cx,&cy);\n d1=(ay-by)*(ay-by)+(bx-ax)*(bx-ax);\n d2=(cy-by)*(cy-by)+(cx-bx)*(cx-bx);\n if(((ay-by)/(ax-bx)==(cy-by)/(cx-bx)||(ax==bx&&bx==cx)))\n printf(\"No\\n\");\n else\n {\n if(d1==d2)\n printf(\"Yes\\n\");\n else printf(\"No\\n\");\n }\n\n return 0;\n}\n", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab"} {"source_code": "#include \n#include \n\nmain()\n {\n int i,j,k,test;\n char s[101];\n scanf(\"%s\",s);\n i = 0;\n while ((s[i]!='\\0') && (s[i]!='@') && ((('a'<=s[i]) && (s[i]<='z')) || (('A'<=s[i]) && (s[i]<='Z')) || (('0'<=s[i]) && (s[i]<='9')) || (s[i]=='_'))) i++;\n if ((s[i]=='\\0') || (s[i]!='@') || (i==0) || (16\nint swap(int* a,int* b)\n{\n\tint c;\n\tc = *a;\n\t*a = *b;\n\t*b = c;\n}\nint main()\n{\n\tint count;\n\tint store;\n\tint arr[3];\n\n\tscanf(\"%d%d\",&count,&store);\n\n\tint c = store;\n\tfor(int i=0;i<3;i++)\n\t{\n\t\tarr[i] == i;\n\t}\n\t\n\tint j,k;\n\tj = c;\n\n\tif(count % 6 == 0)\n\t{\n\t\tif(j == 0)\n\t\t{\n\t\t\tarr[j] = 0;\n\t\t}\n\n\t\telse if(j == 1)\n\t\t{\n\t\t\tarr[j] = 1;\n\t\t}\n\n\t\telse if(j == 2)\n\t\t{\n\t\t\tarr[j] = 2;\n\t\t}\n\n\t}\n\n\telse if(count % 6 == 1)\n\t{\n\t\tif(j == 0)\n\t\t{\n\t\t\tarr[j] = 1;\n\t\t}\n\t\telse if(j == 1)\n\t\t{\n\t\t\tarr[j] = 0;\n\t\t}\n\t\telse if(j == 2)\n\t\t{\n\t\t\tarr[j] = 2;\n\t\t}\n\n\t}\n\n\telse if(count % 6 == 2)\n\t{\n\t\tif(j == 0)\n\t\t{\n\t\t\tarr[j] = 1;\n\t\t}\n\t\telse if(j == 1)\n\t\t{\n\t\t\tarr[j] = 2;\n\t\t}\n\t\telse if(j == 2)\n\t\t{\n\t\t\tarr[j] = 0;\n\t\t}\n\t}\n\n\telse if(count % 6 == 3)\n\t{\n\t\tif(j == 0)\n\t\t{\n\t\t\tarr[j] = 2;\n\t\t}\n\t\telse if(j == 1)\n\t\t{\n\t\t\tarr[j] = 1;\n\t\t}\n\n\t\telse if(j == 2)\n\t\t{\n\t\t\tarr[j] = 0;\n\t\t}\n\t}\n\n\telse if(count % 6 == 4)\n\t{\n\t\tif(j == 0)\n\t\t{\n\t\t\tarr[j] = 2;\n\t\t}\n\n\t\telse if(j == 1)\n\t\t{\n\t\t\tarr[j] = 0;\n\t\t}\n\t\telse if(j == 2)\n\t\t{\n\t\t\tarr[j] = 1;\n\t\t}\n\n\t}\n\n\telse if(count % 6 == 5)\n\t{\n\t\tif(j == 0)\n\t\t{\n\t\t\tarr[j] = 0;\n\t\t}\n\n\t\telse if(j == 1)\n\t\t{\n\t\t\tarr[j] = 2;\n\t\t}\n\n\t\telse if(j == 2)\n\t\t{\n\t\t\tarr[j] = 1;\n\t\t}\n\t}\n\t\t\n/*\twhile(count > 0)\n\t{\n\t\tif(count % 2 == 0)\n\t\t{\n\t\t\tswap(&arr[1],&arr[2]);\n\t\t\tif(j == 2)\n\t\t\t{\n\t\t\t\tj = 1;\n\t\t\t}\n\n\t\t\telse if(j == 1)\n\t\t\t{\n\t\t\t\tj = 2;\n\t\t\t}\n\t\t\tcount = count - 1;\n\t\t\tk = j - 1;\n\t\t\tswap(&arr[j],&arr[k]);\n\t\t\tcount = count - 1;\n\t\t\tj = k;\n\t\t}\n\t\t\n\t\telse\n\t\t{\n\t\t\tswap(&arr[0],&arr[1]);\n\t\t\tif(j == 1)\n\t\t\t{\n\t\t\t\tj = 0;\n\t\t\t}\n\n\t\t\telse if(j == 0)\n\t\t\t{\n\t\t\t\tj = 1;\n\t\t\t}\n\t\t\tcount = count - 1;\n\n\t\t\tk = j + 1;\n\t\t\tswap(&arr[j],&arr[k]);\n\t\t\tcount = count - 1;\n\t\t\tj = k;\n\t\t}\n\n\t}*/\n\n\tprintf(\"%d\\n\",arr[j]);\n\n\treturn 0;\n}\n\n\n", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0"} {"source_code": "#include \n#include \n#include \n\nint main()\n{\n int vR=0,vG=0,vB=0,vY=0,i,j,cpt=0;\n char a='l',ch[100];\n scanf(\"%s\",&ch);\n\n\n\n for(i=0;i<4;i++){\n\n a='l';\n cpt=0;\n for(j=i+4;j\n#include\nint cmpfunc (const void * a, const void * b)\n{\n\t return ( *(int*)a - *(int*)b );\n}\nint main()\n{\n\tint m,i,a[104],x,y,s,t=0;\n\tscanf(\"%d\",&m);\n\tt=0;\n\tfor(i=1;i<=m;i++)\n\t{\n\t\tscanf(\"%d\",&a[i]);\n\t\tt=t+a[i];\n\t}\n\tscanf(\"%d %d\",&x,&y);\n//\tqsort(a,m,sizeof(int),cmpfunc);\n\ts=0;\n\tfor(i=1;i<=m;i++)\n\t{\n\t//\tprintf(\"%d \",a[i]);\n\t\ts=s+a[i];\n\t\tif(s>=x && s<=y && t-s>=x && t-s<=y && i!=0)\n\t\t{\n\t\t\tprintf(\"%d\",i+1);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"0\");\n\treturn 0;\n}\n", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b"} {"source_code": "#include \n#include \n\n#define N 100\n\nint main() {\n\tstatic char s[N + 1], t[N + 1];\n\n\tscanf(\"%s%s\", s, t);\n\tprintf(\"%s\\n\", strcmp(s, t) == 0 ? s : \"1\");\n\treturn 0;\n}\n", "src_uid": "9c5b6d8a20414d160069010b2965b896"} {"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", "src_uid": "34b67958a37865e1ca0529bbf528dd9a"} {"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 }", "src_uid": "0fdd91ed33431848614075ebe9d2ee68"} {"source_code": "#include\n#include\nint main( )\n{\n int n,m,i,j,c;\n scanf(\"%d\" ,&m);\n int arr[m];\n memset(arr , 0 , sizeof(arr));\t\t\t\t\t\t\t\t\t\t//new!!\n for(i=2;i*i<=m;i++){\n\t\tfor(j=i*i;j<=m;j+=i){\n\t\tarr[j]=1;\n\t\t}\n\t}\n /*for(i=1;i<=m;i++){\n \tprintf(\"%d\\n\" ,arr[i]);\n }*/\n c=0;\n for(j=1;j<=m;j++){\n \tn=0;\n for(i=2;i<=j;i++){\n \tif(arr[i]==0){\n \t\tif(j%i==0){\n \t\t\tn++;\n \t\t\t//printf(\">>%d\\t\" ,i);\n\t\t}\n\t }\n }\n //printf(\"for j=%d n=%d\\n\" ,j , n);\n if(n==2) ++c;\n }\n printf(\"%d\" ,c);\n return 0;\n}", "src_uid": "356666366625bc5358bc8b97c8d67bd5"} {"source_code": "#include\nint main()\n{\n int n,a[105],i,sum=0,count=0;\n scanf(\"%d\",&n);\n for(i=0;i\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", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93"} {"source_code": "#include\n#include\n#include\nint main () {\n int a[11][1024],i,j,p=0;\n a[1][0]=1;\n a[1][1]=-1;\n for(i=2;i<=10;i++) {\n for(j=0;j<(int)pow(2,i-1);j++)\n a[i][p++]=a[i-1][j]+1;\n for(j=0;j<(int)pow(2,i-1);j++)\n a[i][p++]=a[i-1][j]-1;\n p=0;\n }\n int d=0,f=0,k=0,ctr=0;\n double ans,ctr1,p1;\n char c[11],b[11];\n scanf(\"%s%s\",c,b);\n for(i=0;i\n#include\nint min(int,int);\nint main()\n{\n int i,t,n,p,l,r,count1,count2,s,x,y,z;\n scanf(\"%d %d %d %d\",&n,&p,&l,&r);\n if((l==1)&&(r==n))\n printf(\"0\");\n else\n {\n if(l==1)\n {\n if(r\n\nint main(){\n\n int x, a, b, y, z;\n\n scanf(\"%d %d\",&a, &b);\n\n x = a+b;\n\n if(x%2 == 0){\n\n \ty = z = x/2;\n }\n else{\n\n \ty = x/2;\n\n \tz = y + 1;\n }\n\n if(a == 0 && b == 0) printf(\"NO\\n\");\n else if(a == y && b == z||a == z&& b == y ) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n\n\treturn 0;\n}\n", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037"} {"source_code": "#include\nmain()\n{\n int a,b,c;\n scanf(\"%d %d %d\",&a,&b,&c);\n printf(\"%d\",((a-1)*(b+c-1)+(b*c)));\n return 0;\n}\n \n", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da"} {"source_code": "#include\n#include\n\nint main()\n{\n long n,x,y,t;\n long sum;\n scanf(\"%ld%ld%ld\",&n,&x,&y);\n sum=n*y;\n if(sum%100==0)\n t=sum/100;\n else\n t=sum/100+1;\n t-=x;\n if(t<0) t=0;\n printf(\"%ld\",t);\n return 0;\n}\n", "src_uid": "7038d7b31e1900588da8b61b325e4299"} {"source_code": "/* practice with Dukkha */\n#include \n\n#define N\t4000\n#define MD\t1000000007\n\nint main() {\n\tstatic int ch[N + 1][N + 1], dp[N + 1], pp[N + 1];\n\tint n, i, j, k, p;\n\tlong long x, y, ans;\n\n\tscanf(\"%d\", &n);\n\tch[0][0] = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tch[i][0] = 1;\n\t\tfor (j = 1; j <= n; j++)\n\t\t\tch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;\n\t}\n\tdp[0] = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tx = 0;\n\t\tfor (j = 2; j <= i; j++) {\n\t\t\ty = dp[i - j];\n\t\t\tif (dp[i - j] != 0)\n\t\t\t\tx = (x + y * ch[i - 1][j - 1]) % MD;\n\t\t}\n\t\tdp[i] = x;\n\t}\n\tp = 1;\n\tfor (i = 0; i <= n; i++) {\n\t\tpp[i] = p - 1;\n\t\tp = p * 2 % MD;\n\t}\n\tans = 0;\n\tfor (k = 1; k <= n; k++)\n\t\tans = (ans + (long long) pp[k] * ch[n][k] % MD * dp[n - k]) % MD;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "aa2c3e94a44053a0d86f61da06681023"} {"source_code": "#include\n#include\nint main(){\n\nint n;\nscanf(\"%d\",&n);\nint gap=1,sum=1,count=1;\nwhile(count\n#include\n#include\nint main()\n{\n int i,j,k,l,m,temp,res=0,max=0;\n char s[300],in[10];\n scanf(\"%s\",s);\n scanf(\"%d\",&k);\n l=strlen(s);\n if(k>=l)\n printf(\"%d\\n\",((k+l)/2)*2);\n else\n {\n for(i=0;i=1;j--)\n {\n temp=0;\n for(m=i;m=l)\n break;\n if(s[m]!=s[m+j])\n {temp=-1;break;}\n }\n if(temp==0 && j>max)\n max=j;\n //printf(\"%d %d %d %d\\n\",i,j,temp,max);\n }\n \n }\n if(max>k)\n printf(\"%d\\n\",2*max);\n else\n printf(\"%d\\n\",2*k);\n }\n return 0;\n}", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab"} {"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", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e"} {"source_code": "#include\nint main()\n{\n int a1,b1,c1,a2,b2,c2;\n scanf(\"%d%d%d\",&a1,&b1,&c1);\n scanf(\"%d%d%d\",&a2,&b2,&c2);\n if(a1==a2 || b1==b2 || c1==c2)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6"} {"source_code": "#include\nint main()\n{\n\n long long s[]={0,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};\n long long n,i=0,a,cnt=0;\n scanf(\"%I64d\",&n);\n long long f=n;\n while(n!=0)\n {\n if(n%10!=0)\n {\n cnt++;\n }\n a=n%10;\n n=n/10;\n i++;\n }\n if(cnt>1 && i!=1)\n {\n printf(\"%I64d\\n\",(a+1)*(s[i-1])-f);\n }\n else if(cnt==1 && i!=1)\n {\n printf(\"%I64d\\n\",(s[i-1]));\n }\n else if(i==1)\n printf(\"1\\n\");\n return 0;\n\n}\n", "src_uid": "a3e15c0632e240a0ef6fe43a5ab3cc3e"} {"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 */\nlong long ans,s,x;\nint max,k,n1,n2,i,j,a[100],b[100],c[100];\nint main(int argc, char *argv[]) {\n\tscanf(\"%I64d%I64d\",&s,&x);\n\tmemset(a,0,sizeof(a));\n\tmemset(b,0,sizeof(b));\n\tmemset(c,0,sizeof(c));\n\tn1=0;n2=0;\n\twhile(s!=0)\n\t{\t\n\ta[n1]=s%2;\n\ts=s/2;\n\tn1++;\n\t}\n\twhile(x!=0)\n\t{\t\n\tb[n2]=x%2;\n\tx=x/2;\n\tn2++;\n\t}\n\n\tj=0;\n\tk=0;\n\tans=1;\n\twhile(j<=n1||j<=n2)\n\t{\n\tif(k==0)\n\t {\n\t if(b[j]!=a[j]) {ans=0;break;}\n\t if(b[j]==1) {c[j]=2;k=0;}\n\t if(b[j]==0) \n\t {\n\t\tif(a[j+1]==b[j+1])\n\t\t {c[j]=0;k=0;}\n\t\telse\n\t\t {c[j]=1;k=1;}\n\t\t}\n\t }\n\telse\n\t {\n\t if(b[j]==a[j]) {ans=0;break;}\n\t if(b[j]==1) {c[j]=2;k=1;}\n\t if(b[j]==0) \n\t {\n\t\tif(a[j+1]==b[j+1])\n\t\t {c[j]=0;k=0;}\n\t\telse\n\t\t {c[j]=1;k=1;}\n\t\t}\n\t \n\t }\n\tj++;\n\t}\n\tif(ans==0)\n\tprintf(\"%I64d\\n\",ans);\n\telse\n\t{\n\t\ti=0;j=0;\n\t\twhile(j<=n1||j<=n2)\n\t\t{\n\t\tif(c[j]==2)\n\t\tans*=2;\n\t\tif(c[j]==1)\n\t\ti=1;\n\t\tj++;\n\t\t}\n\tif(i==0&&ans>=2)\n\tans=ans-2;\n\tprintf(\"%I64d\\n\",ans);\n\t\n\t}\n\t\n\t\n\treturn 0;\n}", "src_uid": "18410980789b14c128dd6adfa501aea5"} {"source_code": "#include \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} ", "src_uid": "1c80040104e06c9f24abfcfe654a851f"} {"source_code": "#include\nint v[100];\nint main(){\n\tint n,i;\n\tint prev = 0;\n\tint min = 0;\n\tscanf(\"%d\",&n);\n\tfor(i=0;i\n#include \n\ntypedef struct list {\n struct list * next;\n int n;\n} List;\n\ntypedef struct edge {\n struct edge * next;\n int to;\n int weight;\n} Edge;\n\ntypedef struct graph {\n int size;\n Edge * nodes[];\n} Graph;\n\nvoid add_to_list (List ** base, int n) {\n List * list = (List *) malloc(sizeof(List));\n list->n = n;\n list->next = *base;\n (*base) = list;\n}\n\nint list_length (List * list) {\n int i = 0;\n while (list != NULL) {\n i++;\n list = list->next;\n }\n return i;\n}\n\nvoid delete_list (List * list) {\n while (list != NULL) {\n List * ptr = list;\n list = list->next;\n free(ptr);\n }\n}\n\nGraph * new_graph_ptr(int size) {\n Graph * graph = (Graph *) malloc(sizeof(Graph) + size * sizeof(Edge *));\n graph->size = size;\n for (int i = 0; i < size; i++)\n graph->nodes[i] = NULL;\n return graph;\n}\n\nvoid add_edge(Graph * graph, int from, int to, int weight) {\n Edge * edge = (Edge *) malloc(sizeof(Edge));\n edge->to = to;\n edge->weight = weight;\n edge->next = graph->nodes[from];\n graph->nodes[from] = edge;\n}\n\nvoid add_edges(Graph * graph, int from, int to, int weight) {\n add_edge(graph, from, to, weight);\n add_edge(graph, to, from, weight);\n}\n\nvoid delete_graph(Graph * graph) {\n int size = graph->size;\n for (int i = 0; i < size; i++) {\n Edge * edge = graph->nodes[i];\n while (edge != NULL) {\n Edge * ptr = edge;\n edge = edge->next;\n free(ptr);\n }\n }\n free(graph);\n}\n\nint main (void) {\n int a, b;\n scanf(\"%d %d\", &a, &b);\n \n List * list = NULL;\n add_to_list(&list, b);\n while (b > a) {\n if ((b&1) == 0) {\n b >>= 1;\n add_to_list(&list, b);\n } else if (b%10 == 1) {\n b /= 10;\n add_to_list(&list, b);\n } else {\n printf(\"NO\\n\");\n free(list);\n return 0;\n }\n }\n if (a == b) {\n printf(\"YES\\n\");\n printf(\"%d\\n\", list_length(list));\n printf(\"%d\", list->n);\n List * ptr = list->next;\n while (ptr != NULL) {\n printf(\" %d\", ptr->n);\n ptr = ptr->next;\n }\n printf(\"\\n\");\n } else {\n printf(\"NO\\n\");\n }\n free(list);\n return 0;\n}\n", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3"} {"source_code": "#include \n#include \n\nint GetSize(char a[])\n{\n int i;\n for(i=0;a[i]!='\\0';i++);\n return i;\n}\nvoid CopyArr(char a[],char b[],int l,int r)\n{\n int i,j;\n for(i=l,j=0;i<=r;i++,j++)\n{\n a[j]=b[i];\n}\n}\n long long int Max(long long int f,long long int s)\n{\n if(f>s)\n return f;\n else\n return s;\n}\n long long int GetVal(char *s,int l,int r)\n{\nint n;\nlong long int v;\nchar x[30]=\"\";\nCopyArr(x,s,l,r);\nn=GetSize(x);\n v=atoll(x);\n if(v>1000000)\n return -1;\nelse if(x[0]=='0'&&n>1)\n return -1;\nelse\n return v;\n}\nint main()\n{\n int i,j,n;\n long long int l,m,r,max=-1;\n char s[31]=\"\";\n scanf(\"%s\",s);\n n=GetSize(s);\n for(i=0;i\n#include \n#include \n#include \n\n#define MAX 16\n#define max(a,b) ((a)>(b) ? (a):(b))\n#define clr(ar) memset(ar, 0, sizeof(ar))\n\nconst double multiplier = 0.997;\n\nchar str[MAX], color[MAX];\nint n, m, last[MAX], order[MAX], R[MAX], B[MAX];\n\ndouble rand_real(){\n return (double)rand() / RAND_MAX;\n}\n\nint solve(){\n int i, j, res = 0, red = 0, blue = 0, rcard = 0, bcard = 0;\n\n for (j = 0; j < n; j++){\n i = order[j];\n int req_red = max(R[i] - rcard, 0);\n int req_blue = max(B[i] - bcard, 0);\n\n int buy_red = max(req_red - red, 0);\n int buy_blue = max(req_blue - blue, 0);\n\n int tokens_bought = max(buy_red, buy_blue);\n\n res += tokens_bought;\n red += tokens_bought, blue += tokens_bought;\n red -= req_red, blue -= req_blue;\n\n if (color[i] == 'R') rcard++;\n else bcard++;\n }\n return res + n;\n}\n\nint main(){\n int t, i, j, k, x, lim, res, cur, next;\n\n while (scanf(\"%d\", &n) != EOF){\n for (i = 0; i < n; i++){\n scanf(\"%s %d %d\", str, &R[i], &B[i]);\n color[i] = str[0];\n }\n for (i = 0; i < n; i++) order[i] = i;\n\n\n double temperature = 666666;\n cur = res = solve(), lim = 666666;\n\n for (t = 0; t < lim; t++){\n m = ((lim - t - 1) * n * 2 / lim) + 1;\n for (i = 0; i < n; i++) last[i] = order[i];\n\n while (m--){\n i = rand() % n, j = rand() % n;\n x = order[i], order[i] = order[j], order[j] = x;\n }\n\n next = solve();\n if (next < res) res = next;\n\n if (next < cur) cur = next;\n else{\n double p = exp((double)-(next - cur) / temperature);\n if (rand_real() <= p) cur = next;\n else{\n for (i = 0; i < n; i++) order[i] = last[i];\n }\n }\n\n if (temperature > 1e-20) temperature *= multiplier;\n }\n\n printf(\"%d\\n\", res);\n }\n return 0;\n}", "src_uid": "25a77f2b7cb281ff3c7800a20b3e5969"} {"source_code": "#include\nint main()\n{\n int i , n , X = 0 , x=0,d;\n\n scanf(\"%d\",&n) ;\n\n char s[n+1] ;\n\n scanf(\"%s\",s);\n\n for(i = 0 ; s[i] ; i++)\n {\n if(s[i]== 'X')X++;\n else x++;\n\n }\n d = x > X ? x : X ;\n d = d - n/2 ;\n if(x == n/2)\n {\n printf(\"0\\n\");\n puts(s);\n return 0 ;\n }\n i=0;\n n = d ;\n if(X > x)\n {\n while(d)\n {\n\n if(s[i] == 'X'){\n s[i] = 'x';\n d--;\n }\n i++;\n\n }\n printf(\"%d\\n\",n);\n puts(s);\n }\n else\n {\n while(d)\n {\n if(s[i] == 'x'){\n s[i] = 'X';\n d--;\n }\n i++;\n\n\n }\n printf(\"%d\\n\",n);\n puts(s);\n }\n\n return 0 ;\n}\n", "src_uid": "fa6311c72d90d8363d97854b903f849d"} {"source_code": "#include\n\nint main(){\n int largest = 0;\n scanf(\"%d\\n\", &largest);\n for(int i = largest; i > 0; i--)\n {\n if(largest % i == 0)\n {\n largest = i;\n printf(\"%d \" ,i);\n }\n }\n return 0;\n}\n", "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63"} {"source_code": "//In the name of God\n#include \n\n#define MAXN 2100\ndouble pr[MAXN][MAXN];\n\ndouble get_pr(int w,int b)\n{\n if(w<=0 || b<0)\n return 0;\n return pr[w][b];\n}\n\nvoid fill_pr()\n{\n int W,B;\n for(W=1;W=1)\n\t cpr+=w/(w+b);\n\tif(b>=3)\n\t cpr+=(b/(w+b))*((b-1)/(w+b-1))*((b-2)/(w+b-2))*get_pr(W,B-3);\n\tif(b>=2 && w>=1)\n\t cpr+=(b/(w+b))*((b-1)/(w+b-1))*(w/(w+b-2))*get_pr(W-1,B-2);\n\tpr[W][B]=cpr;\n }\n}\n\nint main()\n{\n fill_pr();\n int w,b;\n scanf(\"%d %d\",&w,&b);\n printf(\"%.15lf\\n\",get_pr(w,b));\n return 0;\n}\n", "src_uid": "7adb8bf6879925955bf187c3d05fde8c"} {"source_code": "/* upsolved using pre-shifting */\n/* https://codeforces.com/blog/entry/70720 */\n#include \n\n#define N\t300000\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint main() {\n\tstatic char cc[N + 1];\n\tstatic int pp[N], pp_[N];\n\tint n, h, i, j, p_, k0, k, k_, i_, j_;\n\n\tscanf(\"%d%s\", &n, cc);\n\tfor (i = 0; i < n; i++)\n\t\tpp[i] = (i == 0 ? 0 : pp[i - 1]) + (cc[i] == '(' ? 1 : -1);\n\tif (pp[n - 1] != 0) {\n\t\tprintf(\"0\\n\");\n\t\tprintf(\"1 1\\n\");\n\t\treturn 0;\n\t}\n\tp_ = n + 1;\n\tfor (i = 0; i < n; i++)\n\t\tp_ = min(p_, pp[i]);\n\tfor (i = 0; i < n; i++)\n\t\tpp[i] -= p_;\n\th = -1, k0 = 0;\n\tfor (i = 0; i < n; i++)\n\t\tif (pp[i] == 0)\n\t\t\th = i, k0++;\n\tfor (i = 0; i < n; i++)\n\t\tpp_[i] = pp[(i + h + 1) % n];\n\tk_ = k0, i_ = 0, j_ = 0;\n\tfor (i = 0, j = 0, k = 0; j < n; j++)\n\t\tif (pp_[j] < 1) {\n\t\t\tif (k_ < k)\n\t\t\t\tk_ = k, i_ = i, j_ = j;\n\t\t\ti = j + 1, k = 0;\n\t\t} else if (pp_[j] == 1)\n\t\t\tk++;\n\tfor (i = 0, j = 0, k = 0; j < n; j++)\n\t\tif (pp_[j] < 2) {\n\t\t\tif (k_ < k0 + k)\n\t\t\t\tk_ = k0 + k, i_ = i, j_ = j;\n\t\t\ti = j + 1, k = 0;\n\t\t} else if (pp_[j] == 2)\n\t\t\tk++;\n\tprintf(\"%d\\n\", k_);\n\tprintf(\"%d %d\\n\", (i_ + h + 1) % n + 1, (j_ + h + 1) % n + 1);\n\treturn 0;\n}\n", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d"} {"source_code": "/* practice with Dukkha */\n#include \n#include \n\n#define K\t8\n#define L\t840\n\nlong long min(long long a, long long b) { return a < b ? a : b; }\nlong long max(long long a, long long b) { return a > b ? a : b; }\n\nint main() {\n\tstatic long long aa[K + 1], dp[L * K], dq[L * K];\n\tlong long w, ans, a, p;\n\tint i, y, y_, q, q_;\n\n\tscanf(\"%lld\", &w);\n\tfor (i = 1; i <= K; i++)\n\t\tscanf(\"%lld\", &aa[i]);\n\tmemset(dp, -1, L * K * sizeof *dp);\n\tdp[0] = 0;\n\tfor (i = 1; i <= K; i++) {\n\t\ta = aa[i];\n\t\tfor (y = 0; y < L * K; y++)\n\t\t\tdq[y] = -1;\n\t\tfor (y = 0; y < L * K; y++) {\n\t\t\tif (dp[y] < 0)\n\t\t\t\tcontinue;\n\t\t\tq_ = L / i;\n\t\t\tfor (q = 0; q < q_ && q <= a; q++) {\n\t\t\t\tp = (a - q) / q_;\n\t\t\t\ty_ = y + q * i;\n\t\t\t\tdq[y_] = max(dq[y_], dp[y] + p);\n\t\t\t}\n\t\t}\n\t\tfor (y = 0; y < L * K; y++)\n\t\t\tdp[y] = dq[y];\n\t}\n\tans = 0;\n\tfor (y = 0; y < L * K && y <= w; y++)\n\t\tans = max(ans, min((w - y) / L, dp[y]) * L + y);\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "8097e10157320524c0faed56f2bc4880"} {"source_code": "#include \n\nint n,m;\n\nint main()\n{\n int i,j;\n\n scanf(\"%d%d\",&m,&n);\n for(i=n;i>m;i--)\n {\n for(j=2;j*j<=i&&j<=m;j++) if(i%j == 0) break;\n if(j*j>i || j>m) goto OK;\n }\n printf(\"-1\"); return 0;\n OK: printf(\"%d\",i); return 0;\n}\n", "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"source_code": "#include\n\n\nint main()\n{\n char n[100000];\n\n scanf(\"%s\",n);\n\n int i,l=strlen(n);\n\n for(i=l-1;i>=0;i--)\n {\n\n int r = n[i]-48;\n\n\n switch(r)\n {\n case 0:\n printf(\"O-|-OOOO\\n\");\n break;\n\n case 1:\n printf(\"O-|O-OOO\\n\");\n break;\n\n case 2:\n printf(\"O-|OO-OO\\n\");\n break;\n\n case 3:\n printf(\"O-|OOO-O\\n\");\n break;\n\n case 4:\n printf(\"O-|OOOO-\\n\");\n break;\n\n case 5:\n printf(\"-O|-OOOO\\n\");\n break;\n\n case 6:\n printf(\"-O|O-OOO\\n\");\n break;\n\n case 7:\n printf(\"-O|OO-OO\\n\");\n break;\n\n case 8:\n printf(\"-O|OOO-O\\n\");\n break;\n\n case 9:\n printf(\"-O|OOOO-\\n\");\n break;\n\n\n }\n\n\n }\n\n return 0;\n}\n", "src_uid": "c2e3aced0bc76b6484360563355d23a7"} {"source_code": "#include \n\n#define K\t50\n\nint main() {\n\tint q;\n\n\tscanf(\"%d\", &q);\n\twhile (q--) {\n\t\tstatic long long aa[K];\n\t\tlong long a, b, m, lower, upper, x;\n\t\tint i, j, k, good;\n\n\t\tscanf(\"%lld%lld%lld\", &a, &b, &m);\n\t\tif (a == b) {\n\t\t\tprintf(\"1 %lld\\n\", a);\n\t\t\tcontinue;\n\t\t}\n\t\tgood = 0;\n\t\tfor (k = 2; k <= K; k++) {\n\t\t\tlower = (a << (k - 2)) + (1LL << (k - 2)) - 1 + 1;\n\t\t\tif (lower > b)\n\t\t\t\tbreak;\n\t\t\tupper = (a << (k - 2)) + m * ((1LL << (k - 2)) - 1) + m;\n\t\t\tif (b <= upper) {\n\t\t\t\tgood = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!good) {\n\t\t\tprintf(\"-1\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\tb -= lower;\n\t\tprintf(\"%d %lld\", k, aa[0] = a);\n\t\tfor (j = 1; j < k; j++) {\n\t\t\ta = 1LL << (j == k - 1 ? 0 : k - 2 - j);\n\t\t\tx = 1 + b / a;\n\t\t\tif (x > m)\n\t\t\t\tx = m;\n\t\t\tb -= (x - 1) * a;\n\t\t\tfor (i = 0; i < j; i++)\n\t\t\t\tx += aa[i];\n\t\t\tprintf(\" %lld\", aa[j] = x);\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}\n", "src_uid": "c9d646762e2e78064bc0670ec7c173c6"} {"source_code": "#include \n#include \n\nint main()\n{\n char a[1000];\n int i,t,j,c=0;\n scanf(\"%d\",&t);\n for(i=0;i<=t;i++){\n scanf(\"%c\",&a[i]);\n }\n for(i=0;a[i]!='\\0';i++){\n if(a[i]==a[i+1]){\n c++;\n }\n }\n\n printf(\"%d\",c);\n return 0;\n}\n", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8"} {"source_code": "#include \n#include \nint main()\n{\n\tint n,\n\t\t*a,\n\t\tmax /* max sum less than 180 */;\n\n\tint sum;\n\n\tscanf(\"%d\", &n);\n\t\n\ta = (int *) calloc(n, sizeof(int));\n\t\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%d\", &a[i]);\n\t}\n\n\tmax = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tint sum;\n\t\tsum = 0;\n\t\tfor (int j = 0; j < n; j++) {\n\t\t\tsum += a[(i + j) % n];\n\t\t\tif (sum > 180) break;\n\t\t\telse if (sum > max) max = sum;\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", 2 * (180 - max));\n}", "src_uid": "1b6a6aff81911865356ec7cbf6883e82"} {"source_code": "#include\n\nint main() {\n int n, ans, num1;\n ans = 0;\n int count = 0;\n int flag = 0;\n int num_zero = 0;\n int num_one = 0;\n \n scanf(\"%d\", &n);\n int array[n];\n for(int q = 0; q ans){\n ans = num1 + num_zero;\n }\n }\n if (array[i] == 1){\n num_one += 1;\n }\n else{\n num_zero += 1; \n }\n }\n ans += 1;\n if (num_one >= ans && num_one >= num_zero){\n printf(\"%d\", num_one);\n return 0;\n }\n else if (num_zero >= ans && num_zero >= num_one) {\n printf(\"%d\", num_zero);\n return 0;\n } \n printf(\"%d\", ans);\n return 0;\n}\n", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95"} {"source_code": "#include\n#include\nint main(void)\n{\n int i,j,m,k=1,sum=0,t,r,l;\n int n;\n while((scanf(\"%d\",&n))!=EOF)\n {\n k=1;\n t=1;\n sum=0;\n m=n/10;\n while(m)\n {\n m=m/10;\n k++;\n }\n for(i=1;i=1;i--)\n {\n l=i-1;\n while(l)\n {\n t=t*10;\n l--;\n }\n\n //printf(\"%d %d\\n\",t,i);\n r=n/t;\n //printf(\"?%d %d %d\\n\",r,t,n);\n if(r==4)\n {\n n=n%t;\n //printf(\"!!!%d %d\\n\",n,t);\n }\n else if(r==7)\n {\n n=n%t;\n sum+=(pow(2,i)/2);\n //printf(\"%d\\n\",sum);\n }\n t=1;\n }\n sum+=1;\n printf(\"%d\\n\",sum);\n }\n return 0;\n}\n\n ", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3"} {"source_code": "#include\n\nint main()\n{\n int a,b=1,c=2,count=0;\n scanf(\"%d\",&a);\n\n while(a>=b){\n a=a-b;\n b=b+c;\n c++;\n count++;\n\n }\n printf(\"%d\",count);\n\n}\n", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0"} {"source_code": "#include\nint main()\n{\n int n,i,x=1002,b=0,d=0,g,h,j;\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;ib)\n {\n b=a[i];\n h=i;\n }\n }\n }\n if(g==h)\n {\n a[g]=0;\n for(j=n-1;j>0;j--)\n {\n if(a[j]>0)\n h=j;\n }\n }\n a[g]=0;\n a[h]=0;\n x=1002;\n b=0;\n\n printf(\"%d %d\",g+1,h+1);\n printf(\"\\n\");\n d++;\n }\n return 0;\n\n}\n", "src_uid": "6e5011801ceff9d76e33e0908b695132"} {"source_code": "#include \n#include \n#include \n\n#define clr(ar) memset(ar, 0, sizeof(ar))\n#define read() freopen(\"lol.txt\", \"r\", stdin)\n\nlong long int n, m, k, d;\n\nlong long int F(long long int lim){\n lim++;\n int i, j, low, high, mid;\n long long int x, counter = 0;\n\n for (i = 1; i <= n; i++){\n x = i;\n low = 1, high = m;\n if (lim <= x) break;\n\n if (lim > x){\n if (lim > (x * high)) counter += m;\n else{\n while ((low + 1) < high){\n mid = (low + high) >> 1;\n if ((x * mid) < lim) low = mid;\n else high = mid;\n }\n if ((x * high) < lim) counter += high;\n else if ((x * low) < lim) counter += low;\n }\n }\n if (counter > k) break;\n }\n\n return counter;\n}\n\nint main(){\n int i, j, l;\n\n while (scanf(\"%I64d %I64d %I64d\", &n, &m, &k) != EOF){\n long long int low = 1, high = (n * m);\n\n while ((low + 1) < high){\n long long int mid = (low + high) >> 1LL;\n if (F(mid) < k) low = mid;\n else high = mid;\n }\n\n if (F(low) >= k) printf(\"%I64d\\n\", low);\n else printf(\"%I64d\\n\", high);\n }\n return 0;\n}\n", "src_uid": "13a918eca30799b240ceb9de47507a26"} {"source_code": "\n#include \n\nint main()\n{\n int n,m,x[10],y[100],i,j;\n scanf(\"%d%d\",&n,&m);\n for(i=0;i\n\nlong long int lrg=100000000000000;\n\nlong long int comp(long long int m,long long int x,long long int y,long long int a,long long int b)\n{\n\tlong long int i,j,t,c,d;\n\tc=(m/y)-(m/(x*y));\n\td=(m/x)-(m/(x*y));\n\tif(c>a)\n\t{\n\t\tc=a;\n\t}\n\tif(d>b)\n\t{\n\t\td=b;\n\t}\n\ti=(m-(m/x)-(m/y)+(m/(x*y)));\n\treturn (i>=(a+b-c-d));\n}\t\n\nint main()\n{\nlong long int i,j,t,a,b,c,m,fg=0,d,x,y,l,r;\nscanf(\"%lld %lld %lld %lld\",&a,&b,&x,&y);\nl=1,r=lrg;\nwhile(l<=r)\n{\n\tm=((l+r)/2);\n\tt=comp(m,x,y,a,b);\n\t//printf(\"%lld %lld\\n\",m,t);\n\tif(t==1)\n\t{\n\t\tr=m-1;\n\t}\n\telse\n\t{\n\t\tl=m+1;\n\t}\n\tif(comp(l,x,y,a,b)==1)\n\t{\n\t\tfg=l;\n\t\tbreak;\t\n\t}\n\tif(comp(r,x,y,a,b)==0)\n\t{\n\t\tfg=r+1;\n\t\tbreak;\n\t}\n}\nprintf(\"%lld\\n\",fg);\nreturn 0;\n}\n", "src_uid": "ff3c39b759a049580a6e96c66c904fdc"} {"source_code": "#include\nint main()\n{\n int n,m,flag=1;\n scanf(\"%d %d\",&n,&m);\n char r[n],c[m];\n scanf(\"%s\",r);\n scanf(\"%s\",c);\n if(r[0]=='>'&&c[0]=='v')\n flag=0;\n if(r[0]=='<'&&c[m-1]=='v')\n flag=0;\n if(r[n-1]=='<'&&c[m-1]=='^')\n flag=0;\n if(r[n-1]=='>'&&c[0]=='^')\n flag=0;\n if(flag)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}", "src_uid": "eab5c84c9658eb32f5614cd2497541cf"} {"source_code": "#include \n\ndouble dp[2001][2001];\n\nint main(void) {\n int i, j;\n int n, t;\n double p;\n double ans;\n\n scanf(\"%d %lf %d\", &n, &p, &t);\n\n dp[0][0] = 1.0;\n for (i = 0; i < t; i++)\n for (j = 0; j < 2000; j++)\n if (j < n) {\n dp[i + 1][j] += dp[i][j] * (1 - p);\n dp[i + 1][j + 1] += dp[i][j] * p;\n } else\n dp[i + 1][j] += dp[i][j];\n\n ans = 0.0;\n for (i = 1; i <= n; i++)\n ans += i * dp[t][i];\n\n printf(\"%f\\n\", ans);\n\n return 0;\n}\n", "src_uid": "20873b1e802c7aa0e409d9f430516c1e"} {"source_code": "#include\n#include\nint main()\n{\n int n, c, i, j,l=0, r=0, s=0, s2=0;\n scanf(\"%d %d\", &n, &c);\n int p[ n ], t[ n ];\n for(i=0;i=0){\n l = l + p[ i ] - (c*s) ;}\n s2 = s2 + t[ j ];\n if(p[ j ] - (c*s2)>=0){\n r = r + p[ j ] - (c*s2);}\n }\n if(l>r){printf(\"Limak\");}\n else if(l\n#include\nint main()\n{\n long long int n,j=1,c=0,p;\n long double t=0.0,q;\n scanf(\"%I64d\",&n);\n while(((j*(j+1))/2)\n#include \n\nint n, sum;\nint a[16];\nint b[4][4];\n\nint cmp(const void *a, const void *b)\n{\n return *((int *)a) - *((int *)b);\n}\n\nint dfs(int x, int y, int z)\n{\n int p, q, i, j;\n \n if (x == n && y == 0) return 1;\n \n p = x;\n q = y + 1;\n \n if (q == n) {\n p = x + 1;\n q = 0;\n }\n \n for (i = 0; i < n * n; i++) {\n if ((z >> i) & 1) continue;\n \n if (x == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][y];\n \n if (s + a[i] != sum) continue;\n }\n \n if (y == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[x][j];\n \n if (s + a[i] != sum) continue;\n }\n \n if (x == n - 1 && y == 0) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][n - j - 1];\n \n if (s + a[i] != sum) continue;\n }\n \n if (x == n - 1 && y == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][j];\n \n if (s + a[i] != sum) continue;\n }\n \n b[x][y] = a[i];\n \n if (dfs(p, q, z | (1 << i)) == 1) return 1;\n \n for (j = i + 1; j < n * n; j++) {\n if (a[i] != a[j]) break;\n }\n \n i = j - 1;\n }\n \n return -1;\n}\n\nint dfs2(int p, int q)\n{\n int x, y, i, j;\n \n if (p == 16) return 1;\n \n if (p <= 3) {\n x = 0;\n y = p;\n } else if (p <= 6) {\n x = p - 3;\n y = 0;\n } else if (p <= 9) {\n x = 1;\n y = p - 6;\n } else if (p <= 11) {\n x = p - 8;\n y = 1;\n } else if (p <= 13) {\n x = 2;\n y = p - 10;\n } else {\n x = 3;\n y = p - 12;\n }\n \n for (i = 0; i < n * n; i++) {\n if ((q >> i) & 1) continue;\n \n if (x == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][y];\n \n if (s + a[i] != sum) continue;\n }\n \n if (y == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[x][j];\n \n if (s + a[i] != sum) continue;\n }\n \n if (p == 10) {\n int s = 0;\n \n for (j = 0; j < n; j++) {\n if (j == 2) continue;\n \n s += b[j][n - j - 1];\n }\n \n if (s + a[i] != sum) continue;\n }\n \n if (x == n - 1 && y == n - 1) {\n int s = 0;\n \n for (j = 0; j < n - 1; j++) s += b[j][j];\n \n if (s + a[i] != sum) continue;\n }\n \n b[x][y] = a[i];\n \n if (dfs2(p + 1, q | (1 << i)) == 1) return 1;\n \n for (j = i + 1; j < n * n; j++) {\n if (a[i] != a[j]) break;\n }\n \n i = j - 1;\n }\n \n return -1;\n}\n\nint main()\n{\n int i, j;\n \n scanf(\"%d\", &n);\n \n for (i = 0; i < n * n; i++) {\n scanf(\"%d\", &a[i]);\n \n sum += a[i];\n }\n \n sum /= n;\n \n printf(\"%d\\n\", sum);\n \n qsort(a, n * n, sizeof(int), cmp);\n\n if (n <= 3) {\n dfs(0, 0, 0);\n } else {\n dfs2(0, 0);\n }\n \n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n if (j > 0) putchar(' ');\n \n printf(\"%d\", b[i][j]);\n }\n \n puts(\"\");\n }\n \n return 0;\n}\n", "src_uid": "7c806fb163aaf23e1eef3e6570aea436"} {"source_code": "#include \n\n// this BinarySearch sometimes cannot find the x\n\nconst int P = 1000000007;\n\nint main()\n{\n int n, x, pos;\n int l, r, m;\n int lc, rc; // count of L, count of R\n int ans;\n int i;\n\n scanf(\"%d %d %d\", &n, &x, &pos);\n l=0;\n r=n;\n lc=0;\n rc=0;\n while (l\nint main()\n{\n\tint n,t,a[1002],ans,cnt=0,i,j,k,max=0,temp;\n\tscanf(\"%d\",&n);\n\tfor(i=0;ia[j+1])\n {\n temp=a[j];\n a[j]=a[j+1];\n a[j+1]=temp;\n }\n scanf(\"%d\",&t);\n\tfor(i=0;imax)\n\tmax=ans;\n\t}\n\tprintf(\"%d\",max);\n\t\n}", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c"} {"source_code": "#include \r\n\r\nint main() {\r\n long long int n,m;\r\n scanf(\"%lld %lld\", &n, &m);\r\n if(m>1.5){\r\n printf(\"%lld\\n\",(m-1)*(n));\r\n \r\n }\r\n else{\r\n printf(\"%lld\\n\",n-1);\r\n }\r\n return 0;\r\n}", "src_uid": "a91aab4c0618d036c81022232814ef44"} {"source_code": "#include \n#include \n#include \n#define EPS 1e-10\n#define SQ(x) ((x)*(x))\n#define EQ(x,y) (fabs((x)-(y))EPS){\n bllg=(blg*19+brg)/20; brrg=(blg+brg*19)/20;\n bld=hh(th,bllg); brd=hh(th,brrg);\n bld>brd?blg=bllg:(brg=brrg);\n }\n return la+bld;\n}\n\ndouble f(double th){\n double tx=r*cos(th),ty=r*sin(th),lr,lb;\n lr=hypot(ax-tx,ay-ty);\n th=angle(tx,ty,bx,by);\n lb=sqrt(SQ(d)+SQ(bd)-2*d*bd*cos(th*r/d));\n return lr+lb;\n}\n\nmain(){\n int i,j;\n double ans=1e9,alg,arg,allg,arrg,ald,ard;\n\n scanf(\"%d%d%lf%lf%lf%lf%lf%lf\",&r,&h,&ax,&ay,&az,&bx,&by,&bz);\n if(EQ(ax,bx)&&EQ(ay,by)&&EQ(az,bz)) print(.0);\n if(azEPS){\n allg=(alg*49+arg)/50; arrg=(alg+arg*49)/50;\n ald=f(allg); ard=f(arrg);\n ald>ard?alg=allg:(arg=arrg);\n }\n print(ald);\n }\n\n if(EQ(bz,h)) print(ad);\n temp1=sqrt(SQ(ad)+SQ(bd)-2*ad*bd*cos(th*r/d));\n alg=0; arg=2*M_PI;\n while(arg-alg>EPS){\n allg=(alg*49+arg)/50; arrg=(alg+arg*49)/50;\n ald=g(allg); ard=g(arrg);\n ald>ard?alg=allg:(arg=arrg);\n }\n temp2=ald;\n print(temp1\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\nint main()\n{\n\tint a,b,i,j,max,min,count=0;\n\tint c[10000]={};\n\tscanf(\"%d %d\",&a,&b);\n\tif(a==b)\n\t{\n\t\tprintf(\"infinity\\n\");\n\t}\n\telse if(a=min && c[i]<=max)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\",count);\n\t}\n\treturn 0;\n}\n", "src_uid": "6e0715f9239787e085b294139abb2475"} {"source_code": "#include\n#include\nint main()\n{\n\tint i,k=0,n;\n\tscanf(\"%d\",&n);\n\tchar s[n+1];\n\tscanf(\"%s\",s);\n\tfor(i=0;i<=n-1;i=i+k)\n\t{\n\t\tprintf(\"%c\",s[i]);\n\t\tk=k+1;\n\t\t\n\t}\n\treturn 0;\n}\n", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf"} {"source_code": "#include\nint main(){\n int a,b,k;\n char arr[50];\n char store[50];\n scanf(\"%d%d\",&a,&b);\n getchar();\n double s=0;\n double res=0; double x=0;\n int i;\n for(i=0;i=0;k--){\n if(store[k]=='2'){\n s=(2*res)+0.5;\n res=s;\n x=x+(res*b);\n }\n else{\n s=(2*res);\n res=s;\n x=x+(res*b);\n }}\n printf(\"%lld\",(long long int)x);\n}\n", "src_uid": "6330891dd05bb70241e2a052f5bf5a58"} {"source_code": "#include\n#include\n\nint main(){\nint n,i;\nlong int a;\nscanf(\"%d\",&n);\nif(n%2!=0){a=0;}\nelse{\na=pow(2,(n/2));\n}\nprintf(\"%ld\",a);\nreturn 0;\n}", "src_uid": "4b7ff467ed5907e32fd529fb39b708db"} {"source_code": "/*\n * Find out the minimum number of prime addends which number n can be split into.\n * Algorithm Complexity\n * Time: O(???)\n * Space: O(1)\n */\n\n#include \n#include \n#include \n\n\nchar IsPrime(int a){\n\tif(a == 2) return 1;\n\tint i;\n\tchar prime = 1;\n\tfor(i = 2; i <= (int)sqrt((double)a) && prime == 1; i++)\n\t\tif(a%i == 0) prime = 0;\n\treturn prime;\n}\n\nint optimal(int n){\n\tint i = n, p = 0;\n\twhile(i != 0){\n\t\tif(IsPrime(i) == 1 && n-1 != 1 && optimal(n-i) < 3){\n\t\t\tp++;\n\t\t\tn -= i;\n\t\t\ti = n;\n\t\t}else i--;\n\t}\n\treturn p;\n}\n\n\nint main(int argc, char* argv[]){\n\tint n, p = 0, i;\n\tscanf(\"%d\", &n);\n\ti = n;\n\t\n\tif(IsPrime(n) == 1){ \n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\tif(n%2 == 0){\n\t\tprintf(\"2\\n\");\n\t\treturn 0;\n\t}\n\twhile(i != 0){\n\t\tif(IsPrime(i) == 1 && n-i != 1 && optimal(n-i) < 3){\n\t\t\tp++;\n\t\t\t//printf(\"%d \", i);\n\t\t\tn -= i;\n\t\t\ti = n;\n\t\t}else i--;\n\t}\n\tif(p > 3) p = 3;\n\tprintf(\"%d\\n\", p);\n\treturn 0;\n}\n", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b"} {"source_code": "/*\r\n * @题目: \r\n * @算法: \r\n * @Author: Blore\r\n * @Language: c++11\r\n * @Date: 2021-08-06 09:23:07\r\n * @LastEditors: Blore\r\n * @LastEditTime: 2021-08-06 11:14:30\r\n */\r\n#include \r\n\r\nint main()\r\n{\r\n int t;\r\n scanf(\"%d\", &t);\r\n while (t--)\r\n {\r\n int n, m, k1;\r\n scanf(\"%d%d%d\", &n, &m, &k1);\r\n int k2 = n * m / 2 - k1;\r\n if (m % 2 == 1)\r\n {\r\n k2 -= n / 2;\r\n if (k2 < 0)\r\n {\r\n puts(\"NO\");\r\n continue;\r\n }\r\n }\r\n else if (n % 2 == 1)\r\n {\r\n k1 -= m / 2;\r\n if (k1 < 0)\r\n {\r\n puts(\"NO\");\r\n continue;\r\n }\r\n }\r\n if (k1 * k2 % 2 != 0)\r\n puts(\"NO\");\r\n else\r\n puts(\"YES\");\r\n }\r\n return 0;\r\n}", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8"} {"source_code": "#include\nint main()\n{\n int k,i,j;\n scanf(\"%d\", &k);\n for ( i = 0; i < 26; i++)\n {\n int cnt = 1;\n while ((cnt + 1) * cnt / 2 <= k) \n cnt++;\n k -= cnt * (cnt - 1) / 2;\n for ( j = 0; j < cnt; j++) \n printf(\"%c\", 'a' + i);\n }\n return 0;\n}", "src_uid": "b991c064562704b6106a6ff2a297e64a"} {"source_code": "#include \n\nint main() {\n\tint n, k, i, j, min, max;\n\tscanf(\"%d%d\", &n, &k);\n\tif (n != k && k!= 0) min = 1;\n\telse min = 0;\n\n\tif ( (n / 3) >= k) {\n\t\tmax = k * 2;\n\t}\n\telse {\n\t\tmax = n - k;\n\t}\n\n\tprintf(\"%d %d\", min, max);\n}", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86"} {"source_code": "#include //AA06( 11/ 07/ 20) If u see my code, Have a Good Day! (^_^)\n\nint Ans(int n, int k);\n\nint main()\n{\n int n, k;\n\n scanf(\"%d%d\", &n, &k);\n\n printf(\"%d\\n\", Ans(n, k));\n\n return 0;\n}\n\nint Ans(int n, int k)\n{\n int X = ((n/ k) + 1) * k;\n\n return X;\n}\n", "src_uid": "75f3835c969c871a609b978e04476542"} {"source_code": "#include \n#include \n#include \nint main()\n{\n int i = 0, st = 0, sum = 0, res = 1, j = 0, arr[402];\n char c;\n for (i = 0; i < 401; i++) arr[i] = 5;\n i = 0;\n while ((c = getchar()) != '\\n')\n {\n if (c == '>')\n {\n arr[i ] = 1;\n arr[i + 1] = 0;\n arr[i + 2] = 0;\n arr[i + 3] = 0;\n i += 4;\n }\n if (c == '<')\n {\n arr[i ] = 1;\n arr[i + 1] = 0;\n arr[i + 2] = 0;\n arr[i + 3] = 1;\n i += 4;\n }\n if (c == '+')\n {\n arr[i ] = 1;\n arr[i + 1] = 0;\n arr[i + 2] = 1;\n arr[i + 3] = 0;\n i += 4;\n }\n if (c == '-')\n {\n arr[i ] = 1;\n arr[i + 1] = 0;\n arr[i + 2] = 1;\n arr[i + 3] = 1;\n i += 4;\n }\n if (c == '.')\n {\n arr[i ] = 1;\n arr[i + 1] = 1;\n arr[i + 2] = 0;\n arr[i + 3] = 0;\n i += 4;\n }\n if (c == ',')\n {\n arr[i ] = 1;\n arr[i + 1] = 1;\n arr[i + 2] = 0;\n arr[i + 3] = 1;\n i += 4;\n }\n if (c == '[')\n {\n arr[i ] = 1;\n arr[i + 1] = 1;\n arr[i + 2] = 1;\n arr[i + 3] = 0;\n i += 4;\n }\n if (c == ']')\n {\n arr[i ] = 1;\n arr[i + 1] = 1;\n arr[i + 2] = 1;\n arr[i + 3] = 1;\n i += 4;\n }\n st++;\n }\n st *= 4;\n st--;\n for (i = 0; arr[i] != 5; i++)\n {\n if (arr[i])\n {\n for (j = 0; j < st; j++)\n res =res * 2 % 1000003;\n sum += res % 1000003;\n }\n res = 1;\n st--;\n }\n printf(\"%d\", sum % 1000003);\n return 0;\n}\n", "src_uid": "04fc8dfb856056f35d296402ad1b2da1"} {"source_code": "#include\nint main()\n{\n long int n;\n int a=0,b=1;\n scanf(\"%ld\",&n);\n if(n%4==0||n%4==3)\n {\n printf(\"%d\",a);\n }\n else\n {\n printf(\"%d\",b);\n }\n return 0;\n}", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9"} {"source_code": "#include \n#include \nint main()\n{\n\tchar arr[7][20] = {\"sunday\", \"monday\", \"tuesday\",\"wednesday\",\"thursday\",\"friday\",\"saturday\"};\n\tchar str1[20], str2[20];\n\tint i, one, two, diff;\n\tscanf(\"%s\",str1);\n\tscanf(\"%s\",str2);\n\tfor (i=0; i<7; i++)\n\t\tif (!strcmp(str1, arr[i])) one = i;\n\tfor (i=0; i<7; i++)\n\t\tif (!strcmp(str2, arr[i])) two = i;\n\tdiff = (two-one+7) % 7;\n\tif (diff ==0 || diff==2 || diff ==3) printf(\"YES\\n\");\n\telse\tprintf(\"NO\\n\");\n\treturn 0;\n}\n", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"} {"source_code": "#include \n\ntypedef long long int LL;\n\nLL power(int n,int k){\n LL t = 1;\n while(k--){\n t*=n;\n }\n return t;\n}\n\nLL findAns(LL n){\n if(n<10) return n;\n LL ans = 9+(n-10)/10;\n int m = n%10;\n while(n>9){\n n/=10;\n }\n if(m>=n) ++ans;\n return ans;\n}\n\nint main(void){\n LL l,r;\n scanf(\"%I64d %I64d\",&l,&r);\n //printf(\"%I64d %I64d\\n\",l,r);\n if((l<1)||(l>r)||(r>power(10,18)))\n return 0;\n LL ans = findAns(r)-findAns(l-1);\n printf(\"%I64d\",ans);\n return 0;\n}\n", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd"} {"source_code": "#include\n\nint main()\n{\n long long int n,k,numlessk;\n while(scanf(\"%I64d\",&n)==1)\n {\n if(n==0){\n printf(\"1\\n\");\n continue;\n }\n k=(n*6)+1;\n numlessk=((n-1)*(n))/2;\n printf(\"%I64d\\n\",k+numlessk*6);\n }\n return 0;\n}", "src_uid": "c046895a90f2e1381a7c1867020453bd"} {"source_code": "#include \n#include \nint main(){\n long long int n,i,m;\n int k=0;\n scanf(\"%lld\",&n);\n \n \n for( i=2;i*i<=n;i++){\n if(n%i==0){\n while(n%i==0){\n n/=i;\n }\n printf(\"%lld\\n\",n==1?i:1);\n return 0;\n \n }}\n printf(\"%lld\",n);\n \n return 0;\n}", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b"} {"source_code": "#include\n#include\nmain()\n{int n;\nscanf(\"%d\",&n);\nint i,nb=1;\nchar s[n+1];\nscanf(\"%s\",s);\nfor(i=0;i\nint main()\n{long long int a[3]={0},b,c,y,x,i,j,k=0,t;\nscanf(\"%I64d %I64d %I64d\",&a[0],&a[1],&a[2]);\nfor(i=0;i<3;i++)\nfor(j=0;j<3-i-1;j++)\nif(a[j]=0;i--)\n{ if(a[i]-a[i+1]==0)\n {\n k+=a[i];\n goto flag;\n }\n}if(a[1]-a[2]==1)\n{k+=a[0]-a[1];a[0]=a[1];}\nelse\n{\n x=(a[1]+a[2])/2;\n y=x-a[2];\n a[2]=x;\n a[1]-=y;\n a[0]-=y;\n k+=y;\n}\n\nif(a[1]\nint main()\n{\n\tlong long int n,sum=0,a,b,k;\n\tscanf(\"%lld\",&n);\n\ta=1;\n\tb=1;\n\tk=a+b;\n\twhile(k<=n)\n\t{ \n\t\tsum++;\n\t \ta=b;\n\t \tb=k;\n\t \tk=a+b;\t\n\t}\n\tprintf(\"%lld\",sum);\n}", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14"} {"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", "src_uid": "77f28d155a632ceaabd9f5a9d846461a"} {"source_code": "#include \n#include \n\nint main(void)\n{\n char map[4][4], temp[4] = {0,}, map2[4][4];\n int c = 0;\n \n for(int i = 0; i < 4; i++)\n {\n scanf(\"%s\", map[i]);\n }\n \n for(int i = 0; i < 4; i++)\n {\n for(int j = 0; j < 4; j++)\n {\n map2[i][j] = map[j][i];\n }\n }\n \n //row\n for(int i = 0; i < 4; i++)\n {\n for(int j = 0, x = 0, dot = 0; j < 2; j++)\n {\n strncpy(temp, &map[i][j], 3);\n \n for(int k = 0; k < 3; k++)\n {\n if (temp[k] != 'o')\n {\n x++;\n if (temp[k] == '.')\n {\n dot++;\n }\n }\n }\n if (x == 3)\n {\n if (dot == 1 ||dot == 0)\n {\n c++;\n }\n }\n dot = 0;\n x = 0;\n \n }\n }\n //row\n for(int i = 0; i < 4; i++)\n {\n for(int j = 0, x = 0, dot = 0; j < 2; j++)\n {\n strncpy(temp, &map2[i][j], 3);\n \n \n for(int k = 0; k < 3; k++)\n {\n if (temp[k] != 'o')\n {\n x++;\n if (temp[k] == '.')\n {\n dot++;\n }\n }\n }\n if (x == 3)\n {\n if (dot == 1 ||dot == 0)\n {\n c++;\n }\n \n }\n dot = 0;\n x = 0;\n }\n }\n\n for(int i = 0, x = 0, dot = 0; i< 2; i++)\n {\n for(int j = 0; j < 3; j++)\n {\n temp[j] = map[2 - j + i][2 - j];\n }\n for(int k = 0; k < 3; k++)\n {\n if (temp[k] != 'o')\n {\n x++;\n if (temp[k] == '.')\n {\n dot++;\n }\n }\n }\n if (x == 3)\n {\n if (dot == 1 ||dot == 0)\n {\n c++;\n }\n }\n \n dot = 0;\n x = 0;\n }\n for(int i = 0, x = 0, dot = 0; i< 2; i++)\n {\n for(int j = 0; j < 3; j++)\n {\n temp[j] = map[2 - j + i][2 - j + 1];\n }\n for(int k = 0; k < 3; k++)\n {\n if (temp[k] != 'o')\n {\n x++;\n if (temp[k] == '.')\n {\n dot++;\n }\n }\n }\n if (x == 3)\n {\n if (dot == 1 ||dot == 0)\n {\n c++;\n }\n }\n \n dot = 0;\n x = 0;\n }\n \n for(int i = 0, x = 0, dot = 0; i< 2; i++)\n {\n for(int j = 0; j < 3; j++)\n {\n temp[j] = map[2 - j + i][j];\n }\n for(int k = 0; k < 3; k++)\n {\n if (temp[k] != 'o')\n {\n x++;\n if (temp[k] == '.')\n {\n dot++;\n }\n }\n }\n if (x == 3)\n {\n if (dot == 1 || dot == 0)\n {\n c++;\n }\n }\n \n \n dot = 0;\n x = 0;\n }\n for(int i = 0, x = 0, dot = 0; i< 2; i++)\n {\n for(int j = 0; j < 3; j++)\n {\n temp[j] = map[2 - j + i][j + 1];\n }\n for(int k = 0; k < 3; k++)\n {\n if (temp[k] != 'o')\n {\n x++;\n if (temp[k] == '.')\n {\n dot++;\n }\n }\n }\n if (x == 3)\n {\n if (dot == 1 || dot == 0)\n {\n c++;\n }\n }\n dot = 0;\n x = 0;\n }\n \n \n \n if (c == 0)\n {\n puts(\"NO\");\n }\n else\n {\n puts(\"YES\");\n }\n \n return 0;\n}", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917"} {"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<\nint main()\n{\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tint i, j, k;\n\tint a[30], b[30];\n\tfor (i = 0; i < m; i++)\n\t{\n\t\tscanf(\"%d %d\", &a[i], &b[i]);\n\t\ta[i]--;\n\t\tb[i]--;\n\t}\n\tint max = 1;\n\tfor (i = 0; i < n; i++)\n\t\tmax *= 6;\n\tint used[10][10];\n\tfor (i = 0; i < 10; i++)\n\t\tfor (j = 0; j < 10; j++)\n\t\t\tused[i][j] = 1;\n\tint p, q[10];\n\tint ans = 0, count;\n\tfor (j = 0; j < max; j++)\n\t{\n\t\tp = j;\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tq[i] = p % 6;\n\t\t\tp /= 6;\n\t\t}\n\t\tfor (i = 0; i < 10; i++)\n\t\t\tfor (k = i; k < 10; k++)\n\t\t\t\tused[i][k] = 0;\n\t\tcount = 0;\n\t\tfor (i = 0; i < m; i++)\n\t\t{\n\t\t\tif (q[a[i]] < q[b[i]])\n\t\t\t{\n\t\t\t\tif (used[q[a[i]]][q[b[i]]] == 0)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tused[q[a[i]]][q[b[i]]] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (used[q[b[i]]][q[a[i]]] == 0)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tused[q[b[i]]][q[a[i]]] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (ans < count)ans = count;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b"} {"source_code": "int main(n)\n{\n scanf(\"%d\",&n);\n puts(n&1?\"black\":\"white 1 2\");\n return 0;\n }\n", "src_uid": "52e07d176aa1d370788f94ee2e61df93"} {"source_code": "#include \n#include \n\nint n,m;\nchar K[65];\nlong long ans;\n\nint main()\n{\n int i,j;\n long long x,y,p = 1;\n \n scanf(\"%d%s\",&n,K+1);\n m = strlen(K+1);\n \n for(i=j=m;i;i=j)\n {\n x = 0; y = 1;\n for(;j > 0 && x + (K[j]-'0')*y < n && y 1 && K[j+1] == '0') j++;\n ans = ans + x*p;\n p *= n;\n }\n \n printf(\"%I64d\",ans);\n return 0;\n}", "src_uid": "be66399c558c96566a6bb0a63d2503e5"} {"source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\n#define author int\n#define sph_mp main() \n#define fr(i, a, b) for((i) = (a) ; (i) < (b) ; (i)++)\n#define frr(i, a, b) for((i) = (a) ; (i) >= (b) ; (i)--)\n\nint l, r, x, y;\nint a[1000], ai = 0;\n\n\n\n// Function to print the divisors\nvoid printDivisors(int n)\n{\n // Note that this loop runs till square root\n int i;\n for (i=1; i<=sqrt(n); i++)\n {\n if (n%i == 0)\n {\n // If divisors are equal, print only one\n if (n/i == i)\n \t{\n \t\ta[ai] = i;\n \t\tai++;\n\t\t\t\t}\n// printf(\"%d \", i);\n \n else // Otherwise print both\n \t{\n \t\ta[ai] = i;\n \t\ta[ai+1] = n/i;\n \t\tai += 2;\n\t\t\t\t}\n// printf(\"%d %d \", i, n/i);\n }\n }\n}\n \nint valid(int x) {\n\treturn l <= x && x <= r;\n}\n\nint gcd(int a, int b)\n{\n if (a == 0)\n return b;\n return gcd(b%a, a);\n}\n \n// Function to return LCM of two numbers\nunsigned long long lcm(unsigned long long a, unsigned long long b)\n{\n return (a*b)/gcd(a, b);\n}\n\n/* Driver program to test above function */\nauthor sph_mp {\n\tscanf(\"%d %d %d %d\", &l, &r, &x, &y);\n\tprintDivisors(y);\n\tint res = 0;\n\tint i, j;\n\tfr(i, 0, ai) \n\t\tfr(j, 0, ai) {\n\t\t\tif(valid(a[i]) && valid(a[j])) {\n\t\t\t\tif(gcd(a[i], a[j]) == x && lcm((unsigned long long)a[i], (unsigned long long)a[j]) == y) \n\t\t\t\t\t{\n//\t\t\t\t\t\tprintf(\"%d %d\\n\", a[i], a[j]);\n\t\t\t\t\t\tres++;\n\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\tprintf(\"%d\", res);\n return 0;\n}", "src_uid": "d37dde5841116352c9b37538631d0b15"} {"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", "src_uid": "359f5d1264ce16c5c5293fd59db95628"} {"source_code": "#include \"stdio.h\"\n#include \"string.h\"\n\nint main()\n{\n\tchar s[100];\n\twhile (scanf(\"%s\",&s)!= EOF)\n\t{\n\t\tint length = strlen(s);\n\t\tfor (int i = 0; i < length; i++)\n\t\t{\n\t\t\tif (s[i] == 49)\n\t\t\t{\n\t\t\t\tint zeronum = 0;\n\t\t\t\tfor (int j = i + 1; j < length; j++)\n\t\t\t\t{\n\t\t\t\t\tif (s[j] == 48)\n\t\t\t\t\t\tzeronum++;\n\t\t\t\t}\n\t\t\t\tif (zeronum >= 6)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tprintf(\"NO\\n\");\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(i==length-1)\n\t\t\t{\n\t\t\t printf(\"NO\\n\");\n\t\t\t break;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca"} {"source_code": "#include\n#include\nint main()\n{\n int i=0,j=0,a,b,c=0,d=0,n,m;\n char s[100],t[100];\n scanf(\"%s\",s);\n scanf(\"%s\",t);\n m=strlen(t);\n for(i=0;i\nint main ()\n{\nlong long i,k,n,m,max=0,min=0;\nscanf(\"%lld%lld\",&n,&m);\nmax=n-m+1;\nmax=max*(max-1)/2;\nk=n/m;\nmin=(k*m*(k-1))/2+(n%m)*k;\nprintf(\"%lld %lld\",min,max);\nreturn 0;}\n", "src_uid": "a081d400a5ce22899b91df38ba98eecc"} {"source_code": "#include \n#include \n#include \n#include \n#include \n\n\nint main()\n{\n char string[40];\n scanf(\"%s\", string);\n int buffer;\n int len = strlen(string);\n int i;\n \n if(len == 1 && string[i] == '9')\n {\n printf(\"9\\n\");\n return 0;\n }\n\n for(i=0;i %i\\n\\n\",buffer);\n\n if(i==0 && buffer==9)\n {\n printf(\"9\");\n continue;\n \n }\n\n if(9-buffer < buffer && 9-buffer>=0)\n printf(\"%i\",9-buffer);\n else\n printf(\"%i\",buffer);\n\n }\n\n\n\n return 0;\n}", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61"} {"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", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b"} {"source_code": "#include\nint main()\n{\n int d1,d2,d3,a,b,c,t;\n scanf(\"%d%d%d\",&d1,&d2,&d3);\n t=d1+d2+d3;\n a=2*(d1+d2);\n b=2*(d2+d3);\n c=2*(d1+d3);\n if(t<=a&&t<=b&&t<=c)\n {printf(\"%d\",t);}\n else if(a<=t&&a<=b&&a<=c)\n {printf(\"%d\",a);}\n else if(b<=t&&b<=a&&b<=c)\n {printf(\"%d\",b);}\n else if(c<=a&&c<=b&&c<=t)\n {printf(\"%d\",c);}\n}\n", "src_uid": "26cd7954a21866dbb2824d725473673e"} {"source_code": "#include \nint main(void) {\n int a,b,c,d;\n scanf(\"%d%d%d%d\",&a,&b,&c,&d);\n int s=(a+b+c+d);\n if(s%2!=0)\n printf(\"NO\");\n else{\n if(a+b == c+d){\n printf(\"YES\");\n return 0;\n }\n if(a+c == b+d){\n printf(\"YES\");\n return 0;\n }\n if(a+d == b+c){\n printf(\"YES\");\n return 0;\n }\n if(a+b+c == d){\n printf(\"YES\");\n return 0;\n }\n if(d+b+c == a){\n printf(\"YES\");\n return 0;\n }\n if(a+d+c == b){\n printf(\"YES\");\n return 0;\n }\n if(a+b+d == c){\n printf(\"YES\");\n return 0;\n }\n printf(\"NO\");\n }\n\treturn 0;\n}", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37"} {"source_code": "#include\nint main()\n{\n\tlong long int x1,y1,x2,y2,ans=0;\n\tscanf(\"%lld%lld%lld%lld\",&x1,&y1,&x2,&y2);\n\tans=((x2-x1+2)*(y2-y1+2))/4+((x2-x1)*(y2-y1))/4;\n\tprintf(\"%lld\",ans);\n\treturn 0;\n}", "src_uid": "00cffd273df24d1676acbbfd9a39630d"} {"source_code": "#include\n#include\nint mut(int a){return (a<0)?-a:a;}\nint main() {\n\tint i,n,cvp=0,j,arr[100][100];\n\tfor(i=0;i<5;i++)\n\t\tfor(j=0;j<5;j++)\n\t\t\t\tscanf(\"%d\",&arr[i][j]);\n\tfor(i=0;i<5;i++)\n\t\tfor(j=0;j<5;j++)\n\t\t\tif(arr[i][j])\n\t\t\t\tcvp=mut(i-2)+mut(j-2);\n\t\t\t\n\tprintf(\"%d\",cvp);\nreturn 0 ;\n}\n", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9"} {"source_code": "#include \n\nint main()\n{\n int m, n, count = 0;\n scanf(\"%d %d\", &n, &m);\n /*if ( n%2 == 0 && m%2 == 0)\n printf(\"Malvika\");\n else if ( n%2 == 0 && m%2 != 0 )\n printf(\"Malvika\");\n else if ( n%2 != 0 && m%2 == 0 )\n printf(\"Akshat\");\n else if ( n%2 != 0 && m%2 != 0 )\n printf(\"Akshat\");\n while ( m > 0 && n > 0 )\n {\n m--;\n n--;\n count++;\n }\n if ( count % 2 == 0 )\n printf(\"Malvika\");\n else\n printf(\"Akshat\");*/\n int temp;\n if ( m <= n )\n temp = m;\n else\n temp = n;\n\n if ( temp%2 == 0 )\n printf(\"Malvika\");\n else\n printf(\"Akshat\");\n\n}\n", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4"} {"source_code": "//\n// main.c\n// 73A\n//\n// Created by Ki-baek Lee on 11. 9. 5..\n// Copyright 2011년 __MyCompanyName__. All rights reserved.\n//\n\n#include \n#include \n#include \n\n#define min(x,y) (((x)<(y))?(x):(y))\n\nint main (int argc, const char * argv[])\n{\n char notes[][3] = {\"C\", \"C#\", \"D\", \"D#\", \"E\", \"F\", \"F#\", \"G\", \"G#\", \"A\", \"B\", \"H\"};\n int pos[3];\n char input[3][3];\n char tmp[11], *ptr;\n int i, j, diff[3];\n \n gets(tmp);\n ptr = strtok(tmp, \" \");\n strcpy(input[0], ptr);\n ptr = strtok(NULL, \" \");\n strcpy(input[1], ptr);\n ptr = strtok(NULL, \" \");\n strcpy(input[2], ptr);\n \n for(i=0;i<3;++i) {\n for(j=0;j<12;++j)\n if (strcmp(input[i], notes[j]) == 0)\n pos[i] = j;\n }\n \n if (pos[0] > pos[1])\n pos[0] ^= pos[1] ^= pos[0] ^= pos[1];\n if (pos[0] > pos[2])\n pos[0] ^= pos[2] ^= pos[0] ^= pos[2];\n if (pos[1] > pos[2])\n pos[1] ^= pos[2] ^= pos[1] ^= pos[2];\n \n for (i=0; i<3; ++i) {\n int tmp_pos = pos[i];\n diff[i] = 0;\n while (tmp_pos != pos[(i + 1) % 3]) {\n tmp_pos = (tmp_pos + 1) % 12;\n ++diff[i];\n }\n }\n \n if ((diff[0] == 4 && diff[1] == 3)\n || (diff[1] == 4 && diff[2] == 3)\n || (diff[2] == 4 && diff[0] == 3))\n printf(\"major\\n\");\n else if ((diff[0] == 3 && diff[1] == 4)\n || (diff[1] == 3 && diff[2] == 4)\n || (diff[2] == 3 && diff[0] == 4))\n printf(\"minor\\n\");\n else\n printf(\"strange\\n\");\n \n return 0;\n}\n", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58"} {"source_code": "#include \n#include \n#include \n#define LL long long\n#define uLL unsigned long long\nlong ms[2000000];\nvoid print(LL *a,long size) {long i;for (i=1;isize) {e=size;}\n\t\t\tfor (j=1;(s=s;b--)\n\t\t\t{\n\t\t\t\tds[e--]=ds[b];\n\t\t\t}\n\t\t\tfor (b=1;b>1;\n}\ninline int bsf64(int a)\n{\n\t__asm__(\"bsfl %0,%0\":\"+r\"(a));\n\treturn a; \n}\ninline int bsr64(int a)\n{\n\t__asm__(\"bsrl %0,%0\":\"+r\"(a));\n\treturn a; \n}\ninline LL max(LL a,LL b) {if (b>a) {a=b;}return a;}\ninline LL min(LL a,LL b) {if (a>b) {a=b;}return a;}\nLL ans1[1000000],ans2[1000000];\nlong num[1000],num2[1000];\nint main()\n{\n//\tfreopen(\"in.in\",\"r\",stdin);\n\tlong i,j,k,a,b,c,l,p,q,r,m,n,mid;\n\tLL baka;\n\tscanf(\"%ld %ld\\n\",&n,&m);\n//\tprintf(\"%ld %ld\\n\",n,m);\n\tfor (i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%ld\",&num[i]);\n\t\tnum[i]=num[i]%m;\n\t}\t\n\tif (n>10) {q=n>>1;} else {q=n;}\n\t*ans1=(LL)1<>1;\n\t\t\tif (ans1[mid]0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}\n\t\tl=1;r=*ans1;a=2*m-1-ans2[i];\n\t\twhile (l<=r)\n\t\t{\n\t\t\tmid=(l+r)>>1;\n\t\t\tif (ans1[mid]0) {b=(ans2[i]+ans1[r])%m;baka=max(b,baka);}\t\t\n\t}\n\tprintf(\"%lld\\n\",baka);\n\treturn 0;\n}\n", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a"} {"source_code": "#include \nunsigned long long int gcd(unsigned long long int a, unsigned long long int b) { \n if (a == 0) return b; \n return gcd(b % a, a); \n} \nint main() {\n\tunsigned long long int x;\n\tscanf(\"%llu\", &x);\n\tunsigned long long int ans[2]={1, x};\n\tfor (unsigned long long int i=1;i*i<=x;i++) {\n\t\tif (x%i==0) {\n\t\t\tif (i*i==x) continue;\n\t\t\telse {\n\t\t\t\tif (gcd(i, x/i)==1) {\n\t\t\t\t\tans[0]=i;\n\t\t\t\t\tans[1]=x/i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%llu %llu\\n\", ans[0], ans[1]);\n}\n", "src_uid": "e504a04cefef3da093573f9df711bcea"} {"source_code": "#include\n\n#include\n\nlong long int a[10000000];\n\nmain()\n\n{\n\n long long int n,k,i=1,j=1,ans=0,p=0;\n\n scanf(\"%lld%lld\",&n,&k);\n\n while(i<=sqrt(n))\n\n {\n\n if(n%i==0)\n\n { if(i*i!=n){a[p]=n/i;p++;}\n\n if(j==k){ans=i;break;}\n\n j++;\n\n }\n\n i++;\n\n\n\n } if(ans==0)\n\n { p=p-1;if((p-(k-j))>=0)\n\n ans=a[p-(k-j)];\n\n else ans=0;\n\n }\n\n if(ans!=0)printf(\"%lld\\n\",ans);\n\n else printf(\"-1\\n\");\n\n return 0;\n\n}", "src_uid": "6ba39b428a2d47b7d199879185797ffb"} {"source_code": "#include \n\nint min(int a, int b)\n{\n if (a < b) {\n return a;\n } else {\n return b;\n }\n}\n\nint dp[360361];\n\nint main()\n{\n long long a, b, sum = 0;\n int k, p = 1, i, j;\n \n scanf(\"%I64d %I64d %d\", &a, &b, &k);\n \n if (k >= 8) {\n p *= 8;\n } else if (k >= 4) {\n p *= 4;\n } else {\n p *= 2;\n }\n \n if (k >= 9) {\n p *= 9;\n } else if (k >= 3) {\n p *= 3;\n }\n \n if (k >= 5) p *= 5;\n if (k >= 7) p *= 7;\n if (k >= 11) p *= 11;\n if (k >= 13) p *= 13;\n \n dp[0] = 0;\n \n for (i = 1; i <= p; i++) {\n dp[i] = dp[i - 1] + 1;\n \n for (j = 2; j <= k; j++) {\n int x = i % j;\n \n if (x > 0) dp[i] = min(dp[i - x] + 1, dp[i]);\n }\n }\n \n if (a / p > b / p) {\n sum += dp[a % p];\n a = a / p * p;\n \n sum += (a / p - b / p - 1) * dp[p];\n a = b / p * p + p;\n }\n \n for (i = 0; i <= p; i++) dp[i] = 1e9;\n \n if (a % p == 0) {\n if (a == b) {\n printf(\"%I64d\\n\", sum);\n \n return 0;\n }\n \n dp[p] = 0;\n } else {\n dp[a % p] = 0;\n }\n \n for (i = p; i >= 0; i--) {\n if (dp[i] == 1e9) continue;\n \n if (i == b % p) {\n printf(\"%I64d\\n\", sum + dp[i]);\n \n return 0;\n }\n \n dp[i - 1] = min(dp[i - 1], dp[i] + 1);\n \n for (j = 2; j <= k; j++) {\n int x = i % j;\n \n if (x > 0) dp[i - x] = min(dp[i - x], dp[i] + 1);\n }\n }\n \n return 0;\n}\n", "src_uid": "bd599d76c83cc1f30c1349ffb51b4273"} {"source_code": "#include \n\nint main()\n{\n int n,i;\n\n int no=0;\n\n scanf(\"%d\",&n);\n\n int ara[n];\n\n for(i=0; iara[i+1]) continue;\n else\n {\n no=1;\n break;\n }\n }\n\n if(no==1) printf(\"NO\");\n else printf(\"YES\");\n}\n", "src_uid": "5482ed8ad02ac32d28c3888299bf3658"} {"source_code": "int i,j,N,u[100001],D[100001],C[100001],r[100001],x,d;\nint main () {\n scanf(\"%d\",&N);\n for (i=3;i<=N;++i) {\n for (j=2;2*i>=j*(j+1);++j) if ((i-j*(j+1)/2)%j==0) {\n x=(i-j*(j+1)/2)/j,d=C[x+j]^C[x];\n u[d]=i;\n if (!r[i] && !d) r[i]=j;\n }\n while (u[D[i]]==i) ++D[i];\n C[i]=C[i-1]^D[i];\n }\n if (!D[N]) puts(\"-1\");\n else printf(\"%d\\n\",r[N]);\n return 0;\n}\n\n", "src_uid": "63262317ba572d78163c91b853c05506"} {"source_code": "#include\n\nint N, M;\nlong long ans;\n\nint main()\n{\n\tscanf(\"%d%d\",&N,&M);\n\tregister int z, y, x;\n\tfor (x=M+1;2*x<=N+1;x++)\n\t{\n\t\tint st=(N-M-2*x)*(N+1-x)/(M-N-x);\n\t\tif (st<=M) st=M+1;\n\t\tans+=(st-M-1)*(N-M-M);\n\t\tfor (z=st,y=N-M; z<=N-M && y>M; z++)\n\t\t{\n\t\t\twhile (y>M && (x-N-1)*(x+x-y)+(x+y)*z>=0) y--;\n\t\t\tans+=(y-M)*((2*x\n#include \n\nint s[100000];\n\nint compare (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint main ()\n{\n int n;\n int i;\n scanf(\"%d\\n\", &n);\n for (i=0; i\n#include \n\nint a[201][201], x, y, i, j;\nchar c[1000];\n\n\n\nint main()\n{\n\tfor(i = 0; i <= 200; i++)\n\t{\n\t\tfor(j = 0; j <= 200; j++)\n\t\ta[i][j] == 0;\t\n\t}\n\ta[199][200]= 0;\n\tscanf(\"%s\",&c);\n\tx = 100;y = 100;\n\ta[x][y] = 1;\n\tfor(i = 0; i < strlen(c); i++)\n\t{\t\n\t\tif(c[i] == 'L') x = x - 1; \n\t\tif(c[i] == 'R') x = x + 1;\n\t\tif(c[i] == 'U') y = y - 1;\n\t\tif(c[i] == 'D') y = y + 1;\n\t\ta[y][x]++;\n\t}\n\tint flag = 0;\n\tif( strlen(c) > 2 && ((y == 100 && x == 99) || (y == 100 && x == 101)|| ( y == 101 && x == 100)|| ( y == 99 && x == 100))) {printf(\"BUG\"); flag = 1; } \n\telse \n\t{\n\t\t\n\tfor(i = 0; i <= 200; i++)\n\t{\n\t\tfor( j = 0; j<= 200; j++)\n\t\tif((a[i][j] !=0 && a[i][j-1] !=0 && a[i][j+1] !=0 && a[i+1][j]) || (a[i][j] !=0 && a[i][j-1] !=0 && a[i][j+1] !=0 && a[i-1][j]) || (a[i][j] !=0 && a[i][j-1] !=0 && a[i-1][j] !=0 && a[i+1][j]) || (a[i][j] !=0 && a[i-1][j] !=0 && a[i][j+1] !=0 && a[i+1][j])) {printf(\"BUG\");goto end;}\n\t\n\t}\n\t\n\t\n\tfor(i = 0; i <= 200; i++)\n\t{\n\t\tfor( j = 0; j<= 200; j++)\n\t\tif(a[i][j] >= 2 && i != 199 && j != 200 && i != 200) { printf(\"BUG\");flag = 1; break; }\n\t\tif(flag == 1) break;\t\n\t}\n\tfor(i = 0; i <= 200; i++)\n\t{\n\tfor( j = 0; j<= 200; j++)\n\tif((a[i][j]== 1 && a[i][j-1] == 1 && a[i][j] == 1 && a[i -1][j] == 1 && a[i-1][j-1] == 1 ) || (a[i][j] == 1 && a[ i][j +1] == 1 && a[i -1][j] && a[i -1 ][j+1]) || (a[i][j] == 1 && a[i][j+1] == 1 && a[i+1][j+1] == 1 && a[i+1][j]== 1) || (a[i][j] == 1 && a[i][j -1]== 1 && a[i+1][j] == 1 && a[i +1][j -1] == 1)) { printf(\"BUG\");flag = 1; break; }\n\tif(flag == 1) break;\t\n\t}\n\t\n\t\n\tif(flag == 0)printf(\"OK\");\n\t/*\n\tprintf(\"\\n\");\n\tfor(i = 80; i <= 200; i++)\n\t{\n\tfor(j = 80; j <= 200; j++)\n\tprintf(\"%d \",a[i][j]);\n\tprintf(\"\\n\");\t\n\t}\n\t*/\n\t\n\tend: return 0;\n\n\t}\n\t\n}", "src_uid": "bb7805cc9d1cc907b64371b209c564b3"} {"source_code": "#include\nlong long n,n1,sum,a[20],value;\n\nlong long findMinOnes(long long n,int i)\n{\n\tint count = 0;\n\tlong long value1,value2;\n\tif(n<0)\n\t\tn *=-1;\n\tif(i==1)\n\t\treturn n;\n\tif(n==1)\n\t\treturn 1;\n\t\twhile(n>a[i])\n\t\t{\n\t\t\tn-= a[i];\n\t\t\tcount+=i;\n\t\t}\n\t\tvalue1 = count + findMinOnes(n,i-1);\n\t\tn-= a[i];\n\t\tcount+=i;\n\t\tvalue2 = count + findMinOnes(n,i-1);\n\t\tif(value1 < value2)\n\t\t\treturn value1;\n\t\telse\n\t\t\treturn value2;\n}\nint main()\n{\n\tint k=1,i=0,count;\n\tlong long mul = 10;\n\tscanf(\"%I64d\",&n);\n\tn1=n;\n\twhile(n!=0)\n\t{\n\t\tn=n/10;\n\t\ti++;\n\t}\n\ta[k]=1;\n\tfor(k=2;k<=i+1;k++)\n\t{\n\t\ta[k]=a[k-1]+mul;\n\t\tmul*=10;\n\t}\n\tn=n1;\n\tprintf(\"%I64d\",findMinOnes(n,i+1));\n\treturn 0;\n}", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6"} {"source_code": "#include \n\nint main(void) {\n\t\n\tlong long n,a,b,c,d,max=0,min=10000000,ans=0;\n\t\n\tscanf(\"%I64d %I64d %I64d %I64d %I64d\",&n,&a,&b,&c,&d);\n\t\n\tif(maxa+b) min=a+b;\n\tif(min>a+c) min=a+c;\n\tif(min>b+d) min=b+d;\n\tif(min>c+d) min=c+d;\n\t\n\ta=min+n-max;\n\tb=max+1-min;\n\t\n\tif(a<0) a=0;\n\t\n\t\n\tif(a<0) printf(\"0\");\n\telse printf(\"%I64d\",(a)*n);\n\t\n\t\n}\n", "src_uid": "b732869015baf3dee5094c51a309e32c"} {"source_code": "#include \n#include \n\n\n\nint main(){\n\n\tint a,b,c;\n\n\tscanf(\"%d %d %d\", &a, &b, &c);\n\n\tfor(int i = 0; i <= c/a; i++){\n\t\tif((c-i*a)%b == 0){\n\t\t\tprintf(\"Yes\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tprintf(\"No\");\n\n\treturn 0;\n}", "src_uid": "e66ecb0021a34042885442b336f3d911"} {"source_code": "#include \n\nint main()\n{\n int n, res;\n \n scanf (\"%d\", &n);\n \n printf (\"%d\\n\", n % 2 == 1 || n == 2 ? 0 : n / 4 - (n%4 == 0));\n \n return 0;\n}\n", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37"} {"source_code": "#include \n\nint main(void) {\n\t// your code goes here\n\t\n\t\nlong long\tint n,i,sum=0,j=1;\n\tscanf(\"%I64d\",&n);\n\tfor(i=3;i<=n;i++)\n\t{\n\t sum=sum+j;\n\t j=j+2;\n\t \n\t \n\t \n\t}\n\tprintf(\"%I64d\",sum);\n\t\n\treturn 0;\n}\n\n", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b"} {"source_code": "i,k;long long n,p=1;main(){for(scanf(\"%I64d%d\",&n,&k);k>1&&p\nint check(char *s,int pos){\n for(int i=0;i1;i--){\n for(int j=0;j<=len-i;j++){\n char s[i];\n int pos=0;\n for(int k=j;k<=j+i-1;k++)\n s[pos++]=str[k];\n int flag=check(s,pos);\n if(flag==0){\n printf(\"%d\\n\",i);\n return 0;\n }\n }\n }\n printf(\"%d\\n\",0);\n return 0;\n}\n", "src_uid": "6c85175d334f811617e7030e0403f706"} {"source_code": "#include\nint main(){\n\tlong i,n,k,count=0,count1=0,flag=1;\n\tscanf(\"%ld %ld\",&n,&k);\n\tchar str[n];\n\tscanf(\"%s\",str);\n\tfor(i=0;icount){\n\t\twhile(countcount1){\n\t\t\tif(str[count-k]=='#'){\n\t\t\t\tflag=0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcount=count-k;\n\t\t\tif(str[count]=='T'){\n\t\t\t\tflag=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif(flag==1 && str[count]=='T')\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}\n\n\n", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41"} {"source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n int a[100][100],i,j;\n for(i=1;i<=n;i++)\n {\n for(j=1;j<=n;j++)\n {\n if(i==1 || j==1)\n {\n a[i][j]=1;\n }\n else\n {\n a[i][j]=a[i-1][j]+a[i][j-1];\n }\n }\n }\n \n printf(\"%d\",a[n][n]);\n}", "src_uid": "2f650aae9dfeb02533149ced402b60dc"} {"source_code": "#include \n#include \n\n\n\nint main(void) {\n long long int r;\n\n\tscanf(\"%lld\", &r);\n\n\tif((r&1) == 0 || r < 5){\n\t\tprintf(\"NO\");\n\t}\n\telse{\n\t\tprintf(\"%d %I64d\",1,((r-3)/2));\n\t}\n\n\treturn 0;\n}", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba"} {"source_code": "#include \n#define MIN(a,b) a < b ? a : b\nvoid myprint(long long);\nint main() {\n\tint t[3][3];\n\tint i, j;\n\tint n;\n\tlong long cost[3][3][41];\n\tfor(i = 0; i < 3; i++) {\n\t\tfor(j = 0; j < 3; j++) {\n\t\t\tscanf(\"%d\", &t[i][j]);\n\t\t}\n\t}\n\tscanf(\"%d\", &n);\n\n\tfor(i = 0; i < 3; i++) {\n\t\tfor(j = 0; j < 3; j++) {\n\t\t\tif(i == j)\n\t\t\t\tcost[i][j][1] = 0;\n\t\t\telse {\n\t\t\t\tint k = 3 - ( i + j );\n\t\t\t\tcost[i][j][1] = MIN(t[i][j], t[i][k] + t[k][j]);\n\t\t\t}\n\t\t}\n\t}\n\tint nn;\n\tfor(nn = 2; nn <= n ; nn++) {\n\t\tfor(i = 0; i < 3; i++) {\n\t\t\tfor(j = 0; j < 3; j++) {\n\t\t\t\tif(i == j)\n\t\t\t\t\tcost[i][j][nn] = 0;\n\t\t\t\telse {\n\t\t\t\t\tint k = 3 - ( i + j );\n\t\t\t\t\tcost[i][j][nn] = MIN(\n\t\t\t\t\t\t\t\t\t\t\tcost[i][k][nn-1] + cost[k][j][nn-1] + t[i][j],\n\t\t\t\t\t\t\t\t\t\t\tcost[i][j][nn-1] + t[i][k] + cost[j][i][nn-1] + t[k][j] + cost[i][j][nn-1]\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i = 0; i < 3; i++) {\n\t\t\tfor(j = 0; j < 3; j++) {\n\t\t\t\tif(i != j) {\n\t\t\t\t\tint k = 3 - (i + j);\n\t\t\t\t\tcost[i][j][nn] = MIN(cost[i][j][nn], cost[i][k][nn] + cost[k][j][nn]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n/*\tfor(nn = 1; nn <= n; nn++) {\n\t\tprintf(\"%d\\n\", nn);\n\t\tfor(i = 0; i < 3; i++) {\n\t\t\tfor(j = 0; j < 3; j++) {\n\t\t\t\tprintf(\"%3d\", cost[i][j][nn]);\n\t\t\t}\n\t\t\tprintf(\"\\n\");\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n*/\n\tmyprint(cost[0][2][n]);\n}\n\nvoid myprint(long long n) {\n\tif(n > 0) {\n\t\tmyprint(n/10);\n\t\tprintf(\"%d\", (int)(n%10));\n\t}\n}\n\n", "src_uid": "c4c20228624365e39299d0a6e8fe7095"} {"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}", "src_uid": "a524aa54e83fd0223489a19531bf0e79"} {"source_code": "#include\nint main()\n{\n int n,i,a[20],p,q,r,max;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&a[i]);\n }\n p=0;\n q=0;\n r=0;\n for(i=1;i<=n;i++)\n {\n if(i%3==0)\n {\n p=p+a[i];\n }\n else if((i+1)%3==0)\n {\n q=q+a[i];\n }\n else if((i+2)%3==0)\n {\n r=r+a[i];\n }\n }\n if(p>q && p>r)\n {\n max=p;\n }\n else if(q>p && q>r)\n {\n max=q;\n }\n else if(r>p && r>q)\n {\n max=r;\n }\n if(max==p)\n {\n printf(\"back\");\n }\n else if(max==q)\n {\n printf(\"biceps\");\n }\n else if(max==r)\n {\n printf(\"chest\");\n }\n return 0;\n}\n", "src_uid": "579021de624c072f5e0393aae762117e"} {"source_code": "#include \n\n#define min(a, b) (a == -1 ? b : (b == -1 ? a : (a < b ? a : b)))\n\nint n;\nlong long x, y;\nlong long dp[10000010];\n\nint main() {\n\tscanf(\"%d %lld %lld\", &n, &x, &y);\n dp[1] = x;\n for (int i = 2; i <= n; i++) {\n if (i & 1) {\n dp[i] = min(dp[i - 1] + x, dp[(i >> 1) + 1] + y + x);\n } else {\n dp[i] = min(dp[i - 1] + x, dp[i >> 1] + y);\n }\n }\n printf(\"%lld\", dp[n]);\n}", "src_uid": "0f270af00be2a523515d5e7bd66800f6"} {"source_code": "#include\ntypedef long long ll;\nint main()\n{\n\tint n,a,b;\n\tscanf(\"%d %d %d\",&n,&a,&b);\n\tif(b>=0)\n {\n \tif(b>=n)\n \tb=b%n; \n }\n\t else\n {\n while(b<0)\n {\n b+=n;\n }\n }\n a+=b;\n if(a>n)\n {\n a-=n;\n }\n printf(\"%d\",a);\n\treturn 0;\n } \n", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4"} {"source_code": "#include \n\nint main(void)\n{\n long i;\n long long n, min = 1e18, max = 0, a[2], b, c, d;\n scanf(\"%I64d\", &n);\n for (a[0] = 2; (a[0]-1)*(a[0]-1) <= n; a[0]++) {\n if (!(n % (a[0]-1))) {\n a[1] = n / (a[0] - 1) + 1;\n for (i = 0; i < 2; i++)\n for (b = 3; (b-2)*(b-2) <= (n / (a[i]-1)); b++)\n if (!((n / (a[i]-1)) % (b-2))) {\n c = n / ((a[i]-1)*(b-2)) + 2;\n d = 2*a[i]*b + 2*a[i]*c + b*c - 4*a[i] - 2*b - 2*c + 4;\n if (min > d)\n min = d;\n if (max < d)\n max = d;\n } \n }\n }\n printf(\"%I64d %I64d\\n\", min, max);\n return 0;\n}", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7"} {"source_code": "#include \n#include \n\nint main()\n{\n int a,x,y,color; //0:black,1:white\n double b;\n scanf(\"%d%d\",&x,&y);\n\n if(0==x||0==y)\n {\n color=0;\n }\n else\n {\n b=sqrt(x*x+y*y);\n a=(int)b;\n if(a*a == x*x+y*y)\n {\n color=0;\n }\n else\n {\n if(x>0&&y>0 || x<0&&y<0)\n color=a%2;\n else\n color=(a+1)%2;\n }\n }\n if(color)\n printf(\"white\");\n else\n printf(\"black\");\n\n return 0;\n}", "src_uid": "8c92aac1bef5822848a136a1328346c6"} {"source_code": "#include \n\nint main()\n{\n int m,d,dd,x;\n scanf(\"%d %d\",&m,&d);\n if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)\n dd=31;\n else if(m==2)\n dd=28;\n else\n dd=30;\n x=dd-8+d;\n if(x%7==0)\n printf(\"%d\",x/7+1);\n else\n printf(\"%d\",x/7+2);\n return 0;\n}", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74"} {"source_code": "#include\n#include\nint main()\n{\n int i,j,len;\n char ch,s1[]=\"qwertyuiopasdfghjkl;zxcvbnm,./\",s2[100];\n scanf(\"%c %s\",&ch,&s2);\n len=strlen(s2);\n if(ch=='R')\n {\n for(i=0,j=0;i<30;i++)\n {\n if(s2[j]==s1[i])\n {\n printf(\"%c\",s1[i-1]);\n j++;\n i=-1;\n }\n if(j==len)\n {\n printf(\"\\n\");\n break;\n }\n }\n }\n else if(ch=='L')\n {\n for(i=0,j=0;i<30;i++)\n {\n if(s2[j]==s1[i])\n {\n printf(\"%c\",s1[i+1]);\n j++;\n i=-1;\n }\n if(j==len)\n {\n printf(\"\\n\");\n break;\n }\n }\n }\n return 0;\n}\n", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6"} {"source_code": "#include \n#include \n\nint n,M,m,sum;\n\nint calc(int val[]){\n int sum=0,i,temp,j;\n for(i=0;ival[j])\n temp=val[j];\n sum+=temp;\n }\n }\n return sum;\n}\n\nint print_m(int i,int val[]){\n int j;\n\n if(i==n){\n\n if( calc(val)==sum )\n m++;\n if(m==M){\n for(j=0;j\n#include\n#include\n\nint main()\n{\nlong long int n,m,s;\nscanf(\"%I64d\",&s);\nn=(sqrt(1+8*s)-1)/2;\nm=(n*(n+1))/2;\nif(m==s)\nprintf(\"%I64d\",n);\nelse\nprintf(\"%I64d\",s-m);\nreturn 0;\n}\n", "src_uid": "1db5631847085815461c617854b08ee5"} {"source_code": "#include \nint g(int n)\n{\n\tif (n==1 || n==0) return n;\n\telse\n\t\treturn 2;\n}\nint gao(int m, int n)\n{\n\tif (n==1) return m;\n\telse if (n==2)\n\t\treturn (m/4*2 + g(m%4)) * 2;\n\telse\n\t\treturn (n * m + 1 ) / 2;\n\n}\nint main()\n{\n\tint m, n, temp;\n\twhile (~scanf(\"%d %d\", &m, &n))\n\t{\n\t\tif (m\nint main()\n{\n int a,b,r,d;\n scanf(\"%d %d %d\",&a,&b,&r);\n d=2*r;\n if(a>=d&&b>=d) printf(\"First\");\n else printf(\"Second\");\n}\n", "src_uid": "90b9ef939a13cf29715bc5bce26c9896"} {"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,ab;\n\nscanf(\"%lld%lld%lld\",&a,&b,&ab);\nif(a>b){\n printf(\"%lld\",(2*ab)+(b*2)+1);\n}\nelse{\n if(a==b){\n printf(\"%lld\",(2*ab)+(a*2));\n }else{\n printf(\"%lld\",(2*ab)+(a*2)+1);\n }\n}\nreturn 0;\n}\n", "src_uid": "609f131325c13213aedcf8d55fc3ed77"} {"source_code": "#include \n\nint n;\nint p[128];\nint is_gusu[128];\n\nint memo[128][2][128][128];\n\nint search(int idx, int prev_is_gusu, int left_gusu, int left_kisu) {\n\tint answer = 9999, candidate;\n\tif (idx >= n) return 0;\n\tif (memo[idx][prev_is_gusu][left_gusu][left_kisu]) {\n\t\treturn ~memo[idx][prev_is_gusu][left_gusu][left_kisu];\n\t}\n\n\tif (p[idx] == 0) {\n\t\tif (left_gusu > 0) {\n\t\t\tcandidate = search(idx + 1, 1, left_gusu - 1, left_kisu);\n\t\t\tif (idx > 0 && !prev_is_gusu) candidate++;\n\t\t\tif (candidate < answer) answer = candidate;\n\t\t}\n\t\tif (left_kisu > 0) {\n\t\t\tcandidate = search(idx + 1, 0, left_gusu, left_kisu - 1);\n\t\t\tif (idx > 0 && prev_is_gusu) candidate++;\n\t\t\tif (candidate < answer) answer = candidate;\n\t\t}\n\t} else {\n\t\tanswer = search(idx + 1, is_gusu[idx], left_gusu, left_kisu);\n\t\tif (idx > 0 && !prev_is_gusu != !is_gusu[idx]) answer++;\n\t}\n\n\treturn ~(memo[idx][prev_is_gusu][left_gusu][left_kisu] = ~answer);\n}\n\nint main(void) {\n\tint i;\n\tint kisu, gusu;\n\tif (scanf(\"%d\", &n) != 1) return 1;\n\tkisu = (n + 1) / 2;\n\tgusu = n / 2;\n\tfor (i = 0; i < n; i++) {\n\t\tif (scanf(\"%d\", &p[i]) != 1) return 1;\n\t\tif (p[i] != 0) {\n\t\t\tif (p[i] % 2 == 0) {\n\t\t\t\tis_gusu[i] = 1;\n\t\t\t\tgusu--;\n\t\t\t} else {\n\t\t\t\tis_gusu[i] = 0;\n\t\t\t\tkisu--;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", search(0, 0, gusu, kisu));\n\treturn 0;\n}\n", "src_uid": "90db6b6548512acfc3da162144169dba"} {"source_code": "#include \n#include \n#include \n\nint cmpfunc (const void * a, const void * b) {\n return ( *(int*)a - *(int*)b );\n}\n\nint main()\n{\n int N, M;\n scanf(\"%i %i\", &N, &M);\n if(M < N)\n {\n printf(\"0\");\n exit(0);\n }\n int arr[M], amt[101];\n memset(amt, 0, 101*sizeof(int));\n for(int i = 0; i < M; i++)\n {\n scanf(\"%i\", &arr[i]);\n amt[arr[i]]++;\n }\n int max = 0;\n for(int i = 0; i <= 100; i++)\n {\n if(amt[i] > max)\n {\n max = amt[i];\n }\n }\n qsort(arr, M, sizeof(int), cmpfunc);\n int amt2[M+1], count = 0;\n for(int i = 0; i < 101; i++)\n {\n if(amt[i] > 0)\n {\n amt2[count++] = amt[i];\n }\n }\n int ma = 0;\n for(int i = 1; i <= 1000; i++)\n {\n int peop = 0;\n for(int j = 0; j < count; j++)\n {\n peop += amt2[j]/i;\n }\n if(peop >= N)\n {\n ma = i;\n }\n }\n printf(\"%i\", ma);\n}", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe"} {"source_code": "#include \n#include \n#include \n#define P 1000000007\nint m;\nint f[2][200005];\nint cal2[100005];\nint main(void)\n{\n int r,g;\n int i,j;\n int p;\n int ma,k;\n scanf(\"%d%d\",&r,&g);\n if (r>g)\n {\n k=r;\n r=g;\n g=k;\n }\n for (i=1;i<=1500;i++)\n cal2[i]=(i*(i+1))/2;\n //memset(f,0,sizeof(f));\n m=sqrt(2*(r+g))+1;\n p=0;\n k=0;\n if (r>=1)\n {\n f[p][1]=1;\n k++;\n }\n if (g>=1)\n {\n f[p][0]=1;\n k++;\n }\n for (i=2;i<=m&&k>0;i++)\n {\n ma=k;\n k=0;\n for (j=0;j<=r;j++)\n {\n f[1-p][j]=0;\n if (j>=i)\n {\n f[1-p][j]+=f[p][j-i];\n }\n if (cal2[i]-j<=g)\n {\n f[1-p][j]+=f[p][j];\n }\n f[1-p][j]%=P;\n k=(k+f[1-p][j])%P;\n }\n p=1-p;\n // printf(\"%d\\n\",i);\n }\n// ma=0;\n// for (i=0;i<=r;i++)\n// ma=(ma+f[1-p][i])%P;\n printf(\"%d\\n\",ma);\n return 0;\n}\n", "src_uid": "34b6286350e3531c1fbda6b0c184addc"} {"source_code": "#include \"stdio.h\"\n\n#define MAX_MANHOLE_COUNT 5001\n\n#define BASE \"%d\"\ntypedef int Base;\n\ntypedef struct UManhole\n{\n Base Stones;\n Base IsCollected;\n} UManhole;\n\nint main()\n{\n Base Count = 0;\n UManhole Manholes[MAX_MANHOLE_COUNT];\n Base Standing = 0;\n Base Turns = 0;\n Base Garbage = -1;\n \n scanf(BASE BASE, &Count, &Standing);\n for (Base i = 1; i <= Count; i++)\n {\n Manholes[i].Stones = 1;\n Manholes[i].IsCollected = 0;\n }\n \n Turns = Count + Count + 1;\n if (Standing <= Count / 2)\n {\n Turns += (Standing - 1);\n Turns += (Count - 1);\n }\n else \n {\n Turns += (Count - Standing);\n Turns += (Count - 1);\n }\n \n printf(BASE\"\\n\", Turns);\n \n\treturn 0;\n}\n", "src_uid": "24b02afe8d86314ec5f75a00c72af514"} {"source_code": "#include \n#include \n\nint main(int argc, char const *argv[])\n{\n\tchar str[201];\n\tscanf(\"%s\",str);\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i =0;\n\tint count_letter=0,count_sf=0,count_stick=0,length=0;\n\tint sf_index = -1;\n\twhile(str[i] != '\\0')\n\t{\n\t\tif (str[i] == '?')\n\t\t{\n\t\t\tcount_stick++;\n\t\t}\n\t\telse if (str[i] == '*')\n\t\t{\n\t\t\tcount_sf++;\n\t\t\tsf_index = i;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcount_letter++;\n\t\t}\n\t\ti++;\n\t}\n\tlength = i;\n\t//printf(\"%d %d %d %d\\n\",count_letter,count_sf,count_stick,length);\n\n\tif (count_letter - (count_stick+count_sf) > n)\n\t{\n\t\tprintf(\"Impossible\");\n\t}\n\telse\n\t{\n\t\tif(n > count_letter)\n\t\t{\n\t\t\t//printf(\"%d\\n\",sf_index);\n\t\t\tif(sf_index != -1)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < sf_index; ++i)\n\t\t\t\t{\n\t\t\t\t\tif (str[i]!='?' && str[i]!='*')\n\t\t\t\t\t{\n\t\t\t\t\t\tprintf(\"%c\",str[i]);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\n\t\t\t\tfor (int i = 0; i < (n-count_letter); ++i)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%c\",str[sf_index-1]);\n\t\t\t\t}\n\n\t\t\t\tfor (int i = sf_index+1; i < length; ++i)\n\t\t\t\t{\n\t\t\t\t\tif (str[i]!='?' && str[i]!='*')\n\t\t\t\t\t{\n\t\t\t\t\t\tprintf(\"%c\",str[i]);\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\tprintf(\"Impossible\");\n\t\t\t}\n\t\t\t\n\t\t}\n\t\telse if (n < count_letter)\n\t\t{\n\t\t\tcount_letter = count_letter - n ;\n\t\t\tfor (int i = length -1; i >0; --i)\n\t\t\t{\n\t\t\t\tif (count_letter == 0)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(str[i] == '?' || str[i] == '*')\n\t\t\t\t{\n\t\t\t\t\tstr[i-1] = str[i];\n\t\t\t\t\tcount_letter -- ;\n\t\t\t\t\ti--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint j = 0;\n\t\t\twhile(str[j]!= '\\0')\n\t\t\t{\t\n\t\t\t\tif (str[j] != '?' && str[j] != '*')\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%c\",str[j]);\n\t\t\t\t}\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint j = 0;\n\t\t\twhile(str[j]!= '\\0')\n\t\t\t{\t\n\t\t\t\tif (str[j] != '?' && str[j] != '*')\n\t\t\t\t{\n\t\t\t\t\tprintf(\"%c\",str[j]);\n\t\t\t\t}\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276"} {"source_code": "#include\n#include\ntypedef long long int LL;\nchar x[1000];\nchar y[1000];\nchar z[1000];\nint incr()\n{\n int i=0;\n while(x[i]!='\\0')\n i++;\n i--;\n while(x[i]=='z')\n {\n x[i]='a';\n i--;\n }\n x[i]+=1;\n return 0;\n}\nint main()\n{\n int i,diff;\n scanf(\"%s\",x);\n scanf(\"%s\",y);\n incr();\n if(strcmp(y,x)>0)\n printf(\"%s\\n\",x);\n else\n printf(\"No such string\\n\");\n return 0;\n}\n", "src_uid": "47618510d2a17b1cc1e6a688201d51a3"} {"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,count=0;\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[2*n-1]*((fast_expo(fact[n],modd-2)*fast_expo(fact[n-1],modd-2))%modd))%modd;\n\t\tans=(2*ans)-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", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9"} {"source_code": " #include\n main()\n {\n int number[30];\n int i, j, a, n,s=0,k,f=0;\n //printf(\"Enter the value of N\\n\");\n scanf(\"%d\", &k);\n //printf(\"Enter the numbers \\n\");\n for (i = 0; i < 12; ++i)\n scanf(\"%d\", &number[i]);\n for (i = 0; i < 12; ++i)\n {\n for (j = i + 1; j < 12; ++j)\n {\n if (number[i] < number[j])\n {\n a = number[i];\n number[i] = number[j];\n number[j] = a;\n }\n }\n }\n if(k==0)\n printf(\"0\");\n else\n {\n for (i = 0; i < 12; ++i)\n {\n s=s+number[i];\n if(s>=k)\n {\n f=1;\n printf(\"%d\",i+1);\n break;\n }\n }\n if(f==0)\n printf(\"-1\");\n }\n }\n", "src_uid": "59dfa7a4988375febc5dccc27aca90a8"} {"source_code": "#include\n#include\nint main(){\nchar a[100],b[100];\n gets(a);\n strcpy(a,strlwr(a));\n gets(b);\n strcpy(b,strlwr(b));\n if(strcmp(a,b)==0)\n {\n printf(\"%d\",0);\n }\n else if (strcmp(a,b)>0)\n {\n printf(\"%d\",1);\n }\n else\n {\n printf(\"%d\",-1);\n }\n}\n", "src_uid": "ffeae332696a901813677bd1033cf01e"} {"source_code": "#include \n#include \n\nint main(int argc, char *argv[]) {\n\tlong long n, m, l, r, x;\n\tscanf(\"%I64d%I64d\", &n, &m);\n\tif (n <= m) printf(\"%I64d\\n\", n);\n\telse {\n\t\tfor (l = 1, r = sqrt(2 * n - 2 * m) + 1; l <= r; ) {\n\t\t\tx = (l + r) / 2;\n\t\t\tif (x * (x + 1) / 2 >= n - m)\n\t\t\t\tr = x - 1;\n\t\t\telse\n\t\t\t\tl = x + 1;\n\t\t}\n\t\tprintf(\"%I64d\\n\", m + r + 1);\n\t}\n\treturn 0;\n}", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8"} {"source_code": "#include\nint main(){\n int n;\n scanf(\"%d\",&n);\n int i,j;\n int count = 0;\n for(i=j;i<=n;i++){\n for(j=1;j<=n;j++){\n if(i % j == 0 && i*j > n && i/j < n){\n count = 1;\n break;\n }\n }\n if(count == 1){\n break;\n }\n }\n if(count == 1){\n printf(\"%d %d\\n\",i,j);\n }else{\n printf(\"-1\");\n }\n return 0;\n}", "src_uid": "883f67177474d23d7a320d9dbfa70dd3"} {"source_code": "#include\nint main()\n{\n long long a,b;\n scanf(\"%lld%lld\",&a,&b);\n while(a>0&&b>0)\n {\n if(a>=2*b)\n {\n a%=(2*b);\n }\n else if(b>=2*a)\n {\n b%=(2*a);\n }\n else\n {\n break;\n }\n }\n printf(\"%lld %lld\\n\",a,b);\n}\n", "src_uid": "1f505e430eb930ea2b495ab531274114"} {"source_code": "#include \n\nint main()\n{\n int n,m,a,b,x1,y1,x2,y2;\n scanf(\"%d%d%d%d\",&n,&m,&a,&b);\n a--;\n b--;\n x1=a/m;\n y1=a%m;\n x2=b/m;\n y2=b%m;\n if (x1==x2)\n puts(\"1\");\n else if (x1==x2-1)\n puts(!y1&&(y2==m-1||b==n-1)?\"1\":\"2\");\n else\n printf(\"%d\\n\",3-!y1-(y2==m-1||b==n-1||y1==y2+1));\n return 0;\n}\n", "src_uid": "f256235c0b2815aae85a6f9435c69dac"} {"source_code": "#include\n#define N 50+5\nint a[N];\nint main() {\n int n,k;\n scanf(\"%d%d\",&n,&k);\n int i;\n int participants=0;\n //可以不从头加起,而是从第k位加起,这里k就不用减一,因为k正好表示k-1的下一位!\n //因为k前面的都是大于等于第k位的!\n for (i=0;i0 && a[i]>=a[k-1]) {\n participants++;\n }\n }\n\n //printf(\"\\nparticipants = %d\\n\",participants);\n printf(\"%d\\n\",participants);\n return 0;\n}\n", "src_uid": "193ec1226ffe07522caf63e84a7d007f"} {"source_code": "#include\nint p[6][6];\nint n;\nint f(int level,int alphabet)\n{\n//\tif(level==n&&alphabet==0)\n//\t return 1;\n\tif(level==n)\n\t return 1;\n\t \n\tint i;\n\tint ans=0;\n\tfor(i=0;i<6;i++)\n\t{ if(p[alphabet][i])\n\t \tans+=p[alphabet][i]*f(level+1,i);\n\t} \n\t\n\treturn ans;\n\t \n}\nint main()\n{\n\tint q,i,j;\n\tscanf(\"%d%d\",&n,&q);\n\n\tchar str[6];\n\tgets(str);\n\tfor(i=0;i\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\tint i, j, b=0, w=0;\n\tchar arr[8][8];\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\", &arr[i][j]);\n\t\t}\n\t}\n\tfor(i=0;i<8;i++)\n\t{\n\t\tfor(j=0;j<8;j++)\n\t\t{\n\t\t\tswitch(arr[i][j])\n\t\t\t{\n\t\t\t\tcase 'Q':\n\t\t\t\t{\n\t\t\t\t\tw+=9;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'q':\n\t\t\t\t{\n\t\t\t\t\tb+=9;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'R':\n\t\t\t\t{\n\t\t\t\t\tw+=5;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'r':\n\t\t\t\t{\n\t\t\t\t\tb+=5;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'B':\n\t\t\t\tcase 'N':\n\t\t\t\t{\n\t\t\t\t\tw+=3;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'b':\n\t\t\t\tcase 'n':\n\t\t\t\t{\n\t\t\t\t\tb+=3;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'P':\n\t\t\t\t{\n\t\t\t\t\tw+=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'p':\n\t\t\t\t{\n\t\t\t\t\tb+=1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(b>w)\n\t{\n\t\tprintf(\"Black\");\n\t}\n\telse if(w>b)\n\t{\n\t\tprintf(\"White\");\n\t}\n\telse if(w==b)\n\t{\n\t\tprintf(\"Draw\");\n\t}\n}", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442"} {"source_code": "#include\nint main()\n{\n int k,c[35],i,r,ck;\n while(scanf(\"%d\",&k)==1){\n ck=0;\n for(i=0;ick)\n ck=c[i];\n }\n if(ck>25){\n r=ck-25;\n printf(\"%d\\n\",r);\n }\n else\n printf(\"%d\\n\",0);\n }\n return 0;\n}\n", "src_uid": "ef657588b4f2fe8b2ff5f8edc0ab8afd"} {"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", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1"} {"source_code": "#include \n#include \n\nint main()\n{\n int a, m, tab[100001];\n scanf(\"%d %d\", &a, &m);\n\n memset(tab,0,sizeof(int));\n\n while (1)\n {\n int b = a%m;\n if (tab[b] == 1)\n break;\n tab[b] = 1;\n\n a += b;\n\n if (a%m == 0)\n {\n printf(\"Yes\\n\");\n return 0;\n }\n }\n\n printf(\"No\\n\");\n\n return 0;\n}\n", "src_uid": "f726133018e2149ec57e113860ec498a"} {"source_code": "#include\n#include\nint main()\n{\n int x,y;\n scanf(\"%d%d\",&x,&y);\n if(x>=3&&y>=3){\n if(x>y) printf(\"<\");\n else if(y>x) printf(\">\");\n else printf(\"=\");\n }\n else{\n if(pow(x,y)>pow(y,x)) printf(\">\");\n else if(pow(x,y)\nint main()\n{\nint n;\nlong int j;\nscanf(\"%d\",&n);\nif(n%2==0)\n{\n j=n/2;\n printf(\"%ld\",j*(j+1));\n}\nif(n%2!=0)\n{\n j=n/2;\n printf(\"%ld\",(j+1)*(j+1));\n}\nreturn 0;\n}\n", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319"} {"source_code": "#include\n\nint main(){\n int n, p, k, i;\n scanf(\"%d %d %d\", &n, &p, &k);\n\n if(p-k > 1){\n printf(\"<< \");\n }\n for(i = k; i > 0; i--){\n if(p-i >= 1){\n printf(\"%d \", p-i);\n }\n }\n printf(\"(%d) \", p);\n for(i = 1; i <= k; i++){\n if(p+i <= n){\n printf(\"%d \", p+i);\n }\n }\n if(p+k < n){\n printf(\">>\");\n }\n\n return 0;\n}\n", "src_uid": "526e2cce272e42a3220e33149b1c9c84"} {"source_code": "#include\n\nint main(){\n int D;\n long long n, k, M, ans = 0;\n scanf(\"%lld%lld%lld%d\", &n, &k, &M, &D);\n for(int i = 0; i < D; i++){\n long long cur = n / (k * i + 1);\n if(!cur) break;\n if(cur > M) cur = M;\n long long lmax = cur * (i + 1);\n ans = ans > lmax ? ans : lmax;\n }\n printf(\"%lld\", ans);\n return 0;\n}\n", "src_uid": "ac2e795cd44061db8da13e3947ba791b"} {"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 gcd(int u, int v){\n int t;\n\n while (v){\n t = u;\n u = v;\n v = t % v;\n }\n\n if (u < 0) u = 0 - u;\n return u;\n}\n\nint main(){\n int i, j, k, l, x, y, a, b, c, d, u, v, g;\n\n while (scanf(\"%d %d %d %d\", &a, &b, &c, &d) != EOF){\n g = gcd(c, d);\n c /= g, d /= g;\n\n if (a < c || b < d) puts(\"0 0\");\n else{\n x = a / c, y = b / d;\n if (y < x) x = y;\n\n c *= x, d *= x;\n printf(\"%d %d\\n\", c, d);\n }\n }\n return 0;\n}\n", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a"} {"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]b)?counter:counter-1,draw,(a>b)?6-counter-draw:6-counter-draw+1);\n }\n return 0;\n}", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8"} {"source_code": "#include \r\nint T,a,b,c,d;\r\nint main(){\r\n\tscanf(\"%d\",&T);\r\n\twhile(T--){\r\n\t\tscanf(\"%d %d %d %d\",&a,&b,&c,&d);\r\n\t\tif(a+b+c+d==0)\r\n puts(\"0\");\r\n\t\telse if(a+b+c+d==4)\r\n\t\tputs(\"2\");\r\n\t\telse puts(\"1\");\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\n", "src_uid": "7336b8becd2438f0439240ee8f9610ec"} {"source_code": "#include \n#include \nint main()\n{\n char arr[500],arr2[500];\n gets(arr);\n gets(arr2);\n\n int i,j,k;\n\n int len=strlen(arr);\n char arr3[len];\n\n for(i=0,j=len-1 ; i=0 ; i++,j--)\n {\n arr3[i]=arr[j];\n\n if(i==len-1)\n {\n arr3[len]='\\0';\n }\n }\n int cmp = strcmp(arr3,arr2);\n\n if(cmp==0) printf(\"YES\");\n else printf(\"NO\");\n}\n", "src_uid": "35a4be326690b58bf9add547fb63a5a5"} {"source_code": "#include \n#include \n\nint main(){\n char w[500], max = '`';\n scanf(\"%s\", w);\n int n = strlen(w), i;\n for(i = 0; i < n; i++){\n if(w[i] > max){\n if(w[i] != max+1){\n printf(\"NO\\n\");\n return 0;\n }\n max++;\n }\n }\n printf(\"YES\\n\");\n return 0;\n}\n", "src_uid": "c4551f66a781b174f95865fa254ca972"} {"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}", "src_uid": "a307b402b20554ce177a73db07170691"} {"source_code": "#include \n#include \n\nint main(void)\n{\n\tchar n[15];\n\tint k;\n\n\tscanf(\"%s\", n);\n\tscanf(\"%d\", &k);\n\n\tint i = strlen(n) - 1;\n\tint zeros = 0;\n\tint remove = 0;\n\n\twhile(i >= 0 && zeros < k)\n\t{\n\t\tif(n[i] == '0')\n\t\t\tzeros++;\n\t\telse\n\t\t\tremove++;\n\t\ti--;\n\t}\n\n\tif(zeros == k)\n\t\tprintf(\"%d\\n\", remove);\n\telse\n\t\tprintf(\"%d\\n\", strlen(n) - 1);\n}", "src_uid": "7a8890417aa48c2b93b559ca118853f9"} {"source_code": "/* practice with Dukkha */\n#include \n#include \n\nint min(int a, int b) { return a < b ? a : b; }\nint max(int a, int b) { return a > b ? a : b; }\n\nint gcd(int a, int b) {\n\treturn b == 0 ? a : gcd(b, a % b);\n}\n\nint d_, x_, y_;\n\nvoid gcd_(int a, int b) {\n\tif (b == 0)\n\t\td_ = a, x_ = 1, y_ = 0;\n\telse {\n\t\tint t;\n\n\t\tgcd_(b, a % b);\n\t\tt = x_ - a / b * y_; x_ = y_, y_ = t;\n\t}\n}\n\nint div_(int a, int b) {\t/* b > 0 */\n\treturn a >= 0 ? a / b : -((-a + b - 1) / b);\n}\n\nint main() {\n\tint n, s, i, c3, c4, c5, k3, d, c4_, c5_, ans, a3, a4, a5;\n\n\tscanf(\"%d%d\", &n, &s);\n\tc3 = c4 = c5 = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tint x;\n\n\t\tscanf(\"%d\", &x);\n\t\tif (x == 3)\n\t\t\tc3++;\n\t\telse if (x == 4)\n\t\t\tc4++;\n\t\telse\n\t\t\tc5++;\n\t}\n\td = gcd(c4, c5);\n\tc4_ = c4 / d;\n\tc5_ = c5 / d;\n\tgcd_(c4_, c5_);\n\tans = -1, a3 = a4 = a5 = -1;\n\tfor (k3 = 0; k3 * n <= s; k3++) {\n\t\tint t = s - c3 * k3, k4_, k5_, lower, upper;\n\t\tint lower34, upper34, lower45, upper45;\n\t\tint lower1, upper1, lower2, upper2, lower3, upper3, lower4, upper4;\n\n\t\tif (t % d != 0)\n\t\t\tcontinue;\n\t\tt /= d;\n\t\tk4_ = x_ * t, k5_ = y_ * t;\n\t\t/* k4 = k4_ + c5_ * k */\n\t\t/* k5 = k5_ - c4_ * k */\n\n\t\t/* k4 >= k3\n\t\t * k4_ + c5_ * k >= k3\n\t\t * k4_ + c5_ * k > k3 - 1\n\t\t * c5_ * k > k3 - k4_ - 1\n\t\t * k > (k3 - k4_ - 1) / c5_\n\t\t * k >= (k3 - k4_ - 1) / c5_ + 1\n\t\t */\n\t\tlower = div_(k3 - k4_ - 1, c5_) + 1;\n\n\t\t/* k5 >= k4\n\t\t * k5_ - c4_ * k >= k4_ + c5_ * k\n\t\t * (c4_ + c5_) * k <= k5_ - k4_\n\t\t * k <= (k5_ - k4_) / (c4_ + c5_)\n\t\t */\n\t\tupper = div_(k5_ - k4_, c4_ + c5_);\n\t\tif (lower > upper)\n\t\t\tcontinue;\n\n\t\t/* c3 * k3 >= c4 * k4\n\t\t * c3 * k3 >= c4 * (k4_ + c5_ * k)\n\t\t * c4 * c5_ * k <= c3 * k3 - c4 * k4_\n\t\t * k <= (c3 * k3 - c4 * k4_) / (c4 * c5_)\n\t\t */\n\t\tupper34 = div_(c3 * k3 - c4 * k4_, c4 * c5_);\n\t\t/* c3 * k3 < c4 * k4 */\n\t\tlower34 = upper34 + 1;\n\n\t\t/* c4 * k4 >= c5 * k5\n\t\t * c4 * (k4_ + c5_ * k) >= c5 * (k5_ - c4_ * k)\n\t\t * (c4 * c5_ + c5 * c4_) * k >= c5 * k5_ - c4 * k4_\n\t\t * (c4 * c5_ + c5 * c4_) * k > c5 * k5_ - c4 * k4_ - 1\n\t\t * k > (c5 * k5_ - c4 * k4_ - 1) / (c4 * c5_ + c5 * c4_)\n\t\t * k >= (c5 * k5_ - c4 * k4_ - 1) / (c4 * c5_ + c5 * c4_) + 1\n\t\t */\n\t\tlower45 = div_(c5 * k5_ - c4 * k4_ - 1, c4 * c5_ + c5 * c4_) + 1;\n\t\t/* c4 * k4 < c5 * k5 */\n\t\tupper45 = lower45 - 1;\n\n\t\t/* Case 1: c3 * k3 >= c4 * k4 && c4 * k4 >= c5 * k5\n\t\t * goal\n\t\t * = c3 * k3 - c4 * k4 + c4 * k4 - c5 * k5\n\t\t * = c3 * k3 - c5 * k5\n\t\t * = c3 * k3 - c5 * (k5_ - c4_ * k)\n\t\t * +k\n\t\t * minimize k\n\t\t */\n\t\tlower1 = max(lower, lower45);\n\t\tupper1 = min(upper, upper34);\n\t\tif (lower1 <= upper1) {\n\t\t\tint k = lower1;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t\t/* Case 2: c3 * k3 >= c4 * k4 && c4 * k4 < c5 * k5\n\t\t * goal\n\t\t * = c3 * k3 - c4 * k4 - c4 * k4 + c5 * k5\n\t\t * = c3 * k3 - 2 * c4 * k4 + c5 * k5\n\t\t * = c3 * k3 - 2 * c4 * (k4_ + c5_ * k) + c5 * (k5_ - c4_ * k)\n\t\t * -k\n\t\t * maximize k\n\t\t */\n\t\tlower2 = lower;\n\t\tupper2 = min(upper, min(upper34, upper45));\n\t\tif (lower2 <= upper2) {\n\t\t\tint k = upper2;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t\t/* Case 3: c3 * k3 < c4 * k4 && c4 * k4 < c5 * k5\n\t\t * goal\n\t\t * = -c3 * k3 + c4 * k4 - c4 * k4 + c5 * k5\n\t\t * = -c3 * k3 + c5 * k5\n\t\t * = -c3 * k3 + c5 * (k5_ - c4_ * k)\n\t\t * -k\n\t\t * maximize k\n\t\t */\n\t\tlower3 = max(lower, lower34);\n\t\tupper3 = min(upper, upper45);\n\t\tif (lower3 <= upper3) {\n\t\t\tint k = upper3;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t\t/* Case 4: c3 * k3 < c4 * k4 && c4 * k4 >= c5 * k5\n\t\t * goal\n\t\t * = -c3 * k3 + c4 * k4 + c4 * k4 - c5 * k5\n\t\t * = -c3 * k3 + 2 * c4 * k4 - c5 * k5\n\t\t * = -c3 * k3 + 2 * c4 * (k4_ + c5_ * k) - c5 * (k5_ - c4_ * k)\n\t\t * +k\n\t\t * minimize k\n\t\t */\n\t\tlower4 = max(lower, max(lower34, lower45));\n\t\tupper4 = upper;\n\t\tif (lower4 <= upper4) {\n\t\t\tint k = lower4;\n\t\t\tint k4 = k4_ + c5_ * k;\n\t\t\tint k5 = k5_ - c4_ * k;\n\t\t\tint goal = abs(c3 * k3 - c4 * k4) + abs(c4 * k4 - c5 * k5);\n\n\t\t\tif (ans == -1 || ans > goal) {\n\t\t\t\tans = goal;\n\t\t\t\ta3 = k3, a4 = k4, a5 = k5;\n\t\t\t}\n\t\t}\n\t}\n\tif (ans == -1)\n\t\tprintf(\"-1\\n\");\n\telse\n\t\tprintf(\"%d %d %d\\n\", a3, a4, a5);\n\treturn 0;\n}\n", "src_uid": "3f3eb49a127768139283ac04ee44950f"} {"source_code": "/*\n * =====================================================================================\n *\n * Filename: Solitaire.c\n *\n * Description: \n *\n * Version: 1.0\n * Created: 2012年07月25日 13时47分01秒\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", "src_uid": "1805771e194d323edacf2526a1eb6768"} {"source_code": "#include \n\n#define M\t1000000007\n\nint main() {\n\tint i, j, l, n, k, sum;\n\tstatic int dp[2001][2001];\n\n\tscanf(\"%d%d\", &n, &k);\n\tdp[0][1] = 1;\n\tfor (l = 0; l < k; l++)\n\t\tfor (i = 1; i <= n; i++)\n\t\t\tif (dp[l][i] > 0)\n\t\t\t\tfor (j = i; j <= n; j += i)\n\t\t\t\t\tdp[l + 1][j] = (dp[l + 1][j] + dp[l][i]) % M;\n\tsum = 0;\n\tfor (i = 1; i <= n; i++)\n\t\tsum = (sum + dp[k][i]) % M;\n\tprintf(\"%d\\n\", sum);\n\treturn 0;\n}\n", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa"} {"source_code": "#include \n\nint\nmain ()\n{\n int a, b, mod;\n long long i;\n scanf (\"%d %d %d\", &a, &b, &mod);\n if (b >= mod)\n {\n printf (\"2\\n\");\n return 0;\n }\n for (i = 0; i <= a && i < mod; i++)\n if ((i * 1000000000) % mod != 0 && ((i * 1000000000) % mod + b) < mod)\n {\n\tprintf (\"1 %09d\\n\", (int)i);\n\treturn 0;\n }\n printf (\"2\\n\");\n return 0;\n}\n", "src_uid": "8b6f633802293202531264446d33fee5"} {"source_code": "#include\nint main()\n{\n long long int n;\n scanf(\"%lld\",&n);\n long long int k = n-n/2-n/3+n/(2*3)-n/5+n/(2*5)+n/(5*3)-n/(2*3*5)-n/7+n/(2*7)+n/(3*7)+n/(5*7)-n/(2*3*7)-n/(2*5*7)-n/(3*5*7)+n/(2*3*5*7);\n printf(\"%lld\",k);\n return 0;\n}", "src_uid": "e392be5411ffccc1df50e65ec1f5c589"} {"source_code": "#include\n#include\nint main()\n{\n int i,n,sum=0,min=50000;\n\tchar c[51];\n\tscanf(\"%d\\n\",&n);\n\tfor(i=0;i=13?26-fabs(c[i]-'A'):fabs(c[i]-'A');\n\t sum+=fabs(c[i+1]-'C')>=13?26-fabs(c[i+1]-'C'):fabs(c[i+1]-'C');\n\t sum+=fabs(c[i+2]-'T')>=13?26-fabs(c[i+2]-'T'):fabs(c[i+2]-'T');\n\t sum+=fabs(c[i+3]-'G')>=13?26-fabs(c[i+3]-'G'):fabs(c[i+3]-'G');\n\t if(sum<=min)min=sum;\n\t}\n\tprintf(\"%d\",min); \n} ", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543"} {"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", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb"} {"source_code": "#include \n#include \n#include \n#include \n \n//获取给定矩形内的中提琴家的数量\nint get_violas_num(int **grid_array, int x_row, int y_clo, int row_num, int col_num)\n{\n\tint i,j ;\n\tint violas_num = 0;\n\tfor(i = x_row; i <=row_num; i++)\n\t{\n\t\tfor(j = y_clo; j <=col_num; j++)\n\t\t{\n\t\t\tif(1 == grid_array[i][j])\n\t\t\t{\n\t\t\t\tviolas_num++;\n\t\t\t}\n\t\t}\n\t}\n\treturn violas_num;\n}\n//给定起始节点,获取节点内所有可能矩形区域的数目\nint get_rec_num(int **grid_array, int x_value, int y_value, int row_value, int col_value, int mini_value)\n{\n\tint i,j;\n\tint rec_num = 0;\n\tfor(i = x_value; i < row_value; i++)\n\t{\n\t\tfor(j = y_value; j < col_value; j++)\n\t\t{\n\t\t\tif(get_violas_num(grid_array, x_value, y_value, i, j) >= mini_value)\n\t\t\t{\n\t\t\t\trec_num++;\n\t\t\t}\n\t\t}\n\t}\n\treturn rec_num;\n}\nint main() \n{\n\t int row = 0, column = 0, number = 0; //中提琴家的数目\n\t int min_number = 0,recta_num = 0;\n\t int **grid_array;\n\t int i, x, y, j;\n\t scanf(\"%d%d%d%d\",&row, &column, &number, &min_number);\n\t //动态申请二维数组,并初始化\n grid_array = (int**)malloc(sizeof(int*) * row);\n\t if(!grid_array)\n\t {\n\t\t exit(EXIT_FAILURE);\n\t }\n\t for(i = 0; i < row; i++)\n\t {\n\t\t *(grid_array + i) = (int*)malloc(sizeof(int) * column);\n\t }\n\t \n\t for(i = 0; i < number; i++)\n\t {\n\t\t scanf(\"%d%d\",&x, &y);\n\t\t grid_array[x-1][y-1] = 1;\n\t }\n\t for(i = 0; i < row; i++)\n\t {\n\t\t for(j = 0; j < column; j++)\n\t\t {\n\t\t\t recta_num += get_rec_num(grid_array, i, j, row, column, min_number);\n\t\t }\n\t }\n\t printf(\"%d\\n\",recta_num);\n return EXIT_SUCCESS;\n}", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4"} {"source_code": "#include\n#include\nint main()\n{\n int n,i,ln,c=0,t=0;\n scanf(\"%d\",&n);\n char a[n];\n scanf(\"%s\",a);\n for(i=0;i0)\n c--;\n }\n if(c>=0)\n printf(\"%d\",c);\n else printf(\"0\");\n\n}\n", "src_uid": "a593016e4992f695be7c7cd3c920d1ed"} {"source_code": "#include\nint main()\n{\n double x1,y1,x2,y2,x3,y3;\n scanf(\"%lf%lf%lf%lf%lf%lf\",&x1,&y1,&x2,&y2,&x3,&y3);\n double m1,m2,n1,n2,o1,o2,a,b,c,d,e,f;\n m1=(x1+x2)/2;\n m2=(y1+y2)/2;\n n1=(x1+x3)/2;\n n2=(y1+y3)/2;\n o1=(x2+x3)/2;\n o2=(y2+y3)/2;\n a=(2.0*m1)-x3;\n b=(2.0*m2)-y3;\n c=(2.0*n1)-x2;\n d=(2.0*n2)-y2;\n e=(2.0*o1)-x1;\n f=(2.0*o2)-y1;\n printf(\"3\\n\");\n printf(\"%.0lf %.0lf\\n\",a,b);\n printf(\"%.0lf %.0lf\\n\",c,d);\n printf(\"%.0lf %.0lf\",e,f);\n return 0;\n}\n", "src_uid": "7725f9906a1b87bf4e866df03112f1e0"} {"source_code": "#include\nint main()\n{\n int a,b,c;\n scanf(\"%d%d%d\",&a,&b,&c);\n while(b-a <1 || c-a<2)\n {\n a--;\n }\nprintf(\"%d\",a+a+1+a+2);\n}", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5"} {"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", "src_uid": "5c4bd12df3915186a7b506c2060db125"} {"source_code": "#include\r\n#include\r\n#include\r\n#define NUM 1000000007LL\r\n\r\nlong long find(int k)\r\n{\r\n long long a = 4, sum = 1;\r\n k--;\r\n while(k--){\r\n a = a*a;\r\n a %= NUM;\r\n sum *= a;\r\n sum %= NUM;\r\n } \r\n sum *= 6;\r\n sum %= NUM;\r\n return sum;\r\n}\r\n\r\nint main(void)\r\n{\r\n int k; scanf(\"%d\", &k);\r\n printf(\"%lld\\n\", find(k));\r\n return 0;\r\n}", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4"} {"source_code": "#include \n#include \n#include \n\nint main(void)\n{\n\t int x, y, z;\n x=y=z=0;\n char s[1000];\n scanf(\"%s\", s);\n int p=0;\n for(p=0; s[p]!='+'; p++) x++;\n for(p++; s[p]!='='; p++) y++;\n for(p++; p1 && x+y==z-2) {\n for(p=0; p1 || y>1) && x+y==z+2) {\n if(x>1) {\n for(p=0; p\nint res = 0;\n \nint solve(int x){\n\tif(!x)\n\t\treturn 0;\n\tif(x&1)\n\t\tres++ ;\n\tsolve(x>>1);\n\treturn res;\n}\n \nint main(void) {\n\t// your code goes here\n\tlong int x;\n\tscanf(\"%ld\",&x);\n\tprintf(\"%d\",solve(x));\n\treturn 0;\n}", "src_uid": "03e4482d53a059134676f431be4c16d2"} {"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", "src_uid": "619665bed79ecf77b083251fe6fe7eb3"} {"source_code": "#include\n\nint main()\n{\n int n,ar[100000]={0},z=0;\n scanf(\"%d\",&n);\n ar[z++]=1;\n n--;\n while(n)\n {\n ar[z++]=1;\n n--;\n //if(n==0)\n //break;\n //else\n {\n if(ar[z-1]==ar[z-2])\n {\n for(int i=z-1;i>0;i--)\n {\n if(ar[i]==ar[i-1])\n {\n ar[i-1]+=1;\n ar[i]=0;\n --z;\n }\n }\n }\n }\n }\n for(int i=0;ar[i]>0;i++)\n printf(\"%d \",ar[i]);\n return 0;\n}", "src_uid": "757cd804aba01dc4bc108cb0722f68dc"} {"source_code": "#include \n#include \n#include \n#include \n\n#define N 100000\n#define EPS 1E-6\n\nint sign(double x) { \n return x < -EPS ? -1 : x > EPS; \n}\n\ndouble sqr(double x) { \n return x * x; \n}\n\ntypedef struct point {\n double x, y;\n} point;\n\ndouble dist(point a, point b) {\n return hypot(a.x - b.x, a.y - b.y);\n}\n\ndouble cross(point a, point b, point c) {\n return (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);\n}\n\n/* PA * PB */\ndouble dot(point p, point a, point b) {\n return (a.x - p.x) * (b.x - p.x) + (a.y - p.y) * (b.y - p.y);\n}\n\n/* delta angle of ABC */\ndouble delta_angle(point a, point b, point c) {\n return acos(dot(b, a, c) / (dist(a, b) * dist(b, c)));\n}\n\npoint *__o;\n\nint angle_cmp(point *p, point *q) {\n int c;\n if (c = sign(cross(*__o, *p, *q)))\n return -c;\n return sign(dist(*p, *__o) - dist(*q, *__o));\n}\n\npoint stack[N];\n\nint convex_hull(point *ps, int n) {\n int i, k, top;\n point q;\n\n k = 0;\n for (i = 1; i < n; i++)\n if (sign(ps[i].y - ps[k].y) < 0 || sign(ps[i].y - ps[k].y) == 0 && ps[i].x < ps[k].x)\n k = i;\n\n q = ps[k];\n ps[k] = ps[0];\n ps[0] = q;\n\n __o = &ps[0];\n qsort(ps + 1, n - 1, sizeof(point), (int (*)(const void *, const void *))angle_cmp);\n\n top = 0;\n for (i = 0; i < n; i++) {\n// printf(\"%lf,%lf\\n\", ps[i].x, ps[i].y);\n while (top >= 2 && sign(cross(stack[top - 2], stack[top - 1], ps[i])) <= 0) top--;\n stack[top++] = ps[i];\n }\n memcpy(ps, stack, sizeof(point) * top);\n return top;\n}\n\ndouble cccr(point A, point B, point C) {\n double a, b, c, cos_B, sin_B, R;\n\n a = dist(B, C);\n b = dist(A, C);\n c = dist(A, B);\n cos_B = (a * a + c * c - b * b) / (2 * a * c);\n sin_B = sqrt(1.0 - cos_B * cos_B);\n return b / sin_B / 2.0;\n}\n\nint too_straight(point A, point B, point C, double r) {\n// printf(\"R=%lf vs r=%lf\\n\", R, r);\n return sign(dot(B, A, C)) < 0 && sign(cccr(A, B, C) - r) > 0;\n}\n\ndouble area_bow(double r, double l) {\n double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;\n double theta = 2 * asin(l / (r + r));\n double sector = theta * r * r / 2;\n return sector - tri;\n}\n\ndouble area_polygon(const point a[], int n) {\n int i, j;\n double area = 0.0;\n for (j = 0, i = n - 1; j < n; i = j++)\n area += a[i].x * a[j].y - a[i].y * a[j].x;\n return fabs(area) / 2;\n}\n\nvoid die() {\n *(char *)NULL = 0;\n}\n\nint main() {\n static point ps[N];\n int n;\n double r;\n double ans, R, Rmin;\n int i, j, k, z, top, s, ch;\n\n scanf(\"%d %lf\", &n, &r);\n for (i = 0; i < n; i++)\n scanf(\"%lf %lf\", &ps[i].x, &ps[i].y);\n\n if (n == 1) {\n puts(\"0\");\n } else if (n == 2) {\n ans = area_bow(r, dist(ps[0], ps[1])) * 2.0;\n printf(\"%.9lf\\n\", ans);\n } else {\n n = convex_hull(ps, n);\n// printf(\"n=%d\\n\", n);\n\n top = 0;\n for (i = 0; i < n; i++) {\n while (top >= 2 && too_straight(stack[top - 2], stack[top - 1], ps[i], r))\n top--;\n stack[top++] = ps[i];\n }\n\n s = 0;\n ch = 1;\n while (ch) {\n ch = 0;\n while (top - s >= 3 && too_straight(stack[top - 2], stack[top - 1], stack[s], r))\n top--, ch = 1;\n while (top - s >= 3 && too_straight(stack[top - 1], stack[s], stack[s + 1], r))\n s++, ch = 1;\n }\n memcpy(stack, stack + s, sizeof(stack[0]) * (top -= s));\n// printf(\"top=%d\\n\", top);\n\n ans = area_polygon(stack, top);\n for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top) {\n// printf(\"%lf,%lf\\n\", stack[i].x, stack[i].y);\n ans += area_bow(r, dist(stack[i], stack[j]));\n }\n printf(\"%.9lf\\n\", ans);\n\n if (top >= 3)\n for (i = 0, j = 1 % top, k = 2 % top; i < top; i++, j = (j + 1) % top, k = (k + 1) % top)\n if (too_straight(stack[i], stack[j], stack[k], r))\n die();\n }\n\n return 0;\n}\n", "src_uid": "5f2a0960bab9bdc91b190ed07d6adcf7"} {"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}", "src_uid": "bf8a133154745e64a547de6f31ddc884"} {"source_code": "#include\nmain()\n{\n int a;\n scanf(\"%d\",&a);\n if(a%2==0)\n {\n printf(\"%d\",(a/2)-1);\n }\n else\n {\n printf(\"%d\",a/2);\n }\n\n\n}\n", "src_uid": "dfe9446431325c73e88b58ba204d0e47"} {"source_code": "#include \n\nint isp (int points, int place )\n\t{\n\t\tint j = (points/50) % 475;\n\t\tint i;\n\t\tfor ( i = 0; i < 25; i++)\n\t\t\t{\n\t\t\tj = (j*96+42) % 475;\n\t\t\tif ( j+ 26 == place)\n\t\t\t\treturn 1;\n\t\t\t}\n\t\treturn 0;\t\n\t}\n\n\nint main()\n{\n//\tint i,j;\n//\tint s;\n\tint p,x,y; // 26<=p<500 // 1<=y<=x<20000\n\tint result = -1;\n\tint i,j,k;\n\t\n\tscanf(\"%i %i %i\", &p, &x, &y);\n\t\n\t\n\n\tfor ( i = x; i >= y; i-=50)\n\t\t{\n\t\t\n\t\t\tif (isp(i,p) )\n\t\t\t{\n\t\t\t\tresult = 0;\n\t\t\t\tgoto end;\n\t\t\t}\t\n\t\t\t\n\t\t}\n\n\n\n\tfor ( i = x; i < 40001; i+=50) \n\t\t{\n\t\t\t\tif (isp(i,p))\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( (i-x) % 100 != 0)\n\t\t\t\t\t\t\tresult = (i - x ) / 100 +1;\n\t\t\t\t\t\telse result = (i-x)/100;\n\t\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\n\t\t}\n\t\n\nend:\n\tprintf(\"%i\",result);\n\treturn 0;\n}\n\n", "src_uid": "c9c22e03c70a94a745b451fc79e112fd"} {"source_code": "/* practice with Dukkha */\n#include \n\n#define N\t100\n#define MD\t1000000007\n\nint main() {\n\tstatic int aa[10], dp[N + 1], ch[N + 1][N + 1];\n\tint n, d, m, l, i, j, ans;\n\n\tscanf(\"%d\", &n);\n\tfor (d = 0; d < 10; d++)\n\t\tscanf(\"%d\", &aa[d]);\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\tdp[0] = 1;\n\tfor (d = 9; d >= 0; d--)\n\t\tfor (m = n; m >= 0; m--) {\n\t\t\tint x = dp[m];\n\n\t\t\tif (x == 0)\n\t\t\t\tcontinue;\n\t\t\tdp[m] = 0;\n\t\t\tfor (l = aa[d]; m + l <= n; l++) {\n\t\t\t\tint y = d == 0 ? (m + l - 1 < l ? 0 : ch[m + l - 1][l]) : ch[m + l][l];\n\n\t\t\t\tdp[m + l] = (dp[m + l] + (long long) x * y) % MD;\n\t\t\t}\n\t\t}\n\tans = 0;\n\tfor (m = 1; m <= n; m++)\n\t\tans = (ans + dp[m]) % MD;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755"} {"source_code": "#include\n#include\n#include\n\n\nint main(){\n int x1,y1,x2,y2,d,p;\n \n scanf(\"%d%d\",&x1,&y1);\n scanf(\"%d%d\",&x2,&y2);\n \n if(abs(x1-x2)==abs(y1-y2)){\n d=abs(x1-x2);\n }\n else if(abs(x1-x2)>abs(y1-y2)){\n p=abs(x1-x2)-abs(y1-y2);\n d=abs(y1-y2)+p;\n }\n else{\n p=abs(y1-y2)-abs(x1-x2);\n d=abs(x1-x2)+p;\n }\n printf(\"%d\",d);\n return 0;\n}", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4"} {"source_code": "#include \n\nint main(){\n double a,b; \n double div;\n scanf(\"%lf %lf\", &a, &b);\n div = b/a;\n if(div == 1){\n printf(\"0\");\n }\n else{\n if(div-(int)div != 0){\n printf(\"-1\");\n }\n else{\n int count = 0;\n while(1){\n float tmp;\n tmp = div/2;\n if(tmp-(int)tmp != 0){\n break;\n }\n else{\n div = div/2;\n count++;\n }\n }\n while(1){\n float tmp;\n tmp = div/3;\n if(tmp-(int)tmp != 0){\n break;\n }\n else{\n div = div/3;\n count++;\n }\n }\n if(div == 1){\n printf(\"%d\", count);\n }\n else{\n printf(\"-1\");\n }\n }\n }\n}\n", "src_uid": "3f9980ad292185f63a80bce10705e806"} {"source_code": "//Erick Jair García Barradas A01740197\n//Carlos Orozco Flores A01328800\n\n#include \n#include \n#define TRUE 1\n#define FALSE 0\n\n \n int main(int argc, char const *argv[]){\n \tint num = 0;\n \tscanf(\"%d\",&num);\n \tif (num % 2 == 0){\n \t\tprintf(\"%d\\n\", ((num / 2) + 1));\n \t} else {\n \t\tprintf(\"%d\\n\", ((num + 1) / 2));\n \t}\n \t\n }", "src_uid": "5551742f6ab39fdac3930d866f439e3e"} {"source_code": "/*\n * main.c\n *\n * Created on: 03 ���. 2014 �.\n * Author: ulgish\n */\n\n\n/*\n * util.c\n *\n * Created on: 30 ���� 2014 �.\n * Author: ulgish\n */\n#include \n#include \n#include \n#include \n\n#define MAX(A,B) (((A) > (B))?(A):(B))\n#define MIN(A,B) (((A) < (B))?(A):(B))\n\n#define LN printf(\"\\n\")\n#define TAB printf(\"\\t\")\n#define SPACE printf(\" \")\n\ntypedef unsigned long long uint64;\ntypedef long long int64;\ntypedef signed short int16;\ntypedef unsigned short uint16;\ntypedef char byte;\n\n\nvoid int64_print(int64 n){\n\tint64 carry = 10;\n\tif (n == 0){\n\t\tprintf(\"0\");\n\t\treturn;\n\t}\n\tchar buf[20];\n\tbuf[0] = '\\0';\n\tint i = 0, j;\n\twhile (n > 0){\n\t\tbuf[i] = n % carry;\n\t\tn = n / carry;\n\t\ti += 1;\n\t}\n\ti--;\n\tfor (j = i; j>= 0; j--){\n\t\tprintf(\"%c\", 48 + buf[j]);\n\t}\n}\nvoid uint64_print(uint64 n){\n\tuint64 carry = 10;\n\tchar buf[20];\n\tbuf[0] = '\\0';\n\tint i = 0, j;\n\twhile (n > 0){\n\t\tbuf[i] = n % carry;\n\t\tn = n / carry;\n\t\ti += 1;\n\t}\n\ti--;\n\tfor (j = i; j>= 0; j--){\n\t\tprintf(\"%c\", 48 + buf[j]);\n\t}\n}\n\n\nuint64 uint64_read(){\n\tchar* s = (char*) calloc(20, sizeof(char));\n\ts[0] = '\\0';\n\tscanf(\"%s\", s);\n\t//printf(\"=======%s\\n\", s);\n\tuint64 ret = 0;\n\tuint64 carry = 1;\n\tint len = strlen(s), i;\n\tfor (i = 0; i < len; i++){\n\t\tret += carry * (s[len-1-i] - 48);\n\t\tcarry*=10;\n\t};\n\tfree(s);\n\treturn ret;\n}\n\n\nint64 int64_read(){\n\tchar* s = (char*) calloc(21, sizeof(char));\n\ts[0] = '\\0';\n\tscanf(\"%s\", s);\n\t//printf(\"=======%s\\n\", s);\n\tint64 ret = 0;\n\tint64 carry = 1;\n\tint len = strlen(s), i;\n\tfor (i = 0; i < len; i++){\n\t\tret += carry * (s[len-1-i] - 48);\n\t\tcarry*=10;\n\t};\n\tfree(s);\n\treturn ret;\n}\n\n//#define DEBUG\n\nint64 x;\nint a[100001];\nint b[100001];\n\nint n,d;\n\nvoid swap(int* a, int* b){\n\tint c;\n\tc = *a;\n\t*a = *b;\n\t*b = c;\n\treturn;\n}\nint64 getNextX() {\n x = (x * 37 + 10007) % 1000000007;\n return x;\n}\nvoid initAB() {\n\tint i;\n for(i = 0; i < n; i = i + 1){\n a[i] = i + 1;\n }\n for(i = 0; i < n; i = i + 1){\n swap(&(a[i]), &(a[(int)(getNextX() % (i + 1))]));\n }\n for(i = 0; i < n; i = i + 1){\n if (i < d)\n b[i] = 1;\n else\n b[i] = 0;\n }\n for(i = 0; i < n; i = i + 1){\n swap(&(b[i]), &(b[(int)(getNextX() % (i + 1))]));\n }\n}\n\n\nint main(){\n\tscanf(\"%d %d\", &n, &d);\n\tx = int64_read();\n\tint i,j;\n\tinitAB();\n\tint max_a[100000];\n\tint index_a[100001];\n\tint sum_b[100000];\n\tint q[100001];\n\tq[0] = 0;\n\tsum_b[0] = b[0];\n\tmax_a[0] = a[0];\n#ifdef DEBUG\n//\tprintf(\"d:%d\\na:\\n\", d);\n//\tfor (i = 0 ; i < n; i++){\n//\t\tprintf(\"%d\\t\", a[i]);\n//\t}\n//\tLN;\n//\tfor (i = 0 ; i < n; i++){\n//\t\tprintf(\"%d\\t\", b[i]);\n//\t}\n//\tLN;\n//\n#endif\n\tint tmp = -1;\n\tfor (i = 0; i< n; i++){\n\t\tindex_a[a[i]] = i;\n\t\tif (b[i]) q[++q[0]] = i;\n\t\tif (i > 0){\n\t\t\tsum_b[i] = b[i] + sum_b[i-1];\n\t\t}\n\t\tif (sum_b[i] == 0){\n\t\t\ttmp = i;\n\t\t}\n\n\t}\n#ifdef DEBUG\n\tprintf(\"tmp:%d\\n\", tmp);\n\tprintf(\"sum_b[%d]:%d\\n\", tmp+1, sum_b[tmp+1]);\n#endif\n\tfor (i = 0; i <= tmp; i++){\n\t\tmax_a[i] = MAX(a[i], max_a[i-1]);\n\t\tprintf(\"0\\n\");\n\t}\n\tfor (i = tmp+1; i < n; i++){\n\t\tint c = 0;\n\t\tmax_a[i] = MAX(a[i], max_a[i-1]);\n#ifdef DEBUG\n\t\tprintf(\"max_a[%d]:%d\\t index_a[%d:%d]\\t\", i, max_a[i], max_a[i], index_a[max_a[i]]);\n#endif\n\t\tif (sum_b[i] == i+1){\n\t\t\tprintf(\"%d\\n\", max_a[i]);\n\t\t\tcontinue;\n\t\t}\n\t\tint s = 0;\n\t\tbyte next = 0;\n\t\tfor (j = max_a[i]; j >= 1 && s < 100; j--, s++){\n\t\t\tif (index_a[j] <= i){\n#ifdef DEBUG\n\t\t\t\tprintf(\"j:%d\\tb[%d]:%d\\n\", j, i-index_a[j], b[i - index_a[j]]);\n#endif\n\t\t\t\tif (b[i - index_a[j]]){\n\t\t\t\t\tnext = 1;\n\t\t\t\t\tprintf(\"%d\\n\", j);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (next){\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (j = 1; j <= q[0] && q[j] <= i; j++){\n\t\t\tc = MAX(c, a[i - q[j]]);\n\t\t}\n#ifdef DEBUG\n\t\tprintf(\"brutforce:\\t\");\n#endif\n\t\tprintf(\"%d\\n\",c);\n\t}\n\n\treturn 0;\n}\n", "src_uid": "948ae7a0189ada07c8c67a1757f691f0"} {"source_code": "#include \nint gcd(int a,int b);\nint lcm(int a,int b);\nint main()\n{\n int a,b,c,d,lc,hcf;\n scanf(\"%d%d%d%d\",&a,&b,&c,&d);\n if(a>b)\n {\n \ta=a+b;\n \tb=a-b;\n \ta=a-b;\n \tc=c+d;\n \td=c-d;\n \tc=c-d;\n }\n lc=lcm(a,c);\n b=b*lc/a;\n d=d*lc/c;\n hcf=gcd(b,d);\n if(b-d>0)\n printf(\"%d/%d\",(b-d)/hcf,b/hcf);\n else\n {\n b=b*a/lc;\n d=d*c/lc;\n lc=lcm(b,d);\n a=a*lc/b;\n c=c*lc/d;\n hcf=gcd(a,c);\n printf(\"%d/%d\",(a-c)/hcf,a/hcf);\n \n }\n return 0;\n\n}\nint gcd(int a,int b)\n{\n\tif(a==0)\n\t\treturn b;\n\telse if(b==0)\n\t\treturn a;\n\telse\n\t\treturn(gcd(b,a%b));\n}\nint lcm(int a,int b)\n{\n\treturn(a*b/gcd(a,b));\n}", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e"} {"source_code": "#include \n\nvoid primera (){\n\tint i;\n\t\tprintf (\"+\");\n\tfor (i=0;i<24;i++){\n\t\tprintf(\"-\");\n\t}\n\tprintf(\"+\\n\");\n}\nvoid pasajeros (int n, int s){\n\tint i;\n\tint a = n;\n\tint b = 0;\n\tint c = 4;\n\tprintf(\"|\");\n\tif (s == 1){\n\t\tif (n==1){\n\t\t\tfor (i=1;i<12;i++){\n\t\t\t\tprintf(\"#.\");\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t\ti = 1;\n\tdo {\n\t\tif (a>0){\n\t\t\tif (b == 0){\n\t\t\t\ta=a-c;\n\t\t\t\tc--;\n\t\t\t\tb++;\n\t\t\t}\n\t\t\telse \n\t\t\t\ta = a - c;\n\t\t\tprintf(\"O.\");\n\t\t}\n\t\telse \n\t\t\tprintf(\"#.\");\n\t\ti++;\n\t} while (i<=11);\n\t\t}\n\t}\n\telse {\n\ti = 1;\n\tdo {\n\t\tif (a>0){\n\t\t\tif (b == 0){\n\t\t\t\ta=a-c;\n\t\t\t\tc--;\n\t\t\t\tb++;\n\t\t\t}\n\t\t\telse \n\t\t\t\ta = a - c;\n\t\t\tprintf(\"O.\");\n\t\t}\n\t\telse \n\t\t\tprintf(\"#.\");\n\t\ti++;\n\t} while (i<=11);\n\t}\n\n\tprintf(\"|\");\n}\n\nvoid vacia (int n){\n\tprintf(\"|\");\n\tint i;\n\tif (n >= 3){\n\t\tprintf(\"O.\");\n\t}\n\telse \n\t\tprintf(\"#.\");\n\tfor (i=1;i<23;i++){\n\t\tprintf(\".\");\n\t}\n\tprintf(\"|\\n\");\n}\n\nint main (){\n\tint n;\n\tint s = 0;\n\tscanf (\"%i\", &n);\n\tprimera();\n\tpasajeros(n, s);\n\tprintf(\"D|)\\n\");\n\tpasajeros(n-1, s);\n\tprintf(\".|\\n\");\n\tvacia(n);\n\ts = 1;\n\tpasajeros(n-2, s);\n\tprintf(\".|)\\n\");\n\tprimera();\n\t\n\treturn 0;\n}", "src_uid": "075f83248f6d4d012e0ca1547fc67993"} {"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", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50"} {"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}", "src_uid": "020d5dae7157d937c3f58554c9b155f9"} {"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}", "src_uid": "e6e760164882b9e194a17663625be27d"} {"source_code": "#include \n\nint main()\n{\n int n, m, i, max = -1, count;\n scanf(\"%d %d\", &n, &m);\n int arr[n];\n\n for(i=0; i max)\n max = arr[i];\n }\n\n if(max % m == 0)\n count = max / m;\n else\n count = max / m + 1;\n\n for(i=n-1; i>=0; i--){\n if(arr[i] % m == 0){\n if(arr[i] / m == count){\n printf(\"%d\", i + 1);\n return 0;\n }\n }\n else{\n if(arr[i] / m + 1 == count){\n printf(\"%d\", i + 1);\n return 0;\n }\n }\n }\n printf(\"%d\", n);\n\n\treturn 0;\n}\n", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c"} {"source_code": "#include \n\ntypedef long long ll;\n\nll q[10000];\nshort b[10000];\n\nint count(int x, int y, int n)\n{\n int f, r, ret;\n f = r = ret = 0;\n if (x != 0)\n {\n if (x <= n)\n {\n b[r] = 1;\n q[r ++] = x;\n }\n }\n if (y <= n)\n {\n b[r] = 1;\n q[r ++] = y;\n }\n while (f < r)\n {\n if (b[f] == 0)\n {\n ret ++;\n }\n if (q[f] * 10 + x <= n)\n {\n b[r] = 0;\n if (b[f] == 1 && q[f] % 10 == x)\n {\n b[r] = 1;\n }\n q[r ++] = q[f] * 10 + x;\n }\n if (q[f] * 10 + y <= n)\n {\n b[r] = 0;\n if (b[f] == 1 && q[f] % 10 == y)\n {\n b[r] = 1;\n }\n q[r ++] = q[f] * 10 + y;\n }\n f ++;\n }\n return ret;\n}\n\nvoid solve(int n)\n{\n int x, y, ans, ret;\n ll t;\n ans = 0;\n for (x = 0; x <= 9; x ++)\n {\n for (y = x + 1; y <= 9; y ++)\n {\n ret = count(x, y, n);\n ans += ret;\n }\n }\n for (x = 1; x <= 9; x ++)\n {\n t = x;\n while (t <= n)\n {\n ans ++;\n t = t * 10 + x;\n }\n }\n printf(\"%d\\n\", ans);\n}\n\nint main()\n{\n int n;\n while (scanf(\"%d\", &n) == 1)\n {\n solve(n);\n }\n return 0;\n}", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4"} {"source_code": "#include\n#include\nint main()\n{ \n int n,i,r=0,z;\n long long out=0;\n scanf(\"%d\",&n);\n char str[n];\n \n \n\n scanf(\"%s\",str);\n \nfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n\nint main(void) {\n\tint x, y, z, t1, t2, t3;\n\tint jedno;\n\tint drugo;\n\tscanf(\"%d%d%d%d%d%d\", &x, &y, &z, &t1, &t2, &t3);\n\tjedno = abs(x - y)*t1;\n\tif (z == x) {\n\t\tdrugo = 2 * t3 + abs(x - y)*t2 + t3;\n\t}\n\telse {\n\t\tdrugo = abs(x - z)*t2 + 2 * t3 + abs(x - y)*t2 + t3;\n\t}\n\tif (jedno < drugo) printf(\"NO\");\n\telse printf(\"YES\");\n\treturn 0;\n}", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca"} {"source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\\n\",&n);\n char str[n];\n scanf(\"%s\",str);\n int ctr=0;\n for(int i=0;i\n\nint main()\n{\n int n,i,j,k,p=0,a,b=0,c=0;\n char s[51];\n scanf(\"%d\",&n);\n scanf(\"%s\",s);\n \n for(i=0;i\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i,a[n];\n\tfor(i=0;i\nint main(){\n\tint n,x,y,sum,i,j;\n\tscanf(\"%d%d%d\",&n,&x,&y);\n\tint a[100000]={0};\n\tfor(i=0;i1){\n\t\twhile(iy){\n\t\t\t\t\tsum+=(2*y);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tsum+=(2*x);\n\t\t\t\t}\n\t\t\t}\n\t\t\ti++;\n\t\t\tj--;\n\t\t\tif(i==j && a[i]==2){\n\t\t\t\tif(x>y){\n\t\t\t\t\tsum+=y;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tsum+=x;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if(a[i]==2){\n\t\tif(x>y)\n\t\t\tsum=y;\n\t\telse{\n\t\t\tsum=x;\n\t\t}\t\n\t}\n\tprintf(\"%d\\n\",sum);\n\treturn 0;\n}", "src_uid": "af07223819aeb5bd6ded4340c472b2b6"} {"source_code": "#include\nint arr[101],no[101],l[100];\nint main()\n{\n\tint n,m,source,desti,temp,flag,k,i;\n\tscanf(\"%d %d\",&n,&m);\n\tfor(i=0;i\n#include\n#define MAX_NUM 1000000\n// array will be initialized to 0 being global\nint search;\nint main()\n{\n\tint t,i,w,l,k,c,cout,x,first,last,y,q,f,b,d,s,count=0,prime,min,p,m;\n\t//scanf(\"%d\",&t);\n\t//for(i=0;i\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}", "src_uid": "4b8161259545e44c7d1046be2e4fe014"} {"source_code": "#include \n#include \n\nint cmp_perm(const void *a, const void *b)\n{\n return *((int *)a) - *((int *)b);\n}\n\nint next_permutation(int a[], int n)\n{\n int m = a[n - 1], p = 1, i, j;\n int b[20];\n\n b[0] = m;\n\n for (i = n - 2; i >= 0; i--) {\n\tif (m > a[i]) {\n\t qsort(b, p, sizeof(int), cmp_perm);\n\n\t for (j = 0; ; j++) {\n\t\tif (b[j] > a[i]) {\n\t\t m = a[i];\n\t\t a[i++] = b[j];\n\t\t b[j] = m;\n\n\t\t break;\n\t\t}\n\t }\n\n\t for (p = 0; i < n; i++) {\n\t\ta[i] = b[p++];\n\t }\n\n\t return 1;\n\t} else {\n\t b[p++] = a[i];\n\n\t if (a[i] > m) m = a[i];\n\t}\n }\n\n return 0;\n}\n\nint main()\n{\n int r1, r2, c1, c2, d1, d2;\n int a[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};\n\n scanf(\"%d %d\", &r1, &r2);\n scanf(\"%d %d\", &c1, &c2);\n scanf(\"%d %d\", &d1, &d2);\n\n do {\n\t if (a[0] + a[1] != r1) continue;\n\t if (a[2] + a[3] != r2) continue;\n\t if (a[0] + a[2] != c1) continue;\n\t if (a[1] + a[3] != c2) continue;\n\t if (a[0] + a[3] != d1) continue;\n\t if (a[1] + a[2] != d2) continue;\n\n\t printf(\"%d %d\\n\", a[0], a[1]);\n\t printf(\"%d %d\\n\", a[2], a[3]);\n\n\t return 0;\n } while (next_permutation(a, 9));\n\n puts(\"-1\");\n\n return 0;\n}\n", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3"} {"source_code": "/* upsolve using zigzag */\n/* https://codeforces.com/blog/entry/73563 */\n#include \n#include \n\n#define N\t1024\n\nint query(int i) {\n\tif (i == -1) {\n\t\tprintf(\"R\\n\"), fflush(stdout);\n\t\treturn 0;\n\t} else {\n\t\tstatic char s[2];\n\n\t\tprintf(\"? %d\\n\", i + 1), fflush(stdout);\n\t\tscanf(\"%s\", s);\n\t\treturn s[0] == 'N';\n\t}\n}\n\nint main() {\n\tstatic char alive[N];\n\tint n, k, m, g, h, i, ans;\n\n\tscanf(\"%d%d\", &n, &k), m = n / k;\n\tmemset(alive, 1, n * sizeof *alive);\n\tfor (g = 0; g < m; g++) {\n\t\tquery(-1);\n\t\tfor (h = 0; h < m; h++) {\n\t\t\tint g_ = (g + (h % 2 == 0 ? h / 2 : m - (h + 1) / 2)) % m, l = g_ * k, r = (g_ + 1) * k;\n\n\t\t\tfor (i = l; i < r; i++)\n\t\t\t\tif (alive[i] && !query(i))\n\t\t\t\t\talive[i] = 0;\n\t\t}\n\t}\n\tans = 0;\n\tfor (i = 0; i < n; i++)\n\t\tif (alive[i])\n\t\t\tans++;\n\tprintf(\"! %d\\n\", ans), fflush(stdout);\n\treturn 0;\n}\n", "src_uid": "11ad68b4375456733526e74e72606d8d"} {"source_code": "#include \n\nint f(int x,int n,int a[n]){\n int res=0;\n for (int i=0;i\n#include\"string.h\"\nint main()\n{\n char string [100];\n scanf(\"%s\",string);\n int counter_of_number=0;\n int length=strlen(string);\n for(int i=0;i\n \n#define MD\t1000000007\n \nlong long power(int a, int k) {\n\tlong long p;\n \n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k / 2);\n\tp = p * p % MD;\n\tif (k % 2)\n\t\tp = p * a % MD;\n\treturn p;\n}\n \nint main() {\n\tint n, m;\n \n\tscanf(\"%d%d\", &n, &m);\n\tprintf(\"%lld\\n\", power(power(2, m) - 1, n));\n\treturn 0;\n}", "src_uid": "71029e5bf085b0f5f39d1835eb801891"} {"source_code": "// In the name of ˜”*°•.˜”*°• God •°*”˜.•°*”˜\n \n/* \n \n JadedBeast ~~Morocco~~\n \n*/\n#include \n#include \n#include \n#include \n#define N 100001\n\nint main(void){ \n bool *sieve=(bool *)malloc(N*sizeof(bool));\n sieve[0]=false,sieve[1]=false;\n for(int i=2;i0){\n for(int i=0;i\n#include\n#define mod 1000000007\nint main()\n{\n\tlong long int n,x,y,l,result;\n\tscanf(\"%lld %lld\",&x,&y);\n\tscanf(\"%lld\",&n);\n\tif (n%6==0){\n\t\tresult=(x-y)%mod;\n\t}\n\tif (n%6==1){\n\t\tresult=x%mod;\n\t}\n\tif (n%6==2){\n\t\tresult=y%mod;\n\t}\n\tif (n%6==3){\n\t\tresult=(y-x)%mod;\n\t}\n\tif (n%6==4){\n\t\tresult=(-x)%mod;\n\t}\n\tif (n%6==5){\n\t\tresult=(-y)%mod;\n\t}\n\tif (result>=0){\n\t\tprintf(\"%lld\\n\",result);\n\t}\n\telse {\n\t\tl=abs(result);\n\t\tprintf(\"%lld\\n\",mod-l);\n\t}\n\t\t\n\treturn 0;\n}", "src_uid": "2ff85140e3f19c90e587ce459d64338b"} {"source_code": "#include \n#include \n\n\nint main()\n{\n int n,m,i,b,max,max_i,temp,j,sum=0;\n scanf(\"%d%d\",&n,&m);\n int a[m][2];\n for(i=0;imax)\n {\n max=a[j][1];\n max_i=j;\n b=1;\n }\n }\n temp=a[i][1];\n a[i][1]=a[max_i][1];\n a[max_i][1]=temp;\n temp=a[i][0];\n a[i][0]=a[max_i][0];\n a[max_i][0]=temp;\n }\n i=0;\n while(1)\n {\n if(n>a[i][0])\n {\n sum+=((a[i][0])*(a[i][1]));\n n-=a[i][0];\n }\n else\n {\n sum+=n*(a[i][1]);\n n=0;\n }\n i+=1;\n if(i>=m || n==0)\n break;\n }\n printf(\"%d\",sum);\n}\n\n", "src_uid": "c052d85e402691b05e494b5283d62679"} {"source_code": "#include \n#include \n\n#define PI acos(-1)\n#define eqs 0.01\ndouble gcd(double a,double b)\n{\nreturn a < eqs ? b : gcd(fmod(b,a),a);\n}\nint main()\n{\ndouble x1 , y1 , x2 , y2 , x3 , y3 ;\ndouble a , b , c , p , s , r , k ;\ndouble A , B , C ;\nscanf(\"%lf %lf %lf %lf %lf %lf\", &x1, &y1, &x2, &y2, &x3, &y3) ;\na = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;\nb = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) ;\nc = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) ;\np = ( a + b + c ) / 2.0 ;\ns = sqrt( p * (p-a) * (p-b) * (p-c) ) ;\nr = a * b * c / ( 4 * s ) ;\nif( a > c )\n{\nk = a ; a = c ; c = k ;\n}\nif( b > c )\n{\nk = b ; b = c ; c = k ;\n}\nA = 2 * asin(a/(2*r)) ;\nB = 2 * asin(b/(2*r)) ;\nC = 2 * PI - A - B ;\n//printf(\"%lf %lf %lf\\n\", A, B, C) ;\np = gcd(A,B);\np = gcd(p,C) ;\n//printf(\"%lf %lf\\n\", r, p) ;\nprintf(\"%.6lf\\n\", (PI*r*r*sin(p))/p ) ;\nreturn 0;\n}\n", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62"} {"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", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e"} {"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", "src_uid": "68a9508d49fec672f9c61766d6051047"} {"source_code": "#include\nint main(){\n \n long long a,b,n,m,k;\n scanf(\"%I64d %I64d %I64d\",&n,&m,&k);\n if(k\n\nint main()\n{\n int n, x, y, min, max, i = 0;\n\n scanf(\"%d%d%d\", &n, &x, &y);\n\n max = x > y ? x : y;\n min = x < y ? x : y;\n\n for(i = 0; ; i++) {\n if(!(n % min)) break;\n n -= max;\n if(n < 0) break;\n }\n\n if(n < 0) printf(\"NO\");\n else {\n if(x > y) printf(\"YES\\n%d %d\", i, n / min);\n else printf(\"YES\\n%d %d\", n / min, i);\n }\n\n return 0;\n}\n", "src_uid": "b031daf3b980e03218167f40f39e7b01"} {"source_code": "#include\nint a[1000];\nint isprime(int k)\n{\n int j;\n for(j=2;j<=k/2;j++)\n {\n if(k%j==0)\n return 0;\n }\n return 1;\n}\n\n \nint main()\n{\n int i,j,k,l=0,m,n,t=0;\n scanf(\"%d%d\",&n,&k);\n if(k==0)\n {\n printf(\"YES\");\n return 0;\n }\n for(i=2;i<=n;i++)\n {\n if(isprime(i)==1)\n {\n a[l]=i;\n \n l++;\n }\n }\n for(i=0;i\n#include \n\n#define MOD 1000000007\n\nint main()\n{\n int i, j;\n int n, k, d;\n int dp[105];\n int tt[105];\n memset(dp, 0, sizeof(dp));\n memset(tt, 0, sizeof(tt));\n scanf(\"%d%d%d\", &n, &k, &d);\n for ( tt[0] = 1, i = 1; i < 105; i++ )\n {\n tt[i] = 0;\n for ( j = 1; j <= i && j <= k; j++ )\n tt[i] = (tt[i]+tt[i-j])%MOD;\n }\n for ( i = d; i <= n; i++ )\n {\n for ( j = 1; j < d; j++ )\n dp[i] = (dp[i]+dp[i-j])%MOD;\n for ( j = d; j <= k && j <= i; j++ )\n dp[i] = (dp[i]+tt[i-j])%MOD;\n }\n printf(\"%d\\n\", dp[n]);\n return 0;\n}\n", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d"} {"source_code": "#include \n\ntypedef unsigned long long int ll;\n\nll gcd(ll a,ll b)\n{\n if(b==0)\n return a;\n return gcd(b,a%b);\n}\n\nint main()\n{\n ll t,a,b,min,c,q,x,n,l,r;\n scanf(\"%llu %llu %llu\",&t,&a,&b);\n if(a==b)\n {\n printf(\"1/1\\n\");\n return 0;\n }\n if(bmin)\n {\n c=0;\n q=(t/a)*gcd(a,b);\n q=q/b;\n c=c+min-1;\n n=(q*a*(b/gcd(a,b)));\n if((t-n)<=(min-1))\n {\n if(q>=1)\n c=c+(q-1)*min+t-n+1;\n else\n c=c+t-n+1;\n }\n else\n {\n c=c+(q)*min;\n }\n }\n else\n {\n if(t==min)\n c=min-1;\n else\n {\n c=t;\n }\n }\n r=gcd(c,t);\n printf(\"%llu/%llu\\n\",(c/r),(t/r));\n return 0;\n}\n\n", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5"} {"source_code": "#include\nint main()\n{\n int n,k,x,arr[105],sum=0,i;\n scanf(\"%d%d%d\",&n,&k,&x);\n for (i=0;i\n#include \n\nint main()\n{ int x,b,s;\n s=0;\n b=0;\n while(~scanf(\"%d\",&x))\n {b=x/5;\n s=b;\n if(x%5!=0)\n s=s+1;\n printf(\"%d\\n\",s);\n }\n return 0;\n}\n\n \t\t\t \t \t \t \t \t \t \t \t", "src_uid": "4b3d65b1b593829e92c852be213922b6"} {"source_code": "#include \n#define cj(x1,y1,x2,y2) (1LL*(x1)*(y2)-1LL*(x2)*(y1))\n\nstruct case1\n{\n int x,y;\n}ra[50001],rb[50001],rc[50001],p[150001];\n\nint main()\n{\n int i,j,k,a,b,c,x,y,l,r,mid,pa=1,pb=1,pc=1,o=0;\n scanf(\"%d\",&a);\n for (i=1;i<=a;i++)\n {\n scanf(\"%d%d\",&ra[i].x,&ra[i].y);\n if (ra[i].x0)\n {\n x=rb[j%b+1].x-rb[j].x;\n y=rb[j%b+1].y-rb[j].y;\n }\n if (cj(rc[k%c+1].x-rc[k].x,rc[k%c+1].y-rc[k].y,x,y)>0)\n {\n x=rc[k%c+1].x-rc[k].x;\n y=rc[k%c+1].y-rc[k].y;\n }\n if (cj(ra[i%a+1].x-ra[i].x,ra[i%a+1].y-ra[i].y,x,y)==0)\n i=i%a+1;\n if (cj(rb[j%b+1].x-rb[j].x,rb[j%b+1].y-rb[j].y,x,y)==0)\n j=j%b+1;\n if (cj(rc[k%c+1].x-rc[k].x,rc[k%c+1].y-rc[k].y,x,y)==0)\n k=k%c+1;\n p[++o]=(struct case1){ra[i].x+rb[j].x+rc[k].x,ra[i].y+rb[j].y+rc[k].y};\n if (i==pa&&j==pb&&k==pc)\n break;\n }\n scanf(\"%d\",&a);\n while (a--)\n {\n scanf(\"%d%d\",&x,&y);\n x*=3;\n y*=3;\n if (cj(x-p[1].x,y-p[1].y,p[2].x-p[1].x,p[2].y-p[1].y)>0||cj(x-p[1].x,y-p[1].y,p[o].x-p[1].x,p[o].y-p[1].y)<0)\n puts(\"NO\");\n else\n {\n l=2;\n r=o;\n while (l>1;\n if (cj(p[mid].x-p[1].x,p[mid].y-p[1].y,x-p[1].x,y-p[1].y)>=0)\n l=mid;\n else\n r=mid;\n }\n puts((cj(p[l+1].x-p[l].x,p[l+1].y-p[l].y,x-p[l].x,y-p[l].y)>=0)?\"YES\":\"NO\");\n }\n }\n return 0;\n}\n", "src_uid": "a764daf8e19e48a0735811a4f67485c3"} {"source_code": "#include \n#include \n\n#define N\t52\n#define K\t(N * 9)\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nvoid carry(int *aa, int n) {\n\tint i;\n\n\tfor (i = 0; i < n; i++)\n\t\tif (aa[i] >= 10)\n\t\t\taa[i + 1] += aa[i] / 10, aa[i] %= 10;\n\t\telse if (aa[i] < 0)\n\t\t\taa[i + 1] -= (-aa[i] + 9) / 10, aa[i] = (aa[i] % 10 + 10) % 10;\n}\n\nint main() {\n\tstatic char aa[N + 1];\n\tstatic int bb[N + 1], dp[K * 2 + 1], dq[K * 2 + 1], dp_[K * 2 + 1], dq_[K * 2 + 1];\n\tint n, i, j, k, ans;\n\tchar tmp;\n\n\tscanf(\"%s\", aa), n = strlen(aa);\n\tfor (i = 0; i < n; i++)\n\t\taa[i] -= '0';\n\tfor (i = 0, j = n - 1; i < j; i++, j--)\n\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\tn += 2;\n\tmemset(dp, 0x3f, (K * 2 + 1) * sizeof *dp), memset(dq, 0x3f, (K * 2 + 1) * sizeof *dq); \n\tdp[K] = 0;\n\tfor (i = n - 2; i >= 0; i--) {\n\t\tmemset(dp_, 0x3f, (K * 2 + 1) * sizeof *dp_), memset(dq_, 0x3f, (K * 2 + 1) * sizeof *dq_); \n\t\tfor (k = 0; k <= K * 2; k++) {\n\t\t\tint x;\n\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = aa[j] + k - K;\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dp[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdp_[k - d] = min(dp_[k - d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdq_[k - d] = min(dq_[k - d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (j = 0; j <= i + 1; j++)\n\t\t\t\tbb[j] = -bb[j];\n\t\t\tcarry(bb, i + 2), bb[i + 2] = 0;\n\t\t\tif ((x = dq[k]) != INF) {\n\t\t\t\tint d = bb[i + 1] == 1 ? 10 : bb[i];\n\n\t\t\t\tfor (j = i; j >= 0; j--)\n\t\t\t\t\tbb[j] -= d;\n\t\t\t\tbb[0]--;\n\t\t\t\tcarry(bb, i + 2);\n\t\t\t\tif (bb[i + 2] < 0)\n\t\t\t\t\td--;\n\t\t\t\tif (d < 10) {\n\t\t\t\t\tdq_[k + d] = min(dq_[k + d], x + d * (i + 1));\n\t\t\t\t\tif (++d < 10)\n\t\t\t\t\t\tdp_[k + d] = min(dp_[k + d], x + d * (i + 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmemcpy(dp, dp_, (K * 2 + 1) * sizeof *dp_), memcpy(dq, dq_, (K * 2 + 1) * sizeof *dq_); \n\t}\n\tans = INF;\n\tfor (k = 0; k <= K * 2; k++)\n\t\tif ((aa[0] + k - K) % 10 == 0)\n\t\t\tans = min(ans, dp[k]);\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907"} {"source_code": "#include \ntypedef long long unsigned llu;\ntypedef unsigned u;\nu M[55][55];\nint main()\n{\n\tu m,b,i,j;llu k,r=0llu;\n\tscanf(\"%u%u\",&m,&b);\n\tfor(i=-1;++i<=b;)\n\t{\n\t\tj=m*(b-i);\n\t\tk =(j+1)*(i*(llu)(i+1)>>1);\n\t\tk+=(i+1)*(j*(llu)(j+1)>>1);\n\t\tif(r\n#include\n#include\n#define max(a,b) ((a>b)?a:b))\n#define min(a,b) ((a\n#include \n\nint main()\n{\n long long a, b;\n scanf(\"%I64d %I64d\", &a, &b);\n long long counter = 0ll;\n for(long long i = (long long)1; i < b * 100; i *= 2)\n {\n for(long long j = (long long)1; j < b * 100; j *= 3)\n {\n if(i * j >= a && i * j <= b)\n counter++;\n }\n }\n printf(\"%I64d\", counter);\n return 0;\n}\n", "src_uid": "05fac54ed2064b46338bb18f897a4411"} {"source_code": "#include \n#include \n\n\n\n#define rep2(i,k,n) for(i=(k);i<(n);++i)\n#define rep(i,n) rep2(i,0,n)\n\n\n\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef int TKey;\n\n\n#define MAX_NUM 2003\n\nconst ll MOD_MAX = (1e9 + 7);\n\null inv[MAX_NUM];\null wt[MAX_NUM];\n\n\n\n\nvoid calcInv(int m)\n{\n int i;\n inv[0] = 1;\n inv[1] = 1;\n for (i = 2; i < m; i++)\n {\n inv[i] = ((MOD_MAX - MOD_MAX / i) * inv[MOD_MAX % i]) % MOD_MAX;\n }\n}\n\n\null getC(ull n, ull m)\n{\n ull i;\n ull ans = 1;\n //addLog(\"Need C(\" << n << \",\" << m << \")\");\n if (n < m) return 0;\n //cala the min\n if (m > n - m) m = n - m;\n //n %= MOD_MAX;\n for (i = 1; i <= m; i++)\n {\n ans = (ans * inv[i] % MOD_MAX * (n - i + 1)) % MOD_MAX;\n ////addLog(\"ans=\" << ans);\n }\n //addLog(\"C(\" << n << \",\" << m << \")=\" << ans);\n return ans;\n}\n\n//lucas定理:C(n,m)%p = C(n/p,m/p) * C(n%p,m%p)\n//C(n,m)模p等于p进制数上各位的C(ni,mi)模p的乘积\null getLucas(ull n, ull m)\n{\n //C(n,0) = 1\n if (0 == m) return 1;\n return (getC(n % MOD_MAX, m % MOD_MAX) * getLucas(n / MOD_MAX, m / MOD_MAX)) % MOD_MAX;\n}\n\n\null solve(int n, ll s)\n{\n //允许盒子为空一开始要人为加入一个球\n //花同,盒子不同,且允许为空的数量为 C(n+m-1, m-1),相当于找 m-1 个挡板\n ull ans = 0;\n int sign;\n ll sum;\n int i, j;\n for (i = 0; i < (1 << n); i++)\n {\n sign = 1;//__buildin_popcount(i)&1?-1:1;\n sum = s;\n //addLog(\"i=\" << bitset<6>(i));\n for (j = 0; j < n; j++)\n {\n if (i & (1 << j))\n {\n sign = 0 - sign;\n //将当前的盒子全部取光(包括多放进去的 1个初始球)\n sum -= wt[j] + 1;\n //addLog(\"j=\" << j << \",sign=\" << sign << \",sum=\" << sum);\n }\n }\n if (sum < 0)\n {\n //枚举的盒子的花已经超过总个数,这种情况已经在前面计算过了\n //addLog(\"[sum<0]i=\" << bitset<6>(i) << \",sum=\" << sum);\n continue;\n }\n //剩余的盒子当中还需要找花,相当于从 sum 朵花和 n 个盒子找 n-1 个挡板\n //容斥原理\n if (sign < 0)\n ans = (ans + MOD_MAX + sign * getLucas(sum + n - 1, n - 1)) % MOD_MAX;\n else\n ans = (ans + sign * getLucas(sum + n - 1, n - 1)) % MOD_MAX;\n //addLog(\"sign=\" << sign << \",sum=\" << sum << \")=\" << ans);\n }\n return (ans + MOD_MAX) % MOD_MAX;\n}\n\n\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"iofiles/cf#451e.in\", \"rt\", stdin);\n freopen(\"iofiles/cf#451e.out\", \"wt\", stdout);\n#endif // DEBUG\n\n\n int n;\n ull s;\n int i;\n\n scanf(\"%d %I64d\", &n, &s);\n //printf(\"%d, %llu\\n\", n, s);\n\n calcInv(n);\n\n rep(i, n)\n {\n scanf(\"%I64d\", &wt[i]);\n ////addLog(\"wt=\" << wt[i]);\n }\n\n printf(\"%I64d\\n\", solve(n, s));\n\n\n return 0;\n}\n", "src_uid": "8b883011eba9d15d284e54c7a85fcf74"} {"source_code": "#include\nint main()\n{\n int a,b;\n scanf(\"%d %d\",&a,&b);\n if(a\n#include\nint main()\n{\n int n,i,j,k,l,a[4][7],v[105];\n memset(v,0,sizeof(v));\n memset(a,0,sizeof(a));\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n for(j=1;j<=6;j++)\n {\n scanf(\"%d\",&a[i][j]);\n v[a[i][j]]=1;\n }\n }\n for(i=1;i<=n;i++)\n {\n for(j=1;j<=6;j++)\n {\n for(k=1;k<=n;k++)\n {\n if(k==i) continue;\n for(l=1;l<=6;l++)\n v[a[i][j]*10+a[k][l]]=1;\n }\n }\n }\n for(i=1;i<=99;i++)\n if(!v[i])\n {\n printf(\"%d\\n\",i-1);\n break;\n }\n return 0;\n}\n", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b"} {"source_code": "#include\n#include\nint main(){\n int n,i,j,temp=0;\n scanf(\"%d\",&n);\n int a[n];\n for(i=0;i\n#include\n#include\n#include\n#include\n#include\n\n#define MAX( a, b ) ( ( a > b) ? a : b ) \n#define MIN( a, b ) ( ( a < b) ? a : b )\n#define FOR(ii,aa,bb) for(ii=aa;ii\n\nint dp[1 << 24];\nint p[1 << 24][3];\n\nint dist(int x1, int y1, int x2, int y2)\n{\n return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);\n}\n\nint main()\n{\n int x, y, n, i, j, k;\n int a[24], b[24], d[25][25];\n\n scanf(\"%d %d\", &x, &y);\n scanf(\"%d\", &n);\n\n for (i = 0; i < n; i++) scanf(\"%d %d\", &a[i], &b[i]);\n\n for (i = 0; i < n; i++) {\n\t for (j = i + 1; j < n; j++) {\n\t d[i][j] = d[j][i] = dist(a[i], b[i], a[j], b[j]);\n\t }\n\n\t d[i][n] = d[n][i] = dist(x, y, a[i], b[i]);\n }\n\n for (i = 1; i < (1 << n); i++) dp[i] = 1e9;\n\n for (i = 0; i < (1 << n) - 1; i++) {\n\t for (j = 0; j < n; j++) {\n\t if (((i >> j) & 1) == 0) {\n\t\t int c = i ^ (1 << j);\n\n\t\t for (k = j + 1; k < n; k++) {\n\t\t\t if (((i >> k) & 1) == 0) {\n\t\t\t int c = i ^ (1 << j) ^ (1 << k);\n\n\t\t\t if (dp[i] + d[j][k] + d[j][n] + d[k][n] < dp[c]) {\n\t\t\t\t dp[c] = dp[i] + d[j][k] + d[j][n] + d[k][n];\n\n\t\t\t\t p[c][0] = j + 1;\n\t\t\t\t p[c][1] = k + 1;\n\t\t\t\t p[c][2] = i;\n\t\t\t }\n\t\t\t }\n\t\t }\n\n\t\t if (dp[i] + d[j][n] * 2 < dp[c]) {\n\t\t\t dp[c] = dp[i] + d[j][n] * 2;\n\n\t\t\t p[c][0] = j + 1;\n\t\t\t p[c][1] = -1;\n\t\t\t p[c][2] = i;\n\t\t }\n\n\t\t break;\n\t }\n\t }\n }\n\n printf(\"%d\\n\", dp[(1 << n) - 1]);\n\n i = (1 << n) - 1;\n\n while (i > 0) {\n\t if (p[i][1] == -1) {\n\t printf(\"0 %d \", p[i][0]);\n\t } else {\n\t printf(\"0 %d %d \", p[i][0], p[i][1]);\n\t }\n\n\t i = p[i][2];\n }\n puts(\"0\");\n\n return 0;\n}\n", "src_uid": "2ecbac20dc5f4060bc873553946281bc"} {"source_code": "#include \r\n#define mod 1000000007\r\nlong long pow(long long a, long long n)\r\n{\r\n long long result = 1;\r\n while(n != 0)\r\n {\r\n if(n & 1)\r\n {\r\n result *= a;\r\n result %= mod;\r\n }\r\n a *= a;\r\n a %= mod;\r\n n >>= 1;\r\n }\r\n return result;\r\n}\r\nint main()\r\n{\r\n int t;\r\n long long n, k;\r\n scanf(\"%d\", &t);\r\n while (t--)\r\n {\r\n scanf(\"%lld%lld\", &n, &k);\r\n\r\n if(n & 1)\r\n {\r\n printf(\"%lld\\n\", pow(1 + pow(2, n - 1), k));\r\n }\r\n else\r\n {\r\n long long tmp = pow(2, n - 1);\r\n printf(\"%lld\\n\", \r\n (pow(tmp - 1, k) * tmp % mod + \r\n pow(tmp << 1, k)) * (pow(tmp + 1, mod - 2)) \r\n % mod);\r\n }\r\n }\r\n}", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881"} {"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", "src_uid": "dbcb1077e7421554ba5d69b64d22c937"} {"source_code": "#include \n\nvoid output ( long long x , long long y );\nvoid solve ( long long x , long long y );\n\nint w , d;\nlong long n , p;\n\nint main()\n{\n scanf (\"%I64d %I64d %i %i\", &n , &p , &w , &d);\n if (w%d==0 && p%d!=0)\n {\n output ( -1 , -1 );\n }\n else\n {\n solve ( 0 , 0 );\n }\n}\n\nvoid solve ( long long x , long long y )\n{\n static long long point = 0 ;\n long long temp;\n if ( x + y > n || x<0 )\n {\n output ( -1 , -1 );\n }\n else\n {\n if ( point == p )\n {\n output( x , y );\n return;\n }\n if ( point + w <= p )\n {\n temp = ( p - point ) / w ;\n point += ( temp * w );\n solve ( x + temp , y );\n return ;\n }\n if ( point + d <= p )\n {\n temp = ( p - point ) / d ;\n point += ( temp * d );\n solve ( x , y + temp );\n return ;\n }\n point -= w;\n temp = ( p - point ) / d ;\n point += (temp * d );\n solve ( x-1 , y+temp );\n return ;\n }\n}\n\nvoid output ( long long x , long long y )\n{\n long long z;\n if ( x == -1 )\n {\n printf (\"%i\",-1);\n }\n else\n {\n z = n - x - y;\n printf (\"%I64d %I64d %I64d\", x , y , z);\n }\n}\n", "src_uid": "503116e144d19eb953954d99c5526a7d"} {"source_code": "#include \n\nint main(){\n int w, m, l = -1, x;\n char rez = 1;\n scanf(\"%d%d\", &w, &m);\n while(m > 0 && rez){\n x = m % w;\n if(l == 2){\n if(x != w - 1)\n x++;\n }\n if(x == w - 1)\n l = 2;\n else if(x != 0 && x != 1)\n rez = 0;\n else\n l = -1;\n m /= w;\n }\n if(rez)\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}\n", "src_uid": "a74adcf0314692f8ac95f54d165d9582"} {"source_code": "#include\n#include\nint main()\n{\n long k,a,b;\n scanf(\"%ld %ld %ld\",&k,&a,&b);\n long sum=0;\n if(a+b==0)\n {printf(\"-1\");\n return 0;}\n sum=a/k+b/k;\n if(a/k==0&&b/k!=0&&b%k!=0)\n {printf(\"-1\");\n return 0;}\n if(b/k==0&&a/k!=0&&a%k!=0)\n {printf(\"-1\");\n return 0;}\n if(sum>=1)\n printf(\"%ld\",sum);\n else\n printf(\"-1\");\n return 0;\n}\n", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2"} {"source_code": "#include\n#include\nint main()\n{\n\tint t;\n\tscanf(\"%d\",&t);\n\twhile(t--)\n\t{\n\t\tlong long int a,b;\n\t\tscanf(\"%lld%lld\",&a,&b);\n\t\tif(a-b!=1)\n\t\tprintf(\"NO\\n\");\n\t\telse\n\t\t{\n\t\t\tif((a+b)%2==0)\n\t\t\tprintf(\"NO\\n\");\n\t\t\telse\n\t\t\t{\n\t\t\t\tlong long int f=0,n=3,r;\n\t\t\t\tr=sqrt(a+b);\n\t\t\t\twhile(n<=r)\n\t\t\t\t{\n\t\t\t\t\tif((a+b)%n==0)\n\t\t\t\t\t{\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\tn+=2;\n\t\t\t\t}\n\t\t\t\tif(f==0)\n\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\telse\n\t\t\t\tprintf(\"NO\\n\");\n\t\t\t}\n\t\t}\n\t}\n}\n", "src_uid": "5a052e4e6c64333d94c83df890b1183c"} {"source_code": "#include \n\n#define MAXN 101\n\nmain() {\n int n, m;\n scanf(\"%d %d\\n\", &n, &m);\n int pts[MAXN];\n int ans[MAXN];\n int i, temp;\n for (i = 0; i < MAXN; i++) {\n pts[i] = 0;\n }\n for (i = 1; i <= n; i++) {\n scanf(\"%d\", &temp);\n pts[temp] = i;\n }\n int mod = 0;\n for (i = 0; i < MAXN; i++) {\n if(pts[i] != 0) {\n ans[pts[i]] = mod%2;\n mod++;\n }\n }\n for (i = 1; i < n; i++) {\n printf(\"%d \", ans[i]);\n }\n printf(\"%d \\n\", ans[n]);\n}", "src_uid": "692698d4b49ad446984f3a7a631f961d"} {"source_code": "#include \n\nint main(void)\n{\n\n int n,i=0;\n char s[101];\n scanf(\"%d %s\",&n,s);\n\n while(s[i]!='0'&&i\n#include \n\nint main()\n{\n int a,b,c,d,time,hour,mins,new_time;\n\n scanf(\"%d:%d\",&a,&b);\n scanf(\"%d:%d\",&c,&d);\n\n time=((c*60)+d)-((a*60)+b);\n\n time=time/2;\n new_time=(a*60)+b+time;\n\n hour=new_time/60;\n mins=new_time%60;\n\n if(hour<10 && mins<10)\n printf(\"0%d:0%d\\n\",hour,mins);\n else if(hour<10)\n printf(\"0%d:%d\\n\",hour,mins);\n else if(mins<10)\n printf(\"%d:0%d\\n\",hour,mins);\n else\n printf(\"%d:%d\\n\",hour,mins);\n\n return 0;\n}\n", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50"} {"source_code": "#include\nint fact(int n)\n{\n if(n==0||n==1)\n return 1;\n return n*fact(n-1);\n}\n\nint main()\n{\n long long int i,j,k,l;\n scanf(\"%lld%lld\",&i,&j);\n k=fact(i);\n l=fact(j);\n if(i>=j)\n printf(\"%lld\\n\",l);\n else\n printf(\"%lld\\n\",k);\n}", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6"} {"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", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5"} {"source_code": "#include\n#include\n#include\n\nlong long int x,y;\n\n//long long int dif[11];\n//long long int base[12];\n\n//int comparetor (const void * a, const void * b)\n\t//{\n\t//\treturn ( *(int*)a - *(int*)b );\n\t//\n\n\n\nint chke(long long int a)\n{\n//printf(\"%I64d\\n\",a);\n long long int i;\n for(i=2;i<=(int)(sqrt(a))+1;i++)\n {\n if(a%i==0 && i!=a)\n {//printf(\"%I64d\\n\",i);\n x=i;\n return 2;\n }\n }\n\n return 3;\n\n}\n\n\n\nint main()\n{\nlong long int n,sum,i,found;\n\n\n//long long int a[2];\nfound=0;\nsum=0;\nscanf(\"%I64d\",&n);\nif(n==1){\n\n printf(\"1\\n\");\n printf(\"0\");\n exit(0);\n\n\n\n\n}\n\nif(n==2){\n\n printf(\"1\\n\");\n printf(\"0\");\n exit(0);\n\n\n\n\n}\n\n\nfor(i=2;i<=(int)(sqrt(n))+1;i++){\n\n //printf(\"%I64d\\n\",i);\n if(n%i==0 && n!=i)\n {found=1;\n//printf(\"%I64d\\n\",i);\n if(chke(n/i)==2){\n\n printf(\"1\\n\");\n printf(\"%I64d\",i*x);\n exit(0);\n\n\n }\n\n else {\n printf(\"2\");\n exit(0);}\n\n\n\n}}\n\nprintf(\"1\\n\");\nprintf(\"0\");\n\n\n}\n", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43"} {"source_code": "//by ahmeterdem™\n#include \n#include \n#include \n#define min(a,b) (a=0;i--)\nlong long int n;\nint main() {\nscanf(\"%lld\",&n);\nprintf(\"%lld\",n*(n-1)*(n-2)*(n-3)*(n-4)/120*n*(n-1)*(n-2)*(n-3)*(n-4));\n\n\n\n\n\n\treturn 0 ;\n}\n", "src_uid": "92db14325cd8aee06b502c12d2e3dd81"} {"source_code": "#include \n\nint main()\n{\n double x,y,i,j,cont,a,b;\n scanf(\"%lf %lf\", &x, &y);\n cont = 0;\n if(x >1 && y >1)\n {\n for(j = 1 ; j < x ; j++ )\n {\n for(i = 1; i< y ; i++)\n {\n a = j;\n b = i;\n if(y - b < b)\n {\n b = y-b;\n }\n if(x-a < a)\n {\n a = x-a;\n }\n cont = cont + a*b;\n }\n }\n }\n printf(\"%.0lf\\n\", cont);\n return 0 ;\n}\n", "src_uid": "42454dcf7d073bf12030367eb094eb8c"} {"source_code": "#include\nint n,m,a[107],c[107];\nvoid cat(){\n\tint i,j;\n\tfor(i=0;i\nvoid mergesort(long int a[],long int i,long int j);\nvoid merge(long int a[],long int i1,long int j1,long int i2,long int j2);\nint main()\n{\nlong int n;\nscanf(\"%li\",&n);\nlong int a[n],i;\nfor(i=0;ia[i+2] && a[i+2]+a[i]>a[i+1])\nbreak;\nif(i>(n-3))\nprintf(\"NO\");\nelse\nprintf(\"YES\");\t\t\n}\t\nvoid mergesort(long int a[],long int i,long int j)\n{\n long int mid;\n if(i\n#include \n int main(){\n int len;\n char introd[101];\n scanf(\"%s\",introd);\n len= strlen(introd);\n if((len==3&&strcmp(introd,\"127\")<=0) || len<3)\n printf(\"byte\\n\");\n else if((len==5&&strcmp(introd,\"32767\")<=0) || len<5)\n printf(\"short\\n\");\n else if((len==10&&strcmp(introd,\"2147483647\")<=0) || len<10)\n printf(\"int\\n\");\n else if((len==19&&strcmp(introd,\"9223372036854775807\")<=0) || len<19)\n printf(\"long\\n\");\n else printf(\"BigInteger\\n\");\n return 0;\n }\n", "src_uid": "33041f1832fa7f641e37c4c638ab08a1"} {"source_code": "#include\n\nint main()\n{\n int k, i, j, l;\n int a[5];\n scanf(\" %d\", &k);\n for(i=1; i 0)\n {\n a[l] = temp % k;\n if((temp = temp/k) > 0)\n l++;\n }\n while( l >= 0 )\n {\n printf(\"%d\", a[l]);\n l--;\n }\n printf(\"\\t\");\n }\n printf(\"\\n\");\n }\n return 0;\n}", "src_uid": "a705144ace798d6b41068aa284d99050"} {"source_code": "#include\n#include\nint main(){\n int v1,v2,t,d,sum=0;\n scanf(\"%d%d%d%d\",&v1,&v2,&t,&d);\n while(t--){\n if(v1>v2){\n int temp=v1;\n v1=v2;\n v2=temp;\n }\n sum+=v1;\n v1+=d;\n }\n printf(\"%d\",sum);\n return 0;\n}\n", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf"} {"source_code": "//Bismillahir rahmanir rahim\n\n#include \n#define lim 62\n\nlong long ans=0,ncr[63][63],i,j;\n\nint main(void) {\n\t// your code goes here\n\tlong long n,m,t;\n\tscanf(\"%lld %lld %lld\",&n,&m,&t);\n\tncr[0][0]=1;\n\tfor(i=1;i<=lim;++i){\n\t for(j=0;j<=lim;++j){\n\t if(j>i) ncr[i][j]=0;\n\t else if(j==i || j==0) ncr[i][j]=1;\n\t else ncr[i][j] = ncr[i-1][j-1] + ncr[i-1][j];\n \t }\n\t}\n\tfor(i=4;t>i;++i){ \t//printf(\"%lld\\n\",ans);\n\t\t\tans+=ncr[n][i]*ncr[m][t-i];\n\t}\n\tprintf(\"%lld\",ans);\n\treturn 0;\n}\n", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8"} {"source_code": "#include \n\n#define MD\t1000000007\n#define L\t50\n#define K\t10000\n\nlong long dp[L + 1][L + 1];\n\nvoid init(int k) {\n\tstatic long long dq[L + 1][L + 1];\n\tstatic int inv[L + 2];\n\tint i1, i2, i, j;\n\n\tfor (i = 1; i <= L + 1; i++) {\n\t\tlong long x = 1;\n\n\t\twhile (x % i != 0)\n\t\t\tx += MD;\n\t\tinv[i] = x / i % MD;\n\t}\n\tfor (i = 0; i <= L; i++)\n\t\tdp[i][i] = dq[i][i] = 1;\n\tfor (i1 = 0; i1 <= L; i1++)\n\t\tfor (i2 = i1 + 1; i2 <= L; i2++)\n\t\t\tdq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;\n\tfor (j = 1; j <= k; j++)\n\t\tfor (i1 = 0; i1 <= L; i1++)\n\t\t\tfor (i2 = i1; i2 <= L; i2++) {\n\t\t\t\tdq[i1][i2] = dp[i1][i2] = dq[i1][i2] * inv[i2 + 1] % MD;\n\t\t\t\tif (i2 > i1)\n\t\t\t\t\tdq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;\n\t\t\t}\n}\n\nint solve(long long a, int cnt) {\n\tint i, sum;\n\tlong long p;\n\n\ta %= MD;\n\tp = 1;\n\tsum = 0;\n\tfor (i = 0; i <= cnt; i++) {\n\t\tsum = (sum + p * dp[i][cnt]) % MD;\n\t\tp = p * a % MD;\n\t}\n\treturn sum;\n}\n\nint main() {\n\tlong long n, ans;\n\tint k, a;\n\n\tscanf(\"%lld%d\", &n, &k);\n\tinit(k);\n\tans = 1;\n\tfor (a = 2; a <= n / a; a++)\n\t\tif (n % a == 0) {\n\t\t\tint cnt = 0;\n\n\t\t\twhile (n % a == 0) {\n\t\t\t\tn /= a;\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t\tans = ans * solve(a, cnt) % MD;\n\t\t}\n\tif (n > 1)\n\t\tans = ans * solve(n, 1) % MD;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2"} {"source_code": "#include\n#include\nint main(){\n\tint w1,h1,w2,h2;\n\tscanf(\"%d %d %d %d\",&w1,&h1,&w2,&h2);\n\tprintf(\"%d\",2*(w1+h1+h2+2));\n\treturn 0;\n}", "src_uid": "b5d44e0041053c996938aadd1b3865f6"} {"source_code": "#include \n#include \n\nint main()\n{\n int a1,a2, a3, a4, a5,n, i;\n scanf(\"%d %d %d %d %d\", &a1, &a2, &a3, &a4, &a5);\n int a= a1+ a2+ a3+ a4+ a5;\n if(((a%5)==0) && (a>0)) printf(\"%d\", (a/5));\n else if (a==0) printf(\"-1\");\n else printf(\"-1\");\n return 0;\n}\n", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20"} {"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}", "src_uid": "f4dbaa8deb2bd5c054fe34bb83bc6cd5"} {"source_code": "#include \n\nint main()\n{\n\tint cost[6][6] = {{3, 3, 4, 4, 3, 3}, {3, 3, 4, 4, 3, 3}, {2, 2, 3, 3, 2, 2}, {2, 2, 3, 3, 2, 2}, {1, 1, 2, 2, 1, 1}, {1, 1, 2, 2, 1, 1}};\n char now[6][6];\n for (int i = 0; i < 6; i++)\n {\n scanf(\"%c%c-%c%c-%c%c\\n\", &now[i][0], &now[i][1], &now[i][2], &now[i][3], &now[i][4], &now[i][5]);\n }\n int mx = -1, x = -1, y = -1;\n for (int i = 0; i < 6; i++)\n {\n for (int j = 0; j < 6; j++)\n {\n if (cost[i][j] > mx && now[i][j] == '.')\n {\n x = i;\n y = j;\n mx = cost[i][j];\n }\n }\n }\n now[x][y] = 'P';\n for (int i = 0; i < 6; i++)\n {\n printf(\"%c%c-%c%c-%c%c\\n\", now[i][0], now[i][1], now[i][2], now[i][3], now[i][4], now[i][5]);\n }\n\treturn 0;\n}\n", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e"} {"source_code": "#include\n#include\n#include\n#include\n\nint main()\n{\n char s[100];\n scanf(\"%s\",&s);\n int p=0;\n for(int i=0;s[i]!='\\0';i++)\n {\n if(s[i]>p)\n p=s[i];\n }\n for(int i=0;s[i]!='\\0';i++)\n {\n if(s[i]==p)\n printf(\"%c\",s[i]);\n }\n return 0;\n}", "src_uid": "9a40e9b122962a1f83b74ddee6246a40"} {"source_code": "#include \n#include \n\nint main()\n{\n int n,j=0,i,b,v=0;\n scanf(\"%d\",&n);\n scanf(\"%d\",&b);\n int A[n/2],B[n/2];\n for (i=0; i\n#include \n\nint main()\n{\n int m,a[101],i,j,t;\n scanf(\"%d\",&m);\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 j=0;\n for(i=0;i\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}", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0"} {"source_code": "#include\n\nint main()\n{\n\n int k1,k2,k3,k4,cout=0,sum=0,i;\n\n scanf(\"%d%d%d%d\",&k1,&k2,&k3,&k4);\n\n if(k10)\n {\n sum+=32;\n k1--;\n }\n }\n\n\n printf(\"%d\",sum);\n\n return 0;\n\n}\n", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e"} {"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", "src_uid": "656bf8df1e79499aa2ab2c28712851f0"} {"source_code": "#include \"stdio.h\"\n#include \"string.h\"\n\n\nint main(int argc, char* argv[])\n{\n char s[102];\n char s1[]=\"CODEFORCES\";\n scanf(\"%s\",s);\n int len=strlen(s);\n if(len<10)\n {\n printf(\"NO\\n\");\n return 0;\n }\n\n int i,j=0;\n for(i=0;i\n#include \n#include \n#include \n\n#define MAX_CHAR 1501\n\ntypedef struct node_struct\n{\n\tstruct node_struct* map[26];\n\tint cost;\t\n}node_t;\n\nnode_t* add(node_t* current, char c, int isGood, int* result, int k)\n{\n\n\tif(current->map[c - 'a'] == NULL)\n\t{\n\t\tcurrent->map[c - 'a'] = (node_t*)(malloc(sizeof(node_t)));\n\t\tfor(int i = 0; i < 26; i++)\n\t\t\tcurrent->map[c - 'a']->map[i] = NULL;\n\n\t\tif(!isGood)\n\t\t\tcurrent->map[c - 'a']->cost = current->cost + 1;\n\t\telse\n\t\t\tcurrent->map[c - 'a']->cost = current->cost;\n\n\t\tif(current->map[c - 'a']->cost <= k)\n\t\t\t*result = *result + 1;\n\n\t\treturn current->map[c - 'a'];\n\t}\n\telse\n\t{\n\t\treturn current->map[c - 'a'];\n\t}\n}\n\nint main()\n{\n\tlong long int n, a, b;\n\tscanf(\"%lld %lld %lld\", &n, &a, &b);\n\n\tn = n * 6;\n\tif(a * b >= n)\n\t{\n\t\tprintf(\"%lld\\n%lld %lld\\n\", (a*b), a, b);\n\t\treturn 0;\n\t}\n\n\tif(n%a == 0)\n\t{\n\t\tprintf(\"%lld\\n%lld %lld\\n\", n, a, (n/a));\n\t\treturn 0;\n\t}\n\n\tif(n%b == 0)\n\t{\n\t\tprintf(\"%lld\\n%lld %lld\\n\", n, (n/b), b);\n\t\treturn 0;\n\t}\n\n\tlong long int naive_guess, a_, b_;\n\tnaive_guess = a * ((n/a) + 1);\n\ta_ = a;\n\tb_ = (n/a) + 1;\n\tif(b * ((n/b) + 1) < naive_guess)\n\t{\n\t\tnaive_guess = b * ((n/b) + 1);\n\t\ta_ = (n/b) + 1;\n\t\tb_ = b;\n\t}\n\n\tint result = 0;\n\tlong long int ans = naive_guess;\n\n\tlong long int max_ab = a < b ? b : a;\n\tlong long int min_ab = a < b ? a : b;\n\tfor(long long int guess = n; guess < naive_guess; guess++)\n\t{\n\t\tif(result == 1)\n\t\t\tbreak;\n\n\t\tfor(long long int factor = min_ab; factor <= sqrt(guess) + 1; factor++)\n\t\t{\n\t\t\tif( guess % factor != 0)\n\t\t\t\tcontinue;\n\n\t\t\tlong long int other_factor = guess/factor;\n\t\t\tif(factor >= a && other_factor >= b)\n\t\t\t{\n\t\t\t\tans = guess;\n\t\t\t\ta_ = factor;\n\t\t\t\tb_ = other_factor;\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (factor >= b && other_factor >= a)\n\t\t\t{\n\t\t\t\tans = guess;\n\t\t\t\tb_ = factor;\n\t\t\t\ta_ = other_factor;\n\t\t\t\tresult = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%lld\\n%lld %lld\\n\", ans, a_, b_);\n}\n\n", "src_uid": "6a2a584d36008151d18e5080aea5029c"} {"source_code": "#include \n#include \n\nint main(void)\n{\n char str[15]={0}, rev[15]={0};\n int i=0, d=0,l=0;\n \n scanf(\"%s\",str);\n l=strlen(str);\n rev[l]='\\0';\n for(i=0;i\nint main()\n{\n int a[5],i,j,temp,sum=0,sum1=0,sum2=0;\n for(i=0;i<5;i++)\n scanf(\"%d\",&a[i]);\n printf(\"\\n\");\n for(i=0;i<5;i++)\n {for(j=0;j<4;j++)\n if(a[j]sum1)\n sum2=sum2-sum;\n else\n sum2=sum2-sum1;\n printf(\"%d\",sum2);\n\n}\n", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a"} {"source_code": "#include \n#include \n\nint main(){\nint n,v, i, price, cmp;\nscanf(\"%d %d\", &n,&v);\nprice =v; cmp=v+1; i=2;\nif(v>=n) price =n-1;\nwhile(cmp <= n){\n\tif(cmp==n) break;\n\tprice += i;\n\tcmp++;\n\ti++;\n\n}\nprintf(\"%d\", price);\n\nreturn 0;\n}", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7"} {"source_code": "#include \n#include \n#include \n\ntypedef long long ll;\n\ntypedef struct {\n ll a,b;\n int c;\n} t_t;\n\n/* n days, m subjects */\nint n,m,K;\nt_t emne[150];\n\n/* [i][j][k]: at beginning of day i (0-indexed), j is last course taken\n (1-indexed, 0=no course taken yet), k:last number of exercises=a_j+k */\nll dp[51][52][101]; /* max exercises so far */\nint dp1[51][52][101]; /* prev j */\nint dp2[51][52][101]; /* prev k */\n\nvoid solve() {\n int i,j,k,l,nextj,nextk;\n ll diff,nextd,cur,next;\n memset(dp,-1,sizeof(dp));\n memset(dp2,-1,sizeof(dp2));\n memset(dp2,-1,sizeof(dp2));\n dp[0][0][0]=0;\n dp1[0][0][0]=-1;\n dp2[0][0][0]=-1;\n for(i=0;i-1) {\n cur=dp[i][j][k];\n /* pick next exercise */\n/* if(!j) printf(\"at day %d, no last course\\n\",i);\n else printf(\"at day %d, last course %d, last ex %I64d\\n\",i,j-1,k+emne[j-1].a);*/\n if(i==0 && j==0) {\n /* first day, can pick everything */\n for(nextj=0;nextjemne[j-1].c) {\n /* difficulty: add k */\n diff=k+emne[j-1].a;\n nextd=diff+K;\n next=cur+nextd;\n if(nextd>=emne[l].a && nextd<=emne[l].b && next>dp[i+1][l+1][(int)(nextd-emne[l].a)]) {\n dp[i+1][l+1][(int)(nextd-emne[l].a)]=next;\n dp1[i+1][l+1][(int)(nextd-emne[l].a)]=k;\n dp2[i+1][l+1][(int)(nextd-emne[l].a)]=j;\n/* printf(\" (add) can pick => %d %d %I64d\\n\",i+1,l,nextd);*/\n }\n /* difficulty: mul k */\n nextd=diff*K;\n next=cur+nextd;\n if(nextd>=emne[l].a && nextd<=emne[l].b && next>dp[i+1][l+1][(int)(nextd-emne[l].a)]) {\n dp[i+1][l+1][(int)(nextd-emne[l].a)]=next;\n dp1[i+1][l+1][(int)(nextd-emne[l].a)]=k;\n dp2[i+1][l+1][(int)(nextd-emne[l].a)]=j;\n/* printf(\" (mul) can pick => %d %d %I64d\\n\",i+1,l,nextd);*/\n }\n }\n }\n }\n}\n\nint fag[100];\nll ex[100];\n\n/* x: last course (1-indexed), y:last k-value */\nvoid timeplan(int x,int y) {\n int dag=n;\n int i,j;\n while(dag) {\n fag[dag-1]=x;\n ex[dag-1]=y+emne[x-1].a;\n i=dp2[dag][x][y];\n j=dp1[dag][x][y];\n dag--;\n x=i;\n y=j;\n }\n for(i=0;imaks) {\n maks=dp[n][i][j];\n besti=i;\n bestj=j;\n }\n if(besti<0) puts(\"NO\");\n else {\n puts(\"YES\");\n timeplan(besti,bestj);\n return 0;\n }\n return 0;\n}\n", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9"} {"source_code": "#include\n#define maxn 5005\ntypedef long long ll;\nconst ll mod=998244353;\nint a,b,cc;\nll fac[maxn];\nll c[maxn][maxn];\nll solve(int x,int y)\n{\n\tll res=0;\n\tfor(int i=0;i<=x && i<=y;i++)\n\t\tres=(res+(((fac[i]*c[x][i])%mod)*c[y][i])%mod)%mod;\n\treturn res;\n}\nint main()\n{\n\tscanf(\"%d%d%d\",&a,&b,&cc);\n\tfac[0]=1;\n\tfor(int i=1;i<=5000;i++)\n\t{\n\t\tfac[i]=(fac[i-1]*i)%mod;\n\t\tc[i][0]=1;c[i][i]=1;\n\t\tfor(int j=1;j<=i-1;j++)\n\t\t\tc[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;\n\t}\n\tll ans=1;\n\tans=(ans*solve(a,b))%mod;\n\tans=(ans*solve(b,cc))%mod;\n\tans=(ans*solve(cc,a))%mod;\n\tprintf(\"%I64d\\n\",ans);\n}", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383"} {"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}", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3"} {"source_code": "#include \n#include \nlong long min(long long x , long long y)\n{ if(x>=y)\n return y;\n else\n return x ;\n}\nint main()\n{\n long long int d , k , a, b, t ;\n scanf(\"%lld %lld %lld %lld %lld\",&d, &k ,&a , &b, &t);\n long long int distance_covered;\n long long int walk ;\n long long int car_reach ;\n if(k>=d)\n {printf(\"%lld\\n\",d*a );}\n else if( k*a + t < k*b) \n {printf(\"%lld\\n\",(d/k)*a*k + (d/k-1)*t + min(d%k*a + t, d%k*b));}\n else \n {printf(\"%lld\\n\",a*k+(d-k)*b );}\nreturn 0;\n}", "src_uid": "359ddf1f1aed9b3256836e5856fe3466"} {"source_code": "#include\nint main()\n{\n\n int n,c=0,d=0,i,j;\n scanf(\"%d\",&n);\n int a[n],b[n];\n for(i=1;i<=n;i++){\n scanf(\"%d %d\",&a[i],&b[i]);\n\n }\n for(i=1;i<=n;i++){\n for(j=1;j<=n;j++){\n if(i!=j){\n if(a[i]==b[j]){\n c++;\n }\n }\n }\n }\n\n\n\n printf(\"%d\\n\",c);\n\n}\n", "src_uid": "745f81dcb4f23254bf6602f9f389771b"} {"source_code": "#include\n\nint main()\n{\n\tint a[60]={31,28,31,30,31,30,31,31,30,31,30,31,31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31,31,28,31,30,31,30,31,31,30,31,30,31,31,28,31,30,31,30,31,31,30,31,30,31};\n\tint n,i,j,b[25],k;\n\t scanf(\"%d\",&n);\n\tfor(i=0;i\n#include \n#include \n\n// we will consider numbers with <= 10^6 digits. Hence, maximal sum of digits is 9*10^6 < 10^7.\n// we can generate all possible sums for excellent numbers:\n// 2^n for n digits of a,b and then we need to sum for n = 1..7, meaning that 2^8 - 2 different possible sums:\n// 1+2+..+2^[n-1] = 2^n - 1, hence 2+..+2^[n-1] = 2^n - 2\n// now for every possible sum we need to solve:\n// ax + by = S\n// x + y = N\n// and this will add binomial(N,x) numbers\n// trivially, writing x = N - y, (b - a)y = S - aN\n\n// to calculate binomial coefficients: it is easy to see that we need not that many of them so it will be easier to calculate them independently\n\nstatic inline int min(int a, int b) { return a < b ? a : b; }\n\nstatic int _sd[254] = {};\nstatic void generate_sd(int a, int b) {\n int sd_count = 0;\n for(int i = 1 ; i <= 7 ; ++i) { // fix number of digits\n for(int j = 0, jn = 1<>= 1)\n n += p10 * (m & 0x1 ? b : a);\n assert(sd_count < 254); _sd[sd_count++] = n;\n }\n }\n}\n\n#define MOD 1000000007LL\n\nstatic inline int64_t factorial_mod(int n) {\n int64_t ret = 1;\n for(int i = 1 ; i <= n ; ++i) ret = (ret*i) % MOD;\n return ret;\n}\n\ntypedef struct ExtGCD { int64_t a_mul, b_mul, gcd; } ExtGCD;\nstatic inline ExtGCD extended_gcd(uint64_t a, uint64_t b) {\n int64_t u[] = {1,0,a}, v[] = {0,1,b};\n while(v[2] > 0) {\n const int64_t q = u[2]/v[2], t[] = { u[0] - v[0]*q, u[1] - v[1]*q, u[2] - v[2]*q };\n u[0] = v[0], v[0] = t[0], u[1] = v[1], v[1] = t[1], u[2] = v[2], v[2] = t[2];\n }\n return (ExtGCD) {.a_mul = u[0], .b_mul = u[1], .gcd = u[2]};\n}\nstatic int64_t inverse_mod(uint64_t n, uint64_t mod) {\n ExtGCD gcd = extended_gcd(n, mod); assert(gcd.gcd == 1);\n return gcd.a_mul < 0 ? gcd.a_mul + mod : gcd.a_mul;\n}\n\nstatic int64_t _NF = 0;\nstatic inline int64_t binomial_mod(int k, int nk) {\n const int64_t kf = factorial_mod(k), nkf = factorial_mod(nk), denom = (kf*nkf) % MOD;\n return (_NF * inverse_mod(denom, MOD)) % MOD;\n}\n\nint main() {\n int A,B,N; scanf(\"%d %d %d\\n\", &A,&B,&N);\n generate_sd(A,B); _NF = factorial_mod(N);\n\n int64_t count = 0;\n for(int si = 0 ; si < 254 ; ++si) {\n const int ss = _sd[si] - A*N;\n if(ss % (B-A) == 0) {\n const int y = ss / (B-A), x = N - y;\n if(x >= 0 && y >= 0) {\n count = (count + binomial_mod(y,x)) % MOD;\n }\n }\n }\n printf(\"%d\\n\", (int)count);\n}\n", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81"} {"source_code": "#include\n#include\nint cmpfunc (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nint main()\n{\n int n,p=0,m=0,i;\n scanf(\"%d\", &n);\n getchar();\n char a[n];\n for(i=0;i='A'&&a[i]<='Z')\n {\n p++;\n }\n if(a[i]==' '||i==n-1)\n {\n if(p>m)m=p;\n p=0;\n }\n }printf(\"%d\", m);\n}\n", "src_uid": "d3929a9acf1633475ab16f5dfbead13c"} {"source_code": "#include \n\nint main(){\n int n,m;\n scanf(\"%d %d\",&n,&m);\n int i,j,v[50];\n for(i = 0;i < m;i++){\n scanf(\"%d\",v+i);\n }\n\n int swap;\n\n for(i = 0;i < m;i++){\n for(j = i;j < m;j++){\n if (v[i] > v[j]) {\n swap = v[j];\n v[j] = v[i];\n v[i] = swap;\n }\n }\n }\n\n int min = 1000,t;\n int start = 0,end = n-1;\n for(i = n; i <= m; i++) {\n t = v[end] - v[start];\n if (min > t) {\n min = t;\n }\n end++;\n start++;\n }\n printf(\"%d\",min);\n return 0;\n}\n\n", "src_uid": "7830aabb0663e645d54004063746e47f"} {"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}", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b"} {"source_code": "#include \n#include \n\nint main()\n{\n int x[9]={0}, i, j;\n char a[82], b[11];\n scanf(\"%s\", a);\n for(i=0; i<10; i++)\n {\n scanf(\"%s\", b);\n for(j=0; j<8; j++)if(x[j]==0 && strncmp(b, &a[j*10], 10)==0)x[j]=i;\n }\n for(i=0; i<8; i++)printf(\"%d\", x[i]);\n}", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9"} {"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}", "src_uid": "14f50a111db268182e5927839a993118"} {"source_code": "#include\n#include\n#include\nlong long arr[2000001],brr[2000001],mod=1000000000+7;\nchar str[2000001],s1[2000001];\nint func(const void *a, const void *b)\n{\n\treturn (*(int*)a-*(int*)b);\n}\nlong long max(long long a, long long b)\n{\n\treturn (a>b)?a:b;\n}\nlong long min(long long a, long long b)\n{\n\treturn (a>b)?b:a;\n}\nlong long power(long long x, long long int y, long long p)\n{\n\tlong long int res = 1;\n\tx = x % p; \n\twhile (y > 0)\n\t{\n\t\tif (y & 1)\n\t\t\tres = (res*x) % p;\n\t\ty = y>>1; // y = y/2\n\t\tx = (x*x) % p; \n\t}\n\treturn res;\n}\nint main()\n{\n\tlong long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;\n\tscanf(\"%lld\", &n);\n\tprintf(\"%lld 2\\n\",2*n-1);\n\tprintf(\"1 2\\n\");\n\n\n\treturn 0;\n}\n", "src_uid": "5c000b4c82a8ecef764f53fda8cee541"} {"source_code": "#include \n#include \n\nint main()\n\n{\n char col ; long long int row , ans = 0, final= 0, segment = 0;\n scanf(\"%I64d%ch\",&row,&col);\n if( col == 'f')\n final = 1;\n else if(col == 'e')\n final = 2;\n else if(col == 'd')\n final = 3;\n else if(col == 'a')\n final = 4;\n else if(col == 'b')\n final = 5;\n else if(col == 'c')\n final = 6;\n segment = row / 4 ;\n if( row == 4 || ( (segment * 4) == row ) )\n segment --;\n\n if(row % 2 == 0 && row % 4 != 0 )\n {\n ans = (segment)*12 + final + (row - 1)*1 + 6;\n }\n else if(row %2 == 0 && (row % 4 == 0 ) )\n {\n ans = (segment)*12 + final + (row - 3)*1 + 6;\n }\n else if(row %2 != 0 && (row + 1) % 4 != 0)\n {\n ans = segment * 12 + final + (row - 1)*1;\n }\n else\n ans = segment * 12 + final + (row - 3)*1;\n printf(\"%I64d\",ans);\n\n\n}\n\n\n", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45"} {"source_code": "#include\nint main()\n{\n long int a,b,ta,tb,js1,js2,t;\n while(scanf(\"%ld %ld\",&a,&b)!=EOF)\n {\n ta=a;\n tb=b;\n js1=0;\n js2=0;\n while(tb!=0)\n {\n t=ta%tb;\n ta=tb;\n tb=t;\n }\n a/=ta;\n b/=ta;\n js1=b-1;\n js2=a-1;\n if(a>b)js1++;\n else js2++;\n if(js1>js2)printf(\"Dasha\\n\");\n else if(js1\n#include\nint main()\n{\n char q[10],e[10],w[10];\n int a=0,b=1,c,l;\n scanf(\"%s%s%s\",q,e,w);\n l=strlen(q);\n while (l--)\n a+=(q[l]-48)*b,b*=10;\n l=strlen(w);\n if (l==5)\n {\n if (a==31) c=7;\n else if (a==30) c=11;\n else c=12;\n }\n else\n {\n if (a==5||a==6) c=53;\n else c=52;\n }\n printf(\"%d\\n\",c);\n return 0;\n}/*2016-02-28 19:27:00.735*/", "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b"} {"source_code": "#include\nint main () {\n\tint k,p,a,a1,a2,b,b1,b2,t;\n\tscanf(\"%d%d%d\\n%d%d%d\",&a,&a1,&a2,&b,&b1,&b2);\n\tscanf(\"%d\",&t);\n\tk=a+a1+a2;\n\tp=b+b1+b2;\n\tprintf((t>=((k)/5+((k)%5!=0))+((p)/10+((p)%10!=0)))?\"YES\":\"NO\");\n}\n\n\n", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e"} {"source_code": "#include \nint main()\n{\n int n;\n scanf(\"%d\", &n);\n int sum = 0, tmp;\n for(int i = 0; i < n; i++)\n {\n scanf(\"%d\", &tmp);\n sum += tmp;\n }\n for(int i = 0; i < n; i++)\n {\n scanf(\"%d\", &tmp);\n sum -= tmp;\n }\n if(sum >= 0)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n return 0;\n}", "src_uid": "e0ddac5c6d3671070860dda10d50c28a"} {"source_code": "#include\n#include\n#include\nint main(){\n int num,i,k,j,temp,f=0;\n scanf(\"%d \",&num);\n temp=num;\n char a[num+1][8];\n for(i=0;i<=num;i++){\n gets(a[i]);\n }\n char b[3],c[3];\nstrcpy(b,a[0]);\n\n\nc[0]=a[temp][5];\nc[1]=a[temp][6];\nc[2]=a[temp][7];\n\n\nif(temp%2==0)\n{\n printf(\"home\");\n}\n\nelse printf(\"contest\");\n}\n", "src_uid": "51d1c79a52d3d4f80c98052b6ec77222"} {"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", "src_uid": "7017f2c81d5aed716b90e46480f96582"} {"source_code": "#include \n#include \n\nint compare_function(const void *a,const void *b) {\n int *x = (int *) a;\n int *y = (int *) b;\n return *x - *y;\n}\n\nvoid print_array(int a[], int size) {\n printf(\"[\");\n for (int i = 0; (i < size); i++) {\n printf(\"%d \", a[i]);\n }\n printf(\"]\\n\");\n}\n\n\nint main(void) {\n int len;\n int input;\n int number_paints = 0;\n int in = 0;\n\n scanf(\"%d\", &len);\n int colors[len];\n int check[len];\n \n\n for(int i = 0; i < len; i++) {\n scanf(\"%d\", &input);\n colors[i] = input;\n //printf(\"EEEE: %d\", colors[i]);\n } \n\n //print_array(colors, len);\n\n qsort(colors, sizeof(colors)/sizeof(colors[0]), sizeof(colors[0]), compare_function);\n\n //print_array(colors, len);\n\n check[0] = colors[0];\n number_paints += 1;\n\n\n for (int color_iter = 0; color_iter < len; color_iter++) {\n for (int check_iter = 0; check_iter < number_paints; check_iter++) {\n if (colors[color_iter] % check[check_iter] == 0) {\n in = 1;\n break;\n }\n\n else {\n in = 0;\n }\n\n }\n if (!in) {\n //printf(\"THIS RUNS\\n\");\n check[number_paints] = colors[color_iter]; \n number_paints += 1;\n in = 1;\n\n }\n //print_array(check, number_paints);\n }\n\n printf(\"%d\" , number_paints);\n\n return 0;\n\n}", "src_uid": "63d9b7416aa96129c57d20ec6145e0cd"} {"source_code": "//Lagrange kth power sum\n//Educational CF R7-F\n//https://codeforces.com/contest/622/problem/F\n//https://ja.wikipedia.org/wiki/%E3%83%A9%E3%82%B0%E3%83%A9%E3%83%B3%E3%82%B8%E3%83%A5%E8%A3%9C%E9%96%93\n\n#include\n#define mod 1000000007\n#define maxdeg 1048576\n\nlong long power(long long a,long long b){\n long long x=1,y=a;\n while(b>0){\n if(b&1ll){\n x=(x*y)%mod;\n }\n y=(y*y)%mod;\n b>>=1;\n }\n return x%mod;\n}\n\nlong long modular_inverse(long long n){\n return power(n,mod-2);\n}\n\nlong long factorial[maxdeg];\nlong long invfact[maxdeg];\n\nvoid cfact(){\n long long i;\n factorial[0]=1;\n factorial[1]=1;\n for(i=2;i=0;i--){\n invfact[i]=invfact[i+1]*(i+1);\n invfact[i]%=mod;\n }\n}\n\n// k...polynominal degree (there must be k+1 data)\n// f(i) = a[i] (0 <= i <= k)\n// a[i] must be 0 <= a[i] < mod\n// return : f(x)\n// complexity = O(k log mod)\nlong long lagrange_liner(long long x,long long k,long long a[]){\n if(x<=k){return a[x];}\n long long i,bsnmr=1,nmr,dmn,res=0,rev=modular_inverse(mod-1),lv;\n for(i=0;i<=k;i++){bsnmr*=(mod+x-i);bsnmr%=mod;}\n for(i=0;i<=k;i++){\n nmr=(bsnmr*modular_inverse((mod+x-i)%mod))%mod;\n dmn=invfact[i]*invfact[k-i];dmn%=mod;\n if((k-i)&1ll){dmn*=rev;dmn%=mod;}\n lv=(nmr*dmn)%mod;\n res+=lv*a[i];\n res%=mod;\n }\n return res;\n}\n\n//0^k + 1^k + 2^k + ... + n^k\nlong long kth_power_sum(long long n,long long k){\n long long i,deg=k+1,a[maxdeg];\n a[0]=0;\n for(i=1;i<=deg;i++){a[i]=a[i-1]+power(i,k);a[i]%=mod;}\n return lagrange_liner(n,deg,a);\n}\n\nint main(){\n cfact();\n long long n,k;\n scanf(\"%lld%lld\",&n,&k);\n printf(\"%lld\\n\",kth_power_sum(n,k));\n return 0;\n}\n", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c"} {"source_code": "#include\nint judge(int n)\n{\n\tfor(;;)\n\t{\n\t\tif(n%2!=0)\n\t\t\tbreak;\n\t\tn/=2;\n\t}\n\tif(n==1)\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\tif(judge(n))\n\t\t\tprintf(\"YES\\n\");\n\t\telse\n\t\t\tprintf(\"NO\\n\");\n\t}\n\treturn 0;\n}", "src_uid": "4bd174a997707ed3a368bd0f2424590f"} {"source_code": "#include\nmain()\n{\n\n\nlong long int p,q,x,y,movep,movev;\n\nscanf(\"%I64d%I64d%I64d%I64d\",&p,&q,&x,&y);\nmovep=p+q;\nmovev=x>=y?x:y;\nif(p>=x && q>=y)\n printf(\"Vasiliy\");\n\nelse if(x>=p && y>=q)\n printf(\"Polycarp\");\n\n\nelse if(movev>=movep)\n\n printf(\"Polycarp\");\n\n\n\n\nelse if(movev\n#include\n#include\n\nint main()\n{\n char s1[1000],s2[1000];\n fgets(s1,1000,stdin);\n fgets(s2,1000,stdin);\n int i,j,l;\n l=strlen(s1)-1;\n char s3[l],c;c='0';\n for(i=l;i>=0;i--)\n {\n if(s1[i]=='0'&&s2[i]=='0')\n {\n s3[i]='0';\n }\n else if(s1[i]=='0'&&s2[i]=='1')\n {\n s3[i]='1';\n }\n else if(s1[i]=='1'&&s2[i]=='0')\n {\n s3[i]='1';\n }\n else if(s1[i]=='1'&&s2[i]=='1')\n {\n s3[i]='0';\n }\n }\n s3[l]='\\0';\n printf(\"%s\",s3);\n return 0;\n}", "src_uid": "3714b7596a6b48ca5b7a346f60d90549"} {"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\nint main()\n{int i,j,k[100005]={0},m,a,b,r;\nscanf(\"%d %d %d %d\",&a,&b,&m,&r);\nk[r]=1;j=0;\nfor(i=2;i<=(m+1);i++)\n{r=(a*r+b)%m;\nif(k[r]>0)\n{\n printf(\"%d\",i-k[r]);\n break;\n}\nelse\n{\n k[r]=i;\n}\n\n}\nreturn 0;\n}\n", "src_uid": "9137197ee1b781cd5cc77c46f50b9012"} {"source_code": "/* practice with Dukkha */\n#include \n\n#define K\t2000000\n#define MD\t1000000007\n\nlong long power(int a, int k) {\n\tlong long p;\n\n\tif (k == 0)\n\t\treturn 1;\n\tp = power(a, k >> 1);\n\tp = p * p % MD;\n\tif (k & 1)\n\t\tp = p * a % MD;\n\treturn p;\n}\n\nint main() {\n\tstatic int cc[K + 1], pp[K + 1], dd[K + 1];\n\tint n, k, a, a2, b, i, ans;\n\t\n\tscanf(\"%d%d\", &n, &k);\n\tfor (a = 2; a <= k; a++) {\n\t\tif (cc[a])\n\t\t\tcontinue;\n\t\tfor (b = a; b <= k; b += a)\n\t\t\tcc[b]++;\n\t}\n\tfor (a = 2; (a2 = a * a) <= k; a++)\n\t\tfor (b = a2; b <= k; b += a2)\n\t\t\tcc[b] = 0;\n\tfor (i = 1; i <= k; i++)\n\t\tpp[i] = power(i, n);\n\tfor (a = 2; a <= k; a++) {\n\t\tif (cc[a] == 0)\n\t\t\tcontinue;\n\t\tfor (i = 1; i * a <= k; i++) {\n\t\t\tint l = i * a, r = (i + 1) * a;\n\t\t\tint p = cc[a] % 2 == 0 ? pp[i] : -pp[i];\n\n\t\t\tdd[l] = (dd[l] + p) % MD;\n\t\t\tif (r <= k)\n\t\t\t\tdd[r] = (dd[r] - p) % MD;\n\t\t}\n\t}\n\tans = 0;\n\tfor (i = 1; i <= k; i++) {\n\t\tint x;\n\n\t\tdd[i] = (dd[i] + dd[i - 1]) % MD;\n\t\tx = (pp[i] + dd[i]) % MD;\n\t\tif (x < 0)\n\t\t\tx += MD;\n\t\tans = (ans + (x ^ i)) % MD;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa"} {"source_code": "#include\n#define m 10*hundreds+tens\n\nint main()\n{\n int hundreds, tens, i, x, y;\n scanf(\"%d %d\", &hundreds, &tens);\n for(i=1; (tens>=22) || (hundreds>0 && tens>=12) || (hundreds>=2 && tens>=2); i++)\n {\n if(i%2)\n {\n if(hundreds>=2)\n {\n hundreds-=2;\n tens-=2;\n }\n else if(hundreds>=1)\n {\n hundreds-=1;\n tens-=12;\n }\n else\n {\n tens-=22;\n }\n }\n else\n {\n if(tens>=22)\n {\n tens-=22;\n }\n else if(tens>=12)\n {\n tens-=12;\n hundreds-=1;\n }\n else\n {\n tens-=2;\n hundreds-=2;\n }\n }\n }\n if(i%2) printf(\"Hanako\");\n else printf(\"Ciel\");\n return 0;\n}\n", "src_uid": "8ffee18bbc4bb281027f91193002b7f5"} {"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", "src_uid": "8787c5d46d7247d93d806264a8957639"} {"source_code": "#include \n#include \n\n#define LMT 105\n\nchar work[LMT];\nint len, n, dp[2][LMT << 1][LMT][52];\n\nint\nmax (int x, int y)\n{\n return x > y ? x : y;\n}\n\nint\ndfs (int dre, int pos, int i, int cn)\n{\n if (cn < 0)\n return 0;\n\n if (!work[i])\n return cn > 0 ? 0 : abs (pos);\n\n if (dp[dre][pos + 100][i][cn] != -1)\n return dp[dre][pos + 100][i][cn];\n\n int mv = dre ? 1 : -1;\n int x = dfs (dre, pos + mv, i + 1, cn - (work[i] != 'F'));\n int y = dfs (!dre, pos, i + 1, cn - (work[i] != 'T'));\n dp[dre][pos + 100][i][cn] = max (x, y);\n return dp[dre][pos + 100][i][cn];\n}\n\nint\nmain ()\n{\n int ans = 0;\n scanf (\"%s%d\", work, &n);\n memset (dp, -1, sizeof (dp));\n for (; n >= 0; n -= 2)\n ans = max (ans, dfs (1, 0, 0, n));\n printf (\"%d\\n\", ans);\n return 0;\n}\n", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d"} {"source_code": "#include\n\nint main(){\n\tint n,k,I,aux=0,J;\n\tscanf(\"%d%d\",&n,&k);\n\tint a[n];\n\tfor(I=0;I=k){\n\t\tprintf(\"YES\\n\");\n\t\tfor(I=0;I\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", "src_uid": "9d1dd9d722e5fe46823224334b3b208a"} {"source_code": "#include\n\nint determine(int set1, int set2, int set4,int n)\n{\n\tint temp = set2 - 2 * n;\n\tint x;\n\tif (temp > set1)\n\t\tx = set4 + set1 + (temp - set1 + 1) * 2 / 3;\n\telse\n\t\tx = set4 + temp + (set1 - temp + 1) / 2;\n\tif (x <= n)\n\t\treturn 1;\n\telse\n\t\treturn 0;\n}\n\nint main()\n{\n\tint n, k, i, set1, set2, set4, temp;\n\tscanf(\"%d %d\", &n, &k);\n\tset1 = 0;\n\tset2 = 0;\n\tset4 = 0;\n\tfor (i = 0; i < k; i++) {\n\t\tscanf(\"%d\", &temp);\n\t\tset4 += temp / 4;\n\t\ttemp %= 4;\n\t\tset2 += temp / 2;\n\t\ttemp %= 2;\n\t\tset1 += temp;\n\t}\n\tif (set1 * 2 + set2 * 2 + set4 * 4 <= n * 8 && determine(set1, set2, set4, n))\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n}", "src_uid": "d1f88a97714d6c13309c88fcf7d86821"} {"source_code": "#include \n#include \n#include \n\n#define NUMSIZE 15 \n\nint cmp (const void *a, const void *b)\n{\n\treturn *(char *)b - *(char *)a;\n}\n\nint main()\n{\n\t/* 4 -- ����� ����� ������� ������ ������ (��� 8 � 9) */\n\tchar a[NUMSIZE + 1], x[4 * NUMSIZE + 1] = \"\", strchg[][8] = {\"\", \"\", \"2\", \"3\", \"322\", \"5\", \"53\", \"7\", \"7222\", \"7332\"};\n\tint i;\n\n\tscanf (\"%*d\\n\");\n\tgets (a);\n\n\tfor (i = 0; a[i]; i++)\n\t\tstrcat (x, strchg[a[i] - '0']); \n\n\tqsort (x, strlen(x), 1, cmp);\n\n\tputs (x);\n\n\treturn 0;\n}\n", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398"} {"source_code": "#include \n\nenum {\n M = 4,\n D = 13,\n MAX = M * D + 2\n};\n\ntypedef struct Card {\n int d, m;\n} Card;\n\nCard a[MAX][MAX];\nchar n2m[M] = {'C', 'D', 'H', 'S'};\nchar n2d[D] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};\n\nint\nm2n(char m)\n{\n switch (m) {\n case 'C':\n return 0;\n case 'D':\n return 1;\n case 'H':\n return 2;\n case 'S':\n return 3;\n default:\n return -1;\n }\n}\n\nint\nd2n(char d)\n{\n switch (d) {\n case 'T':\n return 8;\n case 'J':\n return 9;\n case 'Q':\n return 10;\n case 'K':\n return 11;\n case 'A':\n return 12;\n default:\n return d - '2';\n }\n}\n\nint\ngood(int r, int c)\n{\n int m = a[r][c].m;\n int goodm = 1;\n int ud[D] = {};\n int goodd = 1;\n int i, j;\n for (i = r; i < r + 3; ++i) {\n for (j = c; j < c + 3; ++j) {\n goodm &= (a[i][j].m == m);\n goodd &= (ud[a[i][j].d] == 0);\n ud[a[i][j].d] = 1;\n }\n }\n return goodm || goodd;\n}\n\nint\nmain(void)\n{\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n\n int n, m, i, j;\n char s[MAX];\n int j1r, j1c, j2r, j2c;\n j1r = j1c = j2r = j2c = -1;\n int used[M][D] = {};\n scanf(\"%d %d\", &n, &m);\n for (i = 0; i < n; ++i) {\n for (j = 0; j < m; ++j) {\n scanf(\"%s\", s);\n a[i][j].d = d2n(s[0]);\n a[i][j].m = m2n(s[1]);\n if (s[1] == '1') {\n j1r = i;\n j1c = j;\n } else if (s[1] == '2') {\n j2r = i;\n j2c = j;\n } else {\n used[a[i][j].m][a[i][j].d] = 1;\n }\n }\n }\n\n int m1, d1, m2, d2, r1, c1, r2, c2;\n for (m1 = 0; m1 < M; ++m1) {\n for (d1 = 0; d1 < D; ++d1) {\n if (used[m1][d1]) continue;\n used[m1][d1] = 1;\n if (j1r > -1) {\n a[j1r][j1c].d = d1;\n a[j1r][j1c].m = m1;\n }\n for (m2 = 0; m2 < M; ++m2) {\n for (d2 = 0; d2 < D; ++d2) {\n if (used[m2][d2]) continue;\n used[m2][d2] = 1;\n if (j2r > -1) {\n a[j2r][j2c].d = d2;\n a[j2r][j2c].m = m2;\n }\n\n for (r1 = 0; r1 < n - 2; ++r1) {\n for (c1 = 0; c1 < m - 2; ++c1) {\n for (r2 = r1; r2 < n - 2; ++r2) {\n for (c2 = 0; c2 < m - 2; ++c2) {\n if ((r2 < r1 + 3) && ((c2 >= c1 && c2 < c1 + 3) || (c2 + 2 >= c1 && c2 + 2 < c1 + 3))) continue;\n if (good(r1, c1) && good(r2, c2)) {\n printf(\"Solution exists.\\n\");\n if (j1r == -1 && j2r == -1) {\n printf(\"There are no jokers.\\n\");\n } else if (j1r == -1) {\n printf(\"Replace J2 with %c%c.\\n\", n2d[d2], n2m[m2]);\n } else if (j2r == -1) {\n printf(\"Replace J1 with %c%c.\\n\", n2d[d1], n2m[m1]);\n } else {\n printf(\"Replace J1 with %c%C and J2 with %c%c.\\n\", n2d[d1], n2m[m1], n2d[d2], n2m[m2]);\n }\n printf(\"Put the first square to (%d, %d).\\n\", r1 + 1, c1 + 1);\n printf(\"Put the second square to (%d, %d).\\n\", r2 + 1, c2 + 1);\n return 0;\n }\n }\n }\n }\n }\n used[m2][d2] = 0;\n }\n }\n used[m1][d1] = 0;\n }\n }\n printf(\"No solution.\\n\");\n\n return 0;\n}\n", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f"} {"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\nint main(void) {\n // your code goes here\n //printf(\"%d\",'A'-10);\n char s[10],t[10];\n int sh , sm , th, tm , hh, mm ,flag = 0, fh[2],fm[2] ;\n scanf(\"%s%s\",s,t);\n \n sm = s[3]*10 + s[4] ;\n sh = s[0]*10 + s[1] ;\n tm = t[3]*10 + t[4] ;\n th = t[0]*10 + t[1] ;\n \n if(sm\n\nint main(){\n int n;\n scanf(\"%d\", &n);\n int log2Value = 0;\n while(n >0){\n log2Value++;\n\tn >>= 1;\n\t// printf(\"n: %d\\n\", n);\n }\n printf(\"%d\\n\", log2Value);\n return 0;\n}\n", "src_uid": "95cb79597443461085e62d974d67a9a0"} {"source_code": "#include \nconst int N=1000000007;\nlong long int x, i, n, a = 1;\nlong long int k (long long int x, long long int p)\n{\n\tlong long int s = 1;\n\twhile (p)\n\t{\n\t\tif (p % 2)\n\t\t\ts = s * x % N;\n\t\tp /= 2;\n\t\tx = x * x % N;\n\t}\n return s;\n}\nlong long int d (long long int p)\n{\n\tlong long int m = n, sum = 0;\n\twhile (m)\n\t\tsum += m /= p;\n\treturn k(p, sum);\n}\nint main()\n{\n\tscanf(\"%lld%lld\", &x, &n);\n\tfor (i = 2; i * i <= x; i++)\n\t\tif (x % i == 0)\n\t\t{\n\t\t\ta = a * d(i) % N;\n\t\t\twhile (x % i == 0)\n\t\t\t\tx /= i;\n\t\t}\n\tif (x != 1)\n\t\ta = a * d(x) % N;\n\tprintf(\"%lld\", a);\n}", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c"} {"source_code": "#include \n#include \n\nint n,m,k;\n\nint modpow(int x,int y){\n int ret,MOD=1e9+7;\n long long temp=1;\n while(y--){\n temp*=x;\n temp%=MOD;\n }\n return (int)temp;\n}\n\nvoid print(int x){printf(\"%d\\n\",x);exit(0);}\n\nmain(){\n scanf(\"%d%d%d\",&n,&m,&k);\n if(n\n\n\nint main()\n{\n\n int n,m,m1,arr[1000]= {},inc[1000];\n scanf(\"%d%d\",&n,&m);\n if(m==0){\n if(n>1)\n {\n printf(\"-1 -1\\n\");\n return 0;\n }\n else{\n printf(\"0 0\\n\");\n return 0;\n }\n }\n if(n==1 && m<=9){\n arr[0]=m;\n }\n else if(n==1 && m>9)\n {\n printf(\"-1 -1\\n\");\n return 0;\n }\n else\n {\n m1=m-1;\n for(int i=n-1; i>=0; i--)\n {\n if(m1>=9)\n {\n arr[i]=9;\n m1-=9;\n }\n\n else if(m1==8)\n {\n arr[i]=8;\n m1-=8;\n }\n\n else if(m1==7)\n {\n arr[i]=7;\n m1-=7;\n }\n\n else if(m1==6)\n {\n arr[i]=6;\n m1-=6;\n }\n\n else if(m1==5)\n {\n arr[i]=5;\n m1-=5;\n }\n\n else if(m1==4)\n {\n arr[i]=4;\n m1-=4;\n }\n\n else if(m1==3)\n {\n arr[i]=3;\n m1-=3;\n }\n\n else if(m1==2)\n {\n arr[i]=2;\n m1-=2;\n }\n\n else if(m1==1)\n {\n arr[i]=1;\n m1-=1;\n }\n\n else\n {\n arr[i]=0;\n }\n }\n\n if(arr[0]==9)\n {\n printf(\"-1 -1\\n\");\n return 0;\n }\n else\n arr[0]++;\n }\n for(int i=0; i=9)\n {\n inc[i]=9;\n m-=9;\n }\n\n else if(m==8)\n {\n inc[i]=8;\n m-=8;\n }\n\n else if(m==7)\n {\n inc[i]=7;\n m-=7;\n }\n\n else if(m==6)\n {\n inc[i]=6;\n m-=6;\n }\n\n else if(m==5)\n {\n inc[i]=5;\n m-=5;\n }\n\n else if(m==4)\n {\n inc[i]=4;\n m-=4;\n }\n\n else if(m==3)\n {\n inc[i]=3;\n m-=3;\n }\n\n else if(m==2)\n {\n inc[i]=2;\n m-=2;\n }\n\n else if(m==1)\n {\n inc[i]=1;\n m-=1;\n }\n\n else\n {\n inc[i]=0;\n }\n }\n\n\n\n\n for(int i=0; i\n#include\nchar a[22],b[22];\nvoid f1(char a[22])\n{\n\tint i,j;char m;\n\tfor(i=0;a[i];i++)\n\t{\tfor(j=i+1;a[j];j++)\n\t\t\tif(a[i]0&&strcmp(c,b)<=0)\n\t\t\t{k=a[i];a[i]=a[j];a[j]=k;}\n\t\t}\n\t}\n\tputs(a);\n}\nvoid f3(char a[22])\n{\n\tint i,j;char m;\n\tfor(i=0;a[i];i++)\n\t\tfor(j=i+1;a[j];j++)\n\t\t\tif(a[i]>a[j])\n\t\t\t{\n\t\t\t\tm=a[i];a[i]=a[j];a[j]=m;\n\t\t\t}\n}\nint main()\n{\n int i,j,alen,blen;\n\tscanf(\"%s%s\",a,b);\n\talen=strlen(a);blen=strlen(b);\t\n f1(a);\n\tif(alen\n#include\n\n int luckyNo(int x)\n {\n int n=x;\n int r,sum=0,m=1;\n while(n)\n {\n r=n%10;\n n=n/10;\n if(r==4||r==7)\n {\n sum=sum+r*m;\n m=m*10;\n }\n }\n return sum; \n }\nint main()\n{\n int a,b;\n \n scanf(\"%d %d\",&a,&b);\n a++;\n if(a \n#include \n\nchar buf[200]; \n\nint main()\n{ \n int i,len,flag=0; \n \n \n scanf(\"%s\",buf); \n \n len =strlen(buf);\n \n for(i=0;i\n\nvoid solve(long long j, long long i){\n int l, r;\n char ar[11] = \"codeforces\";\n for( l = 0; l < j; l ++ )\n for(r = 0; r < i; r++ )\n printf(\"%c\", ar[l] );\n\n for( l = j; l < 10; l ++ )\n for(r = 0; r < i-1; r++ )\n printf(\"%c\", ar[l] );\n\n printf(\"\\n\");\n return;\n}\n\n\nint main (){\n long long k, i, j, prod, sol;\n scanf(\"%lld\", &k );\n \n if( k == 3 || k == 1){\n if( k == 3 )\n printf(\"codeforcesss\\n\");\n else\n printf(\"codeforces\\n\");\n }else{\n\n i = 1;\n prod = 1;\n while( prod < k ){\n i++;\n prod = 1;\n for( j = 0; j < 10; j++ )\n prod = prod * i;\n }\n sol = 1;\n for( j = 0; j < 10; j++ ) \n sol = sol * (i-1);\n j = 0;\n while( sol < k ){\n sol = i * (sol/(i-1));\n j++;\n }\n solve(j,i);\n }\n return 0;\n}", "src_uid": "8001a7570766cadcc538217e941b3031"} {"source_code": "#include \n\nint main(void) {\n\tint n, a[100+5], non_zero = 0;\n\tscanf(\"%d\", &n);\n\tfor(int i=1;i1)\n\t\t{\n\t\t\tprintf(\"%d %d\\n\", l, i-1);\n\t\t\tl=i; non_zero=0; i--;\n\t\t}\n\t\telse if(i==n)\n\t\t\tprintf(\"%d %d\\n\", l, n);\n\t}\n\treturn 0;\n}", "src_uid": "3a9258070ff179daf33a4515def9897a"} {"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#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)\n#define s(n) scanf(\"%d\",&n)\n#define sc(n) scanf(\"%c\",&n)\n#define sl(n) scanf(\"%I64d\",&n)\n#define sf(n) scanf(\"%lf\",&n)\n#define ss(n) scanf(\"%s\",n)\n#define fill(a,v) memset(a, v, sizeof(a))\nint intcmp(const void *f,const void *s)\n{\n return (*(int *)f -*(int *)s);\n}\nint gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}\n\n#define MAX\n#define MODBY 1000000007\n\ntypedef long long int lld;\ntypedef long double Lf;\n#define LOGMAX 12\nlld cnt[LOGMAX][LOGMAX];//cnt[i][j] contains no of lucky numbers with i digits, of which j are lucky\nlld cum_cnt[LOGMAX][LOGMAX];//cum_cnt[i][j] contains no of lucky numbers with <= i digits, of which j are lucky\nint count_lucky(char *a,int rt)\n{\n int ans=0,i;\n for(i=0;a[i];++i)\n if(a[i]=='4') ans++;\n else if(a[i]=='7') ans++;\n while(rt--){\n --i;\n if(a[i]=='4') --ans;\n else if(a[i]=='7') --ans;\n }\n return ans;\n}\nint isl[100];\nlld real_cnt[LOGMAX]={};\nvoid discount(lld n)\n{\n char a[20];\n lld upper=1;\n int dig=0;\n for(upper=1;upper=0;--i){\n carry[i]++;\n ans+=(real_cnt[i]-carry[i]+1)*get_cnt(left-1,sum-i,carry);\n carry[i]--;\n }\n return (int)(ans%MODBY);\n}\n\nint main()\n{\n int n,i;\n //system(\"clear\");\n init();\n //n=8;\n scanf(\"%d\",&n);\n discount((lld)(n+1));\n //return 0;\n int carry[LOGMAX]={};\n lld ans=0;\n for(i=0;i\nint gcd(int a,int b)\n{\n return b==0?a:gcd(b,a%b);\n}\nint main()\n{\n int a,b,n,t,flag;\n while(scanf(\"%d%d%d\",&a,&b,&n)!=EOF)\n {\n while(1)\n {\n t=gcd(a,n);\n n-=t;\n if(n<0)\n {\n flag=1;\n break;\n }\n t=gcd(b,n);\n n-=t;\n if(n<0)\n {\n flag=0;\n break;\n }\n }\n printf(\"%d\\n\",flag);\n }\n return 0;\n}\n", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2"} {"source_code": "#include\n#include\n#include\n\nint main()\n{\nint x1,y1,x2,y2;\nscanf(\"%d%d%d%d\",&x1,&y1,&x2,&y2);\nif(x1==x2)\n{\n\n\tprintf(\"%d\",(2*(abs(y2-y1)+1))+4);\n}\nelse if(y1==y2)\n{\n\tprintf(\"%d\",2*(abs(x2-x1)+1)+4);\n}\nelse \n{\n\tprintf(\"%d\",2*((abs(x2-x1)+1)+(abs(y2-y1)+1)));\n}\n\nreturn 0;\n}\n", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed"} {"source_code": "#include \n#include\nint main(void) {\n // your code goes here\n int r,h,n,temp;\n float t;\n scanf(\"%d %d\",&r,&h);\n temp=h/r;\n n=2*temp;\n t=h%r;\n if(t<0.5*r){\n n++;\n }\n else if(t>=0.5*r&&t\nint max(int a,int b) {\n if(a>b) return a;\n else return b;\n}\n/*interface implementation*/\n/*client*/\nint main() {\n int a1,b1;\n scanf(\"%d%d\",&a1,&b1);\n int a2,b2;\n scanf(\"%d%d\",&a2,&b2);\n int a3,b3;\n scanf(\"%d%d\",&a3,&b3);\n int is_ok=0;\n if(b2+b3<=b1 && max(a2,a3)<=a1) {\n is_ok=1;\n } else if(b2+a3<=b1 && max(a2,b3)<=a1) {\n is_ok=1;\n } else if(a2+b3<=b1 && max(b2,a3)<=a1) {\n is_ok=1;\n } else if(a2+a3<=b1 && max(b2,b3)<=a1) {\n is_ok=1;\n } else if(a2+a3<=a1 && max(b2,b3)<=b1) {\n is_ok=1;\n } else if(a2+b3<=a1 && max(b2,a3)<=b1) {\n is_ok=1;\n } else if(b2+a3<=a1 && max(a2,b3)<=b1) {\n is_ok=1;\n } else if(b2+b3<=a1 && max(a2,a3)<=b1) {\n is_ok=1;\n } else {\n is_ok=0;\n }\n if(is_ok) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n\n return 0;\n}\n", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9"} {"source_code": "#include\nint main()\n{\n char a[20];\n int i,sum;\n while(gets(a))\n {\n sum=0;\n for(i=0;a[i]!='\\0';i++)\n {\n if(a[i]=='4' || a[i]=='7')\n {\n sum++;\n }\n }\n if(sum==4 ||sum==7)\n {\n printf(\"YES\\n\");\n }\n else\n {\n printf(\"NO\\n\");\n }\n }\n return 0;\n}\n", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1"} {"source_code": "#include \n \nint main(void) {\n\t// your code goes here\n \n\tint n,m,k,temp;\n\tscanf(\"%d %d %d\",&n,&m,&k);\n\tif(k%(2*m)==0) printf(\"%d \", k/(2*m)); else printf(\"%d \",k/(2*m)+1);\n \n\ttemp=k%(2*m);\n\tif(temp==0) printf(\"%d \",m);\n\telse{\n\tif(temp%2==0) printf(\"%d \",temp/2);\n\telse printf(\"%d \",temp/2+1);\n\t}\n \n\tif(k%2!=0) printf(\"L\"); else printf(\"R\");\n \n\treturn 0;\n}", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb"} {"source_code": "#include \n#include \n\nint dp[21][11][10][5][5];\n\nvoid func(int n, int t)\n{\n int i, j, k, g, h, f, ans = 0;\n memset(dp, 0, sizeof(dp));\n for (i = 1; i <= 4; i ++)\n {\n for (j = 1; j <= 4; j ++)\n {\n if (i != j)\n {\n dp[2][0][0][i][j] = 1;\n }\n }\n }\n for (i = 3; i <= n; i ++)\n {\n for (j = 0; j <= t; j ++)\n {\n for (k = 0; k <= t - 1; k ++)\n {\n for (g = 1; g <= 4; g ++)\n {\n for (h = 1; h <= 4; h ++)\n {\n if (g != h)\n {\n for (f = 1; f <= 4; f ++)\n {\n if (f != h)\n {\n if (g < h && h > f)\n {\n if (j < t)\n {\n dp[i][j + 1][k][h][f] += dp[i - 1][j][k][g][h];\n }\n }\n else if (g > h && h < f)\n {\n if (k < t - 1)\n {\n dp[i][j][k + 1][h][f] += dp[i - 1][j][k][g][h];\n }\n }\n else\n {\n dp[i][j][k][h][f] += dp[i - 1][j][k][g][h];\n }\n }\n }\n }\n }\n }\n }\n }\n }\n for (i = 1; i <= 4; i ++)\n {\n for (j = 1; j <= 4; j ++)\n {\n if (i != j)\n {\n ans += dp[n][t][t - 1][i][j];\n }\n }\n }\n printf(\"%d\\n\", ans);\n}\n\nint main()\n{\n int n, t;\n while (scanf(\"%d%d\", &n, &t) == 2)\n {\n func(n, t);\n }\n return 0;\n}", "src_uid": "6d67559744583229455c5eafe68f7952"} {"source_code": "#include \n\nint main() {\n\tint s;\n\tscanf(\"%d\", &s);\n\tswitch(s/10)\n\t{\n\tcase 2:printf(\"twenty\"); break;\n\tcase 3:printf(\"thirty\"); break;\n\tcase 4:printf(\"forty\"); break;\n\tcase 5:printf(\"fifty\"); break;\n\tcase 6:printf(\"sixty\"); break;\n\tcase 7:printf(\"seventy\"); break;\n\tcase 8:printf(\"eighty\"); break;\n\tcase 9:printf(\"ninety\"); break;\n\t}\n\tif( s % 10 != 0 && s > 20 ) {\n\t\tprintf(\"-\");\n\t\ts %= 10;\n\t}\n\tswitch(s)\n\t{\n\tcase 0: printf(\"zero\"); break;\n\tcase 1: printf(\"one\"); break;\n\tcase 2: printf(\"two\"); break;\n\tcase 3: printf(\"three\"); break;\n\tcase 4: printf(\"four\"); break;\n\tcase 5: printf(\"five\"); break;\n\tcase 6: printf(\"six\"); break;\n\tcase 7: printf(\"seven\"); break;\n\tcase 8: printf(\"eight\"); break;\n\tcase 9: printf(\"nine\"); break;\n\tcase 10: printf(\"ten\"); break;\n\tcase 11: printf(\"eleven\"); break;\n\tcase 12: printf(\"twelve\"); break;\n\tcase 13: printf(\"thirteen\"); break;\n\tcase 14: printf(\"fourteen\"); break;\n\tcase 15: printf(\"fifteen\"); break;\n\tcase 16: printf(\"sixteen\"); break;\n\tcase 17: printf(\"seventeen\"); break;\n\tcase 18: printf(\"eighteen\"); break;\n\tcase 19: printf(\"nineteen\"); break;\n\t}\n\treturn 0;\n}\n", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7"} {"source_code": "#include\n#include\n\nint main()\n{\n unsigned int n,a,b,x,i=0;\n scanf(\"%u\",&n);\n\n x = sqrt(n);\n\n if(x*x == n)\n printf(\"%u %u\\n\",x,x);\n else\n {\n for(i = x + 1;;i++)\n {\n if(x * i > n)\n x--;\n else if(x * i == n)\n break;\n }\n printf(\"%u %u\\n\",x,i);\n }\n\n return 0;\n}\n", "src_uid": "f52af273954798a4ae38a1378bfbf77a"} {"source_code": "#include \n#include \n\nchar Visit[256];\n\nint Val(char *a)\n{\n return (a[0] - 'A') * 64 + (a[1] - 'A') * 16 + (a[2] - 'A') * 4 + (a[3] - 'A');\n}\n\nvoid Change(char *str)\n{\n if(str[0] == 'X') {\n str[0] = 'D';\n }\n if(str[1] == 'X') {\n str[1] = 'D';\n }\n}\n\nint main()\n{\n char a[4];\n for(int i = 0; i < 2; ++i) {\n scanf(\"%s\", a + 2 * i);\n Change(a + 2 * i);\n }\n int change[4][2] = {{1, 2}, {0, 3}, {0, 3}, {1, 2}};\n Visit[Val(a)] = 1;\n char queue[256][4];\n int head = 0, tail = 1;\n for(int i = 0; i < 4; ++i) {\n queue[0][i] = a[i];\n }\n while(head < tail) {\n for(int i = 0; i < 4; ++i) {\n if(queue[head][i] == 'D') {\n char update[4];\n for(int j = 0; j < 2; ++j) {\n for(int k = 0; k < 4; ++k) {\n update[k] = queue[head][k];\n }\n char temp = update[change[i][j]];\n update[change[i][j]] = update[i];\n update[i] = temp;\n if(!Visit[Val(update)]) {\n Visit[Val(update)] = 1;\n memcpy(queue[tail], update, sizeof(update));\n ++tail;\n }\n }\n }\n }\n ++head;\n }\n for(int i = 0; i < 2; ++i) {\n scanf(\"%s\", a + 2 * i);\n Change(a + 2 * i);\n }\n puts(Visit[Val(a)] ? \"YES\" : \"NO\");\n return 0;\n}\n", "src_uid": "46f051f58d626587a5ec449c27407771"} {"source_code": "#include\n\n\nint main(){\n\tlong long res,a,b,w,x,c;\n\tscanf(\"%I64d%I64d%I64d%I64d%I64d\",&a,&b,&w,&x,&c);\n\tif (a\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]\nint main()\n{\n int k,n,w,c,i;\n scanf(\"%d%d%d\",&k,&n,&w);\n c=0;\n for(i=1;i<=w;i++)\n {\n c=c+(k*i);\n }\n if(c>=n)\n {\n printf(\"%d\",(c-n));\n }\n else\n {\n printf(\"0\");\n }\n return 0;\n}", "src_uid": "e87d9798107734a885fd8263e1431347"} {"source_code": "#include\n\nint main()\n{\n int n,i,c=0;\n scanf(\"%d\",&n);\n for(i=1; i\n\nint main(void){\n int check,i,l,d,v,g,r,sum=0,roop;\n double t1,t2,t;\n scanf(\"%d %d %d %d %d\",&l,&d,&v,&g,&r);\n roop=g+r;\n t1=(double)d/v;\n //printf(\"t1:%f\\n\",t1);\n i=1;\n while(sumt1) check=2;\n else if(sum==t1) check=3;\n }else{\n sum+=r;\n if(sum>t1) check=1;\n else if(sum==t1) check=2;\n }\n i++;\n }\n if(check==1) t1=sum;\n else if(check==3) t1+=r;\n //printf(\"t1:%f\\n\",t1);\n t2=((double)l-(double)d)/v;\n //printf(\"t2:%f\\n\",t2);\n t=t1+t2;\n printf(\"%f\\n\",t);\n return 0;\n}\n", "src_uid": "e4a4affb439365c843c9f9828d81b42c"} {"source_code": "#include \n\nlong long zcy(long long m)\n{\n long long ans = m;\n while (m > 0)\n {\n ans = ans * 10 + m % 10;\n m /= 10;\n }\n return ans;\n}\n\nint main()\n{\n int k, p,i;\n\n scanf(\"%d %d\", &k, &p);\n long long sum = 0;\n\n for (i = 1; i <= k; i++)\n\n sum = (sum + zcy(i)) % p;\n\n printf(\"%I64d\\n\", sum);\n\n return 0;\n}\n", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609"} {"source_code": "#include\n\nint main(void){\n\tint n;\n\tchar k;\n\tscanf(\"%c%d\", &k,&n);\n\tif((k=='a'||k=='h')&&(n==8 || n==1)){\n\t\tprintf(\"3\");\n\t\treturn 0;\n\t}\n\tif(n==1 || n==8 || k=='a' || k=='h'){\n\t\tprintf(\"5\");\n\t\treturn 0;\n\t}\n\tprintf(\"8\");\n\treturn 0;\n}", "src_uid": "6994331ca6282669cbb7138eb7e55e01"} {"source_code": "#include \n\nint main()\n{\n\tint ibit;\n\tunsigned long long l, r, x, res, bit;\n\tscanf(\"%I64d%I64d\", &l, &r);\n\tx = l ^ r;\n\tres = 0;\n\tfor ( ibit = 63; --ibit >= 0; )\n\t{\n\t\tbit = (unsigned long long) 1 << ibit;\n\t\tif ( x & bit )\n\t\t{\n\t\t\tres |= bit;\n\t\t\tif ( r & bit )\n\t\t\t{\n\t\t\t\tres |= bit - 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse if ( (l >> ibit) == (r >> ibit) )\n\t\t\tcontinue;\n\t\telse if ( !(l & bit) )\n\t\t{\n\t\t\tres |= bit | bit - 1;\n\t\t\tbreak;\n\t\t}\n\t\telse if ( r & bit )\n\t\t{\n\t\t\tres |= bit | bit - 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tprintf(\"%I64d\\n\", res);\n\treturn 0;\n}\n", "src_uid": "d90e99d539b16590c17328d79a5921e0"} {"source_code": "#include\n#include\n#include\n\nint main()\n{\n char ch[101];\n gets(ch);\n int i,count[100] = {0},s=0,sum=0;\n if(ch[strlen(ch)-1] != 'n'&&ch[strlen(ch)-1] != 'a'&&ch[strlen(ch)-1] != 'e'&&ch[strlen(ch)-1] != 'i'&&ch[strlen(ch)-1] != 'o'&&ch[strlen(ch)-1] != 'u'){\n printf(\"NO\\n\");\n return 0;\n }\n if(strcmp(ch,\"nn\")==0){\n printf(\"YES\\n\");\n return 0;\n }\n if(strlen(ch)==1){\n if(ch[0] == 'a'||ch[0] =='e'||ch[0] =='i'||ch[0] =='o'||ch[0] =='u'||ch[0] == 'n')\n printf(\"YES\\n\");\n\n else\n printf(\"NO\\n\");\n return 0;\n }\n if(strlen(ch)==2){\n if(ch[1] == 'a'||ch[1] =='e'||ch[1] =='i'||ch[1] =='o'||ch[1] =='u')\n printf(\"YES\\n\");\n\n else\n printf(\"NO\\n\");\n return 0;\n }\n for(i=0; i\n#include\n#include\n#include\n\nlong long int XY(int A, int B, int C, int X_plus_Y)\n{\n\tlong long int x = 0;\n\tint i;\n\tint j1, j2;\n\t\n\ti = A;\n\tj1 = X_plus_Y - i;\n\t\n\tif(j1>C)\n\t{\n\t\tj1 = C;\n\t}\n\t\n\ti = B;\n\tj2 = X_plus_Y - i;\n\t\n\tif(j2\n#include\n\nint main()\n{\n int n,i,l,k,j;\n char a[8][10] = {\"vaporeon\",\"jolteon\",\"flareon\",\"espeon\",\"umbreon\",\"leafeon\",\"glaceon\",\"sylveon\"};\n char b[10];\n scanf(\"%d %s\",&n,b);\n for(i=0; i<8; i++)\n {\n if(strlen(a[i])==n)\n {\n l = 0,k = 0;\n for(j=0; b[j]; j++)\n {\n if(b[j]=='.') l++;\n else if(b[j]==a[i][j]) k++;\n else break;\n }\n }\n if(l+k==strlen(b))\n {\n printf(\"%s\\n\",a[i]);\n return 0;\n }\n }\n}\n\n", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0"} {"source_code": "#include \n\nint main() {\n int i, n, winner[100], spectator[100] = {3};\n scanf(\"%d\", &n);\n for(i = 0; i < n; i++) {\n scanf(\"%d\", &winner[i]);\n if (i)\n spectator[i] = 6 - winner[i - 1] - spectator[i - 1];\n }\n for(i = 0; i < n; i++) {\n if (winner[i] == spectator[i]) {\n printf(\"NO\\n\");\n return 0;\n }\n }\n printf(\"YES\\n\");\n return 0;\n}", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87"} {"source_code": "#include\n#include\nint main()\n{\n int i,j,n,max=-1,count,a;\n char c1,c2;\n scanf(\"%d\",&n);\n char s[n];\n scanf(\"%s\",s);\n for(i=0;imax)\n {\n max=count;\n c1=s[i];\n c2=s[i+1];\n }\n }\n printf(\"%c%c\\n\",c1,c2);\n return 0;\n}\n", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1"} {"source_code": "#include\n#define max(a,b) a>b?a:b\nint main()\n{\n __int64 n,a,b,c,x=0,y=0;\n scanf(\"%I64d%I64d%I64d%I64d\",&n,&a,&b,&c);\n __int64 d=b-c;\n if(n>=a)\n {\n x+=n/a;\n __int64 e=n%a;\n if(e>=b)\n {\n x+=(e-b)/d+1;\n }\n }\n if(n>=b)\n {\n __int64 f=(n-b)/d+1;\n y+=f;\n y+=(n-f*d)/a;\n }\n __int64 ccc=max(x,y);\n printf(\"%I64d\\n\",ccc);\n return 0;\n}\n", "src_uid": "0ee9abec69230eab25de51aef0984f8f"} {"source_code": "#include \n\nint main()\n{\n int dd, mm, yy, bd, bm, by, f = 0;\n int d[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n\n scanf(\"%d.%d.%d\", &dd, &mm, &yy);\n scanf(\"%d.%d.%d\", &bd, &bm, &by);\n\n if (yy > by + 18 || (yy == by + 18 && (mm > bm || (mm == bm && dd >= bd)))) {\n\t f = 1;\n }\n\n if (by <= 12 && (d[by - 1] >= bd || (by == 2 && bm % 4 == 0 && bd == 29))) {\n\t if (yy > bm + 18 || (yy == bm + 18 && (mm > by || (mm == by && dd >= bd)))) {\n\t f = 1;\n\t }\n }\n\n if (bd <= 12 && (d[bd - 1] >= bm || (bd == 2 && by % 4 == 0 && bm == 29))) {\n\t if (yy > by + 18 || (yy == by + 18 && (mm > bd || (mm == bd && dd >= bm)))) {\n\t f = 1;\n\t }\n }\n\n if (by <= 12 && (d[by - 1] >= bm || (by == 2 && bd % 4 == 0 && bm == 29))) {\n\t if (yy > bd + 18 || (yy == bd + 18 && (mm > by || (mm == by && dd >= bm)))) {\n\t f = 1;\n\t }\n }\n\n if (d[bm - 1] >= by || (bm == 2 && bd % 4 == 0 && by == 29)) {\n\t if (yy > bd + 18 || (yy == bd + 18 && (mm > bm || (mm == bm && dd >= by)))) {\n\t f = 1;\n\t }\n }\n\n if (bd <= 12 && (d[bd - 1] >= by || (bd == 2 && bm % 4 == 0 && by == 29))) {\n\t if (yy > bm + 18 || (yy == bm + 18 && (mm > bd || (mm == bd && dd >= by)))) {\n\t f = 1;\n\t }\n }\n\n if (f == 1) {\n\t puts(\"YES\");\n } else {\n\t puts(\"NO\");\n }\n\n return 0;\n}\n", "src_uid": "5418c98fe362909f7b28f95225837d33"} {"source_code": "#include\n#include\nint main()\n{\n char str[200],c1,c2;\n scanf(\"%s\", str);\n int i, s1, s2, sum=0;\n for(i=0; istr[i-1]){\n c1=str[i-1];\n c2=str[i];\n }\n else{\n c1=str[i];\n c2=str[i-1];\n }\n s1=c2-c1;\n s2=c1-c2+26;\n if(s1\n#include \nint ar[9];\nint main()\n{\n\tchar s[60];\n\tint i,j,len;\n\tscanf(\"%s\",s);\n\tlen=strlen(s);\n\tfor (i=0; iar[7]) printf(\"4\\n\");\n\telse printf(\"7\\n\");\n\t\n\treturn 0;\n}", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a"} {"source_code": "#include \n#include \n#include \n#include \n#include \n\nint main()\n{\n int n,i,j,k,l,min;\n scanf(\"%d\",&n);\n\n int len=1,num=n;\n\n while(1){\n num=num/10;\n if(num==0){\n break;\n }\n else{\n len++;\n }\n }\n\n min=len;\n\n for(i=1;i*i<=n;i++){\n j=i*i;\n num=j;\n k=1;\n\n while(1){\n num=num/10;\n if(num==0){\n break;\n }\n else{\n k++;\n }\n }\n\n num=n;\n l=k;\n\n while(1){\n while(1){\n if(num%10==j%10){\n num=num/10;\n l--;\n break;\n }\n else{\n num=num/10;\n if(num==0){\n break;\n }\n }\n }\n if(l==0){\n if((len-k)\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}", "src_uid": "8b8327512a318a5b5afd531ff7223bd0"} {"source_code": "#include \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}", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2"} {"source_code": "#include\nint main(){\n\tint n,m;\n\tscanf(\"%d%d\", &n, &m);\n\tif(nm) {\n\t\t if(n%2==0) {\n\t\t\tif((n/2)%m==0) printf(\"%d\",n/2);\n\t\t\telse printf(\"%d\", n/2+m-(n/2%m));\n\t\t}\n\t\telse {\n\t\t\tif((n/2+1)%m==0) printf(\"%d\",n/2+1);\n\t\t\telse printf(\"%d\",n/2+1+m-((n/2+1)%m));\n\t\t}\n\t}\nreturn 0;\n}", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f"} {"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}", "src_uid": "64fada10630906e052ff05f2afbf337e"} {"source_code": "#include\nint main()\n{\n float x,h,c,y,m;\n scanf(\"%f:%f\",&x,&y);\n if((x==12 && y==0) || (x==0 && y==0))\n {\n h=0;\n m=y*6;\n }\n else if((x==12 && y!=0) || (x==0 && y!=0))\n {\n m=y*6;\n h=y/2;\n }\n else\n {\n if(x>0 && x<12)\n {\n m=y*6;\n h=((x*60)+y)/2;\n }\n else if(x>=13 && x<24)\n {\n c=x-12;\n m=y*6;\n h=((c*60)+y)/2;\n }\n }\n printf(\"%.1f %.0f\",h,m);\n return 0;\n}\n", "src_uid": "175dc0bdb5c9513feb49be6644d0d150"} {"source_code": "#include\n#include\n#include\n#include\n#include\n\ntypedef int64_t i64;\ntypedef int32_t i32;\n\nstatic void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}\nstatic i64 read_int(void){int prev='\\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}\n\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))\n\n#define POS(i, j, k) ((((i) & 1) * (n + 1) + (j)) * (n + 1) + (k))\n\nvoid run (void) {\n const i32 n = read_int();\n const i32 m = read_int();\n const i32 mod = 998244353;\n i64 *dp = ALLOC (2 * (n + 1) * (n + 1), i64);\n dp[POS(1, 1, 1)] = 1;\n for (i32 i = 1; i < n; ++i) {\n memset (dp + POS(i + 1, 0, 0), 0, sizeof (*dp) * (n + 1) * (n + 1));\n for (i32 j = 1; j <= i; ++j) {\n for (i32 k = 1; k <= i; ++k) {\n dp[POS(i, j, k)] %= mod;\n dp[POS(i + 1, MAX (j, k + 1), k + 1)] += dp[POS(i, j, k)];\n dp[POS(i + 1, j, 1)] += dp[POS(i, j, k)];\n }\n }\n }\n i64 *way = ALLOC (n + 1, i64);\n for (i32 j = 1; j <= n; ++j) {\n for (i32 k = 1; k <= j; ++k) {\n way[j] += dp[POS(n, j, k)] % mod;\n }\n }\n for (i32 i = 1; i <= n; ++i) {\n way[i] %= mod;\n }\n i64 ans = 0;\n for (i32 i = 1; i <= n; ++i) {\n for (i32 j = 1; j <= n; ++j) {\n if (i * j < m) {\n ans += way[i] * way[j] % mod;\n }\n }\n }\n ans = 2 * ans % mod;\n print_int (ans);\n puts (\"\");\n}\n\nint main (void) {\n run ();\n return 0;\n}\n", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b"} {"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", "src_uid": "eb9d24070cc5b347d020189d803628ae"} {"source_code": "#include\n#include\nint main()\n{\n int n,i=0,k=0,l=0;\n scanf(\"%d\",&n);\n char *a=(char*)malloc(sizeof(char)*(n+1));\n int *c=(int*)malloc(sizeof(int)*n);\n scanf(\"%s\",a);\n for(i=0;i\n\nint main()\n{\n int a, x, y;\n\n scanf(\"%d %d %d\", &a, &x, &y);\n\n if (y % a == 0) {\n\t puts(\"-1\");\n } else {\n\t y /= a;\n\n\t if (y == 0) {\n\t if (x >= 0 && a > x * 2 || x <= 0 && a > - x * 2) {\n\t\t puts(\"1\");\n\t } else {\n\t\t puts(\"-1\");\n\t }\n\t } else if (y % 2 == 0) {\n\t if (x > 0 && a > x) {\n\t\t printf(\"%d\\n\", 3 * y / 2 + 1);\n\t } else if (x < 0 && a > -x) {\n\t\t printf(\"%d\\n\", 3 * y / 2);\n\t } else {\n\t\t puts(\"-1\");\n\t }\n\t } else {\n\t if (x >= 0 && a > x * 2 || x <= 0 && a > - x * 2) {\n\t\t printf(\"%d\\n\", 3 * y / 2 + 1);\n\t } else {\n\t\t puts(\"-1\");\n\t }\n\t }\n }\n\n return 0;\n}\n", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02"} {"source_code": "#include \nint main()\n{\n int n,i,j,m=0;\n char pass[3],kash[100][2];\n scanf(\"%s\",pass);\n scanf(\"%d\",&n);\n for(i=0;i\nint main(){\n long long int n,a[3][3],a1[3][3],r[3][3],r1[3][3],s,i,j,k,p=1000000007,sum=0;\n\tscanf(\"%lld\",&n);\n\n\ta[0][0]=10;\n\ta[0][1]=3;\n\ta[1][0]=0;\n\ta[1][1]=0;\n\n\tr[0][0]=6;\n\tr[0][1]=1;\n\tr[1][0]=-8;\n\tr[1][1]=0;\n\n\ts=n-2;\n\tif(n==0)\n\t\tprintf(\"1\\n\");\n\telse if(n==1)\n\t\tprintf(\"3\\n\");\n\telse{\n\twhile(s>0)\n\t{\n\t\tsum=0;\n\t\tif(s%2!=0)\n\t\t{\n\t\t\tfor(i=0;i<2;i++){\n\t\t\t\tfor(j=0;j<2;j++){\n\t\t\t\t\tfor(k=0;k<2;k++){\n\t\t\t\t\t//\tif(s==1){\n\t\t\t\t\t//\t\tprintf(\"%lld %lld\\n\",a[i][k],r[k][j]);\n\t\t\t\t\t//\t\tprintf(\"%lld\\n\",sum);}\n\t\t\t\t\t//\tif(r[k][j]<0)\n\t\t\t\t\t\t//\tst=a[i][k]*r[k][j]\n\t\t\t\t\t\tsum=(sum+(a[i][k]*r[k][j]+p)%p)%p;\n\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t//\tif(s==1)\n\t\t\t\t\t//\tprintf(\"%lld\\n\",sum);\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\ta1[i][j]=sum%p;\n\t\t\t\t//\tprintf(\"%lld\\n\",sum);\n\t\t\t\t\tsum=0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor(i=0;i<2;i++){\n\t\t\t\tfor(j=0;j<2;j++){\n\t\t\t\t\ta[i][j]=a1[i][j];}}\n//\t\t\tprintf(\"%lld\\n\",a[0][0]);\n\t\t}\n\t\tsum=0;\n\n\t\ts=s/2;\n\t\tfor(i=0;i<2;i++){\n\t\t\tfor(j=0;j<2;j++){\n\t\t\t\tfor(k=0;k<2;k++){\n\t\t\t\t\tsum=(sum+(r[i][k]*r[k][j]+p)%p)%p;\n\t\t\t\t}\n\t\t\t\tr1[i][j]=sum%p;\n\t\t\t//\tprintf(\"%lld\\n\",sum);\n\n\t\t\t\tsum=0;\n\t\t\t}\n\t\t}\n\t\tfor(i=0;i<2;i++){\n\t\t\tfor(j=0;j<2;j++){\n\t\t\t\tr[i][j]=r1[i][j];}}\n\n\t\t\t}\n\t\t\t printf(\"%lld\\n\",a[0][0]%p);\n\t\t\n\t}\n\t\t\treturn 0;\n}\n\n\n\n", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085"} {"source_code": "#include\n#include\nint main() \n{\n int n, a[10000],p=0,q=0, i;\n scanf(\"%d\",&n);\n for(i=0;i0)\n p++;\n else if(a[i] <0)\n q++;\n } \n float f=n/2.0;\n if(p>=f) \n printf(\"1\\n\");\n else if(q>=f) \n printf(\"-1\\n\");\n else\n printf(\"0\");\n}\n\n", "src_uid": "a13cb35197f896cd34614c6c0b369a49"} {"source_code": "#include \n#include \n#include \n\nint comp(const void* a, const void* b) {\n return(*(int*)a - *(int*)b);\n}\n\nint main() {\n int n, k, p[50], s1 = 0, s2 = 0, res;\n scanf(\"%d\", &n);\n k = n/2;\n for (int i=0; i\n#include \n#define ll int64_t\n\n\nstruct pr\n{\n ll f, s;\n} a[100001], b[100001];\n\nint cmp(const void* p1, const void* p2)\n{\n ll d = - ((const struct pr*)p1)->f + ((const struct pr*)p2)->f;\n if (d) return d < 0 ? -1 : 1;\n return ((const struct pr*)p1)->s - ((const struct pr*)p2)->s > 0 ? 1 : -1;\n}\n\nint main()\n{\n int n, m; ll d;\n scanf(\"%d%d%I64d\", &n, &m, &d);\n for(int i = 0; i < n; ++i)\n {\n scanf(\"%I64d%I64d\", &(a[i].f), &(a[i].s));\n }\n for(int i = 0; i < m; ++i)\n {\n scanf(\"%I64d%I64d\", &(b[i].f), &(b[i].s));\n }\n qsort(a, n, sizeof(struct pr), cmp);\n qsort(b, m, sizeof(struct pr), cmp);\n for(int i = 1; i < n; ++i)\n {\n a[i].f += a[i-1].f;\n a[i].s += a[i-1].s;\n }\n for(int i = 1; i < m; ++i)\n {\n b[i].f += b[i-1].f;\n b[i].s += b[i-1].s;\n }\n int i = 0, j = 0;\n if (a[0].s + b[0].s > d)\n {\n printf(\"0\");\n return 0;\n }\n while(i < n && a[i].s + b[0].s <= d) ++i;\n ll ans = 0;\n while(j < m && i >= 0)\n {\n if (i < n && a[i].s + b[j].s <= d)\n {\n if (a[i].f + b[j].f > ans) ans = a[i].f + b[j].f;\n ++j;\n }\n else --i;\n }\n printf(\"%I64d\", ans);\n return 0;\n}", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff"} {"source_code": "/* https://codeforces.com/contest/1185/submission/55797221 (Dukkha) */\n#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}\n", "src_uid": "ed5f913afe829c65792b54233a256757"} {"source_code": "#include\n#include\nint main()\n{\n\tchar str[100];\n\tscanf(\"%s\", str);\n\tint i, p = 0, l = strlen(str);\n\tfor(i = 0; i < l; ){\n\t\tif(str[i] == 'V' && str[i+1] == 'K'){\n\t\t\tp++;\n\t\t\ti = i + 2;\n\t\t}\n\t\telse{\n\t\t\ti++;\n\t\t}\n\t}\n\tfor(i = 0; i < l;){\n\t\tif(str[i] == 'V' && str[i+1] == 'V' && (str[i+2] == 'V' || str[i+2] == '\\0')){\n\t\t\tp++;\n\t\t\tbreak;\n\t\t}\n\t\telse if(str[i] == 'K' && str[i + 1] == 'K' && str[i-1] =='K'){\n\t\t\tp++;\n\t\t\tbreak;\n\t\t}\n\t\telse if(i == 0 && str[i] == 'K' && str[i + 1] == 'K'){\n\t\t\tp++;\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\ti++;\n\t\t}\n\t}\n\tprintf(\"%d\", p);\n}\n\t\n\t\n\t\t\n\t\t", "src_uid": "578bae0fe6634882227ac371ebb38fc9"} {"source_code": "#include \nint main()\n{\n int n,a=0;\n scanf(\"%d\",&n);\n int i,w;\n for(i=0;i\n\nint main()\n{\n puts(\"Karen\");\n return 0;\n}\n", "src_uid": "1649d2592eadaa8f8d076eae2866cffc"} {"source_code": "#include \n\nint main() {\n int x,y,z,i,o;\n scanf(\"%d %d %d\",&x,&y,&z);\n if(x3) o+=(x-2)/2;\n if(x>2) o+=(x-1)/2;\n printf(\"%d\\n\",o);\n } else if(x%2==0 && y%2) {\n o=(x+1)/2*2;\n if(y>3) o+=(y-2)/2;\n if(y>2) o+=(y-1)/2;\n printf(\"%d\\n\",o);\n }\n return 0;\n }\n x-=2;\n y-=2;\n if(y<1 || x<1) break;\n }\n puts(\"0\");\n return 0;\n}\n", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb"} {"source_code": "#include \n#include \n\nstruct table\n{\n int arr[10];\n};\n\nvoid fillt(struct table *t, int n)\n{\n int x;\n for(x = 0; x < 10; x++)\n {\n t->arr[x] = 0;\n }\n while(n)\n {\n t->arr[n % 10] = 1;\n n /= 10;\n }\n}\n\nint compt(struct table *a, struct table *b)\n{\n int x;\n for(x = 0; x < 10; x++)\n {\n if(a->arr[x] == 1 && b->arr[x] == 1)\n {\n return 1;\n }\n }\n return 0;\n}\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n int x;\n struct table nt, xt;\n fillt(&nt, n);\n int ans = 0;\n for(x = 1; x <= sqrt(n); x++)\n {\n if(n % x == 0)\n {\n fillt(&xt, x);\n ans += compt(&xt, &nt);\n if(n / x != x)\n {\n fillt(&xt, n / x);\n ans += compt(&xt, &nt);\n }\n }\n }\n printf(\"%d\", ans);\n return 0;\n}", "src_uid": "ada94770281765f54ab264b4a1ef766e"} {"source_code": "#include \n#include \n#include \n#define maximun 50\n\nint cambia_letra(char x)\n{\n switch(x)\n {\n case 'a':\n return 1;\n case 'b':\n return 2;\n case 'c':\n return 3;\n case 'd':\n return 4;\n case 'e':\n return 5;\n case 'f':\n return 6;\n case 'g':\n return 7;\n case 'h':\n return 8;\n }\n return 0;\n}\n\nint main()\n{\n char coordenada[3];\n int resptorre[9][2], respcaballo[9][2],i,j;\n int pasos_caballo[8][2]={{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1}};\n\n gets(coordenada);\n resptorre[0][0]=atoi(&coordenada[1]);\n resptorre[0][1]=cambia_letra(coordenada[0]);\n\n gets(coordenada);\n respcaballo[0][0]=atoi(&coordenada[1]);\n respcaballo[0][1]=cambia_letra(coordenada[0]);\n\n for(i=0;i<=7;i++)\n {\n if(resptorre[0][0]+pasos_caballo[i][0]>=1 && resptorre[0][0]+pasos_caballo[i][0]<=8 && resptorre[0][1]+pasos_caballo[i][1]>=1 && resptorre[0][1]+pasos_caballo[i][1]<=8)\n {\n resptorre[i+1][0]=resptorre[0][0]+pasos_caballo[i][0];\n resptorre[i+1][1]=resptorre[0][1]+pasos_caballo[i][1];\n }\n else\n {\n resptorre[i+1][0]=0;\n resptorre[i+1][1]=0;\n }\n\n }\n\n for(i=0;i<=7;i++)\n {\n if(respcaballo[0][0]+pasos_caballo[i][0]>=1 && respcaballo[0][0]+pasos_caballo[i][0]<=8 && respcaballo[0][1]+pasos_caballo[i][1]>=1 && respcaballo[0][1]+pasos_caballo[i][1]<=8)\n {\n respcaballo[i+1][0]=respcaballo[0][0]+pasos_caballo[i][0];\n respcaballo[i+1][1]=respcaballo[0][1]+pasos_caballo[i][1];\n }\n else\n {\n respcaballo[i+1][0]=0;\n respcaballo[i+1][1]=0;\n }\n\n }\n\n for(i=1;i<=8;i++)\n {\n\n if(resptorre[i][0]!=0)\n {\n for(j=1;j<=8;j++)\n {\n if((resptorre[i][0]==respcaballo[j][0] && resptorre[i][1]==respcaballo[j][1]) || resptorre[0][0]==respcaballo[j][0] || resptorre[0][1]==respcaballo[j][1])\n {\n respcaballo[j][0]=0;\n respcaballo[j][1]=0;\n }\n }\n }\n }\n j=0;\n for(i=0;i<=8;i++)\n {\n if(resptorre[i][0]!=0) j++;\n if(respcaballo[i][0]!=0) j++;\n }\n printf(\"%d\",maximun-j);\n return 0;\n}\n", "src_uid": "073023c6b72ce923df2afd6130719cfc"} {"source_code": "#include \n#include \n\nint main(int argc, char *argv[])\n{\n\tchar minutes[102];\n\tscanf(\"%s\", minutes);\n\n\tunsigned short nMissedTrains = 0;\n\tunsigned long nDigits = strlen(minutes);\n\tif(nDigits % 2 == 0)\n\t{\n\t\tprintf(\"%ld\", (strlen(minutes) / 2));\n\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tnMissedTrains = (strlen(minutes) / 2);\n\t}\n\n\tunsigned short nOnes, i;\n\tnOnes = i = 0;\n\twhile(nOnes <= 1 && minutes[i] != '\\0')\n\t{\n\t\tif(minutes[i] == '1')\n\t\t\tnOnes++;\n\t\ti++;\n\t}\n\n\tif(nOnes > 1)\n\t\tnMissedTrains++;\n\n\tprintf(\"%d\", nMissedTrains);\n\n\treturn 0;\n}\n", "src_uid": "d8ca1c83b431466eff6054d3b422ab47"} {"source_code": "#include \n#include \n#include \n\n\nint\nmain (int ac, char *av[])\n{\n\tint i, j, k, len;\n\tchar num[32];\n\tchar x;\n\tint\tsw1 = -1;\n\tint\tsw2 = -1;\n\t\n\tscanf (\"%s\", num);\n\n\tlen = strlen(num)-1;\n\n\tfor (i = len; i >= 0; --i) {\n\n\t\tif (num[i] == '5') {\n\t\t\tint xx = 0;\n\t\t\tif (i == 0 && num[1] == '0') {\n\t\t\t\tfor (k = 1; k < len; k++) {\n\t\t\t\t\tif (num[k] != '0') break;\n\t\t\t\t\t++xx;\n\t\t\t\t}\n\t\t\t\tif (k == len) continue;\n\t\t\t}\t\n\n\t\t\tfor (j=len; j>=0; --j) {\n\t\t\t\tx = num[j];\n\t\t\t\tif (j == 0 && num[1] == '0') {\n\t\t\t\t\tfor (k = 1; k < len; k++) {\n\t\t\t\t\t\tif (num[k] != '0') break;\n\t\t\t\t\t\t++xx;\n\t\t\t\t\t}\n\t\t\t\t\tif (k == len) continue;\n\t\t\t\t}\n\n\t\t\t\tif (x == '2' || x == '7') {\n\t\t\t\t\tsw1 = (len-i) + (len-j)+xx;\n if (j < i) --sw1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor (i = len; i >= 0; --i) {\n\t\tif (num[i] == '0') {\n num[i] = '9';\n\t\t\tfor (j=len; j>=0; --j) {\n\t\t\t\tx = num[j];\n\t\t\t\tif (x == '0' || x == '5') {\n\t\t\t\t\tsw2 = (len-i)+(len-j);\n if (j < i) --sw2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (sw1 != -1) {\n\t\tif (sw2 != -1) {\n\t\t\tprintf (\"%d\\n\", (sw1>sw2) ? sw2:sw1);\n\t\t} else {\n\t\t\tprintf (\"%d\\n\", sw1);\n\t\t}\n\t} else {\n\t\tprintf (\"%d\\n\", sw2);\n\t}\n\n\treturn 0;\n}\n", "src_uid": "ea1c737956f88be94107f2565ca8bbfd"} {"source_code": "#include \n#include \n#include \n\nstatic bool has_duplicates (int arr[], size_t sz);\nstatic void decrease_duplicates (int arr[], size_t sz);\nstatic unsigned long long sum_positive (int arr[], size_t sz);\n\nint main (void) {\n\tsize_t letter_count;\n\tscanf(\"%I64u\", &letter_count);\n\n\tint max_letter_freq[letter_count];\n\tfor (size_t i = 0; i < letter_count; ++i) {\n\t\tscanf(\"%d\", &max_letter_freq[i]);\n\t}\n\n\twhile (has_duplicates(max_letter_freq, letter_count)){\n\t\tfor (size_t i = 0; i < letter_count; ++i) {\n\t\t\tdecrease_duplicates(max_letter_freq + i, letter_count - i);\n\t\t}\n\t}\n\n\tprintf(\"%llu\\n\", sum_positive(max_letter_freq, letter_count));\n\n\treturn 0;\n}\n\nstatic bool has_duplicates (int arr[], size_t sz) {\n\tif (sz == 1)\n\t\treturn false;\n\tfor (size_t i = 0; i < sz - 1; ++i)\n\t\tfor (size_t j = i + 1; j < sz; ++j)\n\t\t\tif (arr[i] == arr[j])\n\t\t\t\treturn true;\n\n\treturn false;\n}\n\nstatic void decrease_duplicates (int arr[], size_t sz) {\n\tif (sz == 1)\n\t\treturn;\n\n\tint elem = arr[0];\n\tint decrease_by = 1;\n\tfor (size_t i = 1; i < sz; ++i) {\n\t\tif (arr[i] == elem) {\n\t\t\tarr[i] -= decrease_by;\n\t\t\tdecrease_by++;\n\t\t}\n\t}\n}\n\nstatic unsigned long long sum_positive (int arr[], size_t sz) {\n\tunsigned long long sum = 0;\n\tfor (size_t i = 0; i < sz; ++i)\n\t\tif (arr[i] > 0)\n\t\t\tsum += arr[i];\n\n\treturn sum;\n}\n", "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f"} {"source_code": "#include \r\n \r\ntypedef long long ll;\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\tdp[i][0] = (sum[i - 1][0] + sum[i - 1][1] + 1) % m;\r\n\t\tif (i == 2){\r\n\t\t\tdp[i][1] = 1;\r\n\t\t} else {\r\n\t\t\tdp[i][1] = (dp[i][1] + dp[i - 1][1] + ((i - i / 2) - ((i - 1) - (i - 1) / 2))) % m;\r\n\t\t}\r\n\t\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] = (((ll)dp[j][1] + dp[i][0] + dp[i][1] - dp[i - 1][0] - dp[i - 1][1]) % m + m) % 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}", "src_uid": "77443424be253352aaf2b6c89bdd4671"} {"source_code": "#include\n\nint dias_ano(int ano){\n\tif(ano%400==0){\n\t\treturn 366;\n\t}\n\tif(ano%4==0){\n\t\tif(ano%100==0){\n\t\t\treturn 365;\n\t\t}\n\t\treturn 366;\n\t}\t\n\treturn 365;\n}\n\nint main(void){\n\tint ano;\n\tint dias=0;\n\tint parada;\n\tint dia=0;\n\tscanf(\"%d\", &ano);\n\tparada = dias_ano(ano);\n\twhile(1){\n\t\tdia = dias_ano(ano);\n\t\tdias += dia;\n\t\tif(dias%7==0 && dias_ano(ano+1)==parada){break;}\n\t\tano++;\n\t}\n\tprintf(\"%d\\n\", ano+1);\n\treturn 0;\n}", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2"} {"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", "src_uid": "db1a50da538fa82038f8db6104d2ab93"} {"source_code": "#include \n#include \n#include \n\nint qsort_compare (const void *a, const void *b)\n{\n char strA = *(char*)a;\n char strB = *(char*)b;\n return strA - strB;\n}\n\nint main()\n{\n char n[100];\n char n2[100];\n int i;\n\n scanf (\" %s\", n);\n scanf (\" %s\", n2);\n\n qsort (n, strlen (n), 1, qsort_compare);\n\n for (i = 0; n[i] == '0'; i++);\n\n if (n[i] != '\\0')\n {\n char c = n[i];\n n[i] = n[0];\n n[0] = c;\n }\n\n for (i = 0; n[i] == n2[i] && n[i] && n2[i]; i++);\n \n if (!n[i] && !n2[i])\n printf(\"OK\");\n else\n printf(\"WRONG_ANSWER\");\n\n return 0;\n}\n", "src_uid": "d1e381b72a6c09a0723cfe72c0917372"} {"source_code": "#include\nint main(void)\n{\n long long int n,k,t;\n scanf(\"%lld %lld %lld\",&n,&k,&t);\n if(t>=(n+k))\n t%=(n+k);\n if(t<=k)\n printf(\"%lld\\n\",t);\n else if(t>k&&t<=n)\n printf(\"%lld\\n\",k);\n else if(t<(n+k)&&t>n)\n printf(\"%lld\\n\",((n+k)-t));\n return 0;\n}\n", "src_uid": "7e614526109a2052bfe7934381e7f6c2"} {"source_code": "#include\n\nlong long perm(int n, int i) {\n\tlong long sum = 1;\n\twhile (i--) sum = sum * n--;\n\treturn sum;\n}\n\nlong long comb(int n, int i) {\n\treturn perm(n, i) / perm(i, i);\n}\n\nint main() {\n\tint n, k;\n\tscanf(\"%d %d\", &n, &k);\n\tlong long dp[5], sum, tt, temp;\n\tdp[0] = 1;\n\tdp[1] = 1;\n\n\tfor (int i = 2; i <= k; i++) {\n\t\tsum = comb(n, i) * perm(i, i);\n\t\ttemp = 0;\n\t\tfor (int j = i - 1; j >= 0; j--) {\n\t\t\ttt = comb(n - j, i - j) - 1;\n\t\t\tsum -= (tt - temp) * dp[j];\n\t\t\ttemp += tt - temp;\n\t\t}\n\t\tdp[i] = sum;\n\t}\n\n\tprintf(\"%lld\", dp[k]);\n}", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f"} {"source_code": "/*\n ============================================================================\n Name : diplomas.c\n Author : \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(void) {\n int n;\n scanf(\"%i\",&n);\n if ( n >= 3 && n <= 3000000)\n {\n int min1,min2,min3;\n int max1,max2,max3;\n scanf(\"%i\",&min1);\n scanf(\"%i\",&max1);\n scanf(\"%i\",&min2);\n scanf(\"%i\",&max2);\n scanf(\"%i\",&min3);\n scanf(\"%i\",&max3);\n if((min1 >= 1) && (max1 >= min1) && (1000000 >= max1) && (min2 >= 1) && (max2 >= min2) && (1000000 >= max2) && (min3 >= 1) && (max3 >= min3) && (1000000 >= max3) )\n {\n int n1 = min1;\n int n2 = min2;\n int n3 = min3;\n\n while( (n1 + n2 + n3) < n )\n {\n if ( n1 < max1 )\n {\n n1++;\n }\n else if ( n2 < max2 )\n {\n n2++;\n }\n else\n {\n n3++;\n }\n }\n printf(\"%i %i %i\",n1,n2,n3);\n fflush(stdout);\n return 0;\n }\n else\n return 0;\n }\n else\n return 0;\n}\n", "src_uid": "3cd092b6507079518cf206deab21cf97"} {"source_code": "#include\nint main()\n{\n int n;\n while(~scanf(\"%d\",&n))\n {\n if(n<=10||n>21) printf(\"0\\n\");\n else if(n>=12&&n<=19) printf(\"4\\n\");\n else if(n==20) printf(\"15\\n\");\n else if(n==11||n==21) printf(\"4\\n\");\n }\n return 0;\n}\n", "src_uid": "5802f52caff6015f21b80872274ab16c"} {"source_code": "/**\n * Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe.\n * She thinks that each Fibonacci number can be represented as sum of three not necessary different\n * Fibonacci numbers.\n *\n * Let's remember how Fibonacci numbers can be calculated. F0 =0, F1 = 1, and all the next numbers are Fi = F(i-2) + F(i-1).\n *\n * So, Fibonacci numbers make a sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, ...\n *\n * If you haven't run away from the PC in fear, you have to help the virus. Your task is to divide given Fibonacci number\n * n by three not necessary different Fibonacci numbers or say that it is impossible.\n *\n * Input\n * The input contains of a single integer n (0 ≤ n < 10^9) — the number that should be represented by the rules described\n * Auto-Indent : Ctrl + K + D\n * Output\n * Output three required numbers: a, b and c. If there is no answer for the test you have to print \"I'm too stupid to solve\n * this problem\" without the quotes.\n *\n * If there are multiple answers, print any of them.\n *\n * Examples\n *\n * Input\n * 3\n *\n * Output\n * 1 1 1\n *\n * Input\n * 13\n *\n * Output\n * 2 3 8\n */\n\n#include \n#include \n\nint main(void) {\n\n\t// User input\n\tint n = 0;\n\n\t// Current term\n\tint t1 = 0;\n\n\t// Next term\n\tint t2 = 1;\n\t\n\t// Array to store squence\n\tlong F[10000];\n\n\t// Next next successive term\n\tint nextTerm = 0;\n\n\t/* F[i] = F[i-1] + F[i-2]\n\t F[i-2] = F[i-3] + F[i-4]\n\t F[i] = F[i-1] + F[i-3] + F[i-4]\n\n\t F[i] = F[i-2]+F[i-3] + F[i-2]\n\t*/\n\t\n\t// nextTerm is sum of current and successive term\n\t\tnextTerm = t1 + t2;\n\n\t//Read user input ('n')\n\tscanf(\"%d\", &n);\n\n\tF[0] = 0;\n\tF[1] = 1;\n\tF[2] = 1;\n\t\n\t//Calculate the fibonacci sequence and store it of later use\n\tfor (int i = 3; F[i] <= n; i++) {\n\n\t\t//printf(\"%d \", t1);\n\t\tF[i] = F[i-1]+F[i-2];\n\n\t\tif(n==F[i])\n\t\t{\n\t\t\tprintf(\"%d %d %d\",F[i-3],F[i-2],F[i-2]);\n\t\t\treturn EXIT_SUCCESS;\n\t\t}\n\t}\n\n\tprintf(\"0 0 %d\",n);\n\n\treturn EXIT_SUCCESS;\n}", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1"} {"source_code": "#include\nint main()\n{\n int n,a,b,i,x,s[10005];\n scanf(\"%d %d %d\",&n,&a,&b);\n\n for(i=0;i\nint main()\n{\n int m,n,i=0,a[120],b[120],sum1=0,sum2=0,k=1,z=0;\n scanf(\"%d\",&m);\n for(n=0;n\n#include\n#include\n#include\nint main()\n{\n long long int i,j=0,k=0,n,t_h,h,t_m,m;\n char ch[1005],previous='z';\n scanf(\"%lld \",&n);\n gets(ch);\n\n if(n==1){\n if(ch[0]=='0') printf(\"No\\n\");\n else printf(\"Yes\\n\");\n\n return 0;\n }\n\n if((ch[0]==ch[1] && ch[0]=='0') || (ch[n-1]==ch[n-2] && ch[n-1]=='0'))\n {\n printf(\"No\\n\");\n return 0;\n }\n for(i=0;i2 || k>1)\n {\n printf(\"No\\n\");\n return 0;\n }\n }\n\n printf(\"Yes\\n\");\n\n return 0;\n}\n", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d"} {"source_code": "#include \n#include \n#include \n#define LL long long\nlong num[1000000];\nlong num2[1000000];\nlong shit[1000000];\nlong ans[1000000];\nlong ms[1000000];\nint compare(long a,long b)\n{\n\treturn num[a]-num[b];\n}\nvoid mergesort(long *ds,int (*compare)(long a,long b),long size)\n{\n\tlong i,j,k,s,b,e;\n\tfor (k=1;k<=size;k=k<<1)\n\t{\n\t\tfor (i=1;i+k<=size;i+=k<<1)\n\t\t{\n\t\t\ts=i;b=i+k;e=b+k-1;\n\t\t\tif (e>size) {e=size;}\n\t\t\tfor (j=1;(s=s;b--)\n\t\t\t{\n\t\t\t\tds[e--]=ds[b];\n\t\t\t}\n\t\t\tfor (b=1;b\n#include\n#include\n#define mod 100000007\nchar x[100001]= {'1','2','3','4','5','6','7','8','9','1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9','2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9','3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9','4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9','5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9','6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9','7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9','8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9','9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9','1','0','0','1','0','1','1','0','2','1','0','3','1','0','4','1','0','5','1','0','6','1','0','7','1','0','8','1','0','9','1','1','0','1','1','1','1','1','2','1','1','3','1','1','4','1','1','5','1','1','6','1','1','7','1','1','8','1','1','9','1','2','0','1','2','1','1','2','2','1','2','3','1','2','4','1','2','5','1','2','6','1','2','7','1','2','8','1','2','9','1','3','0','1','3','1','1','3','2','1','3','3','1','3','4','1','3','5','1','3','6','1','3','7','1','3','8','1','3','9','1','4','0','1','4','1','1','4','2','1','4','3','1','4','4','1','4','5','1','4','6','1','4','7','1','4','8','1','4','9','1','5','0','1','5','1','1','5','2','1','5','3','1','5','4','1','5','5','1','5','6','1','5','7','1','5','8','1','5','9','1','6','0','1','6','1','1','6','2','1','6','3','1','6','4','1','6','5','1','6','6','1','6','7','1','6','8','1','6','9','1','7','0','1','7','1','1','7','2','1','7','3','1','7','4','1','7','5','1','7','6','1','7','7','1','7','8','1','7','9','1','8','0','1','8','1','1','8','2','1','8','3','1','8','4','1','8','5','1','8','6','1','8','7','1','8','8','1','8','9','1','9','0','1','9','1','1','9','2','1','9','3','1','9','4','1','9','5','1','9','6','1','9','7','1','9','8','1','9','9','2','0','0','2','0','1','2','0','2','2','0','3','2','0','4','2','0','5','2','0','6','2','0','7','2','0','8','2','0','9','2','1','0','2','1','1','2','1','2','2','1','3','2','1','4','2','1','5','2','1','6','2','1','7','2','1','8','2','1','9','2','2','0','2','2','1','2','2','2','2','2','3','2','2','4','2','2','5','2','2','6','2','2','7','2','2','8','2','2','9','2','3','0','2','3','1','2','3','2','2','3','3','2','3','4','2','3','5','2','3','6','2','3','7','2','3','8','2','3','9','2','4','0','2','4','1','2','4','2','2','4','3','2','4','4','2','4','5','2','4','6','2','4','7','2','4','8','2','4','9','2','5','0','2','5','1','2','5','2','2','5','3','2','5','4','2','5','5','2','5','6','2','5','7','2','5','8','2','5','9','2','6','0','2','6','1','2','6','2','2','6','3','2','6','4','2','6','5','2','6','6','2','6','7','2','6','8','2','6','9','2','7','0','2','7','1','2','7','2','2','7','3','2','7','4','2','7','5','2','7','6','2','7','7','2','7','8','2','7','9','2','8','0','2','8','1','2','8','2','2','8','3','2','8','4','2','8','5','2','8','6','2','8','7','2','8','8','2','8','9','2','9','0','2','9','1','2','9','2','2','9','3','2','9','4','2','9','5','2','9','6','2','9','7','2','9','8','2','9','9','3','0','0','3','0','1','3','0','2','3','0','3','3','0','4','3','0','5','3','0','6','3','0','7','3','0','8','3','0','9','3','1','0','3','1','1','3','1','2','3','1','3','3','1','4','3','1','5','3','1','6','3','1','7','3','1','8','3','1','9','3','2','0','3','2','1','3','2','2','3','2','3','3','2','4','3','2','5','3','2','6','3','2','7','3','2','8','3','2','9','3','3','0','3','3','1','3','3','2','3','3','3','3','3','4','3','3','5','3','3','6','3','3','7','3','3','8','3','3','9','3','4','0','3','4','1','3','4','2','3','4','3','3','4','4','3','4','5','3','4','6','3','4','7','3','4','8','3','4','9','3','5','0','3','5','1','3','5','2','3','5','3','3','5','4','3','5','5','3','5','6','3','5','7','3','5','8','3','5','9','3','6','0','3','6','1','3','6','2','3','6','3','3','6','4','3','6','5','3','6','6','3','6','7','3','6','8','3','6','9','3','7','0'};\nint main()\n{\n int n,i,a;\n scanf(\"%d\",&n);\n printf(\"%c\",x[n-1]);\n\n return 0;\n}\n", "src_uid": "2d46e34839261eda822f0c23c6e19121"} {"source_code": "#include\nint dist_square(int x1,int y1, int x2, int y2)\n{\n\tint dist=(x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);\n\treturn dist;\n}\nint check_right(int x1,int y1,int x2,int y2,int x3,int y3)\n{\n\tint a=dist_square(x2,y2,x3,y3);\n\tint b=dist_square(x1,y1,x3,y3);\n\tint c=dist_square(x1,y1,x2,y2);\n\tif(a==(b+c) || (b==(a+c)) || (c==(a+b)))\n\treturn 1;\n\telse\n\treturn 0;\n}\nint check_tria(int x1,int y1, int x2, int y2, int x3,int y3)\n{\n\tif(x1==x2 && y1==y2)\n\treturn 0;\n\tif(x1==x3 && y1==y3)\n\treturn 0;\n\tif(x2==x3 && y2==y3)\n\treturn 0;\n\treturn 1;\n}\nint main()\n{\n\tint x1,y1,x2,y2,x3,y3;\n\tscanf(\"%d%d%d%d%d%d\",&x1,&y1,&x2,&y2,&x3,&y3);\n\tif(check_right(x1,y1,x2,y2,x3,y3)==1 && check_tria(x1,y1,x2,y2,x3,y3)==1)\n\t{\n\t\t\n\t\tprintf(\"RIGHT\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1-1,y1,x2,y2,x3,y3)==1 && check_tria(x1-1,y2,x2,y2,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1+1,y1,x2,y2,x3,y3)==1 && check_tria(x1+1,y1,x2,y2,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1-1,x2,y2,x3,y3)==1 && check_tria(x1,y1-1,x2,y2,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1+1,x2,y2,x3,y3)==1 && check_tria(x1,y1+1,x2,y2,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2-1,y2,x3,y3)==1 && check_tria(x1,y1,x2-1,y2,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2+1,y2,x3,y3)==1 && check_tria(x1,y1,x2+1,y2,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2,y2-1,x3,y3)==1 && check_tria(x1,y1,x2,y2-1,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2,y2+1,x3,y3)==1 && check_tria(x1,y1,x2,y2+1,x3,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2,y2,x3-1,y3)==1 && check_tria(x1,y1,x2,y2,x3-1,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2,y2,x3+1,y3)==1 && check_tria(x1,y1,x2,y2,x3+1,y3)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2,y2,x3,y3-1)==1 && check_tria(x1,y1,x2,y2,x3,y3-1)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tif(check_right(x1,y1,x2,y2,x3,y3+1)==1 && check_tria(x1,y1,x2,y2,x3,y3+1)==1)\n\t{\n\t\tprintf(\"ALMOST\");\n\t\treturn 0;\n\t}\n\tprintf(\"NEITHER\");\n\treturn 0;\n}", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d"} {"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#include\nint main()\n {\n int m,n,ok=1;\n scanf(\"%d %d\",&m,&n);\n getchar();\n char a[1001][1001]={0};\n char b[1001][1001]={0};\n memset(b,'.',1001*1001);\n for(int i=0;i\n\nint a[4],b[4],a2[4],a3[4];\n\nint mypow(int a,int k)\n{\n\tint t=1;\n\twhile(k--) t*=a;\n\treturn t;\n}\nvoid div3(int k,int u)\n{\n\tif(a3[k]>=u) {a[k]/=mypow(3,u);a[k]*=mypow(2,u);a2[k]+=u;}\n\telse {\n\t\ta[k]/=mypow(3,a3[k]); a[k]*=mypow(2,a3[k]); a2[k]+=a3[k];\n\t\ta[k+1]/=mypow(3,u-a3[k]); a[k+1]*=mypow(2,u-a3[k]); a2[k+1]+= (u-a3[k]);\n\t}\n}\n\nvoid div2(int k,int v)\n{\n\tif(a2[k]>=v) a[k]/=mypow(2,v);\n\telse {\n\t\ta[k]/=mypow(2,a2[k]);\n\t\ta[k+1]/=mypow(2,v-a2[k]);\n\t}\n}\n\n\nint main()\n{\n\tint i,t,u,v;\n\tfor(i=0;i<4;i++)\n\t{\n\t\tscanf(\"%d\",a+i);\n\t\tb[i]=a[i];a2[i]=0;a3[i]=0;\n\t\twhile(b[i]!=1&&b[i]%2==0) {a2[i]++;b[i]/=2;}\n\t\twhile(b[i]!=1&&b[i]%3==0) {a3[i]++;b[i]/=3;}\n\t}\n\tif((long long)b[0]*b[1]!=(long long)b[2]*b[3])\n\t\t{printf(\"-1\\n\");return 0;}\n\tu = (a3[0]+a3[1]) - (a3[2]+a3[3]);\n\tv = (a2[0]+a2[1]) - (a2[2]+a2[3]) + u;\n\tif(v<0) t=-v; else t=v;\n\tif(u<0) t-=u; else t+=u;\n\tprintf(\"%d\\n\",t);\n\tif(u>0) div3(0,u);\n\telse if(u<0) div3(2,-u);\n\tif(v>0) div2(0,v);\n\telse if(v<0) div2(2,-v);\n\tprintf(\"%d %d\\n%d %d\\n\",a[0],a[1],a[2],a[3]);\n\treturn 0;\n}\n", "src_uid": "4fcd8c4955a47661462c326cbb3429bd"} {"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*/", "src_uid": "cec37432956bb0a1ce62a0188fe2d805"} {"source_code": "/***********************************************\n * Program Name: ex1\n * OS: Linus 8\n * Compiler: GCC\n * Author: KlareH \n * Description: \n *\n * ********************************************/\n\n#include \n#define t_mol 1000000007\n\nint main(void){\n int n = 0;\n int i, c1, c2;\n long long all_kind, six_kind;\n \n all_kind = six_kind = 1;\n c1 = c2 = 0;\n \n \n scanf(\"%d\", &n);\n \n for(i = (3 * n);i > 0;i--){\n all_kind *= 3;\n // c1 += all_kind / t_mol;\n all_kind = ( all_kind % t_mol );\n }\n \n //printf(\"all = %d + %d\\n\", c1, all_kind);\n \n for(i = n;i > 0;i--){\n six_kind *= 7;\n // c2 += six_kind / t_mol;\n six_kind = ( six_kind % t_mol );\n }\n\n //printf(\"six = %d + %d\\n\", c2, six_kind);\n \n //c1 -= c2;\n \n all_kind = all_kind - six_kind;\n if (all_kind < 0 ){\n // c1 -= 1;\n all_kind += t_mol;\n }\n printf(\"%d\\n\", all_kind);\n\n return 0;\n}\n", "src_uid": "eae87ec16c284f324d86b7e65fda093c"} {"source_code": "#include \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}", "src_uid": "4b9cf82967aa8441e9af3db3101161e9"} {"source_code": "#include\nint main()\n{\n int a1,a2,a3,b1,b2,b3;\n scanf(\"%d%d%d\",&a1,&a2,&a3);\n scanf(\"%d%d%d\",&b1,&b2,&b3);\n if((a1==0&&a2==0&&a3!=0)||(b1==0&&b2==0&&b3!=0)) printf(\"0\");\n else if((a1*b2-a2*b1)!=0) printf(\"1\");\n else if((a1*b3-b1*a3)==0) printf(\"-1\");\n else printf(\"0\");\n return 0;\n} ", "src_uid": "c8e869cb17550e888733551c749f2e1a"} {"source_code": "#include \n#include \n#include \n\nint main() {\n\tstatic char s[256], used[26];\n\tint n, i, max, cnt;\n\n\tscanf(\"%d%s\", &n, s);\n\tmax = cnt = 0;\n\tfor (i = 0; i < n; i++)\n\t\tif (isupper(s[i])) {\n\t\t\tmemset(used, 0, sizeof used);\n\t\t\tcnt = 0;\n\t\t} else {\n\t\t\tif (!used[s[i] - 'a']) {\n\t\t\t\tused[s[i] - 'a'] = 1;\n\t\t\t\tcnt++;\n\t\t\t}\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", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3"} {"source_code": "#include \ntypedef long long int i64;\ni64 min(i64 a, i64 b) {\n return a < b ? a : b;\n}\nint main(void) {\n i64 a, b, c, d, ans = 0;\n scanf(\"%I64d%I64d%I64d%I64d\", &a, &b, &c, &d);\n for (int i = 0; i <= 100; i++) {\n\t\tfor (int j = 0; j <= 100; j++) {\n\t\t\tif (b + a*i == d + c*j) {\n\t\t\t\tans = ans == 0 ? b + a * i : min(b + a*i, ans);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%I64d\", ans ? ans : -1);\n\treturn 0;\n}", "src_uid": "158cb12d45f4ee3368b94b2b622693e7"} {"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}", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4"} {"source_code": "#include\n#include\nvoid zidian(char str[]);\nint main()\n{\n\tint i,len;\n\tchar str[11];\n\tchar s1[11],s2[11];\n\tscanf(\"%s\",str);\n\tlen=strlen(str);\n\tif(len%2==0)\n\t{\n\t\tfor(i=0;i=0)\n\t\t\t\t{\n\t\t\t\t\tstrcpy(str,s1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tzidian(s1);\n\t\t\t}\n\t\t}\n\n\t\t\t\n\t}\n\telse\n\t{\n\t\t\n\t\t\n\t\t\tlen+=1;\n\t\t\tfor(i=0;i\nint main()\n{\n int p,q,n,d,i,j,a[105],l=1099,k=0,z=0;\n scanf(\"%d %d\",&n,&d);\n for(i=0;i\nint main()\n{\n\tint a,b,y,i=0;\n\tscanf(\"%d%d\",&a,&b);\n\twhile(a<=b)\n\t{\n\t\ta=a*3;\n\t\tb=b*2;\n\t\ti++;\n\t}\n\tprintf(\"%d\\n\",i);\n\treturn 0;\n}\t\n", "src_uid": "a1583b07a9d093e887f73cc5c29e444a"} {"source_code": "#include \n#include \n#include \nint Abs(int a){return a>=0?a:-a;}\nint main()\n{ int tab[5][2],i,j,stop=0,res,n;\n scanf(\"%d\",&n);\n for(i=0;i\n//需要反向!\n//没有什么参数可以减少的!\n//ABCD 0123\n//直接进行记忆\n//ABCD 0123\nint way[4][10000001];\nint main() {\n\tint n;\n\tscanf(\"%d\",&n);\n\tint i,j;\n\tfor(i=0;i<4;i++){\n\t\tway[i][0]=0;\n\t}\n\tway[0][1]=1;\n\tway[1][1]=1;\n\tway[2][1]=1;\n\tway[3][1]=0;\n\tfor(j=2;j<=n;j++){\n\t\tway[0][j]=((way[1][j-1]+way[2][j-1])%MOD+way[3][j-1])%MOD;\n\t\tway[1][j]=((way[2][j-1]+way[3][j-1])%MOD+way[0][j-1])%MOD;\n\t\tway[2][j]=((way[3][j-1]+way[0][j-1])%MOD+way[1][j-1])%MOD;\n\t\tway[3][j]=((way[0][j-1]+way[1][j-1])%MOD+way[2][j-1])%MOD;\n\t\t//printf(\"%d %d %d %d\\n\", way[0][j],way[1][j],way[2][j],way[3][j]);\n\n\t}\n\t/*有下面的四个公式反导出\n\t way[0][step]=way[1][step-1]+way[2][step-1]+way[3][step-1];\n\t way[1][step]=way[2][step-1]+way[3][step-1]+way[0][step-1];\n\t way[2][step]=way[3][step-1]+way[0][step-1]+way[1][step-1];\n\t way[3][step]=way[0][step-1]+way[1][step-1]+way[2][step-1];\n\t */\n\t/*做了无用的工作\n\t way[0][step]=way[1][step-1]+way[2][step-1]+way[3][step-1];\n\t way[1][step-1]=way[2][step-1]+way[3][step-1]+way[0][step-1];\n\t way[2][step-1]=(-1*way[0][step]+1*way[1][step]+(-2)*way[2][step]+1*way[3][step])/3;\n\t way[3][step-1]=(-1*way[0][step]+1*way[1][step]+1*way[2][step]+(-2)*way[3][step])/3;\n\t */\n\tprintf(\"%d\\n\",way[3][n]);\n\treturn 0;\n}\n", "src_uid": "77627cc366a22e38da412c3231ac91a8"} {"source_code": "#include \n#include \n#include \n\nint main () {\n\t\n\tdouble x, y, z;\n\t\n\tdouble max;\n\tint ind = 0;\n\t\n\tscanf(\"%lf %lf %lf\", &x, &y, &z);\n\t\n\tif (x - 1.0 < 1e-6 && y - 1.0 < 1e-6 && z - 1.0 < 1e-6) {\n\t\t\n\t\tmax = 1000000;\n\t\t\n\t\tif (z * log(y) + log(log(1 / x)) - max < -1e-6) {\n\t\t\tmax = z * log(y) + log(log(1 / x));\n\t\t\tind = 1;\n\t\t}\n// printf(\"%.15lf\\n\", z * log(y) + log(log(1 / x)));\n\t\tif (y * log(z) + log(log(1 / x)) - max < -1e-6) {\n\t\t\tmax = y * log(z) + log(log(1 / x));\n\t\t\tind = 2;\n\t\t}\n// printf(\"%.15lf\\n\", y * log(z) + log(log(1 / x)));\n\t\tif (log(y) + log(z) + log(log(1 / x)) - max < -1e-6) {\n\t\t\tmax = log(y) + log(z) + log(log(1 / x));\n\t\t\tind = 3;\n\t\t}\n// printf(\"%.15lf\\n\", log(y) + log(z) + log(log(1 / x)));\n\t\t\n\t\t\n\tif (z * log(x) + log(log(1 / y)) - max < -1e-6) {\n\t\t\tmax = z * log(x) + log(log(1 / y));\n\t\t\tind = 5;\n\t\t}\n// printf(\"%.15lf\\n\", z * log(x) + log(log(1 / y)));\n\t\tif (x * log(z) + log(log(1 / y)) - max < -1e-6) {\n\t\t\tmax = x * log(z) + log(log(1 / y));\n\t\t\tind = 6;\n\t\t}\n// printf(\"%.15lf\\n\", x * log(z) + log(log(1 / y)));\n\t\tif (log(x) + log(z) + log(log(1 / y)) - max < -1e-6) {\n\t\t\tmax = log(x) + log(z) + log(log(1 / y));\n\t\t\tind = 7;\n\t\t}\n// printf(\"%.15lf\\n\", log(x) + log(z) + log(log(1 / y)));\n\t\t\n\t\t\n\tif (y * log(x) + log(log(1 / z)) - max < -1e-6) {\n\t\t\tmax = y * log(x) + log(log(1 / z));\n\t\t\tind = 9;\n\t\t}\n// printf(\"%.15lf\\n\", y * log(x) + log(log(1 / z)));\n\t\tif (x * log(y) + log(log(1 / z)) - max < -1e-6) {\n\t\t\tmax = x * log(y) + log(log(1 / z));\n\t\t\tind = 10;\n\t\t}\n// printf(\"%.15lf\\n\", x * log(y) + log(log(1 / z)));\n\t\tif (log(x) + log(y) + log(log(1 / z)) - max < -1e-6) {\n\t\t\tmax = log(x) + log(y) + log(log(1 / z));\n\t\t\tind = 11;\n\t\t}\n// printf(\"%.15lf\\n\", log(x) + log(y) + log(log(1 / z)));\n\t\t\n\t\t\n\t} else {\n\t\t\n\t\tmax = -1000;\n\t\t\n\t\tif (x - 1.0 > 0.01) {\n\t\t\tif (z * log(y) + log(log(x)) - max > 1e-6) {\n\t\t\t\tmax = z * log(y) + log(log(x));\n\t\t\t\tind = 1;\n\t\t\t}\n// printf(\"%.15lf\\n\", z * log(y) + log(log(x)));\n\t\t\tif (y * log(z) + log(log(x)) - max > 1e-6) {\n\t\t\t\tmax = y * log(z) + log(log(x));\n\t\t\t\tind = 2;\n\t\t\t}\n// printf(\"%.15lf\\n\", y * log(z) + log(log(x)));\n\t\t\tif (log(y) + log(z) + log(log(x)) - max > 1e-6) {\n\t\t\t\tmax = log(y) + log(z) + log(log(x));\n\t\t\t\tind = 3;\n\t\t\t}\n// printf(\"%.15lf\\n\", log(y) + log(z) + log(log(x)));\n\t\t}\n\t\t\n\t\tif (y - 1.0 > 0.01) {\n\t\t\tif (z * log(x) + log(log(y)) - max > 1e-6) {\n\t\t\t\tmax = z * log(x) + log(log(y));\n\t\t\t\tind = 5;\n\t\t\t}\n// printf(\"%.15lf\\n\", z * log(x) + log(log(y)));\n\t\t\tif (x * log(z) + log(log(y)) - max > 1e-6) {\n\t\t\t\tmax = x * log(z) + log(log(y));\n\t\t\t\tind = 6;\n\t\t\t}\n// printf(\"%.15lf\\n\", x * log(z) + log(log(y)));\n\t\t\tif (log(x) + log(z) + log(log(y)) - max > 1e-6) {\n\t\t\t\tmax = log(x) + log(z) + log(log(y));\n\t\t\t\tind = 7;\n\t\t\t}\n// printf(\"%.15lf\\n\", log(x) + log(z) + log(log(y)));\n\t\t}\n\t\t\n\t\tif (z - 1.0 > 0.01) {\n\t\t\tif (y * log(x) + log(log(z)) - max > 1e-6) {\n\t\t\t\tmax = y * log(x) + log(log(z));\n\t\t\t\tind = 9;\n\t\t\t}\n// printf(\"%.15lf\\n\", y * log(x) + log(log(z)));\n\t\t\tif (x * log(y) + log(log(z)) - max > 1e-6) {\n\t\t\t\tmax = x * log(y) + log(log(z));\n\t\t\t\tind = 10;\n\t\t\t}\n// printf(\"%.15lf\\n\", x * log(y) + log(log(z)));\n\t\t\tif (log(x) + log(y) + log(log(z)) - max > 1e-6) {\n\t\t\t\tmax = log(x) + log(y) + log(log(z));\n\t\t\t\tind = 11;\n\t\t\t}\n// printf(\"%.15lf\\n\", log(x) + log(y) + log(log(z)));\n\t\t}\n\t}\n\t\n\tswitch (ind) {\n\t\tcase 1:\n\t\t\tprintf(\"x^y^z\\n\");\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tprintf(\"x^z^y\\n\");\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tprintf(\"(x^y)^z\\n\");\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tprintf(\"(x^z)^y\\n\");\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tprintf(\"y^x^z\\n\");\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tprintf(\"y^z^x\\n\");\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tprintf(\"(y^x)^z\\n\");\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tprintf(\"(y^z)^x\\n\");\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tprintf(\"z^x^y\\n\");\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tprintf(\"z^y^x\\n\");\n\t\t\tbreak;\n\t\tcase 11:\n\t\t\tprintf(\"(z^x)^y\\n\");\n\t\t\tbreak;\n\t\tcase 12:\n\t\t\tprintf(\"(z^y)^x\\n\");\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tprintf(\"ERROR\\n\");\n\t}\n\t\n\treturn 0;\n\t\n}", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c"} {"source_code": "#include \n#include \n#include \n\n\nint main()\n{\n long double r, g, b;\n double n, k;\n unsigned long int x;\n\n scanf(\"%lf %lf\", &n, &k);\n\n r = ceil(2*n/k);\n g = ceil(5*n/k);\n b = ceil(8*n/k);\n\n x = r+g+b;\n\n\n printf(\"%lu\", x);\n\n\n return 0;\n}\n", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39"} {"source_code": "#include\n#define TRI (cc && a>b)\n t=c,c=a,a=t;\n else if(b>c && b>a)\n t=c,c=b,b=t;\n if(!TRI)\n printf(\"%d\",c-a-b+1);\n else\n printf(\"0\");\n \n}", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09"} {"source_code": "//Problem 331C1: https://codeforces.com/problemset/problem/331/C1?locale=en\n\n#include \n\nint max(int a, int b);\n\nint main() {\n int cnt = 0;\n\n unsigned long long n;\n scanf(\"%llu\", &n);\n int bigger = 0;\n\n while (n) {\n unsigned long long k = n;\n int aux = -1;\n while (k) {\n bigger = max(aux, k % 10);\n aux = bigger;\n k /= 10;\n }\n n -= bigger;\n cnt++;\n }\n\n printf(\"%d\", cnt);\n return 0;\n}\n\nint max(int a, int b) {\n return a > b ? a : b;\n}", "src_uid": "fc5765b9bd18dc7555fa76e91530c036"} {"source_code": "#include \"stdio.h\"\nint main(int argc, char const *argv[])\n{\n\tint n;\n\twhile(~scanf(\"%d\", &n))\n\t{\n\t\tif(n%3==0)\n\t\t{\n\t\t\tprintf(\"%d\\n\", 2*n/3);\n\t\t}\n\t\telse \n\t\t{\n\t\t\tif((n+1)%3==0)\n\t\t\t{\n\t\t\t\tprintf(\"%d\\n\", 2*(n+1)/3-1);\n\t\t\t}\n\t\t\tif((n+2)%3==0)\n\t\t\t{\n\t\t\t\tprintf(\"%d\\n\", 2*(n+2)/3-1);\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "src_uid": "a993069e35b35ae158d35d6fe166aaef"} {"source_code": "#include\n#define MAX 100000\nint arr[MAX];\nint main(int argc, char const *argv[])\n{\n int n,maxh,nr,i,sh,eh,rh,j,sum=0;\n scanf(\"%d%d%d\",&n,&maxh,&nr);\n for(i=1;i<=n;i++)\n {\n arr[i]=maxh;\n }\n for(i=1;i<=nr;i++)\n {\n scanf(\"%d%d%d\",&sh,&eh,&rh);\n for(j=sh;j<=eh;j++)\n {\n if(arr[j]>rh)\n arr[j]=rh; \n }\n\n }\n for(i=1;i<=n;i++)\n {\n sum=sum+arr[i]*arr[i];\n }\n printf(\"%d\",sum);\n\n return 0;\n}\n", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad"} {"source_code": "#include \n#include \n#include \n\nmain( )\n{ int x,y,d;\nscanf(\"%d%d\",&x,&y);\nif(x=y-1)\n{\n y=y-1;\n d=x-y;\n if(y==0&&x>0)\n printf(\"NO\");\n\n else if(d%2==0)\n printf(\"YES\");\n else\n printf(\"NO\");\n}\n\n\n\n\n\n\n }\n", "src_uid": "1527171297a0b9c5adf356a549f313b9"} {"source_code": "#include\nint main(void)\n{\n int h,w,u1,d1,u2,d2,max,other,weight,other_w;\n scanf(\"%d %d %d %d %d %d\",&w,&h,&u1,&d1,&u2,&d2);\n max=d1>d2?d1:d2;\n other=d1+d2-max;\n if(max==d1)\n {\n weight=u1;\n other_w=u2;\n }\n else\n {\n weight=u2;\n other_w=u1;\n }\n for(h;h>=max;h--)\n w+=h;\n if(w>=weight)\n w-=weight;\n else\n w=0;\n for(h;h>=other;h--)\n w+=h;\n if(w>=other_w)\n w-=other_w;\n else\n w=0;\n for(h;h>=0;h--)\n w+=h;\n printf(\"%d\\n\",w);\n return 0;\n}\n", "src_uid": "084a12eb3a708b43b880734f3ee51374"} {"source_code": "/* practice with Dukkha */\n#include \n\nint max(int a, int b) { return a > b ? a : b; }\n\nint count(int x1, int x2, int b) {\n\tif (x1 > x2)\n\t\treturn count(x2, x1, b);\n\tif (x1 > 0)\n\t\treturn x2 / b - x1 / b;\n\tif (x2 < 0)\n\t\treturn -x1 / b - -x2 / b;\n\treturn -x1 / b + x2 / b + 1;\n}\n\nint main() {\n\tint a, b, x1, y1, x2, y2, x, y;\n\n\tscanf(\"%d%d%d%d%d%d\", &a, &b, &x1, &y1, &x2, &y2), a *= 2, b *= 2;\n\tx = x1 - y1, y = x1 + y1; x1 = x; y1 = y;\n\tx = x2 - y2, y = x2 + y2; x2 = x; y2 = y;\n\tprintf(\"%d\\n\", max(count(x1, x2, b), count(y1, y2, a)));\n\treturn 0;\n}\n", "src_uid": "7219d1837c83b5920992aee5a60dc0d9"} {"source_code": "#include\nint color[6];\nint main(void)\n{\n int i,one,two,three,four,five,six;\n char ch[10];\n while(scanf(\"%s\",ch)!=EOF)\n {\n for(i=0;i<6;++i) color[i]=0;\n for(i=0;i<6;++i)\n {\n switch(ch[i])\n {\n case 'R': ++color[0];break;\n case 'O': ++color[1];break;\n case 'Y': ++color[2];break;\n case 'G': ++color[3];break;\n case 'B': ++color[4];break;\n case 'V': ++color[5];break;\n }\n }\n for(i=one=two=three=four=five=six=0;i<6;++i)\n {\n switch(color[i])\n {\n case 1: ++one;break;\n case 2: ++two;break;\n case 3: ++three;break;\n case 4: ++four;break;\n case 5: ++five;break;\n case 6: ++six;break;\n }\n }\n if(one==6) puts(\"30\");\n else if(one==4) puts(\"15\");\n else if(one==3) puts(\"5\");\n else if(one==2)\n {\n if(four==1) puts(\"2\");\n else puts(\"8\");\n }\n else if(one==1)\n {\n if(five==1) puts(\"1\");\n else puts(\"3\");\n }\n else\n {\n if(six==1) puts(\"1\");\n else\n {\n if(two==1&&four==1) puts(\"2\");\n else if(three==2) puts(\"2\");\n else if(two==3) puts(\"6\");\n }\n }\n }\n return 0;\n}\n", "src_uid": "8176c709c774fa87ca0e45a5a502a409"} {"source_code": "#include\n#include\nint main()\n{\n\tlong a,b,c,d;\n\tscanf(\"%ld %ld %ld %ld\",&a,&b,&c,&d);\n\tlong ab,bc;\n\t//ab=abs(a-b);\n\t//bc=abs(b-c);\n\t//ca=abs(c-a);\n\tlong time=0;\n\t\n\tlong large,small,mid;\n\t\n\tif(a=d && bc>=d)\n\t{\n\t\ttime=0;\n\t}\n\telse\n\t{\n\t\t\n\t\t\n\t\t\tif(ab>=d)\n\t\t\t{\n\t\t\t\ttime=d-bc;\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(bc>=d)\n\t\t\t{\n\t\t\t\ttime=d-ab;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ttime=d-ab+d-bc;\n\t\t\t}\n\t\t\n\t}\n\tprintf(\"%ld\",time);\n\treturn 0;\n\t\n}", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3"} {"source_code": "//491bishwock\n#include\nint main()\n{\n char s[2][101];\n int bishwock=0,i,row=0,avail=0;\n for(i=0;i<2;i++)\n scanf(\"%s\",s[i]);\n for(i=0;s[0][i];i++)\n {\n row=(s[0][i]=='0')+(s[1][i]=='0');\n avail+=row;\n if(avail>=3)\n {\n avail-=3;\n bishwock++;\n }\n else avail=row;//not in bishwock shape\n }\n printf(\"%d\\n\",bishwock);\n return 0;\n}\n", "src_uid": "e6b3e787919e96fc893a034eae233fc6"} {"source_code": "#include \n#include \n\nint main(){\n\tint x;\n\tscanf(\" %d\",&x);\n\tif( x==1 ){\n\t\tprintf(\"1\");\n\t}\n\telse if ( x==2 ){\n\t\tprintf(\"3\");\n\t}\n\telse if ( x==3 ){\n\t\tprintf(\"5\");\n\t}\n\telse if( x==4 ){\n\t\tprintf(\"3\");\n\t}\n\telse if( x==5 ){\n\t\tprintf(\"3\");\n\t}\n\telse if( x>5 && x<=13 ){\n\t\tprintf(\"5\");\n\t}\n\telse if( x>13 && x<=25 ){\n\t\tprintf(\"7\");\n\t}\n\telse if( x>25 && x<=41 ){\n\t\tprintf(\"9\");\n\t}\n\telse if( x>41 && x<=61 ){\n\t\tprintf(\"11\");\n\t}\n\telse if( x>61 && x<=85 ){\n\t\tprintf(\"13\");\n\t}\n\telse if( x>85 && x<=100 ){\n\t\tprintf(\"15\");\n\t}\n\treturn 0;\n}", "src_uid": "01eccb722b09a0474903b7e5abc4c47a"} {"source_code": "#include \n#include \n\nint compare(const void *a, const void *b) {\n\tint ia = *(int *) a;\n\tint ib = *(int *) b;\n\t\n\treturn ib - ia;\n}\n\nint main() {\n\tstatic int tt[128];\n\tint n, m, i;\n\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &tt[i]);\n\tfor (i = 0; i < n; i++) {\n\t\tint t, cnt;\n\n\t\tt = tt[i];\n\t\tcnt = 0;\n\t\tm -= t;\n\t\tif (m < 0) {\n\t\t\tstatic int aa[128];\n\t\t\tint j, m_;\n\n\t\t\tfor (j = 0; j < i; j++)\n\t\t\t\taa[j] = tt[j];\n\t\t\tqsort(aa, i, sizeof *aa, compare);\n\t\t\tm_ = m;\n\t\t\tfor (j = 0; j < i && m_ < 0; j++) {\n\t\t\t\tm_ += aa[j];\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d \", cnt);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346"} {"source_code": "/* Problem: 388A - Fox and Box Accumulation */\n/* Solver: Gusztav Szmolik */\n\n#include \n#include \n\nunsigned short x[100];\nunsigned short s[100];\n\nint cmp (const void*, const void*);\n\nint main ()\n {\n unsigned short n;\n unsigned short i;\n unsigned short pc;\n unsigned short bc;\n unsigned short sc;\n \n if (scanf(\"%hu\",&n) != 1)\n return -1;\n if (n < 1 || n > 100)\n return -1;\n for (i = 0; i < n; i++)\n {\n if (scanf(\"%hu\",&x[i]) != 1)\n return -1;\n if (x[i] > 100)\n return -1;\n s[i] = 0;\n }\n qsort (x,n,sizeof(unsigned short),cmp);\n pc = bc = 0;\n while (bc < n)\n {\n sc = 0;\n for (i = 0; i < n; i++)\n if (!s[i] && x[i] >= sc)\n {\n s[i] = 1;\n sc++;\n bc++;\n }\n pc++;\n }\n printf (\"%hu\\n\",pc);\n return 0;\n }\n \nint cmp (p1,p2)\n const void* p1;\n const void* p2;\n {\n unsigned short x1;\n unsigned short x2;\n \n x1 = *(unsigned short*)p1;\n x2 = *(unsigned short*)p2;\n if (x1 == x2)\n return 0;\n return (x1 > x2 ? 1 : -1);\n }\n", "src_uid": "7c710ae68f27f140e7e03564492f7214"} {"source_code": "#include\n#include\nint main()\n{\n int n,a[250]={0},k,i=0,j;\n char b[250]=\"\\0\";\n scanf(\"%d\",&n);\n scanf(\"%s\",b);\n while(i=0)&&(a[j]>k);j--)\n a[j+1]=a[j];\n a[j+1]=k;\n }\n for(i=n+1;i<2*n;i++)\n {\n k=a[i];\n for(j=i-1;(j>=n)&&(a[j]>k);j--)\n a[j+1]=a[j];\n a[j+1]=k;\n }\n \n j=0;\n k=0; \n\n for(i=0;ia[i+n])\n k++;\n }\n\n if((j==i)||(k==i))\n printf(\"YES\");\n else\n printf(\"NO\");\n return(0);\n } \n", "src_uid": "e4419bca9d605dbd63f7884377e28769"} {"source_code": "#include \n#include \n\nint main(int argc, char const *argv[])\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint arr[n];\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tscanf(\"%d\",&arr[i]);\n\t}\n\tint total_min_index = 0 , total_max_index = 0;\n\tint total_length = 0,curr_length;\n\tint curr_min_index = 0 , curr_max_index = 0;\n\tint flag = 1;\n\n\tfor (int i = 0; i < n-1; ++i)\n\t{\n\t\tif (flag == 1)\n\t\t{\n\t\t\tcurr_min_index = i;\n\t\t}\n\n\t\tif(arr[i+1] == arr[i]+1)\n\t\t{\n\t\t\tcurr_max_index = i+1;\n\t\t\tflag = 0;\n\t\t}\n\n\t\tif(arr[i+1] != arr[i]+1 || (arr[i+1] == arr[i]+1 && i == n-2))\n\t\t{\n\t\t\tif (flag == 0)\n\t\t\t{\n\t\t\t\tif (curr_min_index == 0 && arr[curr_min_index] == 1)\n\t\t\t\t{\n\t\t\t\t\tcurr_length = curr_max_index - curr_min_index;\n\t\t\t\t}\n\t\t\t\telse if (curr_max_index == n-1 && arr[curr_max_index] == 1000)\n\t\t\t\t{\n\t\t\t\t\tcurr_length = curr_max_index - curr_min_index;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcurr_length = curr_max_index - curr_min_index - 1;\n\t\t\t\t}\n\t\t\t\tif (curr_length > total_length)\n\t\t\t\t{\n\t\t\t\t\ttotal_length = curr_length;\n\t\t\t\t\ttotal_max_index = curr_max_index;\n\t\t\t\t\ttotal_min_index = curr_min_index;\n\t\t\t\t}\n\t\t\t}\n\t\t\tflag = 1;\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\",total_length);\n\treturn 0;\n}", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198"} {"source_code": "#include \n#include \n#include \nint main (void)\n{\n int n;\n int i;\n int count;\n int sum;\n int j;\n int temp;\n double aver;\n int t[6];\n while(scanf(\"%d\",&n)!=EOF){\n sum = 0;\n memset(t,0,sizeof(t));\n count = 0;\n for(i = 0; i < n; i++){\n scanf(\"%d\", &temp);\n t[temp]++;\n }\n aver = 4.5*n;\n for(i = 2; i <= 5; i++)\n sum = sum + t[i]*i;\n for(i = 2; i <= 5; i++){\n if(sum>=aver)\n break;\n for(j = 0; j < t[i]; j++)\n if(sum < aver){\n sum = sum + (5-i);\n count++;\n }\n else\n break;\n }\n printf(\"%d\",count);\n }\n return 0;\n}\n", "src_uid": "715608282b27a0a25b66f08574a6d5bd"} {"source_code": "#include\n#include\n\nint func(int x);\n\nint main(){\n\tint n,i; \n\tint ent;\n\n\tscanf(\"%d\",&n);\n\n\tfor(i=0;i\n#include\n#include\nint main()\n{\n\tint n,i,j,c=0,d=0,k,l;\n\tchar s[51];\n\tscanf(\"%s\",s);\n\tn=strlen(s);\n\t/*if(n%2==0)\n\t{\n\t\tk=(n/2)-1;\n\t\tj=1;\n\t\tfor(i=k;i>=0;i--)\n\t\t{\n\t\t\tif(j<=n/2)\n\t\t\t{\n\t\t\t\tif(s[i]==s[(2*i)+j])\n\t\t\t\t{\n\t\t\t\t\tc++;\n\t\t\t\t\t//printf(\"%d--\\n\",c);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\td++;\n\t\t\t\t}\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tj=2;\n\t\t\n\t\tfor(i=(n/2)-1;i>=0;i--)\n\t\t{\n\t\t\tif(j<=(n/2)+1)\n\t\t\t{\n\t\t\t\tif(s[i]==s[(2*i)+j])\n\t\t\t\t{\n\t\t\t\t\tc++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\td++;\n\t\t\t\t}\n\t\t\t\tj++;\n\t\t\t}\n\t\t\n\t\t}\n\t}\n\tif(c==0)\n\t{\n\t\tprintf(\"%d\",n);\n\t}\n\telse if(d==0)\n\t{\n\t\tprintf(\"%d\",c);\n\t}\n\telse\n\t{\n\t\tprintf(\"%d\",(2*c)+d);\n\t}*/\n\tchar g;\n\tchar t[51];\n\t//t=s;\n\tstrcpy(t,s);\n\tfor( i=0;i=1;j--)\n\ts[j]=s[j-1];\n\ts[0]=ch;\n\tc++;\n\tif(strcmp(t,s)==0)break;\n\t}\n\tprintf(\"%d\",c);\n\treturn 0;\n}\n", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e"} {"source_code": "#include \n\nint main()\n{\n int n,t,a,m,i,sum;\n while(~scanf(\"%d%d\",&n,&m))\n {\n sum=1;\n for(i=0;i\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}", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27"} {"source_code": "#include \n\nint main() {\n\tint i, x, y, a, b, c;\n\n\tscanf(\"%d%d\", &x, &y);\n\ta = b = c = y;\n\tfor (i = 0; a < x; i++) {\n\t\tint d = x < b + c - 1 ? x : b + c - 1;\n\n\t\ta = b, b = c, c = d;\n\t}\n\tprintf(\"%d\\n\", i);\n\treturn 0;\n}\n", "src_uid": "8edf64f5838b19f9a8b19a14977f5615"} {"source_code": " #include\n int main() \n { \n int n,i,x=0,y=0,j; \n long a[1001]; \n scanf(\"%d\",&n); \n for(i=0;ia[i]&&a[j]>a[i+1])||(a[j]\nint main()\n{\n\tint a,b,c,d,s1=0,s2=0,c1=0,c2=0;\n\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n\ts1=a*3/10;\n\ts2=(a-a*c/250);\n\tif(s1>s2) s1=s1;\n\telse s1=s2;\n\tc1=b*3/10;\n\tc2=(b-b*d/250);\n\tif(c1>c2) c1=c1;\n\telse c1=c2;\n\t\n\t\n\tif(s1>c1) printf(\"Misha\\n\");\n\telse if(c1>s1) printf(\"Vasya\\n\");\n\telse printf(\"Tie\\n\");\n\t\n\treturn 0;\n}", "src_uid": "95b19d7569d6b70bd97d46a8541060d0"} {"source_code": "#include \n\nint count_zero(int n)\n{\n int ans = 0;\n while(n){\n n /= 5;\n ans += n;\n }\n return ans;\n}\n\nint main()\n{\n\tint n, zero;\n\tscanf(\"%d\", &n);\n\n\tint high, low, mid;\n\tlow = 0;\n\thigh = 1000000;\n\twhile (low <= high){\n mid = low + high;\n zero = count_zero(mid);\n if (zero == n){\n int res = (mid / 5) * 5;\n printf(\"5\\n%d %d %d %d %d\", res, res+1, res+2, res+3, res+4);\n return 0;\n }\n else if (zero > n)high = mid - 1;\n else if (zero < n)low = mid + 1;\n\t}\n\tprintf(\"0\");\n\treturn 0;\n}\n\n", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744"} {"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}", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee"} {"source_code": "#include\nint main()\n{\nlong long n;scanf(\"%I64d\",&n);\nprintf(\"%I64d\",n<3?n:n%2?(n*(n-1)*(n-2)):n%3?(n*(n-1)*(n-3)):(n-1)*(n-2)*(n-3));\nreturn 0;\n}\n", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e"} {"source_code": "#include\n#include\nint main()\n{\n char str[1000];\n scanf(\"%s\",str);\n // printf(\"%s\",str);\n int i,cnt1=0,cnt2=0;\n int ln=(strlen(str));\n for(i=0; icnt2)\n printf(\"%d\\n\",ln);\n else if(cnt1==cnt2)\n printf(\"%d\\n\",ln-1);\n else\n printf(\"%d\\n\",ln-((cnt2-cnt1)+1));\n\n }\n", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219"} {"source_code": "#include\n#include\n// long long int poww(long long int a, long long int b)\n// {\n// \tlong long int i,ret=1;\n// \tfor(i=0;i36)\n\t{\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\tlong long int ans = 0;\n\tlong long int i = 0, mul = 1;\n\tfor(i=0;i<(k/2);i++)\n\t{\n\t\tans = ans + 8 * mul;\n\t\tmul = mul * 10;\n\t}\n\tif(k%2 == 1)\n\t{\n\t\tans = ans*10 + 4;\n\t}\n\t\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "src_uid": "0c9973792c1976c5710f88e3520cda4e"} {"source_code": "#include \n\nint main()\n{\n int n,k,R;\n scanf(\"%d%d\",&n,&k);\n if(k<2*n){\n R = 0;\n }else{\n R = n-k+(2*n);\n if(R<0){\n R = 0;\n }\n }\n printf(\"%d\",R);\n return 0;\n}\n", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8"} {"source_code": "#include\n#include\nint asc(const void* a, const void* b)\n{\n\treturn *(int*)a - *(int*)b;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint i;\n\tint x[50], y[50];\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t\tscanf(\"%d %d\", &x[i], &y[i]);\n\tint xx[50], yy[50];\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t\txx[i] = x[i];\n\tqsort(xx, 4 * n + 1, sizeof(int), asc);\n\tif (xx[0] != xx[1])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (x[i] == xx[0])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tif (xx[4 * n - 1] != xx[4 * n])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (x[i] == xx[4 * n])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t\tyy[i] = y[i];\n\tqsort(yy, 4 * n + 1, sizeof(int), asc);\n\tif (yy[0] != yy[1])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (y[i] == yy[0])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tif (yy[4 * n - 1] != yy[4 * n])\n\t{\n\t\tfor (i = 0; i < 4 * n + 1; i++)\n\t\t{\n\t\t\tif (y[i] == yy[4 * n])\n\t\t\t{\n\t\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tint maxx, minx, maxy, miny;\n\tmaxx = maxy = 0;\n\tminx = miny = 100;\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t{\n\t\tif (x[i] < minx)minx = x[i];\n\t\tif (x[i] > maxx)maxx = x[i];\n\t\tif (y[i] < miny)miny = y[i];\n\t\tif (y[i] > maxy)maxy = y[i];\n\t}\n\tfor (i = 0; i < 4 * n + 1; i++)\n\t{\n\t\tif (x[i] != minx && x[i] != maxx && y[i] != miny && y[i] != maxy)\n\t\t{\n\t\t\tprintf(\"%d %d\\n\", x[i], y[i]);\n\t\t\treturn 0;\n\t\t}\n\t}\n}", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06"} {"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}", "src_uid": "b2d59b1279d891dba9372a52364bced2"} {"source_code": "#include\n#include\n#include\n#include\n#define REP(i,a,b) for(i=a;i=0) ok_g = 1;\n if(r>=0) ok_r = 1;\n }\n continue;\n }\n\n if(r > g) m = r-g-1; else m = g-r-1;\n rep(j,10) if(m&1<\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\n#include \n\n/* maximum factors count, 10 must be enough. I take few more ) */\nconst int64_t cnt = 1000; \n\nint64_t\ndecompose(int64_t x, int64_t *p)\n{\n /* factors counter */\n int64_t c = 0;\n /* separate process for 2 */\n if (x % 2 == 0)\n p[c++] = 2;\n while (x % 2 == 0)\n x /= 2;\n\n for (int64_t d = 3; d*d <= x; d += 2)\n {\n if (x % d == 0)\n p[c++] = d;\n while (x % d == 0)\n x /= d;\n }\n if (x != 1) {\n p[c++] = x;\n }\n return c;\n}\n\nint\nmain()\n{\n int64_t x;\n int64_t p[cnt];\n scanf(\"%\"SCNd64, &x);\n\n int64_t c = decompose(x, p);\n\n int64_t min_f = x - p[c-1] + 1;\n int64_t min = min_f;\n for (int64_t f = min_f; f < x; ++f) {\n c = decompose(f, p);\n if ((c != 1 || p[0] != f) && f - p[c-1] + 1 < min)\n min = f - p[c-1] + 1;\n }\n printf(\"%\"PRId64\"\\n\", min);\n return 0;\n}\n", "src_uid": "43ff6a223c68551eff793ba170110438"} {"source_code": "#include \n\n\nint pod(int n) {\n int p = 1;\n while(n > 0) {\n p *= n % 10;\n n /= 10;\n }\n return p;\n}\n\n\nint max(int a, int b) {\n return a > b ? a : b;\n}\n\n\nint main() {\n int n;\n scanf(\"%d\", &n);\n int maxpod = pod(n);\n int a = n / 10, b = 10;\n while(a > 0) {\n maxpod = max(maxpod, pod(a * b - 1));\n a /= 10; b *= 10;\n }\n printf(\"%d\\n\", maxpod);\n return 0;\n}\n", "src_uid": "38690bd32e7d0b314f701f138ce19dfb"} {"source_code": "#include\n#include\nint main()\n{\n\tchar str[110];\n\tint A[4]={0};\n\tscanf(\"%s\",str);\n\tint len=strlen(str);\n\tfor(int i=0;i\r\nint main(){\r\n int n,i,j,k;\r\n scanf(\"%d\",&n);\r\n int num[n];\r\n for(i=0; i\n#define REP(i,a,b) for(i=a;i= N || nj >= N || mp[ni][nj]=='S') continue;\n mp[ni][nj] = 'M';\n }\n }\n \n rep(i,N) rep(j,N) if(cp[i][j]=='S') mp[i][j] = '.';\n rep(i,N-1) rep(j,N) if(cp[i][j]=='S') mp[i+1][j] = 'S';\n }\n\n if(mp[0][0]=='M') puts(\"WIN\"); else puts(\"LOSE\");\n\n return 0;\n}\n", "src_uid": "f47e4ab041288ba9567c19930eb9a090"} {"source_code": "#include\nint main()\n{\n int t,x,i;\n scanf(\"%d\",&t);\n for(i=0;i\n#include\n#define sqr(x) ((x)*(x))\n#define m0(x) memset(x,0,sizeof(x))\n#define m1(x) memset(x,63,sizeof(x))\n#define M 1000000007\n#define N 211111\n\n#define maxN 555\n\nint n, k;\nint dp[maxN][maxN], dp2[maxN][maxN];\nint w[maxN];\n\nint add(int x, int y) {\n\tx += y;\n\tif (x >= M) x-= M;\n\treturn (x);\n}\n\nint min(int a, int b)\n\t{\n\t\tif(a 0) {\n\t\t\tif (j > i) {\n\t\t\t\tint e = i + 1;\n\t\t\t\tint z = dp[j][d] * 1ll * w[e] % M;\n\t\t\t\tdp2[j][d]=(dp2[j][d], z);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint z = (w[i - j + 1] - 1 + M);\n\t\t\tif (z >= M) z -= M;\n\t\t\tz = z * 1ll * w[j] % M;\n\t\t\tz = z * 1ll * dp[j][d] % M;\n\t\t\tdp2[i + 1][min(d + 1, k + 1)]=add(dp2[i + 1][min(d + 1, k + 1)], z);\n\t\t\tz = dp[j][d] * 1ll * w[j] % M;\n\t\t\tdp2[j][d]=add(dp2[j][d], z);\n\t\t}\n\t\tfor ( j = 0; j <= n; j++) for (d = 0; d <= k + 1; d++) dp[j][d] = dp2[j][d];\n\t}\n\tint ans = 0;\n\tfor ( i = 0; i <= n; i++) ans=add(ans, dp[i][k]);\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n\n}\n", "src_uid": "111673158df2e37ac6c019bb99225ccb"} {"source_code": "#include\n\nint main()\n{\n unsigned long long n,m,k,left,right,mid,temp;\n\n scanf(\"%I64u\",&m);\n left=0;\n right=(long long)0xffffffffffffffff;\n while(left=k*k*k)\n {\n temp+=n/(k*k*k);\n k++;\n }\n if(temp==m)printf(\"%I64u\\n\",n);\n else printf(\"-1\\n\");\n\n return 0;\n}\n", "src_uid": "602deaad5c66e264997249457d555129"} {"source_code": "#include \n#define MAX 5\nvoid Read(int *a, int b[])\n{ \n int i; \n scanf(\"%d\", a); \n for (i=0; i<*a; i++)\n scanf(\"%d\", &b[i]); \n return;\n}\nvoid Write(int a)\n{ \n printf(\"%d\\n\", a); \n return;\n}\nvoid Swap(int *a, int *b)\n{\n int t;\n t=*a;\n *a=*b;\n *b=t;\n return;\n}\nvoid QuickSort(int a[], int l, int r)\n{\n int x = a[l + (r - l) / 2];\n int i = l;\n int j = r; \n while(i <= j)\n {\n while(a[i] < x) i++;\n while(a[j] > x) j--;\n if(i <= j)\n {\n Swap(&a[i], &a[j]);\n i++;\n j--;\n }\n }\n if (i\n#include \n\nint n1, n2, k[2];\nlong long dp[222][111][2];\n\nlong long recu(int n, int m, int b){ /* b = 0 -> f | b = 1 -> h */\n\tint i;\n\tlong long sum = 0;\n\tif (m <= 0 && n > 0){\n\t\treturn 0;\n\t}\n\tif (dp[n][m][b] != -1){\n\t\treturn dp[n][m][b];\n\t}\n\tfor (i = 1; i <= k[b]; i++){\n\t\tif (m >= i){\n\t\t\tsum += recu(n - i, n - m, 1 - b);\n\t\t\tif (sum > 100000000){\n\t\t\t\tsum %= 100000000;\n\t\t\t}\n\t\t}\n\t}\n\tdp[n][m][b] = sum;\n\treturn sum;\n}\n\nint main(){\n\tscanf(\"%d%d%d%d\", &n1, &n2, &k[0], &k[1]);\n\tmemset(dp, -1, sizeof(dp));\n\tdp[0][0][0] = dp[0][0][1] = 1;\n\tprintf(\"%Ld\\n\", (recu(n1 + n2, n1, 0) + recu(n1 + n2, n2, 1)) % 100000000);\n\treturn 0;\n}\n", "src_uid": "63aabef26fe008e4c6fc9336eb038289"} {"source_code": "#include\nint main()\n{\n char s[101];\n int i=0,j=0,p,q,r;\n scanf(\"%s\",&s);\n while(s[i]!=0)\n {\n i=i+1;\n }\n while(j<(i-2))\n {\n p=s[j];\n q=s[j+1];\n r=s[j+2];\n if(p+q+r==198 && p!=q && p!=r && q!=r)\n {\n printf(\"Yes\\n\");\n exit(0);\n }\n j=j+1;\n }\n printf(\"No\\n\");\n}", "src_uid": "ba6ff507384570152118e2ab322dd11f"} {"source_code": "\n#include\n#include\nint main()\n{\n long long int p,i,t,n,k,u=0,f;\n scanf(\"%lld%lld\",&n,&k);\n i=sqrt(k*2);\n p=i*(i+1)/2;\n t=i;\n for(;i\n\n#define max(a, b) (((a) > (b)) ? (a) : (b))\n\nstruct dxy\n{\n\tlong long d;\n\tlong long x;\n\tlong long y;\n};\n\nlong long gcd(long long a, long long b)\n{\n\t return (a*b == 0) ? (a + b) : gcd(b, a%b);\n}\n\nstruct dxy ext_euc(long long a, long long b)\n{\n\tlong long x, y;\n\tstruct dxy ans;\n\tif (b == 0)\n\t{\n\t\tans.d = a;\n\t\tans.x = 1;\n\t\tans.y = 0;\n\t\treturn ans;\n\t}\n\t\n\tans = ext_euc(b, a%b);\n\tx = ans.y;\n\ty = ans.x - (a/b)*ans.y;\n\t\n\tans.x = x;\n\tans.y = y;\n\treturn ans;\n}\n\nlong long box(long long numer, long long denom)\n{\n\tif (numer % denom == 0 || (numer >=0 && denom >= 0) || (numer < 0 && denom < 0))\n\t{\n\t\treturn numer / denom;\n\t}\n\t\n\treturn (numer / denom) - 1;\n}\n\nint main()\n{\n\tlong long a1, a2, b1, b2;\n\tlong long L, R;\n\tlong long alpha1, alpha2, r, start, end;\n\tlong long p, p1, q, q1, i, j, ans, base;\n\tlong long hcf;\n\tstruct dxy temp;\n\t\n\tscanf(\"%lld %lld %lld %lld %lld %lld\", &a1, &b1, &a2, &b2, &L, &R);\n\t\n\thcf = gcd(a1, a2);\n\tif ((b2 - b1) % hcf != 0)\n\t{\n\t\tprintf(\"%d\\n\", 0);\n\t\treturn 0;\n\t}\n\t\n\tr = box((b2 - b1), hcf);\n\talpha1 = box(a1, hcf);\n\talpha2 = box(a2, hcf);\n\t\n\ttemp = ext_euc(alpha1, -alpha2);\n\tp = temp.x * r;\n\tp1 = temp.y * r;\n\tif (temp.d < 0)\n\t{\n\t\tp = -p;\n\t\tp1 = -p1;\n\t}\n\t\n\tstart = box((L-b1), a1) + 1;\n\t//printf(\"start = %lld\\n\", start);\n\tstart -= ((L-b1) % a1) == 0 ? 1 : 0;\n\tend = box((R-b1), a1);\n\t\n\tq = box((start-p), alpha2) + 1;\n\tq -= ((start-p) % alpha2) == 0 ? 1 : 0;\n\tq1 = box((end-p), alpha2);\n\t//printf(\"q1 = %lld\\n\", q1);\n\t\n\tbase = box(-p, alpha2) + 1;\n\tbase -= (p % alpha2) == 0 ? 1 : 0;\n\tq = max(q, base);\n\t//printf(\"q = %lld\\n\", q);\n\t\n\tbase = box(-p1, alpha1) + 1;\n\tbase -= (p1 % alpha1) == 0 ? 1 : 0;\n\tq = max(q, base);\n\t//printf(\"q = %lld\\n\", q);\n\t\n\tans = q1 - (q - 1);\n\t//printf(\"ans = %lld\\n\", ans);\n\tif (ans < 0 )\n\t{\n\t\tans = 0;\n\t}\n\n\t/*\n\tj = 0;\n\tfor (i = q; i <= box((end-p), alpha2); i++)\n\t{\n\t\tif (p + i*alpha2 >=0 && p1 + i*alpha1 >= 0)\n\t\t{\n\t\t\tj++;\n\t\t}\n\t}\n\t*/\n\t//printf(\"start = %lld, end = %lld\\n\", start, end);\n\t//printf(\"p = %lld, p1 = %lld, q = %lld, r = %lld\\n\", p, p1, q, r);\n\t//printf(\"%lld %lld\\n\", box((end-p), alpha2), box((start-p), alpha2));\n\t/*\n\tif (p + q*alpha2 < 0 || p1 + q*alpha1 < 0)\n\t{\n\t\tprintf(\"%d\\n\", 0);\n\t\treturn 0;\n\t}\n\t*/\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n\n\n\n\n\n", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4"} {"source_code": "#include \n#include \n\n#define N\t100000\n#define M\t100000\n#define A\t200000\n#define L_\t18\t/* L_ = ceil(log2(A + 1)) */\n#define N_\t(1 << L_)\n#define M0\t469762049\t/* M0 = 56 * 2^23 + 1 */\n#define M1\t595591169\t/* M1 = 71 * 2^23 + 1 */\n\nint MM[2] = { M0, M1 };\n\nlong long power(int a, int k, int md) {\n\tlong long b = a, p = 1;\n\n\twhile (k) {\n\t\tif (k & 1)\n\t\t\tp = p * b % md;\n\t\tb = b * b % md;\n\t\tk >>= 1;\n\t}\n\treturn p;\n}\n\nlong long wu[2][L_ + 1][N_], wv[2][L_ + 1][N_], VV[2], V01;\n\nvoid init() {\n\tint g, l, u, v;\n\n\tV01 = power(M0, M1 - 2, M1);\n\tfor (g = 0; g < 2; g++) {\n\t\tint md = MM[g], i;\n\n\t\tu = power(3, md - 1 >> L_, md), v = power(u, md - 2, md);\n\t\tVV[g] = power(N_, md - 2, md);\n\t\tfor (l = L_; l > 0; l--) {\n\t\t\twu[g][l][0] = wv[g][l][0] = 1;\n\t\t\tfor (i = 1; i < 1 << l; i++)\n\t\t\t\twu[g][l][i] = wu[g][l][i - 1] * u % md, wv[g][l][i] = wv[g][l][i - 1] * v % md;\n\t\t\tu = (long long) u * u % md, v = (long long) v * v % md;\n\t\t}\n\t}\n}\n\nvoid ntt(int *aa, int g, int inverse) {\n\tint md = MM[g], h, i, j, l, r;\n\n\tfor (i = 0, j = 1; j < N_; j++) {\n\t\tint n, tmp;\n\n\t\tn = N_ >> 1;\n\t\twhile ((i ^= n) < n)\n\t\t\tn >>= 1;\n\t\tif (i < j)\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\n\t}\n\tfor (l = 1; l <= L_; l++) {\n\t\tint n = 1 << l, m = n >> 1;\n\n\t\tfor (h = 0; h < N_; h += n)\n\t\t\tfor (r = 0; r < m; r++) {\n\t\t\t\tint a, b;\n\n\t\t\t\ti = h + r, j = i + m;\n\t\t\t\ta = aa[i], b = aa[j] * (inverse ? wv[g][l][r] : wu[g][l][r]) % md;\n\t\t\t\tif ((aa[i] = a + b) >= md)\n\t\t\t\t\taa[i] -= md;\n\t\t\t\tif ((aa[j] = a - b) < 0)\n\t\t\t\t\taa[j] += md;\n\t\t\t}\n\t}\n}\n\nlong long garner(int r0, int r1) {\n\tr1 = (r1 - r0) * V01 % M1;\n\tif (r1 < 0)\n\t\tr1 += M1;\n\treturn (long long) r1 * M0 + r0;\n}\n\nint main() {\n\tstatic long long ans[A + 1];\n\tstatic int aa[N], bb[M], aaa[2][2][N_], bbb[2][2][N_], cc[2][N_];\n\tint n, m, q, g, h, h1, h2, i, j, x, y, z, c;\n\n\tinit();\n\tscanf(\"%d%d%d\", &n, &m, &q);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tfor (j = 0; j < m; j++)\n\t\tscanf(\"%d\", &bb[j]);\n\tif (n == 1 && m == 1)\n\t\tans[aa[0] + bb[0]] = 1;\n\telse if (n == 1)\n\t\tans[aa[0] + bb[0]]--, ans[aa[0] + bb[m - 1]]--;\n\telse if (m == 1)\n\t\tans[aa[0] + bb[0]]--, ans[aa[n - 1] + bb[0]]--;\n\telse {\n\t\tz = aa[0] > aa[1];\n\t\ty = bb[0] > bb[1], c = aa[0] + bb[0];\n\t\tif (z == y)\n\t\t\tans[c]--;\n\t\tx = bb[m - 1] >= bb[m - 2], c = aa[0] + bb[m - 1];\n\t\tif (z == x)\n\t\t\tans[c]--;\n\t\tfor (j = 1; j < m - 1; j++) {\n\t\t\tx = bb[j] >= bb[j - 1], y = bb[j] > bb[j + 1], c = aa[0] + bb[j];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tz = aa[n - 1] >= aa[n - 2];\n\t\ty = bb[0] > bb[1], c = aa[n - 1] + bb[0];\n\t\tif (z == y)\n\t\t\tans[c]--;\n\t\tx = bb[m - 1] >= bb[m - 2], c = aa[n - 1] + bb[m - 1];\n\t\tif (z == x)\n\t\t\tans[c]--;\n\t\tfor (j = 1; j < m - 1; j++) {\n\t\t\tx = bb[j] >= bb[j - 1], y = bb[j] > bb[j + 1], c = aa[n - 1] + bb[j];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tz = bb[0] > bb[1];\n\t\tfor (i = 1; i < n - 1; i++) {\n\t\t\tx = aa[i] >= aa[i - 1], y = aa[i] > aa[i + 1], c = aa[i] + bb[0];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tz = bb[m - 1] >= bb[m - 2];\n\t\tfor (i = 1; i < n - 1; i++) {\n\t\t\tx = aa[i] >= aa[i - 1], y = aa[i] > aa[i + 1], c = aa[i] + bb[m - 1];\n\t\t\tif (!z) {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]--;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]++;\n\t\t\t} else {\n\t\t\t\tif (!x && !y)\n\t\t\t\t\tans[c]++;\n\t\t\t\telse if (x && y)\n\t\t\t\t\tans[c]--;\n\t\t\t}\n\t\t}\n\t\tfor (i = 1; i < n - 1; i++) {\n\t\t\tx = aa[i] >= aa[i - 1], y = aa[i] > aa[i + 1];\n\t\t\tif (!x && !y)\n\t\t\t\taaa[0][0][aa[i]]++;\n\t\t\telse if (x && y)\n\t\t\t\taaa[1][0][aa[i]]++;\n\t\t}\n\t\tfor (j = 1; j < m - 1; j++) {\n\t\t\tx = bb[j] >= bb[j - 1], y = bb[j] > bb[j + 1];\n\t\t\tif (!x && !y)\n\t\t\t\tbbb[0][0][bb[j]]++;\n\t\t\telse if (x && y)\n\t\t\t\tbbb[1][0][bb[j]]++;\n\t\t}\n\t\tfor (h = 0; h < 2; h++) {\n\t\t\tmemcpy(aaa[h][1], aaa[h][0], sizeof aaa[h][0]);\n\t\t\tfor (g = 0; g < 2; g++)\n\t\t\t\tntt(aaa[h][g], g, 0);\n\t\t}\n\t\tfor (h = 0; h < 2; h++) {\n\t\t\tmemcpy(bbb[h][1], bbb[h][0], sizeof bbb[h][0]);\n\t\t\tfor (g = 0; g < 2; g++)\n\t\t\t\tntt(bbb[h][g], g, 0);\n\t\t}\n\t\tfor (h1 = 0; h1 < 2; h1++)\n\t\t\tfor (h2 = 0; h2 < 2; h2++)\n\t\t\t\tfor (g = 0; g < 2; g++) {\n\t\t\t\t\tint md = MM[g], d = h1 == h2 ? md - 2 : 2;\n\n\t\t\t\t\tfor (i = 0; i < N_; i++)\n\t\t\t\t\t\tcc[g][i] = (cc[g][i] + (long long) aaa[h1][g][i] * bbb[h2][g][i] % md * d) % md;\n\t\t\t\t}\n\t\tfor (g = 0; g < 2; g++) {\n\t\t\tint md;\n\t\t\tlong long v;\n\n\t\t\tntt(cc[g], g, 1);\n\t\t\tmd = MM[g], v = VV[g];\n\t\t\tfor (i = 0; i < N_; i++)\n\t\t\t\tcc[g][i] = (long long) cc[g][i] * v % md;\n\t\t}\n\t\tfor (i = 0; i <= A; i++) {\n\t\t\tlong long x = garner(cc[0][i], cc[1][i]);\n\n\t\t\tif (x > (long long) M0 * M1 - x)\n\t\t\t\tx -= (long long) M0 * M1;\n\t\t\tans[i] += x;\n\t\t}\n\t}\n\tans[0]++;\n\tfor (i = 1; i <= A; i++)\n\t\tans[i] += ans[i - 1];\n\twhile (q--) {\n\t\tint x;\n\n\t\tscanf(\"%d\", &x);\n\t\tprintf(\"%lld\\n\", ans[x - 1]);\n\t}\n\treturn 0;\n}\n", "src_uid": "25a6428f57022c12dfabdabbcc69c5a4"} {"source_code": "#include \n#include \n#include \n\nint equations(int m, int n){\n\tint a, b, aux = sqrt(m), aux2 = sqrt(n), mayor, res = 0;\n\tif (aux >= aux2)\n\t\tmayor = aux;\n\telse\n\t\tmayor= aux2;\n\tfor(a = 0; a<=aux; a++){\n\t\tb=0;\n\t\twhile ((a*a + b) <= m){\n\t\t\tif(((a*a + b)==m)&&((b*b + a)==n)){\n\t\t\t\tres++;\n\t\t\t\tb++;}\n\t\t\telse\n\t\t\t\tb++;\n\t\t}\n\t}\n\treturn res;\n}\n\nint main(void){\n\tint m, n;\n\tscanf(\"%d %d\", &m, &n);\n\tprintf(\"%d\\n\", equations(m, n));\n\treturn 0;\n}", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd"} {"source_code": "#include\nint main()\n{\n\tint n;\n\tint k;\n\tint i,sum=0;\n\tint ans=0;\n\tfloat floatk;\n\tscanf(\"%d %d\",&n,&k);\n\tint a[n];\n\t\n\tfor(i=0;i(sum+(k)*ans))\n\t{\n\t\tans=ans+1;\n\t}\n\t\n\tprintf(\"%d\",ans);\n\treturn 0;\n}\n", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900"} {"source_code": "#include \n\n/* http://codeforces.com/contest/411/submission/25959252 (Dukkha) */\n\nint win(int a1, int b1, int a2, int b2) {\n\treturn a1 > b2 && b1 > a2;\n}\n\nint main() {\n\tint a1, b1, a2, b2, a3, b3, a4, b4;\n\n\tscanf(\"%d%d%d%d%d%d%d%d\", &a1, &b1, &a2, &b2, &a3, &b3, &a4, &b4);\n\tif ((win(a1, b2, a3, b4) && win(a1, b2, a4, b3))\n\t\t\t|| (win(a2, b1, a3, b4) && win(a2, b1, a4, b3))) {\n\t\tprintf(\"Team 1\\n\");\n\t\treturn 0;\n\t}\n\tif ((win(a3, b4, a1, b2) || win(a4, b3, a1, b2))\n\t\t\t&& (win(a3, b4, a2, b1) || win(a4, b3, a2, b1))) {\n\t\tprintf(\"Team 2\\n\");\n\t\treturn 0;\n\t}\n\tprintf(\"Draw\\n\");\n\treturn 0;\n}\n", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f"} {"source_code": "#include\nint main(){\nint a,b,c,i,j;\nscanf(\"%d %d %d\",&a,&b,&c);\ni=a*c-c*b;\nj=i/b;\nif(i%b!=0)\n j=j+1;\nprintf(\"%d\",j);\n}\n", "src_uid": "7dd098ec3ad5b29ad681787173eba341"} {"source_code": "#include \n\nint a[8], b[8];\n\nint min(int x, int y) {\n return x < y ? x : y;\n}\n\nint max(int x, int y) {\n return x > y ? x : y;\n}\n\nint main(int argc, char** argv) {\n int i, ok = 0;\n int ax, ay, bx, by;\n int ax1, ax2, ay1, ay2;\n int bx1, bx2, by1, by2;\n \n for (i = 0; i < 8; i++)\n scanf(\"%d\", &a[i]);\n for (i = 0; i < 8; i++)\n scanf(\"%d\", &b[i]);\n for (i = 0; i < 8; i++) {\n a[i] = a[i] * 4;\n b[i] = b[i] * 4;\n }\n \n ax1 = ax2 = a[0];\n ay1 = ay2 = a[1];\n for (i = 2; i < 8; i += 2) {\n ax1 = min(ax1, a[i]);\n ax2 = max(ax2, a[i]);\n }\n for (i = 1; i < 8; i += 2) {\n ay1 = min(ay1, a[i]);\n ay2 = max(ay2, a[i]);\n }\n \n bx1 = bx2 = b[0] + b[1];\n by1 = by2 = b[0] - b[1];\n for (i = 2; i < 8; i += 2) {\n bx1 = min(bx1, b[i] + b[i+1]);\n bx2 = max(bx2, b[i] + b[i+1]);\n }\n for (i = 2; i < 8; i += 2) {\n by1 = min(by1, b[i] - b[i+1]);\n by2 = max(by2, b[i] - b[i+1]);\n }\n \n for (ax = -1000; ax <= 1000; ax++)\n for (ay = -1000; ay <= 1000; ay++) {\n bx = ax + ay;\n by = ax - ay;\n if ((ax1 <= ax && ax <= ax2) && (ay1 <= ay && ay <= ay2) && (bx1 <= bx && bx <= bx2) && (by1 <= by && by <= by2)) {\n ok = 1;\n ax = ay = 2000;\n }\n }\n puts(ok ? \"YES\" : \"NO\");\n \n return 0;\n}\n", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a"} {"source_code": "\n#include\nlong long int abs(long long int n)\n{\n\tif (n < 0)\n\t\tn *= -1;\n\treturn n;\n}\nint main()\n{\n\tlong long int x0, y0, ax, ay, bx, by;\n\tscanf(\"%lld %lld %lld %lld %lld %lld\", &x0, &y0, &ax, &ay, &bx, &by);\n\tlong long int xs, ys, t;\n\tscanf(\"%lld %lld %lld\", &xs, &ys, &t);\n\tlong long int x[102], y[102];\n\tx[0] = x0;\n\ty[0] = y0;\n\tlong long int i, j;\n\tlong long int max = 10000000000000016;\n\tfor (i = 0; x[i] < max && y[i] < max; i++)\n\t{\n\t\tx[i + 1] = ax * x[i] + bx;\n\t\ty[i + 1] = ay * y[i] + by;\n\t}\n\tlong long int c = i + 1;\n\tlong long int ans = 0;\n\tfor (i = 0; i < c; i++)\n\t\tfor (j = 0; j < c; j++)\n\t\t\tif (abs(xs - x[i]) + abs(ys - y[i]) + abs(x[i] - x[j]) + abs(y[i] - y[j]) <= t)\n\t\t\t\tif (ans < abs(i - j) + 1)\n\t\t\t\t\tans = abs(i - j) + 1;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28"} {"source_code": "#include \n#include \n\ntypedef long long int lli;\nlli matriz[36][36];\n\nint main(int argc, char const *argv[]){\n int n,h,i,j;\n scanf(\"%d%d\",&n,&h);\n\n for(int k=1;k<=n;k++){\n matriz[0][k-1]=1;\n for(i=1;i<=n;i++) for (j=0;j\n#include\nint main()\n{\n long long int n,i,j,k,m,s=0,l;\n char a[][14]= { \"Sheldon\" ,\"Leonard\" ,\"Penny\" ,\"Rajesh\" ,\"Howard\"};\n scanf(\"%lld\",&n);\n //l=5+(n-5)/2+(n-5)%2;\n if(n<=5)\n printf(\"%s\",a[n-1]);\n else\n {\n for(i=5;; i*=2)\n {\n s=s+i;\n if(s>=n)\n break;\n }\n //printf(\"%lld\\n\",s);\n //printf(\"%lld\\n\",i);\n l=s-n;\n l=i-l;\n //printf(\"%lld\\n\",l,i);\n if(l<=i/5)\n printf(\"%s\",a[0]);\n else if(l<=2*(i/5))\n printf(\"%s\",a[1]);\n else if(l<=3*(i/5))\n printf(\"%s\",a[2]);\n else if(l<=4*(i/5))\n printf(\"%s\",a[3]);\n else if(l<=i)\n printf(\"%s\",a[4]);\n }\n}", "src_uid": "023b169765e81d896cdc1184e5a82b22"} {"source_code": "#include \n#include \n\ntypedef struct {\n\n\tint cap;\n\tint fil; \n\tint ind; // index\n} cups;\n\n\nint cm (const void * a, const void * b)\n{\n\tcups * A,* B;\n\tA = (cups *)a;\n\tB = (cups *)b;\n\tif ( A->cap == B->cap)\n\treturn 0;\n\telse return A->cap - B->cap;\n}\n\nint cmi (const void * a, const void * b)\n{\n\tcups * A, * B;\n\tA = (cups *)a;\n\tB = (cups *)b;\n\tif ( A->ind == B->ind)\n\treturn 0;\n\telse return A->ind - B->ind;\n}\n\nint main(){\ncups a[100];\nint s;\nint n,w;\nscanf(\"%i %i\",&n,&w);\n\n\nint sum = 0;\nint res = -2;\nint i;\ns = w;\n\nfor (i=0; i sum)\n\t{\n\tres = -1;\n\tgoto end;\n\t}\n\n\tqsort(a,n,sizeof(a[0]),cm); // sort by cap value (see cm)\n//\tfor (i=0;i 0 && i >= 0)\n{\n\tint temp = a[i].cap - a[i].fil;\n\tif (temp > s)\n\t\t{\n\t\ta[i].fil += s;\n\t\ts = 0;\n\t\t}\n\telse\n\t\t{\n\t\ts -= temp;\n\t\ta[i].fil += temp;\n\t\t}\n\ti--;\n\n}\n \n\tqsort(a,n,sizeof(a[0]),cmi); //sort by index (see cmi )\n\n\nend: \n\tif (res > 0)\n\t\tfor (i=0;i\nint main()\n{\n int e=0,m=0,i,n;\n scanf(\"%d\",&n);\n while(n>0)\n {\n if(n%2==0)\n {\n n=2;\n }\n else\n n=1;\n\n if(n<=1)\n break;\n else\n {\n n=n-2;\n m++;\n }\n\n if(n<=0)\n break;\n else\n {\n n=n-1;\n e++;\n }\n }\n if(m>e)\n printf(\"Mahmoud\");\n else\n printf(\"Ehab\");\n return 0;\n\n}\n", "src_uid": "5e74750f44142624e6da41d4b35beb9a"} {"source_code": "#include\n\nint main(){\n int i, j, k;\n char a[4],b[4],c[4];\n scanf(\"%s\", a);\n scanf(\"%s\", b);\n scanf(\"%s\", c);\n for(j=0,k=2; j<3,k>=0; j++,k--){\n if(c[j]==a[k]){\n continue;\n }\n else{\n printf(\"NO\\n\");\n return 0;\n }\n }\n if(b[0]==b[2]){\n printf(\"YES\\n\");\n }\n else{\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9"} {"source_code": "#include\nint main()\n{\n int n,k,l,c,d,p,nl,np;\n scanf(\"%d %d %d %d %d %d %d %d\",&n,&k,&l,&c,&d,&p,&nl,&np);\n ///printf(\"n=%d\\nk=%d\\nl=%d\\nc=%d\\nd=%d\\np=%d\\nnl=%d\\nnp=%d\\n\",n,k,l,c,d,p,nl,np);\n int cdt=c*d;\n int drinkt=k*l;\n int s,q,min;\n s=drinkt/nl;\n q=p/np;\n if(s\n#define max(a,b) (a>b)?a:b\nconst int maxn = 111;\nint main(){\n int n, k;\n char st[maxn];\n int dp[maxn][maxn][maxn];\n scanf(\"%d %d\", &n, &k);\n scanf(\"%s\", st);\n dp[0][0][0] = 1;\n for(int e = 0; st[e]; e++){\n for(int f = 0; f < maxn; f++)\n for(int g = 0; g < maxn; g++){\n if(dp[e][f][g]){\n if(st[e] == 'N') dp[e+1][max(f, g + 1)][g+1] = 1;\n if(st[e] == 'Y') dp[e+1][f][0] = 1;\n if(st[e] == '?'){\n dp[e+1][max(f, g + 1)][g+1] = 1;\n dp[e+1][f][0] = 1;\n }\n }\n }\n }\n int ans = 0;\n for(int e = 0; e <= k; e++)\n if(dp[n][k][e]) ans = 1;\n if(ans) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n return 0;\n}", "src_uid": "5bd578d3da5837c259b222336a194d12"} {"source_code": "#include \n#include \n\nint main()\n{\n int numar ;\n scanf(\"%d\", &numar);\n if(numar%4==1)\n printf(\"0 A \\n\");\n if(numar%4==2)\n printf(\"1 B \\n\");\n if(numar%4==3)\n printf(\"2 A \\n\");\n if(numar%4==0)\n printf(\"1 A \\n\");\n\n return 0;\n}\n", "src_uid": "488e809bd0c55531b0b47f577996627e"} {"source_code": "#include\nint main() {\n int n,a[200],i,c=0;\n scanf(\"%d\",&n);\n for(i=0; i\nint main()\n{\n\tlong n,m,f[100][100];\n\tint i,j,k,t,a[100],b[100];\n\tscanf(\"%ld%ld\",&n,&m);\n\tfor(i=0;if[i][t]+f[t+1][j]) f[i][j]=f[i][t]+f[t+1][j];\n\t\t}\n\t }\n if(m<=4) printf(\"%ld\",f[0][n*m-1]);\n\telse{\n\t\tfor(i=t=0;i<2*n;i++) if(f[i][i+2*n-1]\n__int64 s[100];\nint b[100];\nint main()\n{\n\tint n;\n\t__int64 l,ans,c,d;\n\tint i,j,k;\n\tscanf(\"%d%I64d\",&n,&l);\n\tb[0]=l%2;\n\t//printf(\"%d\",b[0]);\n\tfor(i=1;l/2!=0;i++)\n\t{\n\t\tl=l/2;\n\t\tb[i]=l%2;\n\t\t//printf(\"%d\",b[i]);\n\t}\n\tfor(j=0;j=2*s[j-1])\n\t\ts[j]=2*s[j-1];\n\t //printf(\"%dj%I64d\\n\",j,s[j]);\n\t}\n\tk=0;\n\tc=s[i-1]+100;\n\tans=0;\n\t//printf(\"%d\\n\",i);\n\tfor(j=0;js[j])\n\t\tans=s[j];\n\t\tans=ans+s[j]*b[j];\n\t}\t\n\tprintf(\"%I64d\\n\",ans);\n\treturn 0;\n}\n", "src_uid": "04ca137d0383c03944e3ce1c502c635b"} {"source_code": "/* practice with Dukkha */\n#include \n\n#define MD\t1000000007\n\nint main() {\n\tlong long a, b;\n\n\tscanf(\"%lld%lld\", &a, &b);\n\tprintf(\"%lld\\n\", ((b * (b - 1) / 2) % MD) * ((b * (a * (a + 1) / 2 % MD) + a) % MD) % MD);\n\treturn 0;\n}\n", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f"} {"source_code": "\n#include \n#include \n#include \n\nint main(void) {\n int n, *a;\n int k[100] = {0};\n int p = 0;\n int v = 0;\n bool p_found = false;\n scanf(\"%d\\n\", &n);\n a = malloc(sizeof(int)*n);\n for (int i=0; i\n\nint main()\n{\n int n;\n long long f[21];\n int i;\n long long ans;\n\n scanf(\"%d\", &n);\n f[0] = 1;\n for (i=1; i<21; i++) {\n f[i] = f[i-1] * i;\n }\n ans = f[n] / f[n/2] / f[n/2];\n ans *= f[n/2 - 1];\n ans *= f[n/2 - 1];\n ans /= 2;\n\n printf(\"%lld\\n\", ans);\n\n return 0;\n}\n", "src_uid": "ad0985c56a207f76afa2ecd642f56728"} {"source_code": "#include \n#include \n\nint main()\n{\n int n, m, i;\n double p = 0, q = 0;\n double pi = acos(-1);\n double x = (1 + sqrt(5)) / 2;\n \n scanf(\"%d\", &n);\n \n m = 4 * (n - 1) + 5;\n \n printf(\"%d\\n\", m);\n \n for (i = 0; i < n; i++) {\n if (i == 0) printf(\"%.12lf %.12lf\\n\", p, q);\n \n printf(\"%.12lf %.12lf\\n\", p + 10 * x, q);\n printf(\"%.12lf %.12lf\\n\", p + 5 * x, 10 * cos(54 * pi / 180));\n printf(\"%.12lf %.12lf\\n\", p + 10 * cos(72 * pi / 180), -10 * sin(72 * pi / 180));\n printf(\"%.12lf %.12lf\\n\", p + 10 * x - 10 * cos(72 * pi / 180), -10 * sin(72 * pi / 180));\n \n p += 10 * x;\n }\n \n for (i = 0; i < n; i++) {\n if (i == 0) {\n printf(\"1\");\n } else {\n printf(\"%d\", i * 4 - 2);\n }\n \n printf(\" %d %d %d %d\\n\", i * 4 + 4, i * 4 + 5, i * 4 + 2, i * 4 + 3);\n }\n \n printf(\"1\");\n \n for (i = 0; i < n; i++) printf(\" %d\", i * 4 + 2);\n \n for (i = n - 1; i >= 0; i--) {\n printf(\" %d %d %d\", i * 4 + 4, i * 4 + 3, i * 4 + 5);\n \n if (i == 0) {\n printf(\" 1\");\n } else {\n printf(\" %d\", i * 4 - 2);\n }\n }\n \n puts(\"\");\n \n return 0;\n}", "src_uid": "db263b866e93e3a97731e11102923902"} {"source_code": "\n#include\n#include\n#include\n#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)\n#define s(n) scanf(\"%d\",&n)\n#define sc(n) scanf(\"%c\",&n)\n#define sl(n) scanf(\"%I64d\",&n)\n#define sf(n) scanf(\"%lf\",&n)\n#define ss(n) scanf(\"%s\",n)\n#define fill(a,v) memset(a, v, sizeof(a))\nint intcmp(const void *f,const void *s)\n{\n return (*(int *)f -*(int *)s);\n}\nint gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}\n\n#define MAX 64\n#define MODBY 1000000007\n\ntypedef long long int lld;\ntypedef long double Lf;\n\nint main()\n{\n int cases;\n int i,j;\n int n,m,k;\n int a[MAX];\n scanf(\"%d%d%d\",&n,&m,&k);\n for(i=0;i0)&&(i>=0);--i,++j)\n req-=a[i];\n if(req>0) j=-1;\n printf(\"%d\\n\",j);\n\n return 0;\n}\n", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c"} {"source_code": "#include\n#include\nint main()\n{\n char p[101];\n int j=0,i,t=0;\n scanf(\"%s\",p);\n j=strlen(p);\n for(i=0;i\n#include \n\nchar w[50000], freq[26];\n\nvoid umple(int s, int f){\n int i, y=0;\n for(i=s;i\n#define MOD 1000000009\n\nint sqr(long long int x, int n)\n{\n\tif(n==0)\n\t\treturn 1;\n\telse if(n==1)\n\t\treturn x;\n\telse if(n%2==0)\n\t\treturn sqr( (x*x)%MOD, n/2 ) % MOD;\n\telse\n\t\treturn (x * sqr( (x*x)%MOD, (n-1)/2 )) % MOD;\n}\n\nint main()\n{\n\tint n, m, k;\n\tscanf(\"%d %d %d\", &n, &m, &k);\n\tint x, y, z;\n\tz = n%k;\n\ty = n/k;\n\tif(y*(k-1)+z >= m)\n\t{\n\t\tprintf(\"%d\\n\", m);\n\t}\n\telse\n\t{\n\t\tx = m - y*(k-1) - z;\n\t\ty -= x;\n\t\tlong long int ans;\n\t\tint i;\n\t\tans = sqr(2, x+1);\n\t\tans -= 2;\n\t\tif(ans<0)\n\t\t\tans += MOD;\n\t\tk %= MOD;\n\t\tans *= k;\n\t\tans %= MOD;\n\t\tans += y*(k-1);\n\t\tans %= MOD;\n\t\tans += z;\n\t\tans %= MOD;\n\t\tprintf(\"%lld\\n\", ans);\n\t}\n\treturn 0;\n}\n", "src_uid": "9cc1aecd70ed54400821c290e2c8018e"} {"source_code": " #include\n\n int main()\n {\n int n, x, y, z, max = 1; // minimum #pieces is 1. i can't cut the ribbon\n scanf(\"%d %d %d %d\", &n, &x, &y, &z);\n\n for(int a=0;a<=n;a++) //iterating the coefficients of x and y\n {\n for(int b=0;b<=n;b++)\n {\n int k = n-x*a-y*b; // n=ax+by+k\n if(k>=0 && k%z==0) //checks if k is a multiple of z\n max = ((a+b+k/z) > max) ? (a+b+k/z) : max; // find the maximum value\n }\n\n }\n printf(\"%d\\n\", max);\n return 0;\n }", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43"} {"source_code": "#include\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{\n int i,j,k,highest=0,flag,n,skip,result=0,mark;\n\n scanf(\"%d\",&n);\n\n int a[n];\n\n for(i=0;ihighest)highest=a[i];\n }\n skip=highest;\n flag=highest;\n j=flag;\n\n for(i=0; ;i++)\n {\n if(a[0]==j)\n {\n for(k=1;kflag)break;\n }\n printf(\"%d\",result);\n\n return 0;\n\n}\n", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58"} {"source_code": "#include \r\n#include \r\n#include \r\n#include \r\n\r\nchar *reverse(char *px) {\r\n int n = strlen(px);\r\n char *perm = malloc(sizeof(char) * (n+1));\r\n for (int i = 0; i < n; i++)\r\n perm[i] = px[n-1-i];\r\n perm[n] = '\\0';\r\n return perm;\r\n}\r\n\r\nchar *gen(long long a) {\r\n char *perm = malloc(sizeof(char) * 100);\r\n int i = 0;\r\n while (a) {\r\n if (a & 1) perm[i++] = '1';\r\n else perm[i++] = '0';\r\n a >>= 1;\r\n }\r\n perm[i] = '\\0';\r\n return reverse(perm);\r\n}\r\n\r\nint check(char *y, char *x) {\r\n char *yy = malloc(sizeof(char) * 100), *xx = malloc(sizeof(char) * 100), one[100], temp[100];\r\n strcpy(xx, x), strcpy(yy, y);\r\n for (int i = 0; i < 100; i++) one[i] = '1';\r\n\r\n char *str = strstr(yy, xx);\r\n int len = strlen(xx), i;\r\n if (str != NULL) {\r\n strncpy(temp, str, len);\r\n strncpy(str, one, len);\r\n for (i = 0; yy[i] != '\\0'; i++)\r\n if (yy[i] != '1') break;\r\n strncpy(str, temp, len);\r\n\r\n if (yy[i] == '\\0') return 1;\r\n }\r\n\r\n xx = reverse(xx);\r\n\r\n str = strstr(yy, xx);\r\n if (str != NULL) {\r\n strncpy(temp, str, len);\r\n strncpy(str, one, len);\r\n for (i = 0; yy[i] != '\\0'; i++)\r\n if (yy[i] != '1') break;\r\n strncpy(str, temp, len);\r\n\r\n if (yy[i] == '\\0') return 1;\r\n }\r\n\r\n return 0;\r\n}\r\n\r\nint main() {\r\n long long x, y;\r\n scanf(\"%\"PRId64\"%\"PRId64\"\", &x, &y);\r\n int found = (x == y);\r\n char *permX = gen(x), *permY = gen(y);\r\n x = strlen(permX), y = strlen(permY);\r\n\r\n if (permX[x-1] == '1') {\r\n found |= check(permY, permX);\r\n }\r\n else {\r\n permX[x] = '1', permX[x+1] = '\\0';\r\n found |= check(permY, permX);\r\n while (permX[x-1] == '0') permX[--x] = '\\0';\r\n found |= check(permY, permX);\r\n }\r\n\r\n puts(found ? \"YES\" : \"NO\");\r\n\r\n return 0;\r\n}\r\n", "src_uid": "9f39a3c160087beb0efab2e3cb510e89"} {"source_code": "#include\n\n#define MIN(x,y) (((x)<(y))?(x):(y))\n\nint main(void){\n int n,a,b,c,ans=0;\n scanf(\"%d%d%d%d\",&n,&a,&b,&c);\n if(n>1) ans+=MIN(a,b);\n if(n>2) ans+=(n-2)*MIN(MIN(a,b),c);\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "src_uid": "6058529f0144c853e9e17ed7c661fc50"} {"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}", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402"} {"source_code": "#include \n#define max(a,b) (a)>(b)?(a):(b)\n\nint main(void){\n\tint n,m;\n\tscanf(\"%d %d\",&n,&m);\n\tint a[m+1],b[m+1],c[m+1],d[m+1];\n\tscanf(\"%d %d\",c,d);\n\tb[0]=c[0];\n\ta[0]=n;\n\tint i,j,k;\n\tfor (i=1;i<=m;i++){\n\t\tscanf(\"%d %d %d %d\",a+i,b+i,c+i,d+i);\n\t}\n\tint x[n+1];\n\tfor (i=0;i<=n;i++) x[i]=0;\n\tfor (j=0;j<=m;j++){\n\t\tfor (i=n;i>=0;i--){\n\t\t\tfor (k=0;k<=a[j]*1.0/b[j] && c[j]*k<=i;k++)\n\t\t\t\tx[i]=max(x[i-c[j]*k]+d[j]*k,x[i]);\n\t\t}\n\t}\n\tprintf(\"%d\",x[n]);\n\treturn 0;\n}\n", "src_uid": "4e166b8b44427b1227e0f811161d3a6f"} {"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}", "src_uid": "4a3767011ddac874efa021fff7c94432"} {"source_code": "#include \n#include \n#define min(a,b) ((a)<(b)?(a):(b))\n\ntypedef long long ll;\n\nchar str[200002];\n\nint main()\n{\n\tint i,n,m,res;\n\tll val, pw;\n\tscanf(\"%s%d\",str,&m);\n\tn=strlen(str);\n\tres=m;\n\tpw=1;\n\tval=0;\n\tfor(i=0;i\nint main ()\n{\n int M, N, dominos;\n scanf(\"%d %d\", &M,&N);\n M= M;\n N= N;\n \n if ( M >=1 && N >=M && N<=16)\n {\n \n dominos = (M*N)/2;\n printf(\"%d\",dominos);\n }\n return 0;\n}", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd"} {"source_code": "\n#include \n\n\nint main()\n{\n\tlong long a, b;\n\tlong long x, y, z;\n\tscanf(\"%I64d %I64d\", &a, &b);\n\tscanf(\"%I64d %I64d %I64d\", &x, &y, &z);\n\tlong long tmp = a - 2 * x - y;\n\tlong long tmp2 = b - y - 3 * z;\n\tif(tmp > 0) tmp = 0;\n\tif (tmp2 > 0) tmp2 = 0;\n\tprintf(\"%I64d\", (-tmp - tmp2));\n return 0;\n}\n\n", "src_uid": "35202a4601a03d25e18dda1539c5beba"} {"source_code": "#include \n#include \n\nint main()\n{\n int a[6]={0},b[6]={0};\n int n;\n scanf(\"%d\",&n);\n int i,j;\n for(i=0;i\nint main()\n{\n\tlong a,b,c,d,r1,r2,r3,r4,f1,f2,f3,f4;\n\tr1=0,r2=0,r3=0,r4=0;\n\tscanf(\"%ld %ld %ld %ld\",&a,&b,&c,&f1);\n\tr4+=a;\n\tr3+=b;\n\tr2+=c;\n\tr1+=a+b+c;\n\tscanf(\"%ld %ld %ld %ld\",&a,&b,&c,&f2);\n\tr1+=a;\n\tr4+=b;\n\tr3+=c;\n\tr2+=a+b+c;\n\tscanf(\"%ld %ld %ld %ld\",&a,&b,&c,&f3);\n\tr2+=a;\n\tr1+=b;\n\tr4+=c;\n\tr3+=a+b+c;\n\tscanf(\"%ld %ld %ld %ld\",&a,&b,&c,&f4);\n\tr3+=a;\n\tr2+=b;\n\tr1+=c;\n\tr4+=a+b+c;\n\tif((f1==1 && r1>0) || (f2==1 && r2>0) || (f3==1 && r3>0) || (f4==1 && r4>0))\n\t\tprintf(\"YES\\n\");\n\telse\n\t\tprintf(\"NO\\n\");\n\treturn 0;\n\n\n}\n", "src_uid": "44fdf71d56bef949ec83f00d17c29127"} {"source_code": "//Tiles(incomplete)\n#include\nlong long int power(long long int d,long long int s)\n{\n if(s==1) return d;\n else if(s==0) return 1;\n else\n {\n long long int u,v=d;\n for(u=1;u\n#include \n#include \n\nint main()\n\n{\n int i,h,e,l,o ,j,p,s ;\n h=0;\n e=0;\n l=0;\n o=0;\n\n char w[100];\n gets(w);\n\n int flag=0;\n int length=strlen(w);\n if (length>=5)\n {\n\n for (i=0; il && l>e && e>h )\n {\n printf(\"YES\");\n }\n\n else\n {\n printf(\"NO\");\n }\n\n return 0;\n}\n", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838"} {"source_code": "#include\nint main()\n{\n\tlong long int n;\n\t\n\t\n\t\n\t\n\tscanf(\"%I64d\",&n);\n\t\n\tint count=0,i,a=0;\n\t\n\tif(n<0)\n\tn=n*-1;\n\t\n\t\n\tfor(i=1 ;n!=a;i++)\n\t{\n\t\ta=a+i;\n\t\tcount++;\n\t\t\n\t\tif(n\n\n#define ll long long\n\nint main(){\n long long int n, m, s, x ,y, ans;\n\n scanf(\"%I64d%I64d%I64d\", &n, &m, &s);\n\n if (n <= s)\n x = n;\n else\n x = (n-1)/s + 1;\n\n if (m <= s)\n y = m;\n else\n y = (m-1)/s + 1;\n \n if(s < n)\n x *= ((n - 1) %s) + 1;\n\n if(s < m)\n y *= ((m - 1) %s) + 1;\n\n ans = x*y; \n printf(\"%I64d\\n\", ans);\n\n return 0;\n}\n", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36"} {"source_code": "#include\n#include\n\nint main()\n{\n\tint x[3],i;\n\tint out=10000,dist=0;\n\tfor(i=0;i<3;i++)\n\t{\n\t\tscanf(\"%d\",&x[i]);\n\t\tif(x[i]dist)\n\t\t\tdist=x[i];\n\t}\n\t\n\n\tprintf(\"%d\\n\",dist-out);\n\t\n\treturn 0;\n}\n", "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319"} {"source_code": "#include \n\n\nint main()\n{\n long long unsigned int n,i,j,result=0;\n int m;\n int ss;\n scanf(\"%I64d\",&n);\n scanf(\"%d\",&m);\n if(m==1)\n {\n printf(\"%I64d\",n*n);\n return 0;\n }\n\n /*for(i=1;i<=n;i++)\n for(j=1;j<=i;j++)\n {\n if( (i*i+j*j)%m==0 && i!=j) result+=2;\n if( (i*i+j*j)%m==0 && i==j) result+=1;\n }*/\n long long unsigned int resultiii=0;\n int x=1;\n int y=1;\n for(i=1;i<=m;i++)\n {\n resultiii=0;\n x=n/m;\n if(n%m >= i) x++;\n for(j=1;j<=m;j++)\n {\n if( (i*i+j*j)%m==0 )\n {\n y=n/m;\n if(n%m >= j) y++;\n resultiii+=y;\n }\n\n }\n //printf(\"x=%d y=%d and resulti =%d row %d = %d\\n\",x,y,resultiii,i,(resultiii*y*x));\n result +=(resultiii*x);\n }\n printf(\"%I64d\",result);\n return 0;\n}\n", "src_uid": "2ec9e7cddc634d7830575e14363a4657"} {"source_code": "n,o;\nmain()\n { scanf(\"%d\",&n);\n while(n--&&!o){\n scanf(\"%d\",&o);}\n printf (o?\"hard\":\"easy\");\n}", "src_uid": "060406cd57739d929f54b4518a7ba83e"} {"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}", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3"} {"source_code": "#include\nint main()\n{\n int n,m,a,b,cost=0,k,l,o;\n scanf(\"%d %d %d %d\",&n,&m,&a,&b);\n if(n>m)\n {\n k=(n-n%m)*a;\n l=(n/m*b);\n if(l<=k)\n cost=l;\n else\n cost=k;\n if((n%m*a)<=(n%m*b))\n cost=cost+(n%m*a);\n else\n cost=cost+b;\n\n }\n else\n {\n if(n*a\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", "src_uid": "ed1a2ae733121af6486568e528fe2d84"} {"source_code": "#include\n\nint main(void){\n int n,m,p;\n\n scanf(\"%d%d%d\",&n,&m,&p);\n\n if(n<=m && n<=p){\n printf(\"Yes\");\n }\n else printf(\"No\");\n\n return 0;\n}\n", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4"} {"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#include\n#include\n#define inf 1072114514\n#define llinf 1145141919810364364\n#define mod 1000000007\n\nint max(int a,int b){if(a>b){return a;}return b;}\nint min(int a,int b){if(a= b){return (a/b)+1;}return a/b;}\nint ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}\nint gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}\nint lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}\nint nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}\nint fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}\nint pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}\nlong long llmax(long long a,long long b){if(a>b){return a;}return b;}\nlong long llmin(long long a,long long b){if(a= b){return (a/b)+1;}return a/b;}\nlong long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}\nlong long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}\nlong long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}\nlong long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}\nlong long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}\nlong long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}\ndouble dbmax(double a,double b){if(a>b){return a;}return b;}\ndouble dbmin(double a,double b){if(a*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}\nint sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}\nint llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}\nint llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}\nint dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}\nint dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}\n\nint main(void){\n int a,b,f,k,c=0,zf,i;\n scanf(\"%d%d%d%d\",&a,&b,&f,&k);\n if(b\nint main()\n{\n\tint a,b,c,x,y,z,extra=0,needed=0;\n\tscanf(\"%d%d%d%d%d%d\",&a,&b,&c,&x,&y,&z);\n\tif(a>x)\n\t\textra+=(a-x)/2;\n\telse\n\t\tneeded+=x-a;\n\tif(b>y)\n\t\textra+=(b-y)/2;\n\telse\n\t\tneeded+=y-b;\n\tif(c>z)\n\t\textra+=(c-z)/2;\n\telse\n\t\tneeded+=z-c;\n\tif(extra>=needed)\n\t\tprintf(\"Yes\\n\");\n\telse\n\t\tprintf(\"No\\n\");\n\treturn 0;\n}\n", "src_uid": "1db4ba9dc1000e26532bb73336cf12c3"} {"source_code": "#include\nint main()\n{\n int n,k=0,i;\n scanf(\"%d\",&n);\n char m[105];\n scanf(\"%s\",m);\n for(i=0;m[i]!='\\0';i++)\n {\n if(m[i]=='a'||m[i]=='e'||m[i]=='i'||m[i]=='o'||m[i]=='u'||m[i]=='y')\n {\n k++;\n if(k>1)\n {\n\n }\n else\n printf(\"%c\",m[i]);\n }\n else\n {\n printf(\"%c\",m[i]);\n k=0;\n }\n }\n}\n", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690"} {"source_code": "#include\nint main()\n{\n\tint i,j,k,l,n,m,c,sum,min;\n\tscanf(\"%d%d\",&n,&m);\n\tchar a[n+1];\n\tscanf(\"%s\",a);\n\tfor(j=0;ja[i])\n\t\t\t{\n\t\t\t\tc=a[i]+a[i-1];\n\t\t\t\ta[i]=c-a[i];\n\t\t\t\ta[i-1]=c-a[i-1];\n\t\t\t}\n\t\t}\n\t}\n\tif(m==1)\n\t{\n\tprintf(\"%d\",a[0]-96);\n\treturn 0;\n\t}\n\telse\n\t{\n\tsum=a[0]-96;\n\tc=1;\n\tmin=0;\n\tfor(l=1;l1)\n\t{\n\t\tsum=sum+a[l]-96;\n\t\tc++;\n\t\ta[min]=a[l];\n\t}\t\n\tif(c==m)\n\t{\n\t\tprintf(\"%d\",sum);\n\t\treturn 0;\n\t}\n\t}\n\tif(c!=m)\n\tprintf(\"-1\");\n}\n\treturn 0;\n}\n", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313"} {"source_code": "#include\r\n#include\r\nint main(){\r\n int n=0;\r\n scanf(\"%d\",&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 printf(\"%d\",(4+n+(n-3)/3));\r\n}", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e"} {"source_code": "/* Author Kh. Assaduzzaman Sohan */\n\n#include\n#include\n#include\n#define mod 100000007\nchar x[11][11],y[11][11];\nint main()\n{\n int i,j,k,d=0,X=0;\n\n for(i=0; i<10; i++) scanf(\"%s\",x[i]);\n\n //for(i=0; i<10; i++) printf(\"%s\\n\",x[i]);\n\n for(i=0; i<10; i++)\n {\n for(j=0; j<10; j++)\n {\n y[i][j]=x[j][i];\n }\n }\n //Checking horizontal\n for(i=0; i<10; i++)\n {\n for(j=0; j<6; j++)\n {\n X=0;\n d=0;\n if(x[i][j]=='X') X++;\n if(x[i][j+1]=='X') X++;\n if(x[i][j+2]=='X') X++;\n if(x[i][j+3]=='X') X++;\n if(x[i][j+4]=='X') X++;\n if(x[i][j]=='.') d++;\n if(x[i][j+1]=='.') d++;\n if(x[i][j+2]=='.') d++;\n if(x[i][j+3]=='.') d++;\n if(x[i][j+4]=='.') d++;\n\n if((X==4&&d==1)|| X==5)\n {\n printf(\"YES\");\n return 0;\n }\n }\n }\n //Checking vertical\n for(i=0; i<10; i++)\n {\n for(j=0; j<6; j++)\n {\n X=0;\n d=0;\n if(y[i][j]=='X') X++;\n if(y[i][j+1]=='X') X++;\n if(y[i][j+2]=='X') X++;\n if(y[i][j+3]=='X') X++;\n if(y[i][j+4]=='X') X++;\n if(y[i][j]=='.') d++;\n if(y[i][j+1]=='.') d++;\n if(y[i][j+2]=='.') d++;\n if(y[i][j+3]=='.') d++;\n if(y[i][j+4]=='.') d++;\n\n if((X==4&&d==1)|| X==5)\n {\n printf(\"YES\");\n return 0;\n }\n }\n }\n //Checking diagonal\n for(i=0; i<6; i++)\n {\n for(j=0; j<6; j++)\n {\n X=0;\n d=0;\n if(x[i][j]=='X') X++;\n if(x[i+1][j+1]=='X') X++;\n if(x[i+2][j+2]=='X') X++;\n if(x[i+3][j+3]=='X') X++;\n if(x[i+4][j+4]=='X') X++;\n if(x[i][j]=='.') d++;\n if(x[i+1][j+1]=='.') d++;\n if(x[i+2][j+2]=='.') d++;\n if(x[i+3][j+3]=='.') d++;\n if(x[i+4][j+4]=='.') d++;\n\n if((X==4&&d==1)|| X==5)\n {\n printf(\"YES\");\n return 0;\n }\n }\n }\n for(i=9; i>=4; i--)\n {\n for(j=9; j>=4; j--)\n {\n X=0;\n d=0;\n if(x[i][j]=='X') X++;\n if(x[i-1][j-1]=='X') X++;\n if(x[i-2][j-2]=='X') X++;\n if(x[i-3][j-3]=='X') X++;\n if(x[i-4][j-4]=='X') X++;\n if(x[i][j]=='.') d++;\n if(x[i-1][j-1]=='.') d++;\n if(x[i-2][j-2]=='.') d++;\n if(x[i-3][j-3]=='.') d++;\n if(x[i-4][j-4]=='.') d++;\n\n if((X==4&&d==1)|| X==5)\n {\n printf(\"YES\");\n return 0;\n }\n }\n }\n for(i=0; i<6; i++)\n {\n for(j=9; j>=4; j--)\n {\n X=0;\n d=0;\n if(x[i][j]=='X') X++;\n if(x[i+1][j-1]=='X') X++;\n if(x[i+2][j-2]=='X') X++;\n if(x[i+3][j-3]=='X') X++;\n if(x[i+4][j-4]=='X') X++;\n if(x[i][j]=='.') d++;\n if(x[i+1][j-1]=='.') d++;\n if(x[i+2][j-2]=='.') d++;\n if(x[i+3][j-3]=='.') d++;\n if(x[i+4][j-4]=='.') d++;\n\n if((X==4&&d==1)|| X==5)\n {\n printf(\"YES\");\n return 0;\n }\n }\n }\n for(i=9; i>=4; i--)\n {\n for(j=0; j<6; j++)\n {\n X=0;\n d=0;\n if(x[i][j]=='X') X++;\n if(x[i-1][j+1]=='X') X++;\n if(x[i-2][j+2]=='X') X++;\n if(x[i-3][j+3]=='X') X++;\n if(x[i-4][j+4]=='X') X++;\n if(x[i][j]=='.') d++;\n if(x[i-1][j+1]=='.') d++;\n if(x[i-2][j+2]=='.') d++;\n if(x[i-3][j+3]=='.') d++;\n if(x[i-4][j+4]=='.') d++;\n\n if((X==4&&d==1)|| X==5)\n {\n printf(\"YES\");\n return 0;\n }\n }\n }\n printf(\"NO\");\n\n return 0;\n}\n", "src_uid": "d5541028a2753c758322c440bdbf9ec6"} {"source_code": "#include\n#include\n\nint max(int a,int b)\n{\n\tif(a>b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\n\nint min(int a,int b)\n{\n\tif(a=0;i--){\n\t\td[0][i]=max(d[0][i+1],d[1][i+1]+a[i]);\n\t\td[1][i]=min(d[0][i+1],d[1][i+1]+a[i]);\n\t}\n\t\n\tprintf(\"%d %d\",d[1][1],d[0][1]);\n}", "src_uid": "414540223db9d4cfcec6a973179a0216"} {"source_code": "#include\nint main()\n{\n int n,i;\n scanf(\"%d\",&n);\n char s[n+2];\n scanf(\"%s\",s);\n int c1=0,c0=0;\n for(i=0;s[i]!='\\0';i++){\n if(s[i]=='1')\n c1++;\n else\n c0++;\n }\n if(c1>0){\n printf(\"1\");\n }\n for(i=1;i<=c0;i++)\n printf(\"0\");\n}\n", "src_uid": "ac244791f8b648d672ed3de32ce0074d"} {"source_code": "#include \n#include \nint check(int a,int b);\n\nint main()\n{ int n,h=0,k=1,answer=0,answer1=0,i;// n is length h determine if iam in() or out k is outflag ans1 is number of chars out ans1 number of words inside\n scanf(\"%d\",&n);\n char a[n+1];\n scanf(\"%s\",a);\n\n char x; // x is the character being scanned\nfor(i=0;ib?a:b;\n}\n", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92"} {"source_code": "/* practice with Dukkha */\n#include \n#include \n#include \n\nchar ss[4][32];\n\nint get(char *s) {\n\tstatic int n;\n\tint i;\n\n\tfor (i = 0; i < n; i++)\n\t\tif (strcmp(ss[i], s) == 0)\n\t\t\treturn i;\n\tstrcpy(ss[n], s);\n\treturn n++;\n}\n\nint g1[4], g0[4], pp[4], dd[4];\n\nint compare(const void *a, const void *b) {\n\tint i = *(int *) a;\n\tint j = *(int *) b;\n\tint gi, gj;\n\n\tif (pp[i] != pp[j])\n\t\treturn pp[j] - pp[i];\n\tgi = g1[i] - g0[i];\n\tgj = g1[j] - g0[j];\n\tif (gi != gj)\n\t\treturn gj - gi;\n\tif (g1[i] != g1[j])\n\t\treturn g1[j] - g1[i];\n\treturn strcmp(ss[i], ss[j]);\n}\n\nint main() {\n\tstatic char s[32], t[32], z[8];\n\tstatic int ii[4];\n\tint h, i, j, x, y, x_, y_, r;\n\n\tfor (h = 0; h < 5; h++) {\n\t\tscanf(\"%s%s%s\", s, t, z);\n\t\ti = get(s), j = get(t);\n\t\tx = z[0] - '0';\n\t\ty = z[2] - '0';\n\t\tg1[i] += x, g0[j] += x;\n\t\tg0[i] += y, g1[j] += y;\n\t\tif (x > y)\n\t\t\tpp[i] += 3;\n\t\telse if (x < y)\n\t\t\tpp[j] += 3;\n\t\telse {\n\t\t\tpp[i]++;\n\t\t\tpp[j]++;\n\t\t}\n\t\tdd[i]++;\n\t\tdd[j]++;\n\t}\n\tfor (i = 0; i < 4; i++)\n\t\tii[i] = i;\n\ti = 0;\n\twhile (strcmp(ss[i], \"BERLAND\"))\n\t\ti++;\n\tj = 0;\n\twhile (j == i || dd[j] != 2)\n\t\tj++;\n\tx_ = 30, y_ = 0;\n\tfor (x = 1; x < 30; x++)\n\t\tfor (y = 0; y < x; y++) {\n\t\t\tg1[i] += x, g0[j] += x;\n\t\t\tg0[i] += y, g1[j] += y;\n\t\t\tif (x > y)\n\t\t\t\tpp[i] += 3;\n\t\t\telse if (x < y)\n\t\t\t\tpp[j] += 3;\n\t\t\telse {\n\t\t\t\tpp[i]++;\n\t\t\t\tpp[j]++;\n\t\t\t}\n\t\t\tqsort(ii, 4, sizeof *ii, compare);\n\t\t\tr = 0;\n\t\t\twhile (ii[r] != i)\n\t\t\t\tr++;\n\t\t\tif (r < 2)\n\t\t\t\tif (x_ - y_ > x - y || x_ - y_ == x - y && y_ > y)\n\t\t\t\t\tx_ = x, y_ = y;\n\t\t\tg1[i] -= x, g0[j] -= x;\n\t\t\tg0[i] -= y, g1[j] -= y;\n\t\t\tif (x > y)\n\t\t\t\tpp[i] -= 3;\n\t\t\telse if (x < y)\n\t\t\t\tpp[j] -= 3;\n\t\t\telse {\n\t\t\t\tpp[i]--;\n\t\t\t\tpp[j]--;\n\t\t\t}\n\t\t}\n\tif (x_ < 30)\n\t\tprintf(\"%d:%d\\n\", x_, y_);\n\telse\n\t\tprintf(\"IMPOSSIBLE\\n\");\n\treturn 0;\n}\n", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1"} {"source_code": "#include \n\nint main()\n{\n int i, n, a[100], b[100], total, totala = 0, totalb = 0, m[100], ja = 0, jb = 0, j = 0;\n scanf (\"%d\", &n);\n for (i = 1; i<= n; i++)\n {\n scanf (\"%d\", &a[i]);\n scanf (\"%d\", &b[i]);\n total = a[i] + b[i];\n totala += a[i];\n totalb += b[i];\n if (((a[i] % 2 != 0 ) && (b[i] % 2 == 0)) || ((b[i] % 2 != 0 ) && (a[i] % 2 == 0)))\n {\n j ++;\n }\n }\n if ((totala % 2 == 0) && (totalb % 2 == 0))\n {\n printf (\"0\\n\");\n }\n else\n {\n if (j % 2 == 0 && j > 0)\n {\n printf (\"1\\n\");\n }\n else\n {\n printf(\"-1\\n\");\n }\n }\nreturn 0;\n}\n", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43"} {"source_code": "#include\nlong long int mod=1000000007;\nlong long int modpowfast(long long int b,long long int e)\n{\n\tlong long int ans=1;\n\twhile(e>0)\n\t{\n\t\tif(e&1)\n\t\t\tans=(ans*b)%mod;\n\t\tb=(b*b)%mod;\n\t\te=e>>1;\n\t}\n\treturn ans;\n}\nint main()\n{\n\tlong long int p,k,m,x;\n\tscanf(\"%lld %lld\",&p,&k);\n\tif(k==0)\n\t{\n\t\tprintf(\"%lld\\n\",modpowfast(p,p-1));\n\t}\n\telse if(k==1)\n\t{\n\t\tprintf(\"%lld\\n\",modpowfast(p,p));\t\t\n\t}\n\telse\n\t{\n\t\tx=k;\n\t\tfor(m=1;x!=1;m++)\n\t\t{\n\t\t\tx=(x*k)%p;\n\t\t}\n\t\tprintf(\"%lld\\n\",modpowfast(p,(p-1)/m));\n\t}\n\treturn 0;\n}\n", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e"} {"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", "src_uid": "5d05af36c7ccb0cd26a4ab45966b28a3"} {"source_code": "#include \n#define oo 1000000000\n#define gmin(a,b) ((a)>(b)?(b):(a))\nlong getans=0,w[10000]={0},h[10000]={0},n,min,total=0,hash[40000000]={0},z[2000000]={0},an[200000]={0};\nvoid work(long k,long tot)\n{\n long i,o,j;\n if(k<=n)\n {\n if(k>min)\n return ;\n for(i=1;i<=tot;i++)\n if(w[i])\n {\n w[i]-=k;\n o=min;\n h[k]=i;\n if(w[i] && w[i]=0;i++)\n {\n an[k]=z[i];\n dfs(i+1,k+1,tot,count-z[i]);\n if(getans)\n return ;\n }\n }\n else\n {\n if(hash[count]==0)\n {\n for(i=1;i\n#include\nint main()\n{\n long long x,sum;\n scanf(\"%lld\",&x);\n\n if(x%2==0)sum=x/2;\n else sum=(x-1)/2-x;\n\n printf(\"%lld\",sum);\n\n\n return 0;\n}\n", "src_uid": "689e7876048ee4eb7479e838c981f068"} {"source_code": "#include \nlong long main()\n{\n\tlong long n;\n\tscanf(\"%lld\",&n);\n\tif(n<10)\n\t{\n\t\tprintf(\"%lld\",n);\n\t\treturn 0;\n\t}\n\tif(n>=10 && n<100)\n\t{\n\t\tlong long digits=9+(n-9)*2;\n\t\tprintf(\"%lld\",digits);\n\t\treturn 0;\n\t}\n\tif(n>=100 && n<1000)\n\t{\n\t\tlong long digits=9+90*2+(n-99)*3;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n>=1000 && n<10000)\n\t{\n\t\tlong long digits=9+90*2+900*3+(n-999)*4;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n>=10000 && n<100000)\n\t{\n\t\tlong long digits=9+90*2+900*3+(n-9999)*5+9000*4;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n>=100000 && n<1000000)\n\t{\n\t\tlong long digits=9+90*2+900*3+(n-99999)*6+9000*4+90000*5;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n>=1000000 && n<10000000)\n\t{\n\t\tlong long digits=9+90*2+900*3+(n-999999)*7+9000*4+90000*5+6*900000;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n>=10000000 && n<100000000)\n\t{\n\t\tlong long digits=9+90*2+900*3+(n-9999999)*8+9000*4+90000*5+6*900000+9000000*7;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n>=100000000 && n<1000000000)\n\t{\n\t\tlong long digits=9+90*2+900*3+(n-99999999)*9+9000*4+90000*5+6*900000+9000000*7+90000000*8;\n\t\tprintf(\"%lld\", digits);\n\t\treturn 0;\n\t}\n\tif(n==1000000000)\n\t{\n\t\t\n\t\tprintf(\"8888888899\");\n\t\treturn 0;\n\n\t}\n\n}", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9"} {"source_code": "#include \n\nint main(void) {\n\t// your code goes here\n\tint n;\n\tscanf(\"%d\\n\",&n);\n\tint a[n],swap=0;\n\tint i,j,c=0,temp[n];\n\tfor(i=0;ia[j+1])\n{\tswap=a[j];\n\ta[j]=a[j+1];\n\ta[j+1]=swap;}\n\t}}\n\t \n\t for(i=0;i\nint main()\n{double i,j,t,m,x1,y1,x2,y2,x3,c1,c2,y3;\nscanf(\"%lf%lf%lf%lf%lf%lf\",&x1,&y1,&x2,&y2,&x3,&y3);\nc1=y2-y1;c2=x2-x1;\nif(c2!=0)\n{m=(y2-y1)/(x2-x1);\nif(y3==(m*(x3-x1)+y1))\nprintf(\"TOWARDS\");\nelse if(y3>(m*(x3-x1)+y1))\n{if(c1>=0&&c2>0||c2>0&&c1<0)\nprintf(\"LEFT\");\nelse\nprintf(\"RIGHT\");}\nelse\n{if(c1<=0&&c2<0||c2<0&&c1>0)\nprintf(\"LEFT\");\nelse\nprintf(\"RIGHT\");}}\nelse\n{if(c1>0)\n{if(x3==x2)\nprintf(\"TOWARDS\");\n else if(x3>x2)\n printf(\"RIGHT\");\n else\n printf(\"LEFT\");\n}\nelse\n{if(x3==x2)\nprintf(\"TOWARDS\");\n else if(x3\n#include \nint power(int x,int y)\n{\n int mul=1,i;\n for(i=1;i<=y;i++){\n mul=mul*x;\n }\n return mul;\n}\nint main()\n{\n\tchar s[100010];\n\tgets(s);\n\tint l=strlen(s),c=0,a[10],i;\n\tint flag=0;\n if(s[0]=='?') flag=1;\n else if(s[0]>='A'&&s[0]<='J') flag=2;\n for(i=0;i='A'&&s[i]<='J') a[s[i]-'A']++;\n }\n long long m;\n if(flag==1){\n \tm=power(10,c-1)*9;\n\t}\n\telse{\n\t\tm=power(10,c);\n\t}\n\tint cnt=0,n=9,n1=10;\n\tlong long mal=1;\n\tfor(i=0;i<10;i++){\n\t\tif(a[i]!=0){\n\t\t\tif(flag==2){\n\t\t\t\tmal=mal*n;\n\t\t\t\tcnt++;\n\t\t\t\tif(cnt>1) n--;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tmal=mal*n1;\n\t\t\t\tn1--;\n\t\t\t}\n\t\t}\n\t}\n\tif(c==0) printf(\"%I64d\",mal);\n\telse if(mal==1) printf(\"%I64d\",m);\n\telse printf(\"%I64d\",mal*m);\n\treturn 0;\n}\n", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82"} {"source_code": "#include \n#include \n\nint main()\n{\n int i, j, n, m, x1, y1, x2, y2;\n\n scanf(\"%d %d %d %d %d %d\", &n, &m, &x1, &y1, &x2, &y2);\n\n i = abs(x1 - x2);\n j = abs(y1 - y2);\n\n if (i > j) {\n int aux = i;\n i = j;\n j = aux;\n }\n\n if ((i <= 2 && j <= 4) || (i == 3 && j == 3)) {\n puts(\"First\");\n } else {\n puts(\"Second\");\n }\n\n return 0;\n}\n", "src_uid": "41f6f90b7307d2383495441114fa8ea2"} {"source_code": "#include\nint main()\n{\n\tint n, i, j, k, a[26], flag[26], g, K;\n\tchar s[1000000];\n\twhile (scanf(\"%d%d%s\", &n, &k, &s) != EOF)\n\t{\n\t\tj = 0;\n\t\tg = 0;\n\t\tfor (i = 0; i < 26; i++)\n\t\t{\n\t\t\ta[i] = 0;\n\t\t\tflag[i] = 0;\n\t\t}\n\t\tfor (i = 0; i < n; i++)a[s[i] - 65]++;\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tif (flag[s[i] - 65] == 0)\n\t\t\t{\n\t\t\t\tif (a[s[i] - 65] != 1)\n\t\t\t\t{\n\t\t\t\t\tg++;\n\t\t\t\t\tflag[s[i] - 65]++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tg++;\n\t\t\t\t\tK++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (flag[s[i] - 65] < a[s[i] - 65] - 1)flag[s[i] - 65]++;\n\t\t\telse if(flag[s[i] - 65] == a[s[i] - 65] - 1)\n\t\t\t{\n\t\t\t\tg--;\n\t\t\t}\n\t\t\tif (g > k)\n\t\t\t{\n\t\t\t\tprintf(\"YES\\n\");\n\t\t\t\tj = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (K)\n\t\t\t{\n\t\t\t\tg--;\n\t\t\t\tK = 0;\n\t\t\t}\n\t\t}\n\t\tif (!j)printf(\"NO\\n\");\n\t}\n\treturn 0;\n}", "src_uid": "216323563f5b2dd63edc30cb9b4849a5"} {"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", "src_uid": "3f053c07deaac55c2c51df6147080340"} {"source_code": "#include \n\nint max(int a, int b)\n{\n if (a > b) {\n return a;\n } else {\n return b;\n }\n}\n\nint main()\n{\n int n, m, K, ans = 0, i, j, k, l, p;\n int a[10][100], b[10][100], c[10][100];\n \n scanf(\"%d %d %d\", &n, &m, &K);\n \n for (i = 0; i < n; i++) {\n char s[11];\n \n scanf(\"%s\", s);\n \n for (j = 0; j < m; j++) scanf(\"%d %d %d\", &a[i][j], &b[i][j], &c[i][j]);\n }\n \n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n int dp[101][101] = {0};\n \n if (i == j) continue;\n \n for (k = 0; k < m; k++) {\n for (l = 0; l <= K; l++) {\n for (p = 0; p <= c[i][k] && l + p <= K; p++) {\n dp[k + 1][l + p] = max(dp[k + 1][l + p], dp[k][l] + p * (b[j][k] - a[i][k]));\n }\n }\n }\n \n for (k = 1; k <= K; k++) ans = max(ans, dp[m][k]);\n }\n }\n \n printf(\"%d\\n\", ans);\n \n return 0;\n}\n", "src_uid": "7419c4268a9815282fadca6581f28ec1"} {"source_code": "#include\n#include\n\nint main()\n{\n long long n;\n scanf(\"%I64d\", &n);\n long long result;\n result = n / 2;\n int temp = 1;\n while(temp * 2 <= n)\n temp = temp * 2;\n if(n % 2 == 0)\n {\n printf(\"%I64d\", (n - temp)/2);\n }\n else\n printf(\"%I64d\", result);\n}\n", "src_uid": "422abdf2f705c069e540d4f5c09a4948"} {"source_code": "#include\nint main()\n{\n long long int ara[3][3];\n int i,j;\n for(i=0;i<=2;i++){\n for(j=0;j<=2;j++){\n scanf(\"%I64d\", &ara[i][j]);\n }\n }\n ara[0][0]=(ara[1][0]+ara[1][2]+ara[2][0]+ara[2][1] - (ara[0][1]+ara[0][2]))/2;\n ara[1][1]=(ara[0][1]+ara[0][2]+ara[2][0]+ara[2][1] - (ara[1][0]+ara[1][2]))/2;\n ara[2][2]=(ara[1][0]+ara[1][2]+ara[0][1]+ara[0][2] - (ara[2][1]+ara[2][0]))/2;\n\n for(i=0;i<=2;i++){\n for(j=0;j<=2;j++){\n printf(\"%I64d \", ara[i][j]);\n if(j==2){\n printf(\"\\n\");\n }\n }\n }\n\n return 0;\n}\n", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca"} {"source_code": "#include \n#include \nlong long int m=1000000007;\nlong long int power(long long int x,long long int y,long long int m)\n{\n long long int temp;\n if(y==0)\n return 1;\n temp=power(x,y/2,m);\n if(y%2==0)\n return ((temp%m)*(temp%m))%m;\n else\n return (x*(((temp%m)*(temp%m))%m)%m)%m;\n}\nint main()\n{\n\tlong long int n,p,k,ans,ans1;\n\tscanf(\"%lld %lld %lld\",&n,&p,&k);\n\tif(k==-1 && (n+p)%2==1)\n\tans=0;\n\telse\n\t{\n\tans=power(2,(n-1),m);\n\tans=power(ans,p-1,m);\n\t}\n//ans=(ans*ans1)%m;\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}", "src_uid": "6b9eff690fae14725885cbc891ff7243"} {"source_code": "#include\ntypedef long long unsigned llu;\ntypedef unsigned u;\nllu dicmal();\nint main()\n {\n llu x,y;\n x=dicmal();\n\n\n y=dicmal();\n\n printf((xy)?\"\\n>\":\"\\n=\");\n return 0;\n }\nllu dicmal()\n {\n llu r=0;\n u x,bx,d;\n scanf(\"%u%u\",&x,&bx);\n for(;x>0;x--)\n {\n scanf(\"%u\",&d);\n r=r*bx+d;\n }\n\n return r;\n }\n", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67"} {"source_code": "#include \n#include \n\nint\t\tfinder(int b, int g, int n)\n{\n\tint boys;\n\tint\tgirls;\n\tint\tcounter;\n\n\tboys = 0;\n\tcounter = 0;\n\twhile (boys <= b)\n\t{\n\t\tgirls = 0;\n\t\twhile (girls <= g)\n\t\t{\n\t\t\tif (girls == n - boys)\n\t\t\t{\n\t\t\t\tcounter++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tgirls++;\n\t\t}\n\t\tboys++;\n\t}\n\treturn (counter);\n}\n\nint\t\tmain(void)\n{\n\tint\t\tb;\n\tint\t\tg;\n\tint\t\tn;\n\n\tscanf(\"%d\", &b);\n\tif (b < 1 || b > 300)\n\t\treturn (-1);\n\tscanf(\"%d\", &g);\n\tif (g < 1 || g > 300)\n\t\treturn (-1);\n\tscanf(\"%d\", &n);\n\tif (n < 1 || n > b + g)\n\t\treturn (-1);\n\tprintf(\"%d\", finder(b, g, n));\n\treturn (0);\n}\n", "src_uid": "9266a69e767df299569986151852e7b1"} {"source_code": "#include \n#include\n\nint main()\n{\n\tint n,m,k,a[105],b[105],min,i,j=-1,x;\n\n\tscanf(\"%d\",&n);\n\tscanf(\"%d\",&m);\n\tscanf(\"%d\",&k);\n\n\tfor(i=0;i\nint repetition(int ara[6]){\n int i,j,max=0, count;\n for(i=0; i<6; i++){\n count=0;\n for(j=0; j<6; j++){\n if(ara[j]==ara[i]) count++;\n }\n if(count>max)max=count;\n }\n return max;\n}\n\nint main(void){\n int i,j,count=0;\n int ara[6];\n scanf(\"%d\", &ara[0]);\n for(i=1; i<6; i++){\n scanf(\"%d\", &ara[i]);\n for(j=0; j\n\nvoid quicksort( int *v , int inicio , int fin );\n\nint main(){\n\n int n , i , temp;\n scanf( \"%d\" , &n );\n int v[ n ];\n\n for( i = 0 ; i < n ; i++ )\n scanf( \"%d\" , &v[ i ] );\n \n quicksort( v , 0 , n - 1 );\n\n temp = v[ 0 ];\n v[ 0 ] = v[ n - 1 ];\n v[ n - 1 ] = temp;\n\n for( i = 0 ; i < n ; i++ )\n printf( \"%d \" , v[ i ] );\n\n return 0;\n}\n\nvoid quicksort( int *v , int inicio , int fin ){\n\n\tint i , j , central;\n\tint pivote;\n\tint temp;\n\n\tcentral = ( inicio + fin ) / 2;\n\tpivote = v[ central ];\n\ti = inicio;\n\tj = fin;\n\n\tdo{\n\t\n\t\twhile( v[ i ] < pivote )\n\t\t\ti++;\n\n\t\twhile( v[ j ] > pivote )\n\t\t\tj--;\n\n\t\tif( i <= j ){\n\n\t\t\ttemp = v[ i ];\n\t\t\tv[ i ] = v[ j ];\n\t\t\tv[ j ] = temp;\n\t\t\ti++;\n\t\t\tj--;\n\n\t\t}\n\n\t}while( i <= j );\n\n\tif( inicio < j )\n\n\t\tquicksort( v , inicio , j );\n\t\n\tif( i < fin )\n\n\t\tquicksort( v , i , fin );\t\t\n\n}\n", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4"} {"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", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8"} {"source_code": "#include \nint main()\n{\n long long count=0,n,k;\n\nscanf(\"%lld %lld\",&n,&k);\nif(n>=k)\nn=k-1;\ncount=n-(k/2);\nif(count<=0)\ncount=0;\n\nprintf(\"%lld\",count);\nreturn 0;\n}//1000000000000 1000000000001\n \n", "src_uid": "98624ab2fcd2a50a75788a29e04999ad"} {"source_code": "#include \nint main()\n{\n\tdouble a, b, c;\n\tscanf(\"%lf%lf%lf\", &a, &b, &c);\n\tif(c==0)\n\t{\n\t\tif(a==b) printf(\"YES\\n\");\n\t\telse printf(\"NO\\n\");\n\t}\n\telse\n\t{\n\t\tdouble t=(((b-a)/c)+1);\n\t\tlong long x=t;\n\t//\tprintf(\"c=%lf\\n\", c);\n\t\tif((x==t)&&(x>0)) printf(\"YES\\n\");\n\t\telse printf(\"NO\\n\");\n\t}\n\n\treturn 0;\n}", "src_uid": "9edf42c20ddf22a251b84553d7305a7d"} {"source_code": "#pragma region kyopuro_templates\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)); }\nll max2(ll a,ll b){return a>=b?a:b;}\nll 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=min2(b,a[i]);return b;}\nll maxn(ll n, ll a[]){ll b=-INF;rep(i,0,n) b=max2(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(n0){ t = (n&1) ? t*s%mod : t; s=s*s%mod; n>>=1; } return r?t:0; }\nll m_mul2(ll a, ll b, ll mod){ return a*b%mod; }\nll m_mul3(ll a, ll b, ll c, ll mod){ return m_mul2(a*b%mod,c,mod); }\nll m_mul4(ll a, ll b, ll c, ll d, ll mod){ return m_mul3(a*b%mod,c,d,mod); }\nll m_mul5(ll a, ll b, ll c, ll d, ll e, ll mod){ return m_mul4(a*b%mod,c,d,e,mod); }\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);}\nvoid sort_string(int n,int size,char s[][size]){ qsort( (void*)s , n , sizeof(s[0]) , cmp_string ); }\nvoid sort_char(char *s){ qsort( (void *)s , strlen(s) , sizeof(char) , cmp_char ); }\nll 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; }\nll unique_num(ll n , ll a[]){ ll ans=1; rep(i,1,n) if( a[i]!=a[i-1] ) ans++; return ans; }\n\n\ntypedef struct{ ll a , b,c;}fr;\nint cmp1( const void *p, const void *q ) { return ((fr*)p) ->b - ((fr*)q)->b;}\nint cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}\nvoid strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}\nvoid strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}\nvoid swap_struct( fr* p, fr* q ){\n fr r;\n r=*p;\n *p=*q;\n *q=r;\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 = 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}\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 ){\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 return 0;\n}\n\nvoid set_print(int set_num){ set_main(-1,set_num,0); }\nvoid set_insert(int set_num, ll val){ set_main(1,set_num,val); }\nll set_count(int set_num, ll val){ return set_main(2,set_num,val); }\nvoid set_erase(int set_num, ll val, int is_all){ if(is_all) set_main(4,set_num,val); else set_main(3,set_num,val); }\nvoid set_clear(int set_num){ set_main(5,set_num,0); }\nll set_size(int set_num){ return set_main(6,set_num,0); }\nll set_max(int set_num){ return set_main(7,set_num,0); }\nll set_min(int set_num){ return set_main(8,set_num,0); }\nvoid set_swap(ll set_num1, ll set_num2){ set_main(9,set_num1,set_num2); }\n\n/*\ninsert *\nsize *\nclear *\nerase *\ncount *\nmax *\nmin *\nswap *\nbegin\nend\nmerge source の要素のキーと等価なキーの要素がある場合、その要素は source から抽出されない\nlower_bound\nupper_bound\n*/\n\n// ll map_main()\n\n/*---------------------------AVL start--------------------------------*/\n\n#pragma endregion AVL\n\n\n\n#pragma endregion kyopuro_templates\n\n\n\n\n\n\n\n\n\n\n\n\n\nchar s[1151154];\n// char t[1151154];\nll ans[115115];\nvoid solve(){\n // fgets(s,sizeof(s),stdin); \n ll n;\n // ll ans=0;\n cin(&n);\n scanf(\"%s\",s);\n fr aa[n];\n rep(i,0,n){\n aa[i].a = s[i]-'a';\n aa[i].b=i;\n aa[i].c=-1;\n }\n ll t[n];\n rep(i,0,n){t[i]=aa[i].a;}\n rep(i,0,n){ans[i]=-1;}\n sortup(t,n);\n // rep(i,0,n){printf(\"%lld\",t[i]);}PN;\n rep(i,0,n){\n // rep(i,0,n){\n // printf(\"%2lld\",aa[i].a);\n // }PN;\n // rep(i,0,n){\n // printf(\"%2lld\",aa[i].c);\n // }PN; PN;\n if(t[i]!=aa[i].a){\n ll tmp=-1;\n if(aa[i].c!=-1){\n tmp=aa[i].c;\n }\n rep(j,i+1,n){\n if(t[i]==aa[j].a){\n // printf(\"%lld %lld\\n\",i,j);\n if(tmp==-1){\n if(aa[j].c==-1){\n tmp=0;\n aa[j].c=1;\n }else{\n tmp=aa[j].c^1;\n }\n rep(k,i,j){\n aa[k].c=tmp;\n }\n }else{\n if(aa[j].c==tmp){\n printf(\"NO\\n\"); return;\n }else{\n aa[j].c=tmp^1;\n }\n rep(k,i,j){\n aa[k].c=tmp;\n }\n }\n rrep(k,j-1,i){\n swap_struct(&aa[k],&aa[k+1]);\n }\n break;\n // s[j]=s[i];\n // s[i]=t[i];\n }else{\n if(aa[j].c==-1){\n aa[j].c=tmp;\n }else{\n if(tmp==-1){\n tmp=aa[j].c;\n }else{\n if(tmp!=aa[j].c){\n printf(\"NO\\n\"); return;\n }\n }\n }\n }\n }\n }else{\n if(aa[i].c==-1){\n aa[i].c=0; \n }\n }\n }\n strsortup(aa,n);\n printf(\"YES\\n\");\n rep(i,0,n){\n printf(\"%lld\",aa[i].c);\n }PN;\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 int p = ng + (ok - ng) / 2;\n int cnt = 0;\n for (i = 0; i < n; i++) {\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", "src_uid": "9bd31827cda83eacfcf5e46cdeaabe2b"} {"source_code": "#include \n\nint main() {\n\tint n, m, p[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}, i;\n\tscanf(\"%d %d\", &n, &m);\n\tfor (i = 0; p[i] != n; i++);\n\tprintf (\"%s\", (p[i+1] == m ? \"YES\" : \"NO\"));\n\treturn 0;\n}\n", "src_uid": "9d52ff51d747bb59aa463b6358258865"} {"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", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec"} {"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#include \n#include \n#include \n#include \n\n\ntypedef long long bigint;\n\nint main()\n{\n bigint n;\n scanf(\"%I64d\", &n);\n if(n == 0){\n printf(\"0\\n\");\n return 0;\n }\n if(n % 2 == 0) printf(\"%I64d\\n\", n+1);\n else printf(\"%I64d\\n\", (n+1)/2);\n\n return 0;\n}", "src_uid": "236177ff30dafe68295b5d33dc501828"} {"source_code": "#include \n\n#define BARCNT 50\n\nint nb, tl, kb[BARCNT], sb[BARCNT], st;\n\nvoid read(void)\n{\n int n;\n \n scanf(\"%d %d\", &nb, &tl);\n for (n = 0; n < nb; ++n)\n scanf(\"%d\", &kb[n]);\n for (n = 0; n < nb; ++n)\n scanf(\"%d\", &sb[n]);\n}\n\nvoid exec(void)\n{\n int n, m, kd[BARCNT], sd[BARCNT];\n \n for (n = 0; n < nb - 1; ++n)\n kd[n] = kb[n + 1] - kb[n], sd[n] = sb[n + 1] - sb[n];\n kd[nb-1] = tl - (kb[nb-1] - kb[0]), sd[nb-1] = tl - (sb[nb-1] - sb[0]);\n for (m = 0, n = 0; n < nb && m < nb; ++n)\n for (m = 0; m < nb; ++m)\n if (kd[(n + m) % nb] != sd[m])\n break;\n st = (m == nb);\n}\n\nvoid write(void)\n{\n printf(\"%s\\n\", st ? \"YES\" : \"NO\");\n}\n\nint main(void)\n{\n read();\n exec();\n write();\n return 0;\n}\n", "src_uid": "3d931684ca11fe6141c6461e85d91d63"} {"source_code": "#include \n#include \n\nint main()\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint sum = 0;\n\tfor (int i = 2; i <= n - 1; i++)\n\t{\n\t\tsum += i * (i + 1);\n\t}\n\tprintf(\"%d\", sum);\n}\n", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a"} {"source_code": "#include\n#include\nint isprime(long long n)\n{\n int i;\n for(i=2;i<=sqrt(n);i++)\n {\n if(n%i==0)\n return 0;\n }\n return 1;\n}\nint main()\n{\nlong long n,i;\nscanf(\"%lld\",&n);\nif(isprime(n)==1)\nprintf(\"1\\n%lld\",n);\nelse\n{\n printf(\"3\\n\");\n n=n-3;\n for(i=3;i<=n;i=i+2)\n {\n if(isprime(i)==1 && isprime(n-i)==1)\n {\n printf(\"3 %lld %lld\",i,n-i);\n break;\n }\n }\n}\n}\n", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3"} {"source_code": "#include \n#include \n\nint main()\n{\n int a1,a2,k1,k2,n;\n int b1,b2;\n scanf(\"%d\",&a1);\n scanf(\"%d\",&a2);\n scanf(\"%d\",&k1);\n scanf(\"%d\",&k2);\n scanf(\"%d\",&n);\n int max=k1>k2?k1:k2;\n if(max==k1)\n {\n b1=a1;\n }\n else{\n b1=a2;\n }\n int min=k1>k2?k2:k1;\n if(min==k1)\n {\n b2=a1;\n }\n else{\n b2=a2;\n }\n int yu=n-a1*(k1-1)-a2*(k2-1);\n if(yu>0)\n {\n printf(\"%d \",yu0)\n {\n printf(\"%d\",b2+yu/max);\n }\n else{\n printf(\"%d\",n/min);\n }\n\n return 0;\n}\n", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91"} {"source_code": "#include \n#include \n\nint main()\n{\n char f[10], m[10], s[10];\n int flag = 0;\n scanf(\"%s%s%s\", f, m, s);\n if (strcmp(f, m) == 0)\n {\n if ((strcmp(s, \"scissors\") == 0 && strcmp(f, \"paper\") == 0) || (strcmp(s, \"paper\") == 0 && strcmp(f, \"rock\") == 0) || (strcmp(s, \"rock\") == 0 && strcmp(f, \"scissors\") == 0))\n {\n printf(\"S\");\n flag = 1;\n }\n }\n if (strcmp(f, s) == 0)\n {\n if ((strcmp(m, \"scissors\") == 0 && strcmp(f, \"paper\") == 0) || (strcmp(m, \"paper\") == 0 && strcmp(f, \"rock\") == 0) || (strcmp(m, \"rock\") == 0 && strcmp(f, \"scissors\") == 0))\n {\n printf(\"M\");\n flag = 1;\n }\n }\n if (strcmp(s, m) == 0)\n {\n if ((strcmp(f, \"scissors\") == 0 && strcmp(s, \"paper\") == 0) || (strcmp(f, \"paper\") == 0 && strcmp(s, \"rock\") == 0) || (strcmp(f, \"rock\") == 0 && strcmp(s, \"scissors\") == 0))\n {\n printf(\"F\");\n flag = 1;\n }\n }\n if (!flag)\n {\n printf(\"?\");\n }\n\n return 0;\n}", "src_uid": "072c7d29a1b338609a72ab6b73988282"} {"source_code": "#include\nint main()\n{\n char a[101];\n scanf(\"%s\",a);\n int i,c=1,ans=0;\n for(i=0;a[i+1]!='\\0';i++,c++)\n {\n if(a[i+1]!=a[i])\n {\n if(c%2==0)\n ans++;\n c=0;\n }\n }\n if(c%2==0) ans++;\n printf(\"%d\",ans);\n return 0;\n}\n", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f"} {"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 1000000007\n#define N 1000010\n#define MAX1 1000001\n#define rep(i,n) for (int i=0; ib?a:b;}\nint min(int a,int b) {return ab?a:b;}\n\n\nll n, k, prime[N], v[N], m;\n\n// euler function\nll f(ll n) {\n if (n == 1) return 1;\n ll s = n;\n for (int i=0; i 1) s = s/n*(n-1);\n return s;\n}\n\nll F(ll k, ll n) {\n ll s = n;\n while (k>0 && s>1) s = f(s), k-=2;\n return s;\n}\n\n\nvoid primes(int n) {\n for (int i = 2; i <= n; i++) {\n if (!v[i]) {\n v[i] = i;\n prime[m++] = i;\n }\n for (int j = 0; j < m; j++) {\n if (prime[j] > v[i] || prime[j]*i > n) break;\n v[i * prime[j]] = prime[j];\n }\n }\n}\n\nint main() {\n scanf(\"%lld %lld\", &n, &k);\n primes((int) sqrtl(n)+1);\n printf(\"%lld\\n\", F(k, n) % MOD);\n}\n", "src_uid": "0591ade5f9a69afcbecd80402493f975"} {"source_code": "#include\n\nint result(int n)\n{\n if(n==1)\n return 1;\n int max_count = 0;\n for(int i=2; i<=n; i++)\n {\n if(n % i == 0)\n {\n int count = result(n/i);\n if(count > max_count)\n {\n max_count = count;\n }\n }\n }\n\n return n + max_count;\n}\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n\n printf(\"%d\\n\", result(n));\n return 0;\n}\n", "src_uid": "821c0e3b5fad197a47878bba5e520b6e"} {"source_code": "#include \n\n\nint main(){\n int n,p,q;\n scanf(\"%i\",&n);\n if (n%2==0){\n p=(n-2)/2;\n q=(n+2)/2;\n if(p%2==0&&q%2==0){\n p--;\n q++;\n }\n }\n else{\n p=(n-1)/2;\n q=(n+1)/2;\n if(p%2==0&&q%2==0){\n p--;\n q++;\n }\n }\n printf(\"%i %i\",p,q);\n}", "src_uid": "0af3515ed98d9d01ce00546333e98e77"} {"source_code": "#include\nint f(int x)\n{\n\tint sum=0;\n\twhile(x > 0){\n\t\tsum += x%10;\n\t\tx = x/10;\n\t}\n return sum;\n}\nint main()\n{\n\tint i,n,k,t,a[250];\n\twhile(scanf(\"%d\",&n)!=EOF)\n\t{\n\t\tk=-1;\n\t\tt=0>(n-100)?0:(n-100);\n\t\tfor(i=n;i>t;i--)\n\t\t{\n\t\t\tif( (f(i)+i)==n )\n\t\t\t{\n\t\t\t\t++k;\n\t\t\t\ta[k]=i;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(k==-1)\n\t\t\tprintf(\"0\\n\");\n\t\telse\n\t\t{\n\t\t\tprintf(\"%d\\n\",k+1);\n\t\t\t\t\n\t\t\tfor(i=k;i>-1;i--)\n\t\t\t{\n\t\t\t\t\tprintf(\"%d\\n\",a[i]);\n\t\t\t}\n\t\t} \n\t}\n\treturn 0;\n}\n", "src_uid": "ae20ae2a16273a0d379932d6e973f878"} {"source_code": "#include \n\nint main()\n{\n int a,b;\n scanf(\"%d %d\",&a,&b);\n if(b==0) printf(\"1\\n\");\n else if(b<=(a/2)) printf(\"%d\\n\",b);\n else printf(\"%d\\n\",a-b);\n return 0;\n}\n", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648"} {"source_code": "#include \n#include \n\ntypedef long long ll;\n\nint dp[10];\nint c[10];\n\nconst int mod = 1000000007;\n\nint recur1(int idx) {\n if (dp[idx] != -1) {\n return dp[idx];\n }\n dp[idx] = 0;\n dp[idx] = recur1(c[idx]);\n return dp[idx];\n}\n\nvoid recur0(int idx, int k, ll m, ll* ans) {\n int i, ret;\n if (idx == k) {\n memset(dp, 255, k * sizeof(int));\n dp[0] = 1;\n for (i = 1; i < k; i ++) {\n ret = recur1(i);\n if (ret == 0) {\n return;\n }\n }\n (*ans) += m;\n if ((*ans) >= mod) {\n (*ans) -= mod;\n }\n return;\n }\n for (i = 0; i < k; i ++) {\n if (idx == 0 || i != idx) {\n c[idx] = i;\n recur0(idx + 1, k, m, ans);\n }\n }\n}\n\nvoid solve(int n, int k) {\n int i;\n ll m, ans;\n m = 1;\n for (i = 0; i < n - k; i ++) {\n m *= (n - k);\n if (m >= mod) {\n m %= mod;\n }\n }\n ans = 0;\n recur0(0, k, m, &ans);\n printf(\"%I64d\\n\", ans);\n}\n\nint main() {\n int n, k;\n while (scanf(\"%d%d\", &n, &k) == 2) {\n solve(n, k);\n }\n return 0;\n}", "src_uid": "cc838bc14408f14f984a349fea9e9694"} {"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\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}", "src_uid": "a18833c987fd7743e8021196b5dcdd1b"} {"source_code": "#include\nint main()\n{\nint a,b,c,d,n,i,j,q,w,e,r;\nscanf(\"%d\",&n);\n\n\nfor(i=1;i<=4;i++)\n\t{\n\tscanf(\"%d %d %d %d\",&a,&b,&c,&d);\n\tif(a\n#include \n\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define INF (1ll << 60)\n\ntypedef long long ll;\n\nll a[4];\nchar s[4];\n\nvoid dfs(int pos, ll *b, ll *ans)\n{\n ll c[4];\n int i, j, k, t;\n if (pos == 3)\n {\n *ans = MIN(*ans, b[0]);\n return;\n }\n for (i = 0; i < 4 - pos; i ++)\n {\n for (j = i + 1; j < 4 - pos; j ++)\n {\n for (k = t = 0; k < 4 - pos; k ++)\n {\n if (k != i && k != j)\n {\n c[t ++] = b[k];\n }\n }\n if (s[pos] == '+')\n {\n c[t ++] = b[i] + b[j];\n }\n else\n {\n c[t ++] = b[i] * b[j];\n }\n dfs(pos + 1, c, ans);\n }\n }\n}\n\nvoid solve()\n{\n ll ans = INF;\n ll b[4];\n memcpy(b, a, sizeof(a));\n dfs(0, b, &ans);\n printf(\"%I64d\\n\", ans);\n}\n\nint main()\n{\n int i;\n for (i = 0; i < 4; i ++)\n {\n scanf(\"%I64d\", &a[i]);\n }\n for (i = 0; i < 3; i ++)\n {\n while (scanf(\"%c\", &s[i]) && s[i] != '+' && s[i] != '*');\n }\n solve();\n return 0;\n}", "src_uid": "7a66fae63d9b27e444d84447012e484c"} {"source_code": "\n#include \nint main()\n{\n int n,a,x,b,y,X=0;\n scanf(\"%d%d%d%d%d\",&n,&a,&x,&b,&y);\n while(a!=x && b!=y){\n if(a==b){\n X=1;\n break;\n }\n if(a==n) a=0;\n if(b==1) b=n+1;\n a++;\n b--;\n }\n if(a==b) X=1;\n if(X==1) printf(\"YES\");\n else printf(\"NO\");\n \n \n}\n", "src_uid": "5b889751f82c9f32f223cdee0c0095e4"} {"source_code": "#include\n#include\n\nint main(){\n char str[111], b[4]; scanf(\" %s\", str); int dotpos = -1, epos = -1;\n int i; for(int i = 0; str[i] != '\\0'; i++){\n if(str[i] == '.') dotpos = i;\n if(str[i] == 'e') epos = i;\n }\n int start = 0, pdotpos = dotpos, e = epos - 1; for(i = epos + 1; str[i] != '\\0'; i++) b[start++] = str[i];\n int num = atoi(b), f = 0; str[epos] = '\\0'; //printf(\"%s %d\\n\", str, num);\n for(i = epos - 1; i >= dotpos && !f; i--){\n //printf(\"%d \", str[i] - '0');\n if(str[i] - '0' != 0) { f = 1; e = i; }\n if(!f) str[i] = '\\0';\n } //printf(\"string is %s\\n\",str);\n if(e == dotpos) { str[e] = '\\0'; printf(\"%s\", str); while(num--) printf(\"0\"); printf(\"\\n\"); return 0; }\n if(!num){ printf(\"%s\\n\", str); return 0; }\n int flag = 0; dotpos += num + 1;\n for(i = 0; str[i] != '\\0'; i++){\n if(str[i] - '0' && i != dotpos) flag = 1;\n if(i == dotpos){ printf(\".\"); }\n if(flag && str[i] != '.') printf(\"%c\", str[i]);\n }\n num -= (e - pdotpos);\n if(num > 0){\n while(num--)printf(\"0\"); printf(\"\\n\"); } //printf(\"\\n%d %d %d\\n\", e, pdotpos, num);\n return 0;\n}\n", "src_uid": "a79358099f08f3ec50c013d47d910eef"} {"source_code": "#include \n\n#define eps 1e-6\n\nint\nmain(void)\n{\n\tint a, b, c, d, e, f;\n\tdouble aa, bb, cc, dd, ee, ff;\n\n\tscanf(\"%d%d%d%d%d%d\", &a, &b, &c, &d, &e, &f);\n\n\taa = a;\n\tbb = b;\n\tcc = c;\n\tdd = d;\n\tee = e;\n\tff = f;\n\n\tif (d == 0 || (b == 0 && c != 0))\n\t\tprintf(\"Hermione\\n\");\n\telse if (a == 0 || c == 0)\n\t\tprintf(\"Ron\\n\");\n\telse if (e == 0 && f != 0)\n\t\tprintf(\"Ron\\n\");\n\telse if (e == 0 && f == 0)\n\t\tprintf(\"Hermione\\n\");\n\telse if ((bb / aa) * (dd / cc) * (ff / ee) - 1 > eps)\n\t\tprintf(\"Ron\\n\");\n\telse\n\t\tprintf(\"Hermione\\n\");\n\n\treturn 0;\n}\n", "src_uid": "44d608de3e1447f89070e707ba550150"} {"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 //为什么就算是1e18也只需要这些数就够了呢? 因为越往后,前面的次方就越多\nLL ans,n;\nvoid dfs(LL Y,LL dep,LL num){\n //因子数 深度 当前的数\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]\n#include \n#include \n#include \n#include \n\nchar * read_line();\nvoid allocate_error();\nunsigned short condition();\n\nint main() {\n\n\tchar * buffer = read_line();\n\tchar * rest = buffer;\n\n\tunsigned short candies;\n\tunsigned short friends;\n\tunsigned short rest_candies;\n\tunsigned short fair_candies;\n\tunsigned short friends_with_fair_candies;\n\n\tcandies = (unsigned short) strtol(rest, &rest, 10);\n\tfriends = (unsigned short) strtol(rest, &rest, 10);\n\n\trest_candies = candies % friends;\n\tfair_candies = (unsigned short) round(candies / friends);\n\tfriends_with_fair_candies = friends - rest_candies;\n\n\t// Print the number of candies without the rest\n\tfor (unsigned short fair_friends=0; fair_friends No wasted memory\n\ttmp = realloc(line, strlen(line) + 1);\n\n\t// ERROR\n\tif (tmp == NULL)\n\t\tallocate_error();\n\t// ERROR\n\t\n\tline = tmp;\n\treturn line;\n}\n\nvoid allocate_error() {\n\tperror(\"Couldn't allocate memory!\");\n\texit(1);\n}\n", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23"} {"source_code": "#include\n\nint main () {\n int arr[100], i, j, n, p=100000000, q=0, k, alt=1, t, na[98], c;\n scanf(\"%d\",&n);\n n *= 2;\n for(i=0;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}", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8"} {"source_code": "#include \n\nint main()\n{\n long long n, m;\n scanf(\"%I64d %I64d\", &n, &m);\n long long min = n - 2 * m;\n if(min < 0) {\n min = 0;\n }\n if(m == 0) {\n printf(\"%I64d %I64d\\n\", min, n);\n } else {\n for(long long max = 0; max <= n; ++max) {\n long long cmp = 0;\n if(max & 1) {\n cmp = (max - 1) / 2 * max;\n } else {\n cmp = max / 2 * (max - 1);\n }\n if(m <= cmp) {\n printf(\"%I64d %I64d\\n\", min, n - max);\n break;\n }\n }\n }\n return 0;\n}\n", "src_uid": "daf0dd781bf403f7c1bb668925caa64d"} {"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", "src_uid": "da09a893a33f2bf8fd00e321e16ab149"} {"source_code": "#include \n#include\nint main (){\nlong long int n;\n\tscanf(\"%lld\",&n);\n\tn=4*(2*3*pow(4LL,n-3LL)+(n-3LL)*3*3*pow(4LL,n-4LL));\n\tprintf(\"%lld\\n\",n);\n}", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9"} {"source_code": "#include\nint main() {\n long long int n;\n scanf(\"%lld\",&n);\n printf(\"%lld\", (n - 1) * n * (n + 1) / 6 + n );\n return 0;\n}", "src_uid": "6df251ac8bf27427a24bc23d64cb9884"} {"source_code": "#include\n#include\nint main(){\nchar s[1000];\nint i,c=0,l;\nscanf(\"%s\",s);\nl=strlen(s);\nif(s[0]=='1'){\n c=1;\n for(i=1;i\nint max(int a,int b)\n{\n\tif(a>b)\n\treturn a;\n\telse\n\treturn b;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tint a[n],i,k,l,d;\n\tfor(i=0;il)\n\td=max(n-1-l,k);\n\tif(l>k)\n\td=max(n-1-k,l);\n\tprintf(\"%d\",d);\n\treturn 0;\n}", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4"} {"source_code": "#include \nint dp[51*10010];\nint main()\n{\n int n,d,i,x,sum,ans,ans1,j;\n scanf(\"%d%d\",&n,&d);\n sum=0;\n dp[0]=1;\n for(i=0;i=x;j--){\n if(dp[j-x])\n dp[j]=1;\n }\n }\n ans=ans1=0;\n while(1)\n {\n j=ans+d;\n while(j>ans&&!dp[j])\n j--;\n if(j==ans)\n break;\n ans=j;\n ans1++;\n }\n printf(\"%d %d\\n\",ans,ans1);\n \n return 0;\n}\n\n", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f"} {"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 マジックジェmの構成数\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#include \n\nint main()\n{\n long long int k,b,n,t,i=1,j=1;\n scanf(\"%I64d %I64d %I64d %I64d\",&k,&b,&n,&t);\n long long int result = 0;\n if(t==1)\n {\n printf(\"%I64d\",n);\n return 0;\n }\n i=i*k+b;\n for(i;;i=i*k+b)\n {\n if(n-j+1<=0 || i>t)\n {\n result=n-j;\n break;\n }\n j++;\n }\n printf(\"%I64d\",result+1);\n return 0;\n}", "src_uid": "e2357a1f54757bce77dce625772e4f18"} {"source_code": "#include \n#include \n\nint x, t, a, b, da, db, i, j;\n\nint main(void) {\n\tscanf(\"%d %d %d %d %d %d\", &x, &t, &a, &b, &da, &db);\n\tif (x==0 || x==a || x==b) goto yes;\n\tfor (i=0; i\nint ss,s[1000];\nint main(void){\n int n;scanf(\"%d\",&n);\n int x=n-1;\n int i=2,m=n;\n while (m>1){\n if(m%i==0){s[ss]=i;ss++;}\n while(m%i==0)m/=i;\n i++;}\n for(i=2;i<=n;i++){\n int c=0;\n int j;for(j=0;j1&&cnt=v){y=u;z=v;}\n else{y=v;z=u;}}\n if(cnt\n#include \n#include \n\n#if 0\nint visit(int i)\n{\n if (i == 0) return 1;\n return 5 * visit(--i);\n}\n#endif\n\nint main(void)\n{\n char t;\n char num[3];\n int i, j;\n\n num[0] = '0';\n num[1] = '0';\n num[2] = '\\0';\n i = 0;\n while (1) {\n scanf(\"%c\", &t);\n if (t == 10) break;\n num[0] = num[1];\n num[1] = t;\n i++;\n }\n#if 0\n printf(\"%s\\n\", num);\n printf(\"%d\\n\", atoi(num));\n printf(\"%d\\n\", visit(atoi(num)));\n#endif\n j = atoi(num);\n //printf(\"i(%d) j(%d)\\n\", i, j);\n if (i == 1 && j == 0)\n printf(\"1\\n\");\n else if (i == 1 && j == 1)\n printf(\"5\\n\");\n else\n printf(\"25\\n\");\n\n return 0;\n}\n", "src_uid": "dcaff75492eafaf61d598779d6202c9d"} {"source_code": "#include\n#define mod 1000000007\nint main() {\n long long a[8]={1, 3, 15, 133, 2025, 37851, 1030367, 36362925};\n int i,n;\n long long ans;\n scanf(\"%d\",&n);\n if(n&1) {\n ans=a[n>>1];\n for(i=2;i<=n;i++) ans = (ans*i)%mod;\n printf(\"%d\",ans);\n }\n else printf(\"0\");\n return 0;\n}", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69"} {"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 if(b==0){b=MOD;}\n b=(b-1)%MOD;\n a=(a*b)%MOD;\n printf(\"%lld\",(a+1)%MOD);\n }\n }\n}", "src_uid": "e0e017e8c8872fc1957242ace739464d"} {"source_code": "#include \n#include \n#include \n\n#define N\t500\n\nint main() {\n\tint i, j, n, m, yes;\n\tstatic char color[N + 1];\n\tstatic int cnt[N], adj[N][N];\n\n\tscanf(\"%d%d\", &n, &m);\n\tfor (i = 0; i < m; i++) {\n\t\tint u, v;\n\n\t\tscanf(\"%d%d\", &u, &v);\n\t\tu--, v--;\n\t\tcnt[u]++, cnt[v]++;\n\t\tadj[u][v] = adj[v][u] = 1;\n\t}\n\tfor (i = 0; i < n; i++) {\n\t\tcolor[i] = '-';\n\t\tif (cnt[i] == n - 1)\n\t\t\tcolor[i] = 'b';\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tif (color[i] == '-') {\n\t\t\tint j;\n\n\t\t\tcolor[i] = 'a';\n\t\t\tfor (j = 0; j < n; j++) \n\t\t\t\tif (i != j && color[j] != 'b')\n\t\t\t\t\tcolor[j] = adj[i][j] ? 'a' : 'c';\n\t\t}\n\tyes = 1;\n\tfor (i = 0; i < n; i++)\n\t\tfor (j = i + 1; j < n; j++) {\n\t\t\tint diff = color[i] > color[j] ? color[i] - color[j] : color[j] - color[i];\n\n\t\t\tif ((adj[i][j] && diff > 1) || (!adj[i][j] && diff <= 1)) {\n\t\t\t\tyes = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\tprintf(\"%s\\n\", yes ? \"Yes\" : \"No\");\n\tif (yes)\n\t\tprintf(\"%s\\n\", color);\n\treturn 0;\n}\n", "src_uid": "e71640f715f353e49745eac5f72e682a"} {"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}", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b"} {"source_code": "#include\n\nint main(void){\n unsigned int r,g,b;\n unsigned int r_t,g_t,b_t,max;\n\n scanf(\"%u %u %u\",&r,&g,&b);\n r_t=27+3*((r+1)/2);\n g_t=28+3*((g+1)/2);\n b_t=29+3*((b+1)/2);\n max=r_t;\n if(max\n#include \n\nlong long int length(long long n){\n return (long long)(pow(2, (long long)log2l(n) + 1) - 1);\n}\n\nlong long split( long long n, long long l, long long r, long long a, long long b){\n if (l <= a && b <= r){\n return n;\n }\n if ((n > 1) && !(r < a || b < l)){\n long long n_div = n / 2;\n long long n_mod = n % 2;\n long long n_div_len = length(n_div);\n long long left_split_b = a + n_div_len - 1;\n long long middle_split_index = left_split_b + 1;\n long long right_split_a = left_split_b + 2;\n return (split(n_div, l, r, a, left_split_b)\n + split(n_mod, l, r, middle_split_index, middle_split_index)\n + split(n_div, l, r, right_split_a, b));\n }\n return 0;\n}\n\nlong long count( long long n, long long l, long long r){\n return split(n, l, r, 0, length(n) - 1);\n}\n\nint main(void)\n{\n long long n, l, r;\n scanf(\"%llu\", &n);\n scanf(\"%llu\", &l);\n scanf(\"%llu\", &r);\n l--;\n r--;\n printf(\"%llu\\n\", count(n, l, r));\n return 0;\n}", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a"} {"source_code": "#include \nvoid reverse(char *s, int n)\n{\n char temp;\n int lim = n/2;\n for(int i = 0; i\n#include \n#include \n\nint\nmain (int argc, char *argv[])\n{\n\n int n, m;\n int min, max;\n\n scanf (\"%d %d\", &n, &m);\n\n\n\n if (n == 0)\n {\n if (m > 0)\n\tprintf (\"Impossible\");\n else \n\tprintf (\"0 0\");\n }\n else\n {\n if (n >= m)\n\tmin = n;\n else\n\tmin = m;\n if (m > 0)\n\tmax = n + m - 1;\n else\n\tmax = n;\n printf (\"%d %d\", min, max);\n }\n return 0;\n}\n", "src_uid": "1e865eda33afe09302bda9077d613763"} {"source_code": "#include\n#include\n#include\n#include\n\nint cmpfunc (const void * a, const void * b)\n{\n return ( *(int*)a - *(int*)b );\n}\n\nmain()\n{\n //freopen(\"in.txt\", \"r\", stdin);\n long long n, k, c, d, nt, t;\n\n scanf(\"%I64d %I64d\", &n, &k);\n\n t = n/2;\n d = t/(k+1);\n c = k*d;\n nt = n - d - c;\n printf(\"%I64d %I64d %I64d\", d, c, nt);\n}\n", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80"} {"source_code": "#include \n\nint machine(int n,int m)\n{\n if (m<=n)\n {\n return n-m;\n }\n\nelse\n{\n if (m%2==0)\n {\n return 1+machine(n,m/2);\n }\n\n else\n {\n return 2+machine(n,(m+1)/2);\n }\n \n\n}\n\n \n \n \n\n\n\n\n\n\n\n\n\n}\n\nint main()\n{\n int n,m;\n scanf(\"%d\",&n);\n scanf(\"%d\",&m);\n int answer=machine(n,m);\n printf(\"%d\",answer);\n return 0;\n}", "src_uid": "861f8edd2813d6d3a5ff7193a804486f"} {"source_code": "#include\n#include\nint main()\n{\n int f,s,a,t,o,i=0,n;\n scanf(\"%d\",&a);\n a=a+1;\n\n while(a>=1000){\n o=a%10;\n t=a%100;t=t/10;\n s=a%1000;s=s/100;\n f=a/1000;\n\n if(f!=s && f!=t && f!=o && s!=t && s!=o && t!=o)\n {\n printf(\"%d\",a);return 0;\n }\n else{\n a=a+1;\n }\n }\n}\n", "src_uid": "d62dabfbec52675b7ed7b582ad133acd"} {"source_code": "#include \n\n#define N 10000\n\nint main() {\n\tint n, m, z, i, cnt;\n\n\tscanf(\"%d%d%d\", &n, &m, &z);\n\tcnt = 0;\n\tfor (i = 1; i <= z; i++)\n\t\tif (i % n == 0 && i % m == 0)\n\t\t\tcnt++;\n\tprintf(\"%d\\n\", cnt);\n\treturn 0;\n}\n", "src_uid": "e7ad55ce26fc8610639323af1de36c2d"} {"source_code": "#include \nint n=0;\nchar s[105]={'\\0'};\nchar s1[105]={'\\0'};\nchar s2[105]={'\\0'};\nchar c='b';\nint main()\n{\n int i=0,j=0,k=0,l=0;\n scanf(\"%d\",&n);\n scanf(\"%s\",s);\n for(i=0;i<=n-1;i++)\n {\n s1[i]=s[i];\n s2[i]=s[i];\n }\n while(c<='z')\n {\n int start=1,last=1;\n for(i=0;i<=n-1;i++)\n {\n if(s1[i]==c)\n {\n start=i-1;\n last=i+1;\n while(s1[start]=='\\0'&&start>=0)\n {\n start--;\n }\n while(s1[last]=='\\0'&&last<=n-1)\n {\n last++;\n }\n if((start>=0)&&(s1[start]==c-1&&c-1>='a')&&(s1[i]!='\\0'))\n {\n s1[i]='\\0';\n k++;\n i=-1;\n continue;\n }\n if(last<=n-1&&(s1[last]==c-1&&c-1>='a'))\n {\n s1[i]='\\0';\n k++;\n i=-1;\n }\n }\n }\n c++;\n }\n c='z';\n while(c>='b')\n {\n int start=1,last=1;\n for(i=0;i<=n-1;i++)\n {\n if(s2[i]==c)\n {\n start=i-1;\n last=i+1;\n while(s2[start]=='\\0'&&start>=0)\n {\n start--;\n }\n while(s2[last]=='\\0'&&last<=n-1)\n {\n last++;\n }\n if((start>=0)&&(s2[start]==c-1&&c-1>='a')&&(s2[i]!='\\0'))\n {\n s2[i]='\\0';\n l++;\n i=-1;\n continue;\n }\n if(last<=n-1&&(s2[last]==c-1&&c-1>='a'))\n {\n s2[i]='\\0';\n l++;\n i=-1;\n }\n }\n }\n c--;\n }\n if(k>=l)\n printf(\"%d\\n\",k);\n else printf(\"%d\\n\",l);\n return 0;\n}\n\n", "src_uid": "9ce37bc2d361f5bb8a0568fb479b8a38"} {"source_code": "#include\nint main()\n{\n long long int n,m,i,a=1,b;\n scanf(\"%lld%lld\",&n,&m);\n if(m==10 && n==1)\n printf(\"-1\\n\");\n else if(m<10)\n {\n printf(\"%d\",m);\n for(i=1;i\n\nint main()\n{\n int a,b,c,n,x;\n\n scanf(\"%d %d %d %d\",&a,&b,&c,&n);\n\n x=n-(a+b-c);\n\n if(x<1){\n printf(\"-1\\n\");\n }\n else if(a==0&&c>0){\n printf(\"-1\\n\");\n }\n else if(b==0&&c>0){\n printf(\"-1\\n\");\n }\n else if(a>=n||b>=n||c>=n||c>a||c>b){\n printf(\"-1\\n\");\n }\n else{\n printf(\"%d\",x);\n }\n return 0;\n}\n", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce"} {"source_code": "#include\n#include\nlong long s(long long v)\n{\nint t,m=0;\nwhile(v!=0)\n{\nm+=v%10;\nv=v/10;\n}\nreturn m;\n}\n\nint main()\n{\nlong long int a,b,c;\nscanf(\"%lld %lld %lld\",&a,&b,&c);\nlong long ab[10000];\nlong long i,j,ans=0;\nfor(i=1;i<82;i++)\n{\n long long pw=i;\n for(j=1;j0&&value<1000000000)\n if(s(value)==i)\n ab[ans++]=value;\n}\nprintf(\"%lld\\n\",ans);\nfor(i=0;i\n#include \n\nint low[7][7], high[7][7];\nint cost[7][7];\nint n;\nint flow[7][7];\nint inFlow[7];\nint outFlow[7];\nint minFlow = 100, maxCost = -1;\n\nint rec(int v, int to) {\n if(v == n - 1) {\n int isValid = 1;\n int i, j;\n int total = inFlow[n - 1];\n int ccost = 0;\n for(i = 0; i < n; i++) {\n for(j = i + 1; j < n; j++) {\n if(flow[i][j] < low[i][j] || flow[i][j] > high[i][j])\n isValid = 0;\n if(flow[i][j] > 0) \n ccost += flow[i][j] * flow[i][j] + cost[i][j];\n }\n }\n if(isValid) {\n if(minFlow == total) {\n if(ccost > maxCost)\n maxCost = ccost;\n } else if(minFlow > total) {\n minFlow = total;\n maxCost = ccost;\n }\n }\n } else if(to == n) {\n if(v > 0 && inFlow[v] != outFlow[v])\n return;\n if(inFlow[n - 1] > minFlow)\n return;\n rec(v + 1, v + 2);\n } else {\n int i;\n for(i = low[v][to]; i <= high[v][to]; i++) {\n inFlow[to] += i;\n outFlow[v] += i;\n flow[v][to] = i;\n rec(v, to + 1);\n inFlow[to] -= i;\n outFlow[v] -= i;\n }\n }\n}\n\nint main() {\n scanf(\"%d\", &n);\n int i, from, to, j;\n for(i = 0; i < n * (n - 1) / 2; i++) {\n scanf(\"%d %d\", &from, &to);\n from--;\n to--;\n scanf(\"%d %d %d\", &low[from][to], &high[from][to], &cost[from][to]);\n }\n rec(0, 1);\n if(minFlow == 100)\n puts(\"-1 -1\");\n else\n printf(\"%d %d\\n\", minFlow, maxCost);\n return 0;\n}\n", "src_uid": "38886ad7b0d83e66b77348be34828426"} {"source_code": "#include\n#include\n#include\n\nint main()\n{\n int n,total,sumlow=0,sumhigh=0;\n int* a,*b,*c;\n a=(int*)malloc(sizeof(int)*n);\n scanf(\"%d%d\",&n,&total);\n a=(int*)malloc(sizeof(int)*n);\n b=(int*)malloc(sizeof(int)*n);\n c=(int*)malloc(sizeof(int)*n);\n int i;\n for(i=0;i sumhigh)\n {\n printf(\"NO\\n\");\n return 0;\n }\n else\n {\n printf(\"YES\\n\");\n total-=sumlow;\n while(total > 0)\n {\n for(i=0;i 0;i++)\n {\n if(a[i] < b[i])\n {\n a[i]++;\n total--;\n }\n }\n }\n for(i=0;i\n#include\n#include\n#include\nint main()\n{\n int a[4], i, j, cnt=0, swap;\n for(i=0; i<4; i++)\n {\n scanf(\"%d\", &a[i]);\n }\n for(i=0; i<3; i++)\n {\n for(j=0; j<3-i; j++)\n {\n if(a[j]>a[j+1])\n {\n swap=a[j];\n a[j]=a[j+1];\n a[j+1]=swap;\n }\n }\n }\n for(i=0; i<3; i++)\n {\n if(a[i]==a[i+1])\n {\n cnt++;\n }\n }\n printf(\"%d\\n\", cnt);\n return 0;\n}", "src_uid": "38c4864937e57b35d3cce272f655e20f"} {"source_code": "#include\n#include\nint main()\n{\n int i,j,n,val;\n char arr[90];\n scanf(\"%d\", &n);\n scanf(\"%s\", arr);\n i = 0;\n j=0;\n while(i< n)\n {\n val = 0;\n while(arr[j] != '0' && j\n\nint main()\n{\n\tint n,f,s,g,t;\n\tscanf(\"%d\",&n);\n\tg=n%10;\n\tn=n/10;\n\tf=n%10;\n\tif (g==1){\n\t\tt=7;\n\t}\n\telse if (g==2){\n\t\tt=2;\n\t}\n\telse if (g==3){\n\t\tt=3;\n\t}\n\telse if (g==4){\n\t\tt=3;\n\t}\n\telse if (g==5){\n\t\tt=4;\n\t}\n\telse if (g==6){\n\t\tt=2;\n\t}\n\telse if (g==7){\n\t\tt=5;\n\t}\n\telse if (g==8){\n\t\tt=1;\n\t}\n\telse if (g==9){\n\t\tt=2;\n\t}\n\t\n\telse if (g==0){\n\t\tt=2;\n\t}\n\tif (f==1){\n\t\ts=7;\n\t}\n\telse if (f==2){\n\t\ts=2;\n\t}\n\telse if (f==3){\n\t\ts=3;\n\t}\n\telse if (f==4){\n\t\ts=3;\n\t}\n\telse if (f==5){\n\t\ts=4;\n\t}\n\telse if (f==6){\n\t\ts=2;\n\t}\n\telse if (f==7){\n\t\ts=5;\n\t}\n\telse if (f==8){\n\t\ts=1;\n\t}\n\telse if (f==9){\n\t\ts=2;\n\t}\n\t\n\telse if (f==0){\n\t\ts=2;\n\t}\n\tprintf(\"%d\",s*t);\n\treturn 0;\n}\n", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5"} {"source_code": "\n#include\n#include\n#include\n#include\n//typedef struct node{\n//int data;\n//struct node* next;\n//}node;\n# define print(i) printf(\"%d\",i)\n# define printc(i) printf(\"%c\",i)\n# define printl printf(\"\\n\")\n# define prints(i) printf(\"%s\",i)\n# define PI 3.141592\n\nint main()\n{\n auto int i,j;\n int n,round;\n int flag=0;\n scanf(\"%d\",&n);\n int a[n][4];\n int x_min=31500,x_max=0,y_min=31500,y_max=0,area=0;\n for (i=0;ix_max)\n x_max=a[i][2];\n if(a[i][1]y_max)\n y_max=a[i][3];\n\n }\n if(y_max-y_min != x_max-x_min || area !=((y_max-y_min)*(x_max-x_min)))\n {\n\n printf(\"NO\\n\");\n }\n else\n printf(\"YES\\n\");\n\n\n\n\n //for(i=0;i ;i++)\n return 0;\n}\n", "src_uid": "f63fc2d97fd88273241fce206cc217f2"} {"source_code": "#include \n#include \n\nint i,a[101],n,j,OK,mini,maxi,D,KO,d;\n\nint main()\n{\n scanf(\"%i\",&n);\n scanf(\"%i\",&a[1]);\n mini=maxi=a[1];\n for(i=2;i<=n;i++)\n {\n\n scanf(\"%i\",&a[i]);\n if(a[i]>maxi)\n maxi=a[i];\n if(a[i]\n#include\nint main() {\n\tchar a[100][20],c[]=\"North\",e[]=\"South\",f[]=\"East\",g[]=\"West\";\n\tint b[50],sum=0,jump=0,wang=0;\n\tint n,i;\n\tscanf(\"%d\",&n);\n\tfor(i=1; i<=n; i++) {\n\t\tscanf(\"%d %s\",&b[i],a[i]);\n\t}\n\tfor(i=1; i<=n; i++) {\n\t\tif(strcmp(a[1],e)!=0) {\n\t\t\tprintf(\"NO\\n\");\n\t\t\tbreak;\n\t\t} else {\n\t\t\tif(strcmp(a[i],e)==0) {\n\t\t\t\tsum-=b[i];\n\t\t\t} else if(strcmp(a[i],c)==0) {\n\t\t\t\tsum+=b[i];\n\t\t\t}\n\t\t}\n\t\tif(sum==-20000) {\n\t\t\tif(strcmp(a[i+1],c)!=0) {\n\t\t\t\tprintf(\"NO\\n\");\n\t\t\t\twang=0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else if(sum<-20000||sum>0) {\n\t\t\tprintf(\"NO\\n\");\n\t\t\twang=0;\n\t\t\tbreak;\n\t\t} else if(sum==0) {\n\t\t\tif(i==n) {\n\t\t\t\tjump=1;\n\t\t\t\twang=0;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tif(strcmp(a[i+1],e)!=0) {\n\t\t\t\t\tprintf(\"NO\\n\");\n\t\t\t\t\twang=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\twang=1;\n\t}\n\tif(jump==1) {\n\t\tprintf(\"YES\\n\");\n\t}\n\tif(wang==1) {\n\t\tif(sum==0) {\n\t\t\tprintf(\"YES\\n\");\n\t\t} else {\n\t\t\tprintf(\"NO\\n\");\n\t\t}\n\t}\n\treturn 0;\n}", "src_uid": "11ac96a9daa97ae1900f123be921e517"} {"source_code": "#include\nint main()\n{\n\tint n,i,j,ans=0;\n\tchar c[101];\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",c);\n\tint l;\n\tfor(l=1;l<=n;l++)\n\t{\n\t\tfor(i=0;i\n#include \n#define MAXN 55\nlong n,ls;\nchar s[MAXN]={'\\0'};\nlong a[MAXN]={0},p[MAXN][10]={0};\nlong long f[MAXN][10]={0},ans=0;\nvoid dfs(long now,long b)\n{\n if(p[now][b]) return;\n p[now][b]=1;\n if(now==n-1)\n {\n if(((a[now+1]+b)&1)) f[now][b]=2;\n else f[now][b]=1;\n }\n else\n {\n if(((a[now+1]+b)&1))\n {\n dfs(now+1,((a[now+1]+b)>>1));\n dfs(now+1,((a[now+1]+b)>>1)+1);\n f[now][b]=f[now+1][((a[now+1]+b)>>1)]+f[now+1][((a[now+1]+b)>>1)+1];\n }\n else\n {\n dfs(now+1,((a[now+1]+b)>>1));\n f[now][b]=f[now+1][((a[now+1]+b)>>1)];\n }\n }\n return;\n}\nint main()\n{\n long i,j,k;\n gets(s);ls=strlen(s)-1;if(s[ls]=='\\n') s[ls--]='\\0';\n n=ls+1;\n if(n==1) printf(\"9\\n\");\n else\n {\n for(i=1;i<=n;i++) a[i]=s[i-1]-'0';\n for(i=0;i<=9;i++) \n {dfs(1,i);ans+=f[1][i];}\n for(i=2;i<=n;i++)\n if(((a[i-1]+a[i])>>1)!=a[i] && (((a[i-1]+a[i])>>1)+1)!=a[i])\n break;\n if(i==n+1) ans--; \n printf(\"%I64d\\n\",ans);\n }\n return(0);\n}\n", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b"} {"source_code": "#include\n\nint main()\n{\n char c1,c2;\n scanf(\"%c %c\",&c1,&c2);\n int i,j;\n i=c1;\n j=c2;\n if(i==118)\n i=0;\n else if(i==60)\n i=1;\n else if(i==94)\n i=2;\n else if(i==62)\n i=3;\n if(j==118)\n j=0;\n else if(j==60)\n j=1;\n else if(j==94)\n j=2;\n else if(j==62)\n j=3;\n int n,tempp,tempn;\n scanf(\"%d\",&n);\n tempp=(i+n)%4;\n tempn=(i-n)%4;\n if(tempn<0)\n tempn+=4;\n if(tempp==tempn)\n printf(\"undefined\\n\");\n else if(tempp==j)\n printf(\"cw\\n\");\n else if(tempn==j)\n printf(\"ccw\\n\");\n return 0;\n}\n", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298"} {"source_code": "#include\nmain()\n{\nint ar1[3],ar2[3],ar3[3],a1[3],a2[3],a3[3];\nscanf(\"%d %d %d\",&ar1[0],&ar1[1],&ar1[2]);\nscanf(\"%d %d %d\",&ar2[0],&ar2[1],&ar2[2]);\nscanf(\"%d %d %d\",&ar3[0],&ar3[1],&ar3[2]);\nif ((ar1[0]+ar1[1]+ar2[0])%2==0) a1[0]=1;\nelse a1[0]=0;\nif ((ar2[0]+ar1[0]+ar3[0]+ar2[1])%2==0) a2[0]=1;\nelse a2[0]=0;\nif ((ar3[0]+ar3[1]+ar2[0])%2==0) a3[0]=1;\nelse a3[0]=0;\nif ((ar1[1]+ar1[0]+ar1[2]+ar2[1])%2==0) a1[1]=1;\nelse a1[1]=0;\nif ((ar2[1]+ar1[1]+ar3[1]+ar2[0]+ar2[2])%2==0) a2[1]=1;\nelse a2[1]=0;\nif ((ar3[1]+ar2[1]+ar3[0]+ar3[2])%2==0) a3[1]=1;\nelse a3[1]=0;\nif ((ar1[2]+ar1[1]+ar2[2])%2==0) a1[2]=1;\nelse a1[2]=0;\nif ((ar2[2]+ar2[1]+ar1[2]+ar3[2])%2==0) a2[2]=1;\nelse a2[2]=0;\nif ((ar3[2]+ar2[2]+ar3[1])%2==0) a3[2]=1;\nelse a3[2]=0;\nprintf(\"%d%d%d\\n%d%d%d\\n%d%d%d\",a1[0],a1[1],a1[2],a2[0],a2[1],a2[2],a3[0],a3[1],a3[2]);\n}\n", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6"} {"source_code": "/******************************************************************************\n\nWelcome to GDB Online.\nGDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,\nC#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.\nCode, Compile, Run and Debug online from anywhere in world.\n\n*******************************************************************************/\n#include \n\nint step (int n) {\n if (n==0) return 1;\n else return 10*step(n-1);\n}\n\nint tsifra (int chislo, int mesto) {\n int l, k=0;\n l= chislo;\n while (l!=0) {\n l=l/10;\n ++k;\n }\n k=k-mesto;\n while (k!=0) {\n chislo= chislo/10;\n --k;\n }\n chislo= chislo%10;\n return chislo;\n}\n\nint main()\n{\n int a=0,k=0,x,y,t;\n scanf (\"%d\",&x);\n while (x>a) {\n ++k;\n a=a+k*(step(k) - step(k-1));\n }\n a= x-(a- k*(step(k)-step (k-1)));\n y= step (k-1)-1 + a/k;\n if ((a%k)>0) {\n ++y;\n t=a%k;\n } else t = k;\n y= tsifra (y,t);\n printf (\"%d\",y);\n\n return 0;\n}\n", "src_uid": "1503d761dd4e129fb7c423da390544ff"} {"source_code": "#include\nlong long int fact[500005];\nlong long int modpow(long long int a, long long int n, long long int p)\n{\n\tlong long int res = 1;\n\twhile (n > 0)\n\t{\n\t\tif (n % 2 > 0)\n\t\t\tres = res * a % p;\n\t\ta = a * a % p;\n\t\tn /= 2;\n\t}\n\treturn res;\n}\nlong long int comb(long long int n, long long int r, long long int p)\n{\n\tlong long int res = fact[n];\n\tres = res * modpow(fact[r], p - 2, p) % p;\n\tres = res * modpow(fact[n - r], p - 2, p) % p;\n\treturn res;\n}\nint main()\n{\n\tlong long int n, k;\n\tscanf(\"%lld %lld\", &n, &k);\n\tlong long int p = 998244353;\n\tlong long int ans = 0;\n\tlong long int i;\n\tfact[0] = 1;\n\tfor (i = 1; i <= n; i++)\n\t\tfact[i] = fact[i - 1] * i % p;\n\tfor (i = 1; n / i >= k; i++)\n\t\tans = (ans + comb(n / i - 1, k - 1, p)) % p;\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "src_uid": "8e8eb64a047cb970a549ee870c3d280d"} {"source_code": "#include \n#include \n\nint main(void){\n\n char string[21];\n scanf(\"%s\", string);\n\n /* int alpha[26];\n \n for(int i=0;i<26;i++){\n alpha[i]=0;\n }\n */\n int length = strlen(string);\n\n /*\n for(int i=0;i0){\n distinct+=1;\n }\n }\n */\n int ways=26;\n\n ways+=(25*length);\n\n printf(\"%d\\n\", ways);\n\n\n}\n", "src_uid": "556684d96d78264ad07c0cdd3b784bc9"} {"source_code": "#include\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n if (n<=2){\n printf(\"-1\");\n }\n else{\n for (int i = n; i>0; i--)\n printf(\"%d \", i);\n }\n}\n", "src_uid": "fe8a0332119bd182a0a5b7758716317e"} {"source_code": "/**\n* I'm sorry I was an Idiot\n*/\n#include\n\nint main(){\n\tchar toSee[101];\n\tscanf(\"%s\",toSee);\n\tint conse = 0;\n\tint ans = 0;\n\tfor(int i = 0; toSee[i+1] != '\\0';++i){\n\t\tif(toSee[i] != toSee[i+1]){\n\t\t\t++ans;\n\t\t\tconse = 0;\n\t\t}\n\t\telse\n\t\t\t++conse;\n\t\tif(conse == 5){\n\t\t\t++ans;\n\t\t\tconse = 0;\n\t\t}\n\t}\n\t++ans;\n\tprintf(\"%d\\n\",ans);\n}", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11"} {"source_code": "#include\n#include\n#include\nint main()\n{\n\tint h=0,i,r=0,k=0,p=0;\n\tchar x[1000];\n\tscanf(\"%s\",&x);\n\tint len=strlen(x);\n\tfor(i=0;i0)\n\t\t k=0;\n\t\t}\n\t\telse if(x[i]=='U')\n\t\t{\n\t\t\tk++;\n\t\t if(h>0)\n\t\t h=1;\n\t\t}\n\t\telse if(x[i]=='B')\n\t\t{\n\t\t\tif((h==1)&&(k==1))\n\t\t\t{\n\t\t\t\tx[i]=' ';\n\t\t\t\tx[i-1]=' ';\n\t\t\t\tx[i-2]=' ';\n\t\t\t\th=k=0;\n\t\t\t}\n\t\t}\n\t\telse if(x[i])\n\t\t{\n\t\t\th=0;\n\t\t\tk=0;\n\t\t}\n\t}\n // printf(\"%s\\n\",x);\n for(i=0;i0))\n \t\tprintf(\" \");\n \t}\n \telse\n \t{\n \t\tprintf(\"%c\",x[i]);\n \t\tr=0;\n \t\tp++;\n \t}\n }\n}", "src_uid": "edede580da1395fe459a480f6a0a548d"} {"source_code": "#include\nint main()\n{\nint r,x,rev,i;\nlong long int j=1;\nscanf(\"%d\",&x);\nr=(x/1000)%10;\nrev=(x/10000)*10000+((x%1000)/100)*1000+(x%10)*100+((x%100)/10)*10+r;\nfor(i=1;i<=5;i++)\nj=(j*rev)%100000;\nprintf(\"%05lld\",j);\nreturn 0;\n}\n", "src_uid": "51b1c216948663fff721c28d131bf18f"} {"source_code": "#include\nint main ()\n{\n\tint a,b,c,d,f;\n\tscanf (\"%d %d %d %d\",&a,&b,&c,&d);\n\tif (b%c==0) f=b/c;\n\telse f=b/c+1;\n\tif ((a*f)%d==0) \n\tprintf(\"%d\",(a*f)/d);\n\telse printf(\"%d\",(a*f)/d+1);\n\treturn 0;\n} \n", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780"} {"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", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d"} {"source_code": "#include\n#include\n#include\n\nint main()\n{\n\tint nod,k;\n\tint64_t n,min,max,i,num,rem,s;\n\tfloat x,y;\n\n\tscanf(\"%I64d\",&n);\n\t//for(n=1;n<=200;n++){\n\tnum = n;nod=0;\n\twhile(num)\n\t{\n\t\trem = num%10;\n\t\tnum = num/10;\n\t\tnod++;\n\t}\n\t//printf(\"%d\\n\",nod);\n\n\tx = n;k = 9*(nod/2+1);\n\ty = (-k + sqrtf((k*k)+(4*x)))/2;min = y;\n\ty = (-1 + sqrtf(1+4*x))/2;max = y;\n\t\n\t//printf(\"%d %d\\n\",min,max);\n\n\t//x = n; y = sqrtf(n/2);min=y;\n\tfor(i=min;i<=max;i++)\n\t{\n\t\tnum = i; s = 0;\n\t\twhile(num)\n\t\t{\n\t\t\trem = num%10;\n\t\t\ts = s+rem;\n\t\t\tnum = num/10;\n\t\t}\n\t\t\n\t\tif(i*i + s*i == n)\t{printf(\"%I64d\\n\",i);break;}\n\t}\n\tif(i>max)\tprintf(\"-1\\n\");\n\t//}\n\treturn 0;\n}\n", "src_uid": "e1070ad4383f27399d31b8d0e87def59"} {"source_code": "#include \nchar d[3][3];\nint checkWin(char ch)\n{\n int a = 0, b = 0, c = 0;\n for(int i = 0; i < 3; i++)\n {\n if(d[i][0] == ch)\n a++;\n if(d[i][1] == ch)\n b++;\n if(d[i][2] == ch)\n c++;\n }\n// if(a+b == 6 || b+c == 6 || a+c == 6)\n// return -1;\n if(a == 3 || b == 3 || c == 3)\n return 1;\n a = 0, b = 0, c = 0;\n for(int i = 0; i < 3; i++)\n {\n if(d[0][i] == ch)\n a++;\n if(d[1][i] == ch)\n b++;\n if(d[2][i] == ch)\n c++;\n }\n// if(a+b == 6 || b+c == 6 || a+c == 6)\n// return -1;\n if(a == 3 || b == 3 || c == 3)\n return 1;\n a = 0;\n for(int i = 0; i < 3; i++)\n {\n if(d[i][i] == ch)\n a++;\n }\n if(a == 3)\n return 1;\n a = 0;\n for(int i = 0; i < 3; i++)\n {\n if(d[i][2-i] == ch)\n a++;\n }\n if(a == 3)\n return 1;\n return 0;\n}\nint main()\n{\n//\tfreopen(\"test.txt\", \"r\", stdin);\n int i = 0, j = 0;\n int first = 0, second = 0;\n char ch;\n while((ch=getchar())!=EOF)\n {\n if(ch == 'X' || ch == '0' || ch == '.')\n {\n if(ch == 'X')\n first++;\n else if(ch == '0')\n second++;\n\n d[i][j++] = ch;\n if(j == 3)\n i++, j = 0;\n }\n }\n/* for(int i = 0; i < 3; i++)\n {\n for(int j = 0; j < 3; j++)\n putchar(d[i][j]);\n putchar('\\n');\n }*/\n if(first > second+1 || first < second)\n {\n puts(\"illegal\");\n return 0;\n }\n if(checkWin('X') == 1 && checkWin('0') == 1)\n {\n puts(\"illegal\");\n return 0;\n }\n if(checkWin('X') < 0 || checkWin('0') < 0)\n {\n puts(\"illegal\");\n return 0;\n }\n if(checkWin('X') == 1)\n {\n if(first != second+1)\n puts(\"illegal\");\n else\n puts(\"the first player won\");\n return 0;\n }\n if(checkWin('0') == 1)\n {\n if(first != second)\n puts(\"illegal\");\n else\n puts(\"the second player won\");\n return 0;\n }\n if(first+second == 9)\n {\n puts(\"draw\");\n return 0;\n }\n if(first == second)\n puts(\"first\");\n else\n puts(\"second\");\n}", "src_uid": "892680e26369325fb00d15543a96192c"} {"source_code": "#include\n#include\nint main()\n{\n\tlong int n,i,j;\n\tscanf(\"%I64d\",&n);\n\tj=n%4;\n\tif(n==0)\n\tprintf(\"1\");\n\telse{\n\t\n\tswitch(j)\n\t{\n\tcase 1:\n\tprintf(\"8\");\n\tbreak;\n\tcase 2:\n\tprintf(\"4\");\n\tbreak;\n\tcase 3:\n\tprintf(\"2\");\n\tbreak;\n\tdefault:\n\tprintf(\"6\");\n\tbreak;}\n\t}\treturn 0;\n\t\t\n\t\t\n\t\t\n\t\t\n\n}", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f"} {"source_code": "#include\nint main()\n{\n int n,a[100],b,c,d,i;\n scanf(\"%d\",&n);\n for(i=0;i\n\nint cmpfnc(const void *p, const void *q)\n{\n\treturn (*(int*)p - *(int*)q);\n}\n\nint main()\n{\n\tint n,d,m,sum=0;;\n\tscanf(\"%d %d\",&n,&d);\n\tint ar[n],i;\n\tfor(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\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", "src_uid": "8218255989e5eab73ac7107072c3b2af"} {"source_code": "#include\nint main()\n{\nint n,i;\nscanf(\"%d\",&n);\nchar ch[n+69];\nscanf(\"%s\",ch);\nint B=0,R=0,G=0;\nfor(i=0;ch[i]!='\\0';i++)\n{\nif(ch[i]=='B')\nB++;\nelse\nif(ch[i]=='R')\nR++;\nelse\nif(ch[i]=='G')\nG++\t;\t\n}\n\n//\tprintf(\"%d %d %d\\n\",G,B,R);\n\n\nif(G>0 && B>0 && R>0)\nprintf(\"BGR\\n\");\nelse\nif(G==0)\n{\nif(R==0)\nprintf(\"B\");\nelse\nif(B==0)\nprintf(\"R\");\nelse\nif(R==1 && B==1)\nprintf(\"G\");\nelse\nif(R>1 && B==1)\nprintf(\"BG\");\nelse\nif(B>1 && R==1)\nprintf(\"GR\");\nelse\nprintf(\"BGR\");\t\n}\nelse\nif(B==0)\n{\nif(G==0)\nprintf(\"R\");\nelse\nif(R==0)\nprintf(\"G\");\nelse\nif(G==1 && R==1)\nprintf(\"B\");\nelse\nif(R>1 && G==1)\nprintf(\"BG\");\nelse\nif(G>1 && R==1)\nprintf(\"BR\");\nelse\nprintf(\"BGR\");\t\n}\nelse\nif(R==0)\n{\nif(G==0)\nprintf(\"B\");\nelse\nif(B==0)\nprintf(\"G\");\nelse\nif(G==1 && B==1)\nprintf(\"R\");\nelse\nif(B>1 && G==1)\nprintf(\"GR\");\nelse\nif(G>1 && B==1)\nprintf(\"BR\");\nelse\nprintf(\"BGR\");\n}\nreturn 0;\t\n}", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f"} {"source_code": "#include\nint main()\n{\n long long n,m,a;\n scanf(\"%lld%lld%lld\",&n,&m,&a);\n long long r=n%a==0?n/a:n/a+1;\n long long c=m%a==0?m/a:m/a+1;\n printf(\"%lld\",r*c);\n return 0;\n}", "src_uid": "ef971874d8c4da37581336284b688517"} {"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", "src_uid": "de7731ce03735b962ee033613192f7bc"} {"source_code": "/**\n* I'm sorry I was an Idiot\n*/\n#include\n#include\n#include\n#define max(x,y)(x > y? x:y)\n\nint memo[16][360];\nint N;\nint nums[16];\n\nint solve(int toTake,int sum){\n\tif(toTake == N){\n\t\tif(sum == 0)\n\t\t\treturn 1;\n\t\telse\n\t\t\treturn INT_MIN;\n\t}\n\tint neSum1 = sum +nums[toTake];\n\tint neSum2 = sum - nums[toTake];\n\tif(neSum1 >= 360)\n\t\tneSum1 -= 360;\n\tif(neSum2 < 0)\n\t\tneSum2 += 360;\n\treturn memo[toTake][sum] = max(solve(toTake+1,neSum1),solve(toTake+1,neSum2));\n}\n\nint main(){\n\t//puts(\"lil\");\n\tscanf(\" %d\",&N);\n\tmemset(memo,0,sizeof(memo));\n\tfor(int i = 0; i < N;++i){\n\t\tscanf(\" %d\",&nums[i]);\n\t}\n\tint ans = solve(0,0);\n\tif(ans < 0)\n\t\tputs(\"NO\");\n\telse\n\t\tputs(\"YES\");\n\treturn 0;\n}", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10"} {"source_code": "#include\nmain()\n{\n int i,j,k,l,a,c=0,b,s=0,f=1,g=1;\n char p[100],q[100];\n gets(p);\n l=strlen(p);\n for(i=0;i0;i--)\n {\n p[i]='9';\n }\n p[0]=p[0]-1;\n for(i=0;i\n\nint main() {\n\tlong long n, b;\n\tscanf(\"%lld%lld\", &n, &b);\n\tlong long ans = 1000000000000000000;\n\tfor( long long i=2, p, l, tn, cans; i*i <= b; ++i ) {\n\t\tif( b%i )\n\t\t\tcontinue;\n\t\tfor( l=0, p=1; b%i == 0 ; b /= i )\n\t\t\tl++;\n\t\tcans = 0;\n\t\tfor( tn=n/i; tn; tn /= i ) cans += tn;\n\t\tif( cans/l < ans )\n\t\t\tans = cans/l;\n\t}\n\tif( b != 1 ) {\n\t\tlong long cans = 0;\n\t\tfor( long long tn=n/b; tn; tn /= b ) cans += tn;\n\t\tif( cans < ans )\n\t\t\tans = cans;\t\t\n\t}\n\tprintf(\"%lld\\n\", ans);\n}", "src_uid": "491748694c1a53771be69c212a5e0e25"} {"source_code": "#include \n#include \n#include \n#define MAXN 23333\n#define MAXELEM 308\n\nint n, t;\nint a[MAXN];\n\n// Calculate the longest non-decreasing sequence\n// Time complexity: O(n log n)\nint *lnds(int *a, int n)\n{\n int *ret = (int *)malloc(n * sizeof(int));\n int a_with_f[MAXN], maxlen = 1;\n ret[0] = 1;\n a_with_f[0] = -1;\n a_with_f[1] = a[0];\n int lo, hi, mid, i;\n for (i = 1; i < n; ++i) {\n if (a[i] >= a_with_f[maxlen]) {\n a_with_f[++maxlen] = a[i];\n } else {\n lo = 0, hi = maxlen;\n while (lo < hi - 1) {\n mid = (lo + hi) / 2;\n if (a[i] >= a_with_f[mid]) lo = mid;\n else hi = mid;\n }\n a_with_f[lo + 1] = a[i];\n }\n ret[i] = maxlen;\n }\n return ret;\n}\n\nint main()\n{\n scanf(\"%d%d\", &n, &t);\n int i;\n for (i = 0; i < n; ++i) scanf(\"%d\", &a[i]);\n if (t <= 233) {\n for (i = n; i < n * t; i += n)\n memcpy(a + i, a, n * sizeof(int));\n int *first_part = lnds(a, n * t);\n printf(\"%d\\n\", first_part[n * t - 1]);\n } else {\n for (i = n; i < n * 233; i += n)\n memcpy(a + i, a, n * sizeof(int));\n int *first_part = lnds(a, n * 233);\n int count[MAXELEM] = { 0 }, maxcount = 0;\n for (i = 0; i < n; ++i) ++count[a[i]];\n for (i = 0; i < MAXELEM; ++i) if (maxcount < count[i]) maxcount = count[i];\n for (i = 0; i < n * 233; i += n)\n if (first_part[i + n] - first_part[i] == maxcount) break;\n i /= n;\n // assert(i == 1)?\n printf(\"%d\\n\", first_part[i * n + n - 1] + (t - i - 1) * maxcount);\n }\n return 0;\n}\n", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2"} {"source_code": "#include\n#include\nint main()\n{\n char s[3],t[3],xy,yx;\n int a,b,c,d,x,i=0;\n gets(s);\n gets(t);\n xy=s[0];\n a=s[1];\n yx=t[0];\n b=t[1];\n c=abs(xy - yx);\n d=abs(a-b);\n if(c>d){\n printf(\"%d\\n\",c);\n x=c;\n }\n else{\n printf(\"%d\\n\",d);\n x=d;\n }\n while(i<=x)\n {\n if(xyb)\n {\n printf(\"RD\\n\");\n a--;\n xy++;\n }\n else\n {\n printf(\"R\\n\");\n xy++;\n }\n i++;\n }\n else if(xy>yx){\n if(ab)\n {\n printf(\"LD\\n\");\n a--;\n xy--;\n }\n else\n {\n printf(\"L\\n\");\n xy--;\n }\n i++;\n }\n else{\n if(ab){\n printf(\"D\\n\");\n a--;\n }\n i++;\n }\n }\n\n}\n", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9"} {"source_code": "#include \nint main(){\n long long n,l,r;\n scanf(\"%lli %lli %lli\",&n,&l,&r);\n long long min;\n if(l>1) min = (n-l)+((1<=n){\n max = (1<\n\nint main()\n{\n int t;\n scanf(\"%d\", &t);\n while(t--)\n {\n int x, y = 0, le = 0, k = 0;\n \n scanf(\"%d\", &x);\n \n while(x > 0)\n {\n le++;\n y = x % 10;\n x = x / 10;\n }\n k = (y - 1) * 10;\n \n for(int i = 1; i <= le; i++)\n {\n k += i;\n }\n printf(\"\\n %d\", k);\n }\n\n return 0;\n}\n", "src_uid": "289a55128be89bb86a002d218d31b57f"} {"source_code": "#include \n#include \n#define mod 12345\n\nint a[27],v[27],p[1001],num[1001],mat[123][123],one[123][123],tmp[123][123];\nchar str[15];\nint s=1;\n\nvoid mi(long long a)\n{\n int i,j,k;\n if (!a)\n for (i=0;i>1);\n memset(tmp,0,sizeof(tmp));\n for (i=0;i='0'&&str[j]<='9';j++)\n num[i]=num[i]*10+str[j]-'0';\n s*=num[i];\n }\n for (i=1;i<=c;i++)\n v[p[i]]*=num[i];\n for (i=0;ic)\n break;\n }\n if (j>26)\n ans=(ans+mat[0][i])%mod;\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "src_uid": "76d4684d26dac380713a566a1e277c91"} {"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", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1"} {"source_code": "#include\n#include\n#include\nint main()\n{\n int x1,x2,y1,y2;\n while(~scanf(\"%d%d%d%d\",&x1,&y1,&x2,&y2))\n {\n int n1,n2,n3,tmp1,tmp2;\n printf(\"%d \",!(!abs(x1-x2))+!(!abs(y1-y2)));\n tmp1 = abs(x1-x2);\n tmp2 = abs(y1-y2);\n if((abs(tmp1-tmp2))%2!=0&&abs(tmp1-tmp2)>0)\n printf(\"0 \");\n else \n {\n if(tmp1==tmp2)\n printf(\"1 \");\n else \n printf(\"2 \");\n }\n printf(\"%d\\n\",tmp1>tmp2?tmp1:tmp2);\n }\n}\n", "src_uid": "7dbf58806db185f0fe70c00b60973f4b"} {"source_code": "#include\n#include\ntypedef long long unsigned llu;\ntypedef unsigned u;\nint cmp(const void*x,const void*y)\n{\n\tif(*(llu*)x>*(llu*)y)return 1;\n\tif(*(llu*)x<*(llu*)y)return-1;\n\treturn 0;\n}\nllu Ps[78499];\nu P[78499],S[15626],Pi;\nu DC(llu x)\n{\n\tu i,r=0;\n\tfor(i=-1;Ps[++i]<=x;)while(x%P[i]==0){++r;x/=P[i];}\n\treturn r+(x>1);\n}\nllu A[9],B[9];u D[9],n,r,N[9];\nvoid R(u deep)\n{\n\tu i,j,k;\n\tfor(i=deep;++i1);\n\t\t\tif(N[i]==i){j+=D[i];++k;}\n\t\t}\n\t\tj+=(k>1);\n\t\tif(r>j)r=j;\n\t}\n\telse{N[deep]=deep;R(deep+1);}\n\treturn;\n}\nint main()\n{\n\tu x,y,z,i,j;r=-1u;\n\tfor(x=5,z=4;x<=1000;z^=6,x+=z)\n\t{\n\t\tif((S[x>>6]>>((x>>1)&31))&1)continue;\n\t\tfor(y=x*x,n=z>>1;y<=1000000;n^=3,y+=x<>6]|=1<<((y>>1)&31);\n\t}\n\tPs[Pi]=4;P[Pi++]=2;Ps[Pi]=9;P[Pi++]=3;\n\tfor(x=5,z=4;x<=1000000;z^=6,x+=z)\n\t{\n\t\tif((S[x>>6]>>((x>>1)&31))&1)continue;\n\t\tPs[Pi]=x*(llu)x;P[Pi++]=x;\n\t}\n\tP[Pi]=i=-1u;Ps[Pi]=-1llu;\n\tfor(scanf(\"%u\",&n);++i\n#include\nint main()\n{\n\tint n,i;\n\tscanf(\"%d\",&n);\n\tint a[n];\n\tfor(i=0;ia[n-2])\n\t\t\tprintf(\"UP\");\n\t\telse\n\t\t\tprintf(\"DOWN\");\n\t}\n\telse if(a[n-1]==15)\n\t\tprintf(\"DOWN\");\n\telse\n\t\tprintf(\"UP\");\n}\n\n", "src_uid": "8330d9fea8d50a79741507b878da0a75"} {"source_code": "#include \"stdio.h\"\n\nint main(){\nint i,j,c1,c2,c3,c4,b=1;\nscanf(\"%d%d%d%d\",&c1,&c2,&c3,&c4);\nif(c1!=c4) b=0;\nif(c3!=0&&c1==0&&c4==0) b=0;\nif(b) printf(\"1\");\nelse printf(\"0\");\n\n}\n", "src_uid": "b99578086043537297d374dc01eeb6f8"} {"source_code": "#include\n#include\n#include\n#include\n#include\n#define oo 1000000000\n#define pi 3.14159265359\n#define zero(a) (abb(a)<=1e-7)\n#define lowbit(a) ((a)&(-(a)))\n#define min(a,b) ((a)<(b)?(a):(b))\n#define max(a,b) ((a)>(b)?(a):(b))\n#define abb(a) ((a)>0?(a):(-(a)))\n#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))\n#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))\n#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))\n\nlong head[27001]={0},e[1000001]={0},next[1000001]={0},num[27001]={0},p[2][27001]={0};\nchar rec[27001][35]={0},str[31][35]={0},tmp[35]={0},flag[27001]={0},visit[27001]={0};\nlong tot=1,totm=0;\n\nvoid add(long a,long b)\n{\n e[++totm]=b;\n next[totm]=head[a];\n head[a]=totm;\n}\n\nvoid qs(long x,long y)\n{\n long i=x,j=y;\n char t[35];\n strcpy(t,rec[(x+y)>>1]+1);\n if (x>=y)\n return;\n strcpy(rec[(x+y)>>1]+1,rec[x]+1);\n while (i0)\n j--;\n if (i>1;\n if (strcmp(rec[m]+1,tmp+1)>=0)\n r=m;\n else\n l=m;\n }\n if (!strcmp(rec[r]+1,tmp+1))\n add(x,r);\n}\n\nvoid dfs(long now)\n{\n long i;\n visit[now]=1;\n p[0][now]=p[1][now]=flag[now]=0;\n for (i=head[now];i;i=next[i])\n {\n if (!visit[e[i]])\n dfs(e[i]);\n if (!flag[e[i]]&&!flag[now]||!flag[e[i]]==flag[now]&&p[1][e[i]]+num[e[i]]>p[0][now]||!flag[e[i]]==flag[now]&&p[1][e[i]]+num[e[i]]==p[0][now]&&p[0][e[i]]\n#include\n\nint table[2][3000][3000];\nlong long g, x, y, z;\n#define MAXINT 0x7fffffff\n\nint nextg(){\n\tint ret=g;\n\tg=(g*x+y)%z;\n\treturn ret;\n}\n\nint min(int a, int b){\n\treturn a>1;\n\ta|=a>>2;\n\ta|=a>>4;\n\ta|=a>>8;\n\ta|=a>>16;\n\treturn (a+1)>>1;\n}\n\nint main(){\n\tint i, j, k, n, m, a, b, tren=0, prev, l;\n\tlong long sum=0;\n\tscanf(\"%d %d %d %d %I64d %I64d %I64d %I64d\", &n, &m, &a, &b, &g, &x, &y, &z);\n\tfor(i=0;i>1)\nmain()\n{\n int s,v1,v2,t2,t1,a,b,c,d;\n while(scanf(\"%d%d%d%d%d\",&s,&v1,&v2,&t1,&t2)!=EOF)\n {\n a=(s*v1)+(2*t1);\n b=(s*v2)+(2*t2);\n if(a>b)\n printf(\"Second\\n\");\n else if(a\nmain(){\n char s[]=\"GBIV\";\n int n,i=0;\n scanf(\"%d\",&n);\n printf(\"ROY\");\n while(i\n#include \n\n\nint main()\n{\n\tint i, j, k, len, max = 0;\n\tchar str[110];\n\n\tscanf(\"%s\", str);\n\tlen = strlen(str);\n\trepi(len) rep(j, i+1, len-1)\n\t{\n\t\tk = 0;\n\t\twhile (k < len && str[i+k] == str[j+k]) k++;\n\t\tif (max < k) max = k;\n\t}\n\tprintf(\"%d\\n\", max);\n\treturn 0;\n}\n", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7"} {"source_code": "#include \n#include \nint main(){\n\tint x,y,n;\n\tscanf(\"%d %d %d\\n\",&x,&y,&n);\n\tdouble res = (double)0/1, input = (double)x/y;\n\tint a = 0, b = 1;\n\tint num = 0;\n\tint i;\n\tfor(i = 1; i <= n; i++){\n\t\twhile(1){\n\t\t\tdouble cur = (double)num/i;\n\t\t\tif(fabs(cur-input) < fabs(res-input)){\n\t\t\t\tres = cur;\n\t\t\t\ta = num;\n\t\t\t\tb = i;\n\t\t\t}\n\t\t\tif(num <= x && fabs((double)(num+1)/i - input) < fabs(cur-input) ){\n\t\t\t\tnum++;\n\t\t\t}\n\t\t\telse{\tbreak;\t}\n\t\t}\n\n\t}\n\tprintf(\"%d/%d\\n\",a,b);\n\n\treturn 0;\n}\n", "src_uid": "827bc6f120aff6a6f04271bc84e863ee"} {"source_code": "#include \nlong long n,res,a=1;\nint main()\n{\n\tfor (scanf(\"%I64d\",&n);a>1)),a<<=1ll);\n\tprintf(\"%I64d\\n\",res);\n\treturn 0;\n}", "src_uid": "a98f0d924ea52cafe0048f213f075891"} {"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", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d"} {"source_code": "# include \nint main()\n{\n int n, m, x, y, min;\n while(scanf(\"%d%d\", &n, &m) != EOF)\n {\n min = n < m ? n : m;\n x = (m + n) / 3;\n y = x < min ? x : min;\n printf(\"%d\\n\", y);\n }\n return 0;\n}\n\n\n ", "src_uid": "0718c6afe52cd232a5e942052527f31b"} {"source_code": "#include \n#include \nint cmpfunc(const void *a,const void *b){\n return *(int*)a-*(int*)b;\n}\nint main()\n{\n char a[3],b[3],c[3];\n scanf(\"%s%s%s\",a,b,c);\n int a1[3];\n a1[0]=(int)a[0]-48;\n a1[1]=(int)b[0]-48;\n a1[2]=(int)c[0]-48;\n qsort(a1,3,sizeof(int),cmpfunc);\n if(a[1]!=b[1] && a[1]!=c[1] && b[1]!=c[1]){\n printf(\"2\");exit(0);\n }\n else{\n if(a[1]==b[1] && a[1]==c[1]){\n if(a1[0]==a1[1] && a1[1]==a1[2]){\n printf(\"0\");exit(0);\n }\n else if(a1[1]-a1[0]==1 && a1[2]-a1[1]==1){printf(\"0\");exit(0);}\n else if(a1[0]==a1[1] || a1[1]==a1[2]){printf(\"1\");exit(0);}\n else if(a1[1]-a1[0]==1 || a1[2]-a1[1]==2 || a1[1]-a1[0]==2 || a1[2]-a1[1]==1){printf(\"1\");exit(0);}\n else {printf(\"2\");exit(0);}\n }\n else if(a[1]==b[1]){\n if((int)a[0]==(int)b[0] || abs((int)a[0]-(int)b[0])==1 || abs((int)a[0]-(int)b[0])==2){printf(\"1\");exit(0);}\n else {printf(\"2\");exit(0);}\n }\n else if(a[1]==c[1]){\n if((int)a[0]==(int)c[0] || abs((int)a[0]-(int)c[0])==1 || abs((int)a[0]-(int)c[0])==2){printf(\"1\");exit(0);}\n else {printf(\"2\");exit(0);}\n }\n else{\n if((int)c[0]==(int)b[0] || abs((int)c[0]-(int)b[0])==1 || abs((int)c[0]-(int)b[0])==2){printf(\"1\");exit(0);}\n else {printf(\"2\");exit(0);}\n }\n\n }\n return 0;\n}\n", "src_uid": "7e42cebc670e76ace967e01021f752d3"} {"source_code": "#include \r\n\r\nint a[128], mem[128][204800];\r\n\r\nint main(void) {\r\n int n, s = 0;\r\n scanf(\"%d\", &n);\r\n for (int i = 1; i <= n; i++) {\r\n scanf(\"%d\", &a[i]);\r\n }\r\n mem[0][0] = 1;\r\n for (int i = 1; i <= n; i++) {\r\n s += a[i];\r\n for (int j = 0; j <= s; j++) {\r\n if (j >= a[i] && mem[i - 1][j - a[i]]) mem[i][j] = 1;\r\n else if (mem[i - 1][j]) mem[i][j] = 1;\r\n }\r\n }\r\n if (s & 1) printf(\"0\");\r\n else if (mem[n][s / 2]) {\r\n printf(\"1\\n\");\r\n for (int i = 1; i <= n; i++) {\r\n if (a[i] & 1) {\r\n printf(\"%d\", i);\r\n return 0;\r\n }\r\n else if (!mem[n][(s - a[i]) / 2]) {\r\n printf(\"%d\", i);\r\n return 0;\r\n }\r\n }\r\n return 1;\r\n }\r\n else printf(\"0\");\r\n return 0;\r\n}", "src_uid": "29063ad54712b4911c6bf871969ee147"} {"source_code": "#include\n#include\nint main()\n{\n int l=0,z,g=0;\n char a[1000],t;\n scanf(\"%s\",&a);\n z=strlen(a);\n for(int i=0;i='A'&&b[i]<'a')&&b[i]!='.')\n b[i]=b[i]+32;\n printf(\"%c\",b[i]);\n}\n}\n//koko", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b"} {"source_code": "#include\n\nlong long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}\nlong long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}\n\nint main(){\n long long n,a[128],res=1;\n scanf(\"%lld\",&n);\n for(int i=1;i<=n;i++){scanf(\"%lld\",&a[i]);}\n for(int i=1;i<=n;i++){\n long long len=1,pt=a[i];\n while(len<1000){\n if(pt==i){break;}\n len++;\n pt=a[pt];\n }\n if(len==1000){puts(\"-1\");return 0;}\n if(len%2==0){len/=2;}\n res=lllcm(len,res);\n }\n printf(\"%lld\\n\",res);\n}", "src_uid": "149221131a978298ac56b58438df46c9"} {"source_code": "#include \n#include \n\n#define N\t100000\n\nint jj[N], pp[N], dd[N], mn;\n\nvoid match(int i) {\n\twhile (dd[i] == 1) {\n\t\tint j = jj[i], tmp;\n\n\t\tif (pp[i] == i || dd[j] == 1)\n\t\t\ttmp = pp[i], pp[i] = pp[j], pp[j] = tmp;\n\t\telse\n\t\t\tmn -= 2;\n\t\tjj[i] ^= j, dd[i] = 0, jj[j] ^= i, dd[j]--;\n\t\ti = j;\n\t}\n}\n\nint main() {\n\tint n, h, i, j;\n\n\tscanf(\"%d\", &n);\n\tfor (h = 0; h < n - 1; h++) {\n\t\tscanf(\"%d%d\", &i, &j), i--, j--;\n\t\tjj[i] ^= j, dd[i]++, jj[j] ^= i, dd[j]++;\n\t}\n\tfor (i = 0; i < n; i++)\n\t\tpp[i] = i;\n\tmn = (n - 1) * 2;\n\tfor (i = 0; i < n; i++)\n\t\tmatch(i);\n\tprintf(\"%d\\n\", mn);\n\tfor (i = 0; i < n; i++)\n\t\tprintf(\"%d \", pp[i] + 1);\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "src_uid": "98ded03cdd1870500667f0069d6a84b1"} {"source_code": "#include\n// Merges two subarrays of arr[].\n// First subarray is arr[l..m]\n// Second subarray is arr[m+1..r]\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}\n\nint fu(int a,int b){\nif(a-b<=0){\n return 0;\n}\nelse{\n return a-b;\n}\n}\nint main()\n{\n int n,m,arr[100],i,l,r,mid,in,j,sum=0,w;\n scanf(\"%d%d\",&n,&m);\n for(i=1;i<=n;i++){\n scanf(\"%d\",&arr[i]);\n }\n mergeSort(arr,1,n);\n l=1;r=n;\n while(l<=r)\n {sum=0;w=n;\n mid=(l+r)/2;\n (n%mid==0)?(in=n/mid):(in=(n/mid)+1);\n for(i=0;i=1;j++){\n sum=sum+fu(arr[w],i);\n w--;//printf(\"%d \",sum);\n }\n }//printf(\"\\n%d_%d \",mid,sum);\n if(sum==m){l=mid;r=mid;\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\n else printf(\"-1\");\n return 0;\n}\n", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d"} {"source_code": "#include\nint main() \n{\n\tchar s[28];\n\tchar map[3][14];\n\tint i,j,l,r,mid,n;\n\tscanf(\"%s\",s+1);\n\tfor(i=1;i<=26;i++) \n\t\tfor(j=i+1;j<=27;j++)\n\t\t\tif(s[i]==s[j])\n\t\t\t{\n\t\t\t\tl=i;\n\t\t\t\tr=j;\n\t\t\t}\n\tif(r-l==1)\n\t\tprintf(\"Impossible\");\n\telse\n\t{\n\t\tmid=(r-1-l)/2;\n\t\tn=r-mid;\n\t\tfor(i=1;i<=13;)\n\t\t{\n\t\t\tif(n!=l)\n\t\t\t{\n\t\t\t\tmap[1][i]=s[n];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tn++;\n\t\t\tif(n==28)\n\t\t\t\tn=1;\n\t\t}\n\t\tfor(i=13;i>0;)\n\t\t{\n\t\t\tif(n!=l)\n\t\t\t{\n\t\t\t\tmap[2][i]=s[n];\n\t\t\t\ti--;\n\t\t\t}\n\t\t\tn++;\n\t\t\tif(n==28)\n\t\t\t\tn=1;\n\n\t\t}\n\t\tfor(i=1;i<=2;i++)\n\t\t{\n\t\t\tfor(j=1;j<=13;j++)\n\t\t\t\tprintf(\"%c\",map[i][j]);\n\t\t\tprintf(\"\\n\");\n\t\t}\n\t}\n\treturn 0;\n}\n", "src_uid": "56c5ea443dec7a732802b16aed5b934d"} {"source_code": "#include \nlong long int b,s,num,n[4],p[4],r,c;\n\nint main()\n{\n\tchar str[101];\n\tscanf(\"%s\",str);\n\tc=0;b=0;s=0;\n\tlong long int i,j,k;\n for(i=0;str[i]!='\\0';i++)\n {\n \tif(str[i]=='B')\n \t\tb++;\n \telse if(str[i]=='S')\n \t\ts++;\n \telse\n \t\tc++;\n\n }\n //printf(\"%I64d %I64d %I64d\",b,s,c);\n num=0;\n long long int bb=b,ss=s,cc=c;\n\tfor(i=1;i<4;i++)\n\tscanf(\"%I64d\",&n[i]);\n\tfor(i=1;i<4;i++)\n\tscanf(\"%I64d\",&p[i]);\n\tscanf(\"%I64d\",&r);\n\n\twhile(1)\n\t{\n\n\t\tif((n[1]==0 || b==0) && (n[2]==0 || s==0) && (n[3]==0 || c==0))\n\t\t\tbreak;\n\t\tif(n[1]-b>=0)\n\t\t\tn[1]=n[1]-b;\n\t\telse\n\t\t\t{r=r-(b-n[1])*p[1];\n\t\t\t\tif(r<0)\n\t\t\t\t\t{printf(\"%d\",num);\n\t\t\t\treturn 0;}\n\t\t n[1]=0;}\n\t\tif(r==0)\n\t\t\tbreak;\n\t\tif(n[2]-s>=0)\n\t\t\tn[2]=n[2]-s;\n\t\telse\n\t\t\t{r=r-(s-n[2])*p[2];\n\t\t\t\tif(r<0)\n\t\t\t\t\t{printf(\"%d\",num);\n\t\t\t\treturn 0;}\n\t\tn[2]=0;}\n\t\tif(r==0)\n\t\t\tbreak;\n\t\tif(n[3]-c>=0)\n\t\t\tn[3]=n[3]-c;\n\t\telse\n\t\t\t{r=r-(c-n[3])*p[3];\n\t\t\t\tif(r<0)\n\t\t\t\t\t{printf(\"%d\",num);\n\t\t\t\treturn 0;}\n\t\tn[3]=0;}\n\t\tif(r==0)\n\t\t\tbreak;\n\t\t//printf(\"%I64d %I64d %I64d\\n\",n[1],n[2],n[3]);\n\t\tnum++;\n\n\t}\n\tif(r==0)\n\t\t{\t\n\t\tprintf(\"%I64d\",num+1);\n\t\treturn 0;\n\t\t}\n\tlong int req=b*p[1]+s*p[2]+c*p[3];\n\tnum=num+r/req;\n\tprintf(\"%I64d\",num);\n\n}", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e"} {"source_code": "#include\n#include\n\nint main()\n{\n\n char str[100];\n scanf(\"%s\", str);\n int l,i;\n l = strlen(str);\n for(i=l-1;i>=0;i--){\n if(str[i]=='0'){\n str[i] = '\\0';\n }\n else break;\n }\n int l1,flag;\n l1 = strlen(str);\n flag=0;\n for(i=0;i\n\nint main()\n{\n unsigned long long a, b;\n unsigned long long c = 0;\n\n scanf(\"%I64u %I64u\", &a, &b);\n\n while ((a > 0) && (b > 0))\n {\n if (a >= b)\n {\n c += a / b;\n a = a % b;\n }\n else\n {\n c += b / a;\n b = b % a; \n }\n }\n\n printf(\"%I64u\", c);\n\n return 0;\n}\n\n/*\na = 10 b = 7\na = 10 % 7\n\n\n\n*/\n", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83"} {"source_code": "#include \n\nint main(){\n\tint a[1000];\n\tint n, i, elimina, dif, difMax = 0, difMin = 1000;\n\n\tscanf(\"%d\", &n);\n\n\tfor(i = 0; i < n; i++) scanf(\"%d\", &a[i]);\n\n\tfor(elimina = 1; elimina < n-1; elimina++){\n\t\tdifMax = 0;\n\t\t\n\t\tfor(i = 1; i < n; i++){\n\t\t\tif(elimina == i){\n\t\t\t\tdif = a[i+1] - a[i-1];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tdif = a[i] - a[i-1];\n\t\t\t}\n\n\t\t\tif(dif > difMax) difMax = dif;\n\t\t}\n\n\t\tif(difMax < difMin) difMin = difMax; \n\t}\n\n\tprintf(\"%d\\n\", difMin);\n\n\treturn 0;\n}", "src_uid": "8a8013f960814040ac4bf229a0bd5437"} {"source_code": "#include\n\nint main(){\n\n int w, h, k;\n\n scanf(\"%d %d %d\",&w, &h, &k);\n\n printf(\"%d\",2*k*(w + h) - 4*k*(2*k - 1));\n\n return 0;\n}\n", "src_uid": "2c98d59917337cb321d76f72a1b3c057"} {"source_code": "#include \n\nenum {\n BOUND = 10000 * 1010,\n MAXP = 1000\n};\n\nchar notPrime[BOUND];\nint conv[BOUND];\n\nint countPower(int x, int n) {\n int res = 0;\n while(n % x == 0) {\n n /= x;\n res++;\n }\n return res;\n}\n\nvoid init() {\n int i, j;\n for(i = 1; i < BOUND; i++)\n conv[i] = 1;\n notPrime[0] = notPrime[1] = 1;\n for(i = 2; i < BOUND; i++) {\n if(notPrime[i]) continue;\n conv[i] *= i;\n for(j = 2; i * j < BOUND; j++) {\n notPrime[i * j] = 1;\n if(countPower(i, j) % 2 == 0)\n conv[i * j] *= i;\n }\n }\n}\n\nint main() {\n int i, n, a;\n long long ans = 0;\n init();\n scanf(\"%d %d\", &a, &n);\n for(i = a; i < a + n; i++) {\n ans += conv[i];\n }\n printf(\"%I64d\\n\", ans);\n return 0;\n}\n", "src_uid": "915081861e391958dce6ee2a117abd4e"} {"source_code": "#include \n\nint mod_inv(int a, int p){\n\tint y = p-2;\n\tint res = 1;\n\twhile(y!=0){\n\t\tif(y&1){\n\t\t\tres = ((long long)res * a)%p;\n\t\t}\n\t\ta = ((long long)a*a)%p;\n\t\ty = y>>1;\n\t}\n\treturn res;\n}\n\nint main(void) {\n\t// your code goes here\n\tint n,c,i;\n\tscanf(\"%d %d\",&n,&c);\n\tint res = c;\n\tint prev = c;\n\tint p = 1000003;\n\tfor(i=2; i<=n ;i++){\n\t\tprev = ((((long long)(c+i-1)*prev)%p)*mod_inv(i,p))%p;\n\t\tres = (res + prev)%p;\n\t}\n\tprintf(\"%d\\n\",res);\n\treturn 0;\n}", "src_uid": "e63c70a9c96a94bce99618f2e695f83a"} {"source_code": "#include \n\nint main(){\n int n,t,k,d;\n int oven1;\n int i;\n int totalCakes = 0;\n int isO2Built = 0;\n scanf(\"%d %d %d %d\",&n, &t, &k, &d);\n oven1 = ((n/k)+(n%k!=0))*t;\n for(i = 0; i < oven1; i++){\n if(i == d) isO2Built = 1;\n if(i%t == 0 && i > 0) totalCakes += k;\n if(isO2Built && (i-d)%t == 0 && (i-d) > 0) totalCakes += k;\n if(totalCakes >= n) break;\n }\n // printf(\"cakes: %d, time: %d\\n\",totalCakes, i );\n if(i < oven1) printf(\"YES\\n\" );\n else printf(\"NO\\n\" );\n}\n", "src_uid": "32c866d3d394e269724b4930df5e4407"} {"source_code": "#include \n#include \n\nint main()\n{\n int a;\n int q,r,sum;\n\n\n\n\n\n scanf(\"%d\",&a);\n\n do\n {\n sum=0;\n q=a;\n\n while(q!=0)\n {\n r=q%10;\n q=q/10;\n sum=sum+r;\n }\n\n\n if(sum%4==0)\n {\n printf(\"%d\\n\",a);\n }\n a=a+1;\n }\n while(sum%4!=0);\n\n return 0;\n}\n\n\n", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7"} {"source_code": "#include \n#include \n\nvoid swap(int *n, int *m)\n{\n int temp = *n;\n *n = *m;\n *m = temp;\n}\n\nint main()\n{\n char str[101];\n scanf(\"%s\", str);\n\n int len = strlen(str);\n int nums[101];\n for(int i = 0; i < len; i += 2) {\n nums[i] = str[i] - '0'; \n }\n\n for(int i = 0; i < len; i += 2) {\n for(int k = i + 2; k < len; k += 2) {\n if(nums[i] > nums[k]) {\n swap(&nums[i], &nums[k]);\n }\n }\n }\n\n for(int i = 0; i < len; i += 2) {\n printf(\"%d\", nums[i]);\n if(i != len - 1) printf(\"+\");\n }\n\n return 0;\n}", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8"} {"source_code": "#include\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#include\nchar cmd[100005];\nint main()\n{\n\tint n;\n\tint l = 0, r = 0;\n\tint sum = 0;\n\tscanf(\"%d\", &n);\n\tscanf(\"%s\", cmd);\n\tfor (int i = 0;i < n;i++)\n\t{\n\t\tif (cmd[i] == 'L')l++;\n\t\telse r++;\n\t}\n\tif (l != r)sum = l + r +1;\n\telse sum = l + r + 1;\n\t\tprintf(\"%d\", sum);\n\treturn 0;\n}", "src_uid": "098ade88ed90664da279fe8a5a54b5ba"} {"source_code": "#include\nint main()\n{\n int n,a,r;\n scanf(\"%d\",&n);\n if(n>=0)\n {\n printf(\"%d\",n);\n return 0;\n }\n n=n*(-1);\n a=n%10;\n n=n/10;\n r=n%10;\n n=n/10;\n if(a>r)\n {\n if(n==0&&r==0)\n {\n printf(\"%d\",n);\n return 0;\n }\n if(n==0&&r!=0)\n {\n printf(\"-%d\",r);\n return 0;\n }\n printf(\"-%d%d\",n,r);\n }\n else\n {\n if(n==0&&a==0)\n {\n printf(\"%d\",n);\n return 0;\n }\n if(n==0&&a!=0)\n {\n printf(\"-%d\",a);\n return 0;\n }\n printf(\"-%d%d\",n,a);\n }\n return 0;\n}\n", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e"} {"source_code": "#include\n#include\nint dir[6][2]={{-1,2},{-2,0},{-1,-2},{1,-2},{2,0},{1,2}};\nint main()\n{\n long long n,i;\n scanf(\"%lld\",&n);\n double x,y;\n double a;\n if(!n)\n printf(\"0 0\\n\");\n else\n { \n long long a=sqrt(n/3);\n for(;;++a)\n {\n if(a*(a+1)/2*6==n)\n {\n printf(\"%d %d\\n\",a*2,0);\n return 0;\n }\n if(a*(a+1)/2*6>n)\n {\n break;\n }\n }\n n-=(a*(a-1))*3;\n if(n==0)\n printf(\"%.0lld 0\\n\",2*(a-1));\n else{\n \n x=2*(a-1);y=0; //第a圈的起点 \n i=0; //i记录移动几次 \n x+=1;y+=2;i++; \n\n if(i==n)\n {\n printf(\"%.lf %.lf\\n\",x,y);\n return 0;\n }\n n--;\n for(int k=0;k<6;++k)\n {\n long long t=(k<=0?a-1:a);\n if(n>=t)\n {\n x+=t*dir[k][0];\n y+=t*dir[k][1];\n n-=t;\n }\n else\n {\n x+=n*dir[k][0];\n y+=n*dir[k][1];\n break;\n }\n } \n printf(\"%.lf %.lf\\n\",x,y);\n }\n }\n return 0;\n}", "src_uid": "a4b6a570f5e63462b68447713924b465"} {"source_code": "#include\nint main()\n{\n int a[3]={-1,-1,-1};\n int b[3]={-1,-1,-1};\n int aa[8],bb[8];\n int ca=0,cb=0,ia,ib,i,j;\n for(i=0;i<8;i++)\n {\n scanf(\"%d %d\",&ia,&ib);\n aa[i]=ia; bb[i]=ib;\n if(ia!=a[0] && ia!=a[1] && ia!=a[2])\n {\n a[ca]=ia;\n ca++;\n }\n if(ib!=b[0] && ib!=b[1] && ib!=b[2])\n {\n b[cb]=ib;\n cb++;\n }\n }\n for(i=0;i<3;i++)\n {\n int ta,tb;\n for(j=i+1;j<3;j++)\n {\n if(a[i]>a[j])\n {\n ta=a[j];\n a[j]=a[i];\n a[i]=ta;\n }\n if(b[i]>b[j])\n {\n tb=b[j];\n b[j]=b[i];\n b[i]=tb;\n }\n }\n }\n for(i=0;i<8;i++)\n {\n for(j=i+1;j<8;j++)\n {\n if(aa[i]==aa[j])\n {\n if(bb[i]==bb[j])\n {\n printf(\"ugly\");\n return 0;\n }\n }\n }\n if(aa[i]==a[1] )\n {\n if(bb[i]==b[1] )\n {\n printf(\"ugly\");\n return 0;\n }\n }\n }\n if(ca==3 && cb==3)\n {\n printf(\"respectable\");\n return 0;\n }\n else\n printf(\"ugly\");\n return 0;\n}\n", "src_uid": "f3c96123334534056f26b96f90886807"} {"source_code": "#include\n\nint main()\n{\n\tlong long int n,i,k;\n\tscanf(\"%lld %lld\",&n,&k);\n\tfor(i=0;i\nint main()\n{\n\tint i,a,b,x,c,d;\n\tscanf(\"%d %d %d\",&a,&b,&x);\n\tint arr[x+1];\n\tc=a;\n\td=b;\n\tfor(i=0;i\n#include \nint main()\n{\n char a,b,c,d,e;\n int i,j,k,l;\n scanf(\"%d:%d\",&i,&j);\n l=0;\n while(i%10!=j/10 || i/10!=j%10)\n {\n l++;\n j++;\n if(j>59)\n {\n j=0;\n i++;\n }\n if(i==24)\n break;\n }\n printf(\"%d\",l);\n}", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5"} {"source_code": "#include\nint main()\n{\n long long int n,m,k,max,min,rem,ans,var;\n scanf(\"%lld%lld%lld\", &n, &m, &k);\n if(n>=m)\n {\n max = n;\n min = m;\n }\n else\n {\n max = m;\n min = n;\n }\n if(kans)\n ans = var;\n //}\n }\n }\n else\n {\n rem = k - (max-1);\n// printf(\"%lld\\n\", rem);\n if(rem < min)\n {\n if(min%(rem+1)==0)\n ans = min/(rem + 1);\n else\n ans = min/(rem + 1);\n }\n else\n ans = -1;\n }\n printf(\"%lld\\n\", ans);\n return 0;\n}\n", "src_uid": "bb453bbe60769bcaea6a824c72120f73"} {"source_code": "#include\n\nlong long mod = 998244353;\n\nlong long dp[2002][2002];\n\nlong long mod1(long long n, long long k){\n\n int i, j;\n\n for(i = 0; i < n; i++){\n\n dp[i][0] = 1;\n\n dp[i][1] = i;\n\n dp[i][i] = 1;\n }\n for(i = 2; i < n; i++){\n\n for(j = 1; j < i; j++){\n\n dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;\n }\n }\n return dp[n - 1][k];\n}\nlong long bigmod(long a, long p){\n\n long long res = 1;\n\n long long x = a;\n\n while(p){\n\n if(p & 1){\n\n res = (res*x) % mod;\n }\n x = (x*x)%mod;\n\n p = p >> 1;\n }\n res = (res*(a + 1))%mod;\n\n return res;\n}\nint main(){\n\n long long n,m,k;\n\n scanf(\"%lld %lld %lld\",&n,&m,&k);\n\n long long r = (mod1(n,k)*bigmod(m - 1, k))%mod;\n\n printf(\"%lld\",r);\n\n return 0;\n}\n", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b"} {"source_code": "#include \n\nint min(int a, int b) {\n\treturn a <= b ? a : b;\n}\n\nint main(void) {\n\tint p1; int p2; int p3; int p4; int a; int b;\n\t\n\tscanf(\"%d%d%d%d%d%d\", &p1, &p2, &p3, &p4, &a, &b);\n\t\n\tint min_p = p1;\n\tmin_p = min(min_p, p2);\n\tmin_p = min(min_p, p3);\n\tmin_p = min(min_p, p4);\n\t\n\tint result = 0;\n\tif (a < min_p) {\n\t\tresult = min_p - a;\n\t\tif (b < min_p) result = b - a + 1;\n\t}\n\t\n\tprintf(\"%d\\n\", result);\n\t\n\treturn 0;\n}\n", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a"} {"source_code": "#include\n\nint answer(long long int bx,long long int by,long long int cx,long long int cy);\n\nint main(void){\n struct vector{\n long long int x;\n long long int y;\n }a,b,c,d;\n int flg,j,k;\n \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 flg=0;\n flg+=answer(b.x-a.x,b.y-a.y,c.x,c.y);\n flg+=answer(b.x+a.y,b.y-a.x,c.x,c.y);\n flg+=answer(b.x+a.x,b.y+a.y,c.x,c.y);\n flg+=answer(b.x-a.y,b.y+a.x,c.x,c.y);\n\n if(flg==0) puts(\"NO\");\n else puts(\"YES\");\n return 0;\n}\n\nint answer(long long int bx,long long int by,long long int cx,long long int cy){\n long long int tmp;\n if(cx==0 && cy==0){\n if(bx==0 && by==0) return 1;\n return 0;\n }\n if(cx==0){\n if(bx%cy==0 && by%cy==0) return 1;\n return 0;\n }else if(cy==0){\n if(bx%cx==0 && by%cx==0) return 1;\n return 0;\n }else{\n tmp=cx*cx+cy*cy;\n if((bx*cx+by*cy)%tmp==0 && (by*cx-bx*cy)%tmp==0) return 1;\n return 0;\n }\n return 0;\n}\n\n\n\n\n\n \n", "src_uid": "cc8a8af1ba2b19bf081e379139542883"} {"source_code": "#include\n#include\nint main()\n{\n int i,pos=0;\n char s[100009],s1[1000009];\n scanf(\"%s\",s);\n int l=strlen(s);\n for(i=0;i=26)\n printf(\"%s\",s1);\n else\n printf(\"-1\");\n return 0;\n}", "src_uid": "f8ad543d499bcc0da0121a71a26db854"} {"source_code": "#include\nint main(){\nint i,j,m,max=0,min,A[100],n,a;\nscanf(\"%d\",&n);\nscanf(\"%d\",&m);\nfor(i=0;imax){\n max=A[i];\n }\n}\na=m;\ni=0;\nwhile(m>0&&i=(max-A[i])){\n m=m-(max-A[i]);\n //printf(\"%d %d\\n\",A[i],m);\n }\n else if(m<(max-A[i])){\n A[i]=A[i]+m;\n m=0;\n }\n\n }\n min=max;\n i=i+1;\n}\n\n//printf(\"%d %d\",min,m);\nif(m!=0)\n min=min+m/n;\nif(m%n!=0)\n min=min+1;\nprintf(\"%d %d\",min,max+a);\n}\n", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d"} {"source_code": "#include \n\nint main() {\n\tlong long n, x;\n\n\tscanf(\"%lld\", &n);\n\tfor (x = 2; x * x <= n; )\n\t\tif (n % (x * x) == 0)\n\t\t\tn /= x;\n\t\telse\n\t\t\tx++;\n\tprintf(\"%lld\\n\", n);\n\treturn 0;\n}\n", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92"} {"source_code": "/*\nID: mohamma73\nLANG: C\nTASK: crypt1\n*/\n\n#include\"stdio.h\"\n#include\"stdlib.h\"\n#include\"ctype.h\"\n#include\"math.h\"\n#include\"string.h\"\nstruct element{\n\tint val;\n\tint indx;\n};\nstruct person{\n\tint id;\n\tint nd;\n\tint nl;\n\tint like[15];\n\tint dis[15];\n};\nstruct farmer{\n\tint p;\n\tint c;\n};\nvoid inc(int *a,int n){\n\tint i;\n\tif(a[0]!=2){\n\t\ta[0]++;\n\t\treturn;\n\t}\n\tfor(i=0;it[j])\n\t\treturn 1;\n\telse if(s[i]0 && a[j]l){\n\t\tint q=(l+n)/2;\n\t\tmergesort(a,l,q);\n\t\tmergesort(a,q+1,n);\n\t\tmerge(a,l,q,n);\n\t}\n}\nint isOkay(int a,int *s , int n){\n\tif(a<100 || a>=1000)\n\t\treturn 0;\n\tint c,i;\n\twhile(a/10>0){\n\t\tc=0;\n\t\tfor(i=0;i=10000)\n\t\treturn 0;\n\tint c,i;\n\twhile(a/10>0){\n\t\tc=0;\n\t\tfor(i=0;i0 && a[j-1]>a[j];j--){\n\t\t\t\ttemp=a[j];\n\t\t\t\ta[j]=a[j-1];\n\t\t\t\ta[j-1]=temp;\n\t\t\t\n\t\t}\n}\nvoid fun(int n,char *s){\n\tint i=0;\n\tfor(i=0;n/10!=0;i++,n/=10)\n\t\ts[i]=n%10+'0';\n\ts[i++]=n+'0';\n\ts[i]='\\0';\n}\nvoid sortIn(int *a,int *indx,int n){\n\tint t1;\n\tint i,j;\n\tfor(i=1;i0 && a[j-1]>a[j];j--){\n\t\t\tt1=a[j-1];\n\t\t\ta[j-1]=a[j];\n\t\t\ta[j]=t1;\n\t\t\tt1=indx[j-1];\n\t\t\tindx[j-1]=indx[j];\n\t\t\tindx[j]=t1;\n\t\t}\n}\nint valid(int *a,int l,int r,int n){\n\tint f=0;\n\tif(l>0 && a[l-1]>a[r])\n\t\tf=1;\n\tif(a[l+1]a[l])\n\t\tf=1;\n\tif(r0)\n\t\t\tstripe[0]=colors[stripe[0]-'A'-1];\n\t\telse\n\t\t\tstripe[0]=colors[stripe[0]-'A'+1];\n\t\treturn ;\n\t}\n\tfor(j=0;j0){\n\t\t\tif(stripe[j]==stripe[j+1])\n\t\t\t\tstripe[j]=colors[stripe[j]-'A'-1];\n\t\t\telse if(stripe[j+1]!=colors[stripe[j]-'A'-1])\n\t\t\t\tstripe[j]=colors[stripe[j]-'A'-1];\n\t\t\telse if(stripe[j]-'A'nl;j++){\n\t\t\tfor(z=0;zid!=nom[i]->like[j];z++);\n\t\t\tif(z==m){\n\t\t\t\tinac[m++]=acq[nom[i]->like[j]];\n\t\t\t\tinvite[idx++]=acq[nom[i]->like[j]];\n\t\t\t}\n\t\t}\n\t\t\t\n\t}\n\treturn idx;\n}\nint feasible(struct person *a[],int n){\n\tint i,j,k;\n\tint flag=1;\n\tfor(i=0;flag && ind;j++)\n\t\t\tfor(k=0;flag &&kid==a[i]->dis[j]){\n\t\t\t\t\tflag=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\tif(i==n)\n\t\treturn 1;\n\treturn 0;\n}\nmain(){\n\tchar s[200];\n\tstruct person *acquin[15];\n\tstruct person *nominee[15];\n\tstruct person *invited[15];\n\tstruct person *inac[15];\n\tint i,j;\n\tint greatest=0;\n\tint from,to;\n\tint m,q,r;\n\tgetword(s,20);\n\tint n=atoi(s);\n\tfor(i=0;ind=0;\n\t\tacquin[i]->nl=0;\n\t\tacquin[i]->id=i;\n\t}\n\tgetword(s,20);\n\tint k=atoi(s);\n\tfor(i=0;ilike[acquin[from]->nl++]=to;\n\t\tacquin[to]->like[acquin[to]->nl++]=from;\n\t}\n\tgetword(s,20);\n\tk=atoi(s);\n\tfor(i=0;idis[acquin[from]->nd++]=to;\n\t\tacquin[to]->dis[acquin[to]->nd++]=from;\n\t}\n\tfor(i=0;i0){\n\t\t\tif(!feasible(inac,m))\n\t\t\t\tbreak;\n\t\t\tfor(j=0;jgreatest)\n\t\t\t\tgreatest=(m-q);\n\t\t}\n\t}\n\tprintf(\"%d\",greatest);\n\treturn 0;\n}\n", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1"} {"source_code": "#include\nint main()\n{\n int a[6];\n scanf(\"%d%d%d%d%d%d\",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]);\n\n if(a[1]<=a[4] && (a[2]+a[1])<=(a[4]+a[5]) && a[3]<=(a[4]+a[5]+a[6]-a[2]-a[1]))\n printf(\"YES\");\n else\n printf(\"NO\");\n return 0;\n}", "src_uid": "d54201591f7284da5e9ce18984439f4e"} {"source_code": "#include \n#include \n\nint main()\n{\n long long n,y,prey,ans=0,i;\n scanf(\"%I64d\",&n);\n if(n==0)\n printf(\"1\\n\");\n else\n {\n prey = sqrt(n*n - 1);\n ans++;\n for(i=2;i<=n;i++)\n {\n y = sqrt(n*n-i*i);\n //printf(\"%lld %lld prevy y\\n\",prey,y);\n if(y==prey)\n ans++;\n else\n ans += prey - y;\n prey = y;\n }\n ans--;\n //printf(\"%lld check\\n\",ans);\n ans *= 4;\n\n ans += 4;\n printf(\"%I64d\\n\",ans);\n }\n return 0;\n}\n", "src_uid": "d87ce09acb8401e910ca6ef3529566f4"} {"source_code": "#include\n#include\nlong long int cmpfunc( const void *a, const void *b) {\n return *(long long int*)a - *(long long int *)b;\n}\n\nint main()\n{\n long long int test,d,n,x,i,sum=0,count=0,j,flag=0,p,y,m,max=0,o,g,r,k, a[1002];\n scanf(\"%lld%lld\",&n,&m);\nmax=abs(n-m);\nif(max>=2){\nif(max/2>=max/3){\n printf(\"2\");\n}else{\n printf(\"3\");\n }\n \n \n}else{\n printf(\"%lld\",n);\n}\n\n\n return 0;\n}", "src_uid": "a8d992ab26a528f0be327c93fb499c15"} {"source_code": "#include \n#include \n\nint main()\n{\n int a, b, n, rnds=0;\n scanf(\"%d %d %d\",&n,&a,&b);\n if ((a <= n/2 && b > n/2) || (n == 2) || (b <= n/2 && a > n/2) ) {\n //printf(\"%d,%d,%d\",n,a,b);\n printf(\"Final!\");\n } else {\n while (a != b) {\n a = ceil (a/2.0);\n b = ceil (b/2.0);\n //printf(\"%d,%d,%d\",n,a,b);\n rnds++;\n }\n printf(\"%d\",rnds);\n }\n\n return 0;\n}\n", "src_uid": "a753bfa7bde157e108f34a28240f441f"} {"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", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9"} {"source_code": "#include\nint main()\n{\n int i,k,n,a,min=0;\n scanf(\"%d %d\",&n,&k);\n for (i=0;imin))\n {\n min=a;\n\n }\n }\n printf(\"%d\",k/min);\n return 0;\n}\n", "src_uid": "80520be9916045aca3a7de7bc925af1f"} {"source_code": "#include \n#include \n#define min(a,b) (ab?a:b)\n\nint main()\n{\n int x,y,z,x1,y1,z1;\n int X,Y,Z;\n int a[6];\n scanf(\"%d%d%d%d%d%d\",&x,&y,&z,&x1,&y1,&z1);\n int i;\n for (i=0; i<6; i++) scanf(\"%d\",a+i);\n if (xmax(0,x1)) X=1; else\n X=0;\n if (ymax(0,y1)) Y=1; else\n Y=0;\n if (zmax(0,z1)) Z=1; else\n Z=0;\n if (X<=0) a[x1>0?5:4]=0;\n if (X>=0) a[x1>0?4:5]=0;\n if (Y<=0) a[y1>0?1:0]=0;\n if (Y>=0) a[y1>0?0:1]=0;\n if (Z<=0) a[z1>0?3:2]=0;\n if (Z>=0) a[z1>0?2:3]=0;\n int sum=0;\n for (i=0; i<6; i++) sum+=a[i];\n printf(\"%d\",sum);\n return 0;\n}\n", "src_uid": "c7889a8f64c57cf7be4df870f68f749e"} {"source_code": "#include \nint main()\n{\n\tint n, k, num = 0, i;\n\tscanf(\"%d %d\", &n, &k);\n\tint a[101] = {0};\n\tfor (; n; n--) {\n\t\tscanf(\"%d\", &i);\n\t\ta[i] = 1;\n\t}\n\tfor (; n < k; n++)\n\t\tif (!a[n])\n\t\t\tnum++;\n\tif (a[n])\n\t\tnum++;\n\tprintf(\"%d\", num);\n\treturn 0;\n}\n", "src_uid": "21f579ba807face432a7664091581cd8"} {"source_code": "#include \n#include \n\n#define N\t1000000\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint aa[N + 1], kk[N + 1];\n\nvoid init() {\n\tint a, b, k;\n\n\tmemset(aa, -1, (N + 1) * sizeof *aa);\n\tfor (a = 2; a <= N; a++) {\n\t\tif (aa[a] != -1)\n\t\t\tcontinue;\n\t\tb = 1, k = 0;\n\t\twhile (1) {\n\t\t\tif (b > N / a)\n\t\t\t\tbreak;\n\t\t\tb *= a, k++;\n\t\t\taa[b] = a, kk[b] = k;\n\t\t}\n\t}\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\nlong long solve(int n, int m, int a, long long b, int k, int k_, long long k1, int l) {\n\tif (b <= n)\n\t\treturn solve(n, m, a, b * a, k + 1, k_, k1, l) + solve(n, m, a, b * a, k + 1, k_ == -1 ? k : k_, lcm(k1, k), l + 1);\n\telse\n\t\treturn l == 0 ? 0 : ((long long) m * k_ / k1) * (l % 2 == 1 ? 1 : -1);\n}\n\nint main() {\n\tint n, m, a;\n\tlong long ans;\n\n\tinit();\n\tscanf(\"%d%d\", &n, &m);\n\tans = 1;\n\tfor (a = 2; a <= n; a++)\n\t\tif (aa[a] == a)\n\t\t\tans += solve(n, m, a, a, 1, -1, 1, 0);\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead"} {"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", "src_uid": "a14739b86d1fd62a030226263cdc1afc"} {"source_code": "#include \n#define mod 1000000007\n\nint f[1001],c[1001][1001],r1[1001],r2[2001];\n\nint mi(int a,long long b)\n{\n int t;\n if (!b)\n return 1;\n t=mi(a,b>>1);\n t=(long long)t*t%mod;\n if (b&1)\n t=(long long)t*a%mod;\n return t;\n}\n\nint main()\n{\n int i,j,n,m,k,x,s=0,t=1;\n scanf(\"%d%d%d\",&n,&m,&k);\n if (m==1)\n s=mi(k,n);\n else\n {\n for (i=0;i<=n;i++)\n {\n c[i][0]=1;\n for (j=1;j<=i;j++)\n c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;\n }\n for (i=1;i<=n;i++)\n {\n f[i]=mi(i,n);\n for (j=1;j\n\nlong long min(long long x,long long y){return (x=1;j--){\n for(int k = prev;k=0;i--){\n total = 0;\n for(int j = 0;j<=n;j++) total += store[i][j];\n if(total\n#include\nint main()\n{\n int n,m,x;\n scanf(\"%d%d\",&n,&m);\n x=m%(int)pow(2,n);\n printf(\"%d\\n\",x);\n return 0;\n}", "src_uid": "c649052b549126e600691931b512022f"} {"source_code": "/*\n * LS4.2.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\nint main(int argc, char **argv)\n{\n\tint n,S,min;\n\tscanf(\"%d%d\",&n,&S);\n\tmin=((S-1)/n)+1;\n\tprintf(\"%d\",min);\n\treturn 0;\n}\n\n", "src_uid": "04c067326ec897091c3dbcf4d134df96"} {"source_code": "#include \"stdio.h\"\n\nint main()\n{\n\tint T,S,q,count=0;\n\tscanf(\"%d%d%d\",&T,&S,&q);\n\twhile (S\nint main()\n{\n int c,i ,j,n,a=0,b=0,d=1,l=3,k,s,wap;\n\n scanf(\"%d%d%d\",&n,&k,&c);\n for(i=n;i>=1;i--){\n if(i*2<=k&&i*4<=c){\n j=i;\n\n break;\n }\n else {\n j=0;\n\n }\n }\n printf(\"%d\\n\",j+(j*2)+(j*4));\n return 0;\n}\n\n", "src_uid": "82a4a60eac90765fb62f2a77d2305c01"} {"source_code": "#include \n#include \n#include \n#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 size,max,i,counter=0,buffer=0,j,k;\n scanf(\"%i %i\",&size,&max);\n int array[size];\n int array2[size];\n\n for(i=0;i\n\nint main()\n{\n char arr[3][3];\n int i=0,j;\n for(i=0;i<3;i++)\n {\n scanf(\"%c%c%c\",&arr[i][0],&arr[i][1],&arr[i][2]);\n getchar();\n }\n char arr2[3]={'A','B','C'};\n char arr3[3]={'0','0','0'};\n for(j=0;j<3;j++)\n {\n char check=arr2[j];\n int counter=0;\n for(i=0;i<3;i++)\n {\n if(arr[i][0]==check)\n {\n if(arr[i][1]=='>')\n counter++;\n else\n counter--;\n }\n if(arr[i][2]==check)\n {\n if(arr[i][1]=='>')\n counter--;\n else\n counter++;\n }\n }\n if(counter==2)\n {\n if(arr3[0]=='0')\n arr3[0]=arr2[j];\n else\n {\n arr3[0]='1';\n break;\n }\n\n }\n else if(counter==0)\n {\n if(arr3[1]=='0')\n arr3[1]=arr2[j];\n else\n {\n arr3[1]='1';\n break;\n }\n }\n else if(counter==-2)\n {\n if(arr3[2]=='0')\n arr3[2]=arr2[j];\n else\n {\n arr3[2]='1';\n break;\n }\n }\n }\n if(arr3[0]=='1'||arr3[1]=='1'||arr3[2]=='1')\n printf(\"Impossible\");\n else\n {\n for(i=2;i>=0;i--)\n {\n printf(\"%c\",arr3[i]);\n }\n }\n return 0;\n}\n", "src_uid": "97fd9123d0fb511da165b900afbde5dc"} {"source_code": "#include \n\nint main()\n{\n\tint n,m,x,y;\n\tscanf(\"%d %d %d\",&n,&x,&y);\n\tn=n/2;\n\tif ((x == n || x == n + 1) && (y == n || y == n + 1)) printf(\"NO\\n\"); else printf(\"YES\\n\");\n\n \n\treturn 0;\n}\n", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789"} {"source_code": "#include \n#include \n\nint main()\n{\n char s1[200],s2[200],s3[200],s4[200];\n int l1,l2,l3,l4,i,c;\n while(gets(s1)!=0)\n {\n gets(s2);\n gets(s3);\n gets(s4);\n l1=strlen(s1)-2;\n l2=strlen(s2)-2;\n l3=strlen(s3)-2;\n l4=strlen(s4)-2;\n c=0;\n if((l1>=2*l2&&l1>=2*l3&&l1>=2*l4)||(l1<=l2/2&&l1<=l3/2&&l1<=l4/2))\n {\n i=1;\n c++;\n }\n if((l2>=2*l1&&l2>=2*l3&&l2>=2*l4)||(l2<=l1/2&&l2<=l3/2&&l2<=l4/2))\n {\n i=2;\n c++;\n }\n if((l3>=2*l2&&l3>=2*l1&&l3>=2*l4)||(l3<=l2/2&&l3<=l1/2&&l3<=l4/2))\n {\n i=3;\n c++;\n }\n if((l4>=2*l2&&l4>=2*l3&&l4>=2*l1)||(l4<=l2/2&&l4<=l3/2&&l4<=l1/2))\n {\n i=4;\n c++;\n }\n if(c==0||c>1)\n printf(\"C\\n\");\n else\n {\n if(i==1)\n printf(\"A\\n\");\n else if(i==2)\n printf(\"B\\n\");\n else if(i==3)\n printf(\"C\\n\");\n else\n printf(\"D\\n\");\n }\n }\n return 0;\n}\n", "src_uid": "30725e340dc07f552f0cce359af226a4"} {"source_code": "#include\n#define min(a,b) an)\n printf(\"%lld\\n\",mn);\n else\n {\n while(n>1)\n {\n if(n%k==0)\n {\n s+=min(b,a*(n-(n/k)));\n n/=k;\n }\n else\n {\n s+=((n%k)*a);\n n-=(n%k);\n }\n //printf(\"%lld \",n);\n }\n if(n==0)\n s-=a;\n printf(\"%lld\\n\",min(mn,s));\n }\n}\n", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10"} {"source_code": "#include \n#include \n\n#define N\t50\n#define M\t(N * (N - 1))\n#define N_\t(N + 2)\n#define M_\t(M * 3 + 2)\n#define X\t100000\n#define INF\t0x3f3f3f3f\n\nint min(int a, int b) { return a < b ? a : b; }\n\nint oo[1 + M * 2], oh[1 + M * 2], _ = 1;\n\nint link(int o, int h) {\n\too[_] = o, oh[_] = h;\n\treturn _++;\n}\n\nint oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;\n\nint link_(int o, int h) {\n\too_[__] = o, oh_[__] = h;\n\treturn __++;\n}\n\nint ae[N], af[N], ae_[N_], dd[N_], n_;\nint ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;\nint pq[1 + N], iq[N], cnt;\n\nint less(int u, int v) { return dd[u] < dd[v]; }\n\nint i2(int i) {\n\treturn (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;\n}\n\nvoid pq_up(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_dn(int u) {\n\tint i, j, v;\n\n\tfor (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)\n\t\tpq[iq[v] = i] = v;\n\tpq[iq[u] = i] = u;\n}\n\nvoid pq_add_last(int u) {\n\tpq[iq[u] = ++cnt] = u;\n}\n\nint pq_remove_first() {\n\tint u = pq[1], v = pq[cnt--];\n\n\tif (v != u)\n\t\tiq[v] = 1, pq_dn(v);\n\tiq[u] = 0;\n\treturn u;\n}\n\nvoid dijkstra(int n, int s) {\n\tmemset(dd, 0x3f, n * sizeof *dd);\n\tdd[s] = 0, pq_add_last(s);\n\twhile (cnt) {\n\t\tint i = pq_remove_first(), o;\n\n\t\tfor (o = ae[i]; o; o = oo[o]) {\n\t\t\tint h = oh[o];\n\n\t\t\tif (!tt[h]) {\n\t\t\t\tint j = jj[h], d = dd[i] + ww[h];\n\n\t\t\t\tif (dd[j] > d) {\n\t\t\t\t\tif (dd[j] == INF)\n\t\t\t\t\t\tpq_add_last(j);\n\t\t\t\t\tdd[j] = d, pq_up(j);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid link2(int i, int j, int c) {\n\tint h = m_++;\n\n\tij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;\n\tae_[i] = link_(ae_[i], h << 1);\n\tae_[j] = link_(ae_[j], h << 1 | 1);\n}\n\nint bfs(int s, int t) {\n\tstatic int qu[N_];\n\tint i, head, cnt;\n\n\tfor (i = 0; i < n_; i++)\n\t\tdd[i] = n_;\n\thead = cnt = 0;\n\tdd[s] = 0, qu[head + cnt++] = s;\n\twhile (cnt) {\n\t\tint d, o;\n\n\t\ti = qu[cnt--, head++], d = dd[i] + 1;\n\t\tfor (o = ae_[i]; o; o = oo_[o]) {\n\t\t\tint h_ = oh_[o];\n\n\t\t\tif (cc[h_]) {\n\t\t\t\tint h = h_ >> 1, j = i ^ ij[h];\n\n\t\t\t\tif (dd[j] > d) {\n\t\t\t\t\tdd[j] = d;\n\t\t\t\t\tif (j == t)\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\tqu[head + cnt++] = j;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\nint dfs(int i, int t) {\n\tint d, o;\n\n\tif (i == t)\n\t\treturn 1;\n\td = dd[i] + 1;\n\tfor (o = ae_[i]; o; o = oo_[o]) {\n\t\tint h_ = oh_[o];\n\n\t\tif (cc[h_]) {\n\t\t\tint h = h_ >> 1, j = i ^ ij[h];\n\n\t\t\tif (dd[j] == d && dfs(j, t)) {\n\t\t\t\tcc[h_]--, cc[h_ ^ 1]++;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\tdd[i] = n_;\n\treturn 0;\n}\n\nvoid dinic(int s, int t) {\n\twhile (bfs(s, t))\n\t\twhile (dfs(s, t))\n\t\t\t;\n}\n\nchar reachable[N];\n\nvoid dfs_(int j) {\n\tint o;\n\n\tif (reachable[j])\n\t\treturn;\n\treachable[j] = 1;\n\tfor (o = af[j]; o; o = oo[o]) {\n\t\tint h = oh[o], i = ii[h];\n\n\t\tdfs_(i);\n\t}\n}\n\nint main() {\n\tstatic double ans[X + 1];\n\tstatic int dd1[N], dd2[N], xx[M];\n\tint n, m, q, h, x, s, t;\n\n\tscanf(\"%d%d\", &n, &m);\n\tfor (h = 0; h < m; h++) {\n\t\tint i, j, w;\n\n\t\tscanf(\"%d%d%d\", &i, &j, &w), i--, j--;\n\t\tii[h] = i, jj[h] = j, ww[h] = w;\n\t\tae[i] = link(ae[i], h);\n\t}\n\tn_ = n + 2, s = n, t = n + 1;\n\tx = 0;\n\twhile (x < X) {\n\t\tint k, y, z, d, d_;\n\n\t\tmemset(tt, 0, m * sizeof *tt);\n\t\tdijkstra(n, 0);\n\t\tmemcpy(dd1, dd, n * sizeof *dd);\n\t\td = dd1[n - 1];\n\t\tmemset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;\n\t\tlink2(s, 0, INF);\n\t\tlink2(n - 1, t, INF);\n\t\tfor (h = 0; h < m; h++) {\n\t\t\tint i = ii[h], j = jj[h], w = ww[h];\n\n\t\t\tif (dd1[i] + w == dd1[j]) {\n\t\t\t\ttt[h] = 1;\n\t\t\t\tlink2(s, j, 1), link2(i, t, 1);\n\t\t\t\tif (xx[h] == 0)\n\t\t\t\t\tlink2(j, i, 1);\n\t\t\t}\n\t\t}\n\t\tdinic(s, t);\n\t\td_ = INF;\n\t\tk = 0;\n\t\tmemset(af, 0, n * sizeof *af), _ = 1 + m;\n\t\tfor (h = 0; h < m; h++) {\n\t\t\tint i = ii[h], j = jj[h];\n\n\t\t\tif (tt[h]) {\n\t\t\t\tif ((dd[i] == n_) == (dd[j] == n_)) {\n\t\t\t\t\ttt[h] = 0;\n\t\t\t\t\taf[j] = link(af[j], h);\n\t\t\t\t} else if (dd[i] != n_) {\n\t\t\t\t\ttt[h] = 1;\n\t\t\t\t\tk++;\n\t\t\t\t} else {\n\t\t\t\t\tif (xx[h] > 0) {\n\t\t\t\t\t\ttt[h] = 2;\n\t\t\t\t\t\tk--;\n\t\t\t\t\t\td_ = min(d_, d + xx[h]);\n\t\t\t\t\t} else\n\t\t\t\t\t\ttt[h] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tmemset(reachable, 0, n * sizeof *reachable);\n\t\tdfs_(n - 1);\n\t\tdijkstra(n, 0);\n\t\tmemcpy(dd2, dd, n * sizeof *dd);\n\t\td_ = min(d_, dd2[n - 1]);\n\t\tfor (h = 0; h < m; h++)\n\t\t\tif (tt[h] == 2 && dd2[ii[h]] != INF && dd1[jj[h]] != INF && reachable[jj[h]])\n\t\t\t\td_ = min(d_, d + dd2[ii[h]] + ww[h] - dd1[jj[h]]);\n\t\ty = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;\n\t\tfor (z = x; z <= y; z++)\n\t\t\tans[z] = d + (double) (z - x) / k;\n\t\tif (y < X) {\n\t\t\tfor (h = 0; h < m; h++)\n\t\t\t\tif (tt[h] == 1)\n\t\t\t\t\tww[h] += d_ - d, xx[h] += d_ - d;\n\t\t\t\telse if (tt[h] == 2)\n\t\t\t\t\tww[h] -= d_ - d, xx[h] -= d_ - d;\n\t\t}\n\t\tx = y;\n\t}\n\tscanf(\"%d\", &q);\n\twhile (q--) {\n\t\tscanf(\"%d\", &x);\n\t\tprintf(\"%f\\n\", ans[x]);\n\t}\n\treturn 0;\n}\n", "src_uid": "b0751071e12f729f6700586c5a8eed23"} {"source_code": "#include \nint main()\n{\n\tint day,exam,give,check,prepare;\n\tint flag,t;\n\tint ok;\n\tint dd[100]; \n\tint num1[101],num2[101],num3[101],num4[101]; //本程序数组全部从零开始 \n\tint i,j;\n\twhile(scanf(\"%d %d\",&day,&exam)!=EOF)\n\t{\n\t\tok=0;\n//\t\tprintf(\"%d %d\\n\",day,exam);\n\t\tflag=0;\n\t\t/*基础想法,建立一个一维数组去把天数都赋值为零\n\t\t将考试的天数赋值为check+1;\n\t\t再建四个数组去保存序号,和字面上的三列数据;\n\t\t按照第二组从大到小排序 \n\t\t重右向做找非零数 并将其赋值为第一列序号值;检查是否大于等于第一列序号值 和是否可以赋值;*/\n\t\tfor(i=0;i=0;j--)\n\t\t\t{\n\t\t\t\twhile(num4[i]>0&&j>=0)\n\t\t\t\t{\n\t\t\t\t\tif(dd[j]==0&&j>num2[i]-2)\n\t\t\t\t\t{\n\t\t\t\t\t\tdd[j]=num1[i];\n\t\t\t\t\t\tnum4[i]--;\n\t\t\t\t\t}\n\t\t\t\t\tj--;\t\n\t\t\t\t}\n\t\t\t\tif(num4[i]>0)\n\t\t\t\tflag=1;\n\t\t\t\telse \n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(flag==0)\n\t\t{\n\t\t\t\n\t\t\tfor(i=0;i\n#include \n\nint GetSum(int n)\n{\n return n + n * (n - 1) / 2;\n}\n\nint main()\n{\n int a, b;\n scanf(\"%d %d\", &a, &b);\n int len = abs(a - b);\n printf(\"%d\\n\", GetSum(len / 2) + GetSum(len - len / 2));\n return 0;\n}\n", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da"} {"source_code": "#include \nint main()\n{\n int p,r_t,t,i=0,t2=0;\n scanf(\"%d %d\",&p,&r_t);\n t=240-(r_t);\n for(i=1; i<=p; i++)\n {\n t2=t2+i*5;\n if(t2>t)\n {\n break;\n }\n }\n printf(\"%d\",i-1);\n return 0;\n}\n", "src_uid": "41e554bc323857be7b8483ee358a35e2"} {"source_code": "#include\n#define max(a,b) a>b?a:b\n#define min(a,b) a\nint main()\n{\nlong long int l,r;\nscanf(\"%I64d%I64d\",&l,&r);\nif((r-l)<=1 || (l%2==1) && (r-l)==2)\t\nprintf(\"-1\");\nelse if(l%2==0)\nprintf(\"%I64d %I64d %I64d\",l,l+1,l+2);\nelse\nprintf(\"%I64d %I64d %I64d\",l+1,l+2,l+3); \t\n}", "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d"} {"source_code": "#include \n#include \n#include \nint main()\n{\n int i,j=0;\n char w1[50];\n char w2[50];\n char ansr[50];\n char ansl[50];\n int cr=0,cl=0,s;\n int count=0;\n gets(w1);\n gets(w2);\n s=strlen(w2);\n for(i=0;w1[i]!='|';i++)\n {\n cr++;\n }\n for(i=cr+1;i\nint main()\n{\nlong long int c,marks,temp,a=1;\nscanf(\"%lld\",&marks);\ntemp=marks;\nwhile(temp!=0)\n{\n if(temp%a!=0)\n {\n break;\n }\n else \n a*=3;\n}\nc=temp/a+1;\nprintf(\"%lld\",c);\n}", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd"} {"source_code": "#include\n\nint main()\n{\n\tint a,b,c,d,e,i,x;\n\tscanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e);\n for(i=0;;i++){\n \tif(i==0){\n \t\tx=b;\n \t}\n \telse{\n \t\tx=b+i*d;\n \t}\n \tif(x>c){\n \t\tx=c;\n \t}\n \tif(i==0){\n \t\ta=a-x;\n \t}\n \telse{\n \t\ta=a-x+e;\n \t}\n \tif(a<=0){\n \t\tbreak;\n \t}\n }\n\tprintf(\"%d\",i+1);\n\treturn 0;\n} \n", "src_uid": "b743110117ce13e2090367fd038d3b50"} {"source_code": "#include\nvoid f(int a,int b,char *s)\n{\n\tchar n;\n\tfor(;*s!='\\0';)\n\t{\n\t\tif(*s=='B'&&*(s+1)=='G')\n\t\t{n=*s;*s=*(s+1);*(s+1)=n;s+=2;}\n\t\telse s+=1;\n\t}\n}\nint main()\n{\n\tint m,t,i;char a[1000];\n\tscanf(\"%d%d%s\",&m,&t,&a);\t\n\tfor(i=0;i\n#include\nint main()\n{\n double r,x2,y2,x1,y1,d;\n double s;\n scanf(\"%lf%lf%lf%lf%lf\",&r,&x1,&y1,&x2,&y2);\n d = sqrt((y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1));\n \n s=d/r/2;\n\n printf(\"%.0lf\\n\",ceil(s));\n\n return 0;\n}\n", "src_uid": "698da80c7d24252b57cca4e4f0ca7031"} {"source_code": "#include\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if((n*n)%2!=0)\n {\n printf(\"1\\n\");\n }\n else\n {\n printf(\"2\\n\");\n }\n return 0;\n}\n", "src_uid": "816ec4cd9736f3113333ef05405b8e81"} {"source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define SIZE 1000001\n\nint base_2[] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512};\n\n/*****************************************************************************/\nint main(void)\n{ \n\n long i, j, k, m, n, b, p, w;\n scanf(\"%ld %ld %ld\", &n, &b, &p);\n w = n * p;\n k = 0;\n j = 0;\n i = 10;\n while (n > 1)\n {\n i = 10;\n while (base_2[i] > n)\n {\n --i;\n }\n j += base_2[i - 1];\n k += base_2[i];\n n -= base_2[i - 1];;\n }\n k *= b;\n printf(\"%ld %ld\\n\", k + j, w);\n return 0;\n}", "src_uid": "eb815f35e9f29793a120d120968cfe34"} {"source_code": "#include\nint main()\n{\n long long int n,m,i=1,a,b;\n scanf(\"%lld %lld\",&n,&m);\n a = n;\n b = m;\n while(a>=0 && b>=0)\n {\n if(i%2!=0)\n {\n if(a\nlong long int ans,t,a,b,c,p,q,r;\nint main()\n{\n scanf(\"%I64d %I64d %I64d\",&a,&b,&c);\n if(a==b&&a==c)\n {\n printf(\"%I64d\",a);\n return 0;\n }\n if(a>=b&&a>=c)\n {\n p=a;\n if(b>c)\n {\n q=b;r=c;\n }\n else\n {\n q=c;r=b;\n }\n }\n else if(b>=a&&b>=c)\n {\n p=b;\n if(a>c)\n {\n q=a;r=c;\n }\n else\n {\n q=c;r=a;\n }\n }\n else\n {\n p=c;\n if(a>b)\n {\n q=a;r=b;\n }\n else\n {\n q=b;r=a;\n }\n }\n\n\n t=(p-q)/2;\n if(r>=t)\n {\n r=r-t;\n p=p-(t*2);\n ans=ans+t;\n }\n else\n {\n p=p-(r*2);\n ans=ans+r;r=0;\n }\n p=p-r;\n q=q-r;\n ans=ans+r;\n t=q*2;\n if(p>=t)\n {\n ans=ans+q;\n }\n else\n {\n r=(p+q)/3;\n ans=ans+r;\n }\n printf(\"%I64d\",ans);\n return 0;\n}\n", "src_uid": "bae7cbcde19114451b8712d6361d2b01"} {"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}", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8"} {"source_code": "#include \nint main()\n{\n\tint n,flag=0;\n\tscanf(\"%d\",&n);\n\tint p1,p2,a1[200],a2[200],i,j;\n\tscanf(\"%d\",&p1);\n\tfor(i=0;ia2[i]){\n\t\t\ta1[p1+x]=a2[i];\n\t\t\ta1[p1+x+1]=a1[i];\n\t\t\tx=x+2;\n\t\t}\n\t\telse{\n\t\t\ta2[p2+y]=a1[i];\n\t\t\ta2[p2+y+1]=a2[i];\n\t\t\ty=y+2;\n\t\t}\n\t}\n\tif(flag==1) printf(\"%d 1\",i);\n\telse if(flag==2) printf(\"%d 2\",i);\n\telse printf(\"-1\");\n\treturn 0;\n}", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e"} {"source_code": "#include\nint main()\n{\n char st[1000];\n scanf(\"%s\",st);\n if(st[0]>='a' && st[0]<='z')\n st[0]=st[0]-32;\n printf(\"%s\\n\",st);\n return 0;\n }\n", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "#include\nint main()\n{\n int n,i,j=1,count;\n scanf(\"%d\",&n);\n if(n%10==0)\n {\n printf(\"%d\",n);\n }\n else if(n%10!=0)\n {\n count=n%10;\n if(count>=5)\n {\n for(i=1;i!=0;i=i+0)\n {\n n=n+i;\n if(n%10==0)\n {\n printf(\"%d\",n);\n exit(0);\n }\n }\n }\n else if(count<5)\n {\n for(i=1;i!=0;i=i+0)\n {\n n=n-i;\n if(n%10==0)\n {\n printf(\"%d\",n);\n exit(0);\n }\n }\n }\n }\n\n}\n", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9"} {"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}", "src_uid": "097674b4dd696b30e102938f71dd39b9"} {"source_code": "#include \n#include \n\nint main()\n{\n int n,m,r,s1[35],s2[35];\n int min_s=1001, max_b=0;\n scanf(\"%d %d %d\",&n,&m,&r);\n for(int i=0;i s1[i] ? s1[i] : min_s;\n }\n for(int i=0;i=max_b)\n printf(\"%d\",r);\n else\n printf(\"%d\",r+(r/min_s)*(max_b-min_s));\n}\n", "src_uid": "42f25d492bddc12d3d89d39315d63cb9"} {"source_code": "#include \n\nint main(void) {\n\t// count the number of 1..9\n\t// check if cucumber can press\n\tchar a[4][4];\n\tint k;\n\tint panel[9]= {0};\n\tint temp;\n\tscanf(\"%d\\n\", &k);\n\tfor (int i = 0; i<4; i++)\n\t{\n\t\tfor (int j= 0; j < 4; j++)\n\t\t{\n\t\t\tscanf(\" %c\", &a[i][j]);\n\t\t\tif (a[i][j] != '.')\n\t\t\t{\n\t\t\t\ttemp = a[i][j] - '0';\n\t\t\t\tpanel[temp -1]++;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i < 9; i++)\n\t{\n\t\tif (panel[i] > k*2)\n\t\t{\n\t\t\tprintf(\"NO\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"YES\");\n}\n", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16"} {"source_code": "#include\nint main()\n{\nlong d,l,k,n,p,x,z;\nscanf(\"%ld\",&p);\nn=0;\nk=0;\nd=p;\nwhile(p-->1)\n{\nx=p;\nk=0;\nl=1;\n for(z=d-2;z>=1;--z)\n {\n l=(x*l)%d;\n if((l-1)%d==0)\n {\n k=1;\n break;\n }\n }\n if(k==0)\n {\n l=(x*l)%d;\n if((l-1)%d==0)\n n++;\n }\n}\nprintf(\"%ld\",n);\nreturn 0;\n}\n", "src_uid": "3bed682b6813f1ddb54410218c233cff"} {"source_code": "#include \n\n#define N\t100\n\nint main() {\n\tstatic int aa[N];\n\tint n, i, cnt;\n\n\tscanf(\"%d\", &n);\n\tfor (i = 0; i < n; i++)\n\t\tscanf(\"%d\", &aa[i]);\n\tfor (i = 1; i < n; i++)\n\t\tif (aa[i - 1] != 1 && aa[i] != 1) {\n\t\t\tprintf(\"Infinite\\n\");\n\t\t\treturn 0;\n\t\t}\n\tprintf(\"Finite\\n\");\n\tcnt = 0;\n\tfor (i = 1; i < n; i++)\n\t\tcnt += aa[i] == 1 ? aa[i - 1] + 1 : i >= 2 && aa[i] == 2 && aa[i - 2] == 3 ? 2 : aa[i] + 1;\n\tprintf(\"%d\\n\", cnt);\n\treturn 0;\n}\n", "src_uid": "6c8f028f655cc77b05ed89a668273702"} {"source_code": "#include \nvoid news(int *a,int start,int num,int sum,int newsum,int *flag)\n{\n int i;\n if (num==3){\n if (newsum==sum-newsum){\n *flag=1;\n return;\n }\n }\n for (i=start;i<6;++i) news(a,i+1,num+1,sum,newsum+a[i],flag);\n}\nint main(void)\n{\n int a[6],i,sum,flag=0;\n for (i=0;i<6;++i) {\n scanf(\"%d\",&a[i]);\n sum+=a[i];\n }\n news(a,0,0,sum,0,&flag);\n if (flag==1) printf(\"YES\");\n else printf(\"NO\");\n return 0;\n}\n", "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11"} {"source_code": "#include\nint main(){\n \nint a,n;\n scanf(\"%d\",&n);\n while(scanf(\"%d\",&a)!=EOF){\n\t int p=9,q=0;\n int str[9]={0};\n if(a<10)\n printf(\"%d\\n\",a);\n \n else if(a>=10){\n for(int j=0;j<9;j++){\n \t\n for(int k=1;k<=p;k++){\n str[j]=k;\n if(str[0]+str[1]+str[2]+str[3]+str[4]+str[5]+str[6]+str[7]+str[8]==a){\n q=j;\n for(;q>=0;q--){\n printf(\"%d\",str[q]);\n } printf(\"\\n\"); \n }\n \n }p--;\n } }\n}\n}\n \t\t\t \t\t \t\t \t \t \t \t \t\t \t", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f"} {"source_code": "#include\n#include\nint main()\n{\n float A,B,C,D,E,F;\n scanf(\"%f %f\",&A,&B);\n C=(1/B);\n D=1-C;\n F=1/D;\n E=A*F;\n if(A < B){\n printf(\"%0.0f\\n\",A);\n }\n else if(A==B){\n printf(\"%0.0f\\n\",A+1);\n }\n else if(B ==4 && A/B ==2.25 || A/B ==1.5){\n printf(\"%0.0f\\n\",E-1);\n }\n else if(B == 4){\n printf(\"%0.0f\\n\",E);\n }\n else if (A > B){\n printf(\"%0.0f\\n\",E-1);\n }\n return 0;\n}", "src_uid": "a349094584d3fdc6b61e39bffe96dece"} {"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", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2"} {"source_code": "#include\n\nint is_leap_year(int year)\n{\n int flag = 0;\n if(year%400==0) flag = 1;\n else if(year%4 == 0 && year%100) flag = 1;\n\n return flag;\n}\n\nint in_days(int y1, int m1, int d1)\n{\n int d = d1;\n\n int Months[12] ={31,28,31,30,31,30,31,31,30,31,30,31};\n\n int i;\n\n for(i=0;i=3)\n {\n if(is_leap_year(y1)) d++;\n }\n\n //printf(\"**%d\\n\",d);\n\n return d;\n}\n\nint main()\n{\n int y1,m1,d1,y2,m2,d2;\n\n scanf(\"%d:%d:%d\",&y1,&m1,&d1);\n scanf(\"%d:%d:%d\",&y2,&m2,&d2);\n\n\n\n\n int d,D;\n\n d = in_days(y1,m1,d1);\n\n D = in_days(y2,m2,d2);\n\n printf(\"%d\",abs(D-d));\n\n\n\n\n\n\n\n}\n", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c"} {"source_code": "#include\n#include\nint main()\n{\n char s1[105],s2[105],ans[105];\n int i,j,k,l,len,n,m,x;\n scanf(\"%s\",s1);\n scanf(\"%s\",s2);\n len=strlen(s1);\n x=0;\n for(i=0;is1[i])\n {\n x=1;\n break;\n }\n if(s2[i]==s1[i])\n {\n ans[i]='z';\n }\n if(s2[i]\n#include\n#include\n#include\n#include\n#define min(a,b)(a>b?b:a)\n#define max(a,b)(a>=1;\n } \n return (llu)ret;\n}\nint main()\n{\n int i;\n char str[109];\n scanf(\"%s\",str);\n int len=strlen(str);\n llu p=mpow(2,len-1),count=1,ans=0;\n for(i=len-1; i>=0; i--)\n {\n ans=(ans+(p*(str[i]-'0')*count))%MOD;\n count=(count*2)%MOD;\n }\n printf(\"%lld\\n\",ans);\n return 0;\n}\n\n", "src_uid": "89b51a31e00424edd1385f2120028b9d"} {"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", "src_uid": "a69f95db3fe677111cf0558271b40f39"} {"source_code": "\n//bainchod\n//bainchod\n//bainchod\n//bainchod\n//bainchod\n//bainchod\n//bainchod\n\n#include\nint main ()\n{\n int n;\n scanf(\"%d\",&n);\n\n printf(\"%d\",(n/2)+n);\n\n\n\n}\n", "src_uid": "031e53952e76cff8fdc0988bb0d3239c"} {"source_code": "#include\n#include\n\nint main(){\n double n,R,r;\n double pi = 3.141592653589793;\n double ht;\n\tint flag = 0;\n scanf(\"%lf%lf%lf\",&n,&R,&r);\n\n\tif(r<=R){\n\t\tif(n==1){\n\t\t\tif(r<=R) flag = 1;\n\t\t}else if(n==2){\n\t\t\tif(2*r<=R) flag = 1;\n\t\t}else{\n\t\t\tht = asin(r/(R-r));\n\t\t\tif(n*ht - 1e-7 <= pi) flag = 1;\n\t\t}\n\t}\n if(flag){\n \tprintf(\"YES\");\n }else{\n \tprintf(\"NO\");\n }\n\n\treturn 0;\n}\n", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6"} {"source_code": "#include \nint b[9];\nvoid printDivisors(int n)\n{\n for (int i=n;i>=1;i--)\n { \n \t if (n%i==0)\n {\n \t\tfor (int j = 0; j< 9; ++j)\n \t\t{\n \t\t\t//printf(\"%d\\n\",b[j]);\n \t\t\tif (b[j]==i)\n \t\t\t{\n \t\t\t\tprintf(\"%d\\n\",i );\n \t\t\t\treturn ;\n \t\t\t}\n \t\t}\n }\n }\n}\nvoid function()\n{\n\tfor (int i = 1; ((1<\nint main(void)\n{\n int i,j,b,k,l,n,max=0,a=0,count1=0,count2=0;\n int bin[100];\n scanf(\"%d\",&n);\n for(i=0;imax){\n max=a+(count1-count2);\n }\n }\n }\n printf(\"%d\",max);\n return 0;\n}\n", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99"} {"source_code": "#include \n\nint main()\n{\n\n\tint n, k, i, solution = 0;\n\tint groups[100][2] = {{0}};\n\t\n\tscanf(\"%i %i\", &n, &k);\n\tfor (i = 0; i < n; ++i)\n\t{\n\t\n\t\tint a;\n\t\t\n\t\tscanf(\"%i\", &a);\n\t\t++groups[i % k][a - 1];\n\t\t\n\t}\n\t\n\tfor (i = 0; i < k; ++i)\n\t{\n\t\tsolution += ((groups[i][0] < groups[i][1]) ? groups[i][0] : groups[i][1]);\n\t}\n\t\n\tprintf(\"%d\\n\", solution);\n\t\n\treturn 0;\n\t\n}", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281"} {"source_code": "#include\n#include\n\nint min(int a, int b) {return a\nint main()\n{\n char str[100],t;\n int n;\n int i,j;\n int count=1;\n scanf(\"%d\",&n);\n getchar();\n scanf(\"%s\",str);\n getchar();\n if (n<26)\n {\n printf(\"NO\");\n return 0;\n }\n for (i=0;i\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", "src_uid": "f1b43baa14d4c262ba616d892525dfde"} {"source_code": "#include \n#include \nint main()\n{\n int r,c,i,j,sum=0,result=0,flag1=0,flag2=0;\n scanf(\"%d%d\",&r,&c);\n char x[r+1][c+1];\n char p;\n for(i=1;i<=r;i++)\n {\n for(j=1;j<=c;j++)\n {\n scanf(\"%c\",&p);\n if(p=='S'||p=='.')\n {\n x[i][j]=p;\n }\n else\n {\n j--;\n }\n }\n }\ni=1;j=1;\n while(j<=c&&i<=r)\n {\n if(x[i][j]=='S')\n {\n\n i++;\n j=1;\n }\n else\n {\n j++;\n if(j>c)\n {\n flag1++;\n sum+=c;\n j=1;\n i++;\n\n }\n }\n }\n i=1;j=1;\n while(j<=c&&i<=r)\n {\n if(x[i][j]=='S')\n {\n\n j++;\n i=1;\n }\n else\n {\n i++;\n if(i>r)\n {\n flag2++;\n result+=r;\n i=1;\n j++;\n\n }\n }\n }\n printf(\"%d\",(sum+result)-(flag1*flag2));\n return 0;\n }\n\n\n\n", "src_uid": "ebaf7d89c623d006a6f1ffd025892102"} {"source_code": "#include \r\n\r\nint a[7];\r\n\r\nint main(){\r\n\tint t;\r\n\tscanf(\"%d\", &t);\r\n\tfor (int i = 1; i <= t; i++){\r\n\t\tint x;\r\n\t\tscanf(\"%d\", &x);\r\n\t\tfor (int j = 1; j <= 3; j++){\r\n\t\t\tscanf(\"%d\", &a[j]);\r\n\t\t}\r\n\t\tif (a[x] == 0){\r\n\t\t\tprintf(\"NO\\n\");\r\n\t\t} else {\r\n\t\t\tint t = x;\r\n\t\t\tx = a[x];\r\n\t\t\ta[t] = 0;\r\n\t\t\tif (a[x] == 0){\r\n\t\t\t\tprintf(\"NO\\n\");\r\n\t\t\t} else {\r\n\t\t\t\tprintf(\"YES\\n\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}", "src_uid": "5cd113a30bbbb93d8620a483d4da0349"} {"source_code": "#include \n#include \n\nint main()\n{\n int n, a, b, cnt=0, x, c;\n\n scanf(\"%d\",&n);\n\n for(a=1;a<=n;a++)\n {\n for(b=a;b<=n;b++)\n {\n c=a*a+b*b;\n if(c>n*n)\n continue;\n x=(int)sqrt(c*1.0);\n if(x*x==c)\n cnt++;\n }\n }\n printf(\"%d\\n\",cnt);\n\n return 0;\n}\n", "src_uid": "36a211f7814e77339eb81dc132e115e1"} {"source_code": "#include\n#include\n__int64 d[1<<18][100];\nint main(int argc, char const *argv[])\n{\n int m,i,j,l,k; //l:n的位数\n int a[18],b[10];\n\n __int64 n;\n memset(d,0,sizeof(int)*100*(1<<18));\n memset(b,0,sizeof(int)*10);\n scanf(\"%I64d%d\",&n,&m);\n for(l=0;n;++l)\n {\n a[l]=n%10;\n n/=10;\n if(a[l] && !b[a[l]])\n {\n d[1<\nmain(){\n long long int a,b,x,y,temp;\n scanf(\"%I64d %I64d %I64d %I64d\",&a,&b,&x,&y);\n long long int t1=x,t2=y;\n while(t2!=0){\n temp=t2;\n t2=t1%t2;\n t1=temp;\n }\n x=x/t1;\n y=y/t1;\n if(a/x\n#include \n\nint main()\n{\n char table[8][8];\n int i , j ;\n int counter = 0 ;\n int total = 0 ;\n\n for ( i=0 ; i<8 ; ++i ){\n scanf(\"%s\" , table[i]);\n }\n\n for ( i=0 ; i<8 ; ++i ){\n counter = 0;\n for ( j=0 ; j<8 ; ++j ){\n if ( table[i][j] == 'B' ){\n ++counter ;\n }\n }\n if ( counter == 8 ){\n ++total ;\n }\n }\n\n if ( total == 8 ){\n printf(\"8\");\n return 0 ;\n }\n\n for ( j=0 ; j<8 ; ++j ){\n counter = 0;\n for ( i=0 ; i<8 ; ++i ){\n if ( table[i][j] == 'B' ){\n ++counter ;\n }\n }\n if ( counter == 8 ){\n ++total ;\n }\n }\n\n printf(\"%d\",total);\n\n return 0;\n}\n", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0"} {"source_code": "/*\n * main.c\n *\n * Created on: 30 ���� 2014 �.\n * Author: ulgish\n */\n#include \n#include \n#include \n#include \n\ntypedef unsigned long long uint64;\ntypedef long long int64;\ntypedef char byte;\n\nvoid int64_print(int64 n){\n\tint64 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}\nvoid uint64_print(uint64 n){\n\tuint64 carry = 10;\n\tchar buf[20];\n\tbuf[0] = '\\0';\n\tint i = 0, j;\n\twhile (n > 0){\n\t\tbuf[i] = n % carry;\n\t\tn = n / carry;\n\t\ti += 1;\n\t}\n\ti--;\n\tfor (j = i; j>= 0; j--){\n\t\tprintf(\"%c\", 48 + buf[j]);\n\t}\n}\n\n\nuint64 uint64_read(){\n\tchar* s = (char*) calloc(20, sizeof(char));\n\ts[0] = '\\0';\n\tscanf(\"%s\", s);\n\t//printf(\"=======%s\\n\", s);\n\tuint64 ret = 0;\n\tuint64 carry = 1;\n\tint len = strlen(s), i;\n\tfor (i = 0; i < len; i++){\n\t\tret += carry * (s[len-1-i] - 48);\n\t\tcarry*=10;\n\t};\n\tfree(s);\n\treturn ret;\n}\n\n\nint64 int64_read(){\n\tchar* s = (char*) calloc(21, sizeof(char));\n\ts[0] = '\\0';\n\tscanf(\"%s\", s);\n\t//printf(\"=======%s\\n\", s);\n\tint64 ret = 0;\n\tint64 carry = 1;\n\tint len = strlen(s), i;\n\tfor (i = 0; i < len; i++){\n\t\tret += carry * (s[len-1-i] - 48);\n\t\tcarry*=10;\n\t};\n\tfree(s);\n\treturn ret;\n}\n\n\ntypedef struct{\n\tbyte index[26];\n}set;\n\ntypedef set* setp;\n\nsetp set_create(){\n\tsetp ret = (setp) malloc(sizeof(set));\n\tmemset(ret->index, 0x0, sizeof(byte)*26);\n\treturn ret;\n}\n\nint set_count(setp s,char c){\n\tbyte i = (byte) (c - 'a');\n\treturn s->index[i];\n}\n\nsetp set_add(setp s, char c){\n\tbyte i = (byte) (c - 'a');\n\ts->index[i]++;\n\treturn s;\n}\n\nint set_in(setp part, setp global){\n\tint i;\n\tfor (i = 0; i < 26; i++){\n\t\tif (part->index[i] > global->index[i]){\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 1;\n}\n\nint set_not_equal(setp set1, setp set2){\n\treturn (memcmp(set1->index, set2->index, sizeof(byte)*26));\n}\n\nsetp set_free(setp s){\n\tfree(s);\n\ts = NULL;\n\treturn s;\n}\n\nsetp set_from_str(const char* s){\n\tint len = strlen(s);\n\tsetp ret = set_create();\n\tint i;\n\tfor (i = 0; i < len; i++){\n\t\tret = set_add(ret, s[i]);\n\t}\n\treturn ret;\n}\n\nint main(){\n\tchar s[102], t[102];\n\tscanf(\"%s %s\", s, t);\n\t//printf(\"%s\\t %s\", s, t);\n\tsetp set_s = set_from_str(s);\n\tsetp set_t = set_from_str(t);\n\tint len_s = strlen(s);\n\tint len_t = strlen(t);\n\tif (!set_in(set_t, set_s)){\n\t\tprintf(\"need tree\\n\");\n\t\treturn 0;\n\t}\n\n\tif ((len_t == len_s) && (!set_not_equal(set_s, set_t))){\n\t\tprintf(\"array\\n\");\n\t\tset_s = set_free(set_s);\n\t\tset_t = set_free(set_t);\n\t\treturn 0;\n\t}\n\tset_s = set_free(set_s);\n\tset_t = set_free(set_t);\n\tint i_s = 0, i_t = 0;\n\twhile ((i_s < len_s) && (i_t < len_t)){\n\t\tif (t[i_t] == s[i_s]){\n\t\t\ti_t++;\n\t\t}\n\t\ti_s++;\n\t}\n\tif ((i_t == len_t) && (i_s <= len_s)){\n\t\tprintf(\"automaton\\n\");\n\t\treturn 0;\n\t}else{\n\t\tprintf(\"both\\n\");\n\t\treturn 0;\n\t}\n\treturn 0;\n}\n", "src_uid": "edb9d51e009a59a340d7d589bb335c14"} {"source_code": "#include \n#include \n\nint main(void)\n{\n int i, n, s, pos_c, pos_s, vel_c, win;\n char states[201], direction[10];\n \n memset(states, 0, sizeof(states));\n memset(direction, 0, sizeof(direction));\n \n scanf(\"%d%d%d%*s%s%s\", &n, &pos_s, &pos_c, direction, states);\n \n if (!strcmp(direction, \"head\")) vel_c = -1;\n else vel_c = 1;\n\n s = strlen(states);\n\n if (pos_s < pos_c) pos_s = 1;\n else pos_s = n;\n\n win = 0;\n\n for (i = 0; i < s; i++)\n {\n if (pos_c == pos_s) { win = 1; break; }\n if (pos_c == 1 && vel_c == -1) vel_c = 1;\n if (pos_c == n && vel_c == 1) vel_c = -1;\n \n if (states[i] == '0')\n {\n pos_c += vel_c;\n }\n else\n {\n pos_c += vel_c;\n if (pos_c > 1) {\n if (vel_c == 1) pos_s = 1;\n else pos_s = n;\n }\n if (pos_c < n) {\n if (vel_c == -1) pos_s = n;\n else pos_s = 1;\n }\n }\n }\n\n if (win)\n printf(\"Controller %d\\n\", i);\n else\n printf(\"Stowaway\\n\");\n \n return 0;\n}\n", "src_uid": "2222ce16926fdc697384add731819f75"} {"source_code": "#include\n#include\n#include\n\n\nint main(){\n int n,*arr,i,alice,maj=0,total,max,*result = malloc(100*sizeof(int));\n scanf(\"%d\",&n);\n arr = (int*)malloc(n*sizeof(int));\n for(i=0;imaj){\n printf(\"%d\\n%d\",1,1);\n return 0;\n }\n total = alice;\n max = -1;\n int k =1;\n result[0]=1;\n for(i=1;imaj){\n printf(\"%d\\n\",k);\n for(i=0;i\n#include \n#include \nint all_p_factor(int* ara,int* power,int number){\n int factor=2,i=0,p;\n if(number==1){\n ara[0]=1;power[0]=1;\n return 1;\n }\n while(number!=1){\n if((number%factor)==0){\n ara[i]=factor;\n p=0;\n while((number%factor)==0){\n number=number/factor;\n p++;\n }\n power[i]=p;\n i++;\n }\n factor++;\n }\n return i;\n}\nint max_(int* data,int sz){\n int i,mx=0;\n for(i=0;i\nint main(){\n char ar[100],b[100];\n scanf(\"%s %s\",ar,b);\n printf(\"%c\",ar[0]);\n int i;\n for( i=1;ar[i]!='\\0';i++){\n if(ar[i]-'a'\n#include \n#include \n\n#define FOR(i, a, b) for (i = (a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n\nint cmpfunc (const void * a, const void * b){\n\t//qsort(values, 5, sizeof(int), cmpfunc);\n\treturn ( *(int*)a - *(int*)b );\n}\n\nlong long min(long long a,long long b){\n\treturn a < b ? a : b;\n}\n\nlong long max(long long a,long long b){\n\treturn a > b ? a : b;\n}\n// long long ncr(int n, int k) \n// { \n// long long C[k+1]; \n// memset(C, 0, sizeof(C)); \n// \tint i;\n// \tint j;\n// C[0] = 1; // nC0 is 1 \n \n// for (i = 1; i <= n; i++) \n// { \n// // Compute next row of pascal triangle using \n// // the previous row \n// for ( j = min(i, k); j > 0; j--) \n// C[j] = C[j] + C[j-1]; \n// } \n// return C[k]; \n// } \n\nvoid solve(int t){\n\tint n,k;\n\tscanf(\"%d%d\",&n,&k);\n\tint a[n];\n\tint i,j;\n\tfor(i = 0;i < n;i++){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\n\t// printf(\"Case #%d: %ld\\n\",t,count);\t\n}\n\nlong long gcd(long long a , long long b)\n{\n if(b==0) return a;\n a%=b;\n return gcd(b,a);\n}\n\nint main(){\n\tint n,k,a,b;\n\tscanf(\"%d%d\",&n,&k);\n\tscanf(\"%d%d\",&a,&b);\n\tint i,j;\n\tlong long maximum = LLONG_MIN, minimum = LLONG_MAX;\n\tlong long l = a-b;\n\tlong long total = (long long)n*k;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tl = a+b;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tl = k-a+b;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tl = k-a-b;\n\twhile(l <= total){\n\t\tif(l <= 0){\n\t\t\tl += k;\n\t\t\tcontinue;\n\t\t}\n\t\tlong long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);\n\n\t\tmaximum = max(g,maximum);\n\t\tminimum = min(g,minimum);\n\t\tl += k;\n\t}\n\n\tprintf(\"%I64d %I64d\\n\",minimum,maximum);\n}", "src_uid": "5bb4adff1b332f43144047955eefba0c"} {"source_code": "#include \n#include \n\ntypedef unsigned long long ull;\ntypedef unsigned char uchar;\n\n#define MAX 222\nint g[MAX][MAX];\nint gn[MAX];\nint n;\nint where[MAX];\n\ntypedef struct {\n ull key[4];\n int at;\n} hashdata_t;\n\n#define MAXHASH 5000007\nint maxhash=MAXHASH;\n\nuchar hash[(MAXHASH+7)/8]; /* bit i set if element i is taken */\nhashdata_t hashdata[MAXHASH];\n\nint gethash(hashdata_t *h) {\n int res=h->key[0]%maxhash;\n res=((ull)res*maxhash+h->key[1])%maxhash;\n res=((ull)res*maxhash+h->key[2])%maxhash;\n res=((ull)res*maxhash+h->key[3])%maxhash;\n res=(res*3+h->at)%maxhash;\n return res;\n}\n\n#define HASHBIT(pos) (hash[pos>>3]&(1<<(pos&7)))\n\nint gethashpos(hashdata_t *h) {\n int pos=gethash(h),i;\n while(1) {\n if(!HASHBIT(pos)) break;\n for(i=0;i<4;i++) if(hashdata[pos].key[i]!=h->key[i]) goto next;\n if(hashdata[pos].at!=h->at) goto next;\n break;\n next:\n pos++; if(pos==maxhash) pos=0;\n }\n return pos;\n}\n\nint exists(hashdata_t *h) {\n int pos=gethashpos(h),i;\n for(i=0;i<4;i++) if(hashdata[pos].key[i]!=h->key[i]) return 0;\n return hashdata[pos].at==h->at;\n}\n\nvoid puthash(hashdata_t *h) {\n int pos=gethashpos(h);\n hash[pos>>3]|=1<<(pos&7);\n hashdata[pos]=*h;\n}\n\nvoid inithashdata() {\n memset(hash,0,sizeof(hash));\n}\n\n#define Q 500000\nint qs,qe,qe2;\nhashdata_t q[Q];\n\n#define SET(var,i) var[(i)>>6]|=1ULL<<((i)&63)\n#define CLEAR(var,i) var[(i)>>6]&=~(1ULL<<((i)&63))\n#define ISSET(var,i) var[(i)>>6]&(1ULL<<((i)&63))\n\nvoid insert1(ull mask[4],int at) {\n hashdata_t h;\n int i;\n h.key[0]=mask[0];\n h.key[1]=mask[1];\n h.key[2]=mask[2];\n h.key[3]=mask[3];\n h.at=at;\n if(exists(&h)) return;\n puthash(&h);\n q[qe2].at=at;\n q[qe2].key[0]=mask[0];\n q[qe2].key[1]=mask[1];\n q[qe2].key[2]=mask[2];\n q[qe2].key[3]=mask[3];\n qe2++; if(qe2==Q) qe2=0;\n}\n\nvoid pop(hashdata_t *h) {\n h->key[0]=q[qs].key[0];\n h->key[1]=q[qs].key[1];\n h->key[2]=q[qs].key[2];\n h->key[3]=q[qs].key[3];\n h->at=q[qs].at;\n qs++; if(qs==Q) qs=0;\n}\n\nint bfs() {\n int i,j,moves=0,done;\n ull cur[4];\n hashdata_t c;\n qs=qe=qe2=0;\n for(i=0;i<4;i++) cur[i]=0;\n for(i=0;i\nint main()\n{ int n,k,ar[21],x=0,i,j,m;\nscanf(\"%d%d\",&n,&k);\n m=n;\nfor(i=0;i\n#include\n#include\n#define me(x) memset(x,0,sizeof(x))\nlong n,a[105],p[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};\nlong dp[105][65536],ch[105][65536],va[60];\nlong ab(long x)\n{\n\treturn x>0?x:-x;\n}\nlong an[105];\nint main()\n{\n\tlong i,j,k;\n\tscanf(\"%ld\",&n);\n\tfor (i=1;i<=n;i++) scanf(\"%ld\",&a[i]);\n\tme(dp[0]);\n\tfor (i=1;i<=n;i++) for (j=0;j<65536;j++) dp[i][j]=99999999;\n\tfor (j=1;j<=58;j++)\n\t{\n\t\tva[j]=0;\n\t\tfor (i=0;i<16;i++) if (j%p[i]==0) va[j]+=1<dp[i][j]+ab(k-a[i+1]))\n\t\t{\n\t\t\tdp[i+1][j|va[k]]=dp[i][j]+ab(k-a[i+1]);\n\t\t\tch[i+1][j|va[k]]=k;\n\t\t}\n\t}\n\tj=65535;\n\tfor (i=n;i>0;i--)\n\t{\n\t\tan[i]=ch[i][j];\n\t\tj^=va[ch[i][j]];\n\t}\n\tfor (i=1;i<=n;i++)\n\t{\n\t\tprintf(\"%ld\",an[i]);\n\t\tif (i!=n) printf(\" \");\n\t}\n\treturn 0;\n}\n", "src_uid": "f26c74f27bbc723efd69c38ad0e523c6"} {"source_code": "#include\nint count=0;\nvoid fun(char a[],int i,int j)\n\n{\n\tint nl,nr,nu,nd,k;\n\tnl=nr=nd=nu=0;\n\tfor(k=i;k<=j;k++)\n\t{\n\t\t if(a[k]=='L')\n\t\t nl++;\n\t\t if(a[k]=='R')\n\t\t nr++;\n\t\tif(a[k]=='U')\n\t\t nu++;\n\t\t if(a[k]=='D')\n\t\t nd++;\n\t\t //printf(\"%c\",a[k]);\n\t}\n//\tprintf(\"\\n\");\n\tif(nl==nr&&nu==nd)\n\tcount++;\n}\nint main()\n{\n\tint n,i,j;\n\tchar a[1000];\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",&a);\n\tfor(i=0;i\n\nint main(){\n\nint i, n, m, c = 0, a;\nscanf(\"%d%d\", &n, &m);\nfor(i = 1; i <= n; i++){\n c = c + i;\n if(c == m){\n printf(\"0\\n\");\n break;\n }\n else if(i == n && c < m){\n i = 0;\n }\n else if(c > m){\n c = c - i;\n a = m - c;\n printf(\"%d\\n\", a);\n break;\n }\n}\n\nreturn 0;\n}\n", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb"} {"source_code": "#include\n#include\nint main (){int n,i,l,count=0,m=0;char integer[10],result[10000];scanf(\"%d\",&n);snprintf(integer, 10, \"%d\", n);l=strlen(integer);int starting=1,we_can_start_now=0,next=0;for(;;){for(i=0;i='1' && starting==1)result[m]='1',m++,starting=0,integer[i]=integer[i]-'1'+48;if(we_can_start_now==1){if(integer[i]>='1')result[m]='1',m++,integer[i]=integer[i]-'1'+48;else result[m]='0',m++;}if(starting==0)we_can_start_now=1,next=1;}starting=1;we_can_start_now=0;/*printf(\" \");*/if(next==0)break;result[m]=' ',m++;count++;next=0;}printf(\"%d\\n\",count);puts(result);return 0;}\n\n", "src_uid": "033068c5e16d25f09039e29c88474275"} {"source_code": "\n#include \n\nint main(void)\n{\n long long int filyaS, filyaE;\n long long int sonyaS, sonyaE;\n long long int k;\n long long int meetingS, meetingE;\n \n scanf(\"%lld %lld %lld %lld %lld\", &filyaS, &filyaE, &sonyaS, &sonyaE, &k);\n \n if(filyaS>sonyaS)\n {\n meetingS=filyaS;\n }\n else\n {\n meetingS=sonyaS;\n }\n \n if(filyaE>sonyaE)\n {\n meetingE=sonyaE;\n }\n else\n {\n meetingE=filyaE;\n }\n \n if(meetingE-meetingS>=0)\n {\n if(k>=meetingS&&meetingE>=k)\n {\n printf(\"%lld\", meetingE-meetingS);\n }\n else\n {\n printf(\"%lld\", meetingE-meetingS+1);\n }\n }\n else\n {\n printf(\"0\");\n }\n\n return 0;\n}\n", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82"} {"source_code": "#include\nint main()\n{\n int a[3],b[2],i,j,ans,mid;\n while(scanf(\"%d %d %d\",&a[0],&a[1],&a[2])!=EOF)\n {\n ans=0;\n for(i=0;i<3;i++)\n for(j=1;j<3;j++)\n {\n if(a[i]>a[j])\n {\n mid=a[i];\n a[i]=a[j];\n a[j]=mid;\n }\n }\n ans=a[0];a[1]=a[1]-a[0];a[2]=a[2]-a[0];\n ans = ans+ a[2]/3 + a[1]/3; b[0]=a[1]%3;b[1]=a[2]%3;\n if(b[0]+b[1]==4&&a[0]!=0)\n printf(\"%d\\n\",a[0]+1+ a[2]/3+a[1]/3);\n else \n printf(\"%d\\n\",ans);\n }\n return 0;\n \n}\n", "src_uid": "acddc9b0db312b363910a84bd4f14d8e"} {"source_code": "#include\nint main()\n{\n int k, a, b, v;\n int temp;\n int sum = 0;\n scanf(\"%d%d%d%d\", &k, &a, &b, &v);\n temp = a;\n if(a < v)\n sum = 1;\n else\n if(b < k-1)\n {\n temp = a - (b+1) * v;\n sum++;\n if(temp)\n // sum = 1;\n // else\n sum +=((temp-1)/v + 1);\n }\n else\n {\n while(temp > 0 && b >= k-1)\n {\n temp = temp - k * v;\n sum++;\n b = b - k + 1;\n }\n if (b < k-1 && temp > 0)\n {\n temp = temp - (b + 1) * v;\n if(temp <= 0)\n sum++;\n else\n {\n if(temp % v)\n sum += temp / v + 2;\n else\n sum += temp / v + 1;\n }\n }\n\n }\n printf(\"%d\\n\", sum);\n return 0;\n}\n", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652"} {"source_code": "#include\n\nint main()\n{\n int n,a[110][110],sum=0;\n scanf(\"%d\",&n);\n for(int i=0;i\nint main()\n{\n\tint n,a,b;\n\tscanf(\"%d\\n%d\\n%d\",&n,&a,&b);\n\tif(4*a+2*b<=n)\n\t printf(\"1\");\n else if((4*a<=n&&2*b<=n)||(3*a<=n&&a+2*b<=n)||(2*a+b<=n))\n printf(\"2\");\n else if((2*a<=n&&2*b<=n)||(a+b<=n&&2*a<=n)||(4*a<=n))\n printf(\"3\");\n\telse if((a+b)<=n||2*a<=n)\n\t printf(\"4\");\n\telse if(2*b<=n)\n\t printf(\"5\");\n\telse\n printf(\"6\");\n\treturn 0;\n}\n", "src_uid": "1a50fe39e18f86adac790093e195979a"} {"source_code": "#include \n#include \n\nint main()\n{\n long long int X[4][2] , Y[4][2] , a , b , c , d ;\n int i , j , countA=0 , countB=0 , countC=0 , countD=0 , sameX=0 , sameY=0 ;\n\n for(i=0 ; i<4 ; i++)\n {\n scanf(\"%lld %lld %lld %lld\",&X[i][0],&Y[i][0],&X[i][1],&Y[i][1]);\n if((X[i][0] == X[i][1] && Y[i][0] == Y[i][1]) || (X[i][0] != X[i][1] && Y[i][0] != Y[i][1]))\n {\n printf(\"NO\");\n return 0;\n }\n if(X[i][0] != X[i][1])\n {\n a = X[i][0];\n b = X[i][1];\n }\n else\n sameX++;\n \n if(Y[i][0] != Y[i][1])\n {\n c = Y[i][0];\n d = Y[i][1];\n }\n else\n sameY++;\n }\n \n if(sameX ==4 || sameY ==4)\n {\n printf(\"NO\");\n return 0;\n }\n \n for(i=0 ; i<4 ; i++)\n for(j=0 ; j<2 ; j++)\n {\n if(X[i][j] == a) countA++;\n else if(X[i][j] == b) countB++;\n\n if(Y[i][j] == c) countC++;\n else if(Y[i][j] == d) countD++;\n }\n\n if(countA==4 && countB==4 && countC==4 && countD==4)\n printf(\"YES\");\n else\n printf(\"NO\");\n\n return 0;\n}", "src_uid": "ad105c08f63e9761fe90f69630628027"} {"source_code": "#include\nint main()\n{\n long long int n,x,i,count=0;\n scanf(\"%I64d %I64d\",&n,&x);\n for(i=1;i<=n;i++)\n {\n if(n*i>=x && x%i==0)\n count++;\n }\n printf(\"%I64d\\n\",count);\n return 0;\n}\n", "src_uid": "c4b139eadca94201596f1305b2f76496"}