{"source_code": "void main(){\n import std.stdio, std.algorithm, std.string, std.conv;\n\n int n, k; rd(n, k);\n auto as=readln.split.to!(int[]);\n\n int cur=0;\n bool[int] set;\n int[] idx;\n foreach(int i, a; as){\n if(a in set) continue;\n set[a]=true;\n idx~=(i+1);\n if(set.length==k){\n writeln(\"YES\");\n writefln(\"%(%s %)\", idx);\n return;\n }\n }\n\n writeln(\"NO\");\n}\n\nvoid rd(T...)(ref T x){\n import std.stdio, std.string, std.conv;\n auto l=readln.split;\n assert(l.length==x.length);\n foreach(i, ref e; x) e=l[i].to!(typeof(e));\n}", "positive_code": [{"source_code": "import std.stdio ;\n\nvoid main() {\n\tint n,k,x,r,i = 1;\n\tbool[105] arr ;\n\n\treadf(\"%s %s\",&n,&k);\n\tint[105] arr2 ;\n\n\twhile(i <= n) {\n\t\treadf(\" %s\",&x);\n\t\tif(arr[x] == false && r f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\n\n\nvoid main() {\n try {\n for (; ; ) {\n const A = readInt();\n const B = readInt();\n \n int ans;\n int a = A, b = B;\n for (; !(a > b); ) {\n ++ans;\n a *= 3;\n b *= 2;\n }\n writeln(ans);\n }\n } catch (EOFException e) {\n }\n}\n"}, {"source_code": "import std.stdio;\n\nint main()\n{\n\tint a=0;\n\tint b=0;\n\treadf(\" %d\", &a);\n\treadf(\" %d\", &b);\n\tint i=0;\n\twhile(a<=b)\n\t{\n\t\ta=a*3;\n\t\tb=b*2;\n\t\ti=i+1;\n\t}\n\twriteln(i);\n\treturn 0;\n}"}, {"source_code": "import std.stdio, std.string, std.conv;\nvoid main()\n{\n byte[] arr = readln.chomp.split(' ').to!(byte[]);\n byte ret = 0;\n while(3^^ret * arr[0] <= 2^^ret * arr[1]) ret ++;\n writeln(ret);\n}\n"}], "negative_code": [], "src_uid": "a1583b07a9d093e887f73cc5c29e444a"} {"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.algorithm;\nimport std.math;\n\nint main(string[] argv)\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint sum = 0;\n\tforeach (int i; 1..n)\n\t{\n\t\tsum += i * (n-i);\n\t}\n\twrite(sum + n);\n\treturn 0;\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.math;\n\nvoid main() {\n int n = readln.chomp.to!int;\n\n int ans = 0;\n for (int i = 1; i <= n - 1; i++) {\n ans += i * (n - i);\n }\n\n writeln(ans + n);\n}"}, {"source_code": "import std.stdio, std.string, std.conv;\nimport std.range, std.algorithm, std.array, std.typecons, std.container;\nimport std.math, std.numeric, core.bitop;\n\n\n\nvoid main() {\n long n;\n scan(n);\n long ans = n * (n*n + 5) / 6;\n writeln(ans);\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\nvoid scan(T...)(ref T args) {\n import std.stdio : readln;\n import std.algorithm : splitter;\n import std.conv : to;\n import std.range.primitives;\n\n auto line = readln().splitter();\n foreach (ref arg; args) {\n arg = line.front.to!(typeof(arg));\n line.popFront();\n }\n assert(line.empty);\n}\n\n\nvoid fillAll(R, T)(ref R arr, T value) {\n static if (is(typeof(arr[] = value))) {\n arr[] = value;\n }\n else {\n foreach (ref e; arr) {\n fillAll(e, value);\n }\n }\n}"}, {"source_code": "import std.array : split;\nimport std.conv : to;\nimport std.stdio;\nimport std.string : strip;\n\nprivate {\n\tstring[] temp;\n}\n\nvoid main() {\n\tread();\n\n\tint n = get!int(0);\n\t\n\tint count = 0;\n\n\tforeach (i; 1 .. n + 1) {\n\t\tcount += (n - (i - 1)) * i - i + 1;\n\t}\n\n\tstdout.write(count);\n}\n\nvoid read() {\n\ttemp = split(strip(stdin.readln()));\n}\n\nT get(T)(int p) {\n\treturn to!(T)(temp[p]);\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.algorithm;\nimport std.math;\n\nint main(string[] argv)\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint sum = 0;\n\tforeach (int i; 0..n)\n\t{\n\t\tsum += (sum + 1);\n\t}\n\twrite(sum);\n\treturn 0;\n}"}, {"source_code": "import std.array : split;\nimport std.conv : to;\nimport std.stdio;\nimport std.string : strip;\n\nprivate {\n\tstring[] temp;\n}\n\nvoid main() {\n\tread();\n\n\tint n = get!int(0);\n\t\n\tint count = n;\n\n\tforeach (i; 1 .. n) {\n\t\tcount += 2 * (n - i) - 1;\n\t}\n\n\tstdout.write(count);\n}\n\nvoid read() {\n\ttemp = split(strip(stdin.readln()));\n}\n\nT get(T)(int p) {\n\treturn to!(T)(temp[p]);\n}"}], "src_uid": "6df251ac8bf27427a24bc23d64cb9884"} {"source_code": "import core.bitop;\nimport std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.exception;\nimport std.functional;\nimport std.math;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\treadln;\n\t\tauto a = readln.split.map !(to !(int)).array;\n\t\tauto f = new int [3] [n + 1];\n\t\tforeach (i; 0..n)\n\t\t{\n\t\t\tauto prev = f[i].reduce !(max);\n\t\t\tf[i + 1][] = prev;\n\t\t\tforeach (j; [1, 2])\n\t\t\t{\n\t\t\t\tif (a[i] & j)\n\t\t\t\t{\n\t\t\t\t\tf[i + 1][j] = max (f[i + 1][j],\n\t\t\t\t\t max (f[i][0], f[i][j ^ 3]) + 1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tauto res = f[n].reduce !(max);\n\t\twriteln (n - res);\n\t}\n}\n", "positive_code": [{"source_code": "import core.bitop;\nimport core.checkedint;\nimport core.simd;\nimport core.stdc.string;\nimport std.algorithm;\nimport std.array;\nimport std.ascii;\nimport std.bigint;\nimport std.bitmanip;\nimport std.complex;\nimport std.container;\nimport std.conv;\nimport std.datetime;\nimport std.functional;\nimport std.math;\nimport std.meta;\nimport std.numeric;\nimport std.random;\nimport std.regex;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport std.variant;\n\nbool read(T...)(T ptrs) if (ptrs.length > 0) {\n return readf(' ' ~ replicate(\"%s \", ptrs.length), ptrs) == ptrs.length;\n}\n\nint n;\nint[100] _a;\nint[ ] a;\n\nint[3][100] dp;\n\nint dyn(int day, int prevMask) {\n if (day == n)\n return 0;\n if (~dp[day][prevMask])\n return dp[day][prevMask];\n int result = dyn(day + 1, 0x0) + 1;\n foreach (mask; 0x1 .. 0x3)\n if ((a[day] & mask) && !(prevMask & mask))\n result = min(result, dyn(day + 1, mask));\n return (dp[day][prevMask] = result);\n}\n\nvoid main() {\n while (read(&n)) {\n a = _a[0 .. n];\n foreach (ref x; a)\n read(&x);\n memset(dp.ptr, 0xFF, dp.sizeof);\n writeln(dyn(0, 0x0));\n }\n}\n"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.algorithm;\nvoid main() {\n int d0 = 0, d1 = 0, d2 = 0;\n int n;\n readf(\"%d\", &n);\n foreach (i; 0 .. n) {\n \t//write(i);\n int c;\n readf(\" %d\", &c);\n int n0 = max(d0, max(d1, d2));\n int n1 = -1;\n int n2 = -1;\n if (c & 1) {\n n1 = max(n1, max(d0, d2) + 1);\n }\n if (c & 2) {\n n2 = max(n2, max(d0, d1) + 1);\n }\n d0 = n0, d1 = n1, d2 = n2;\n //writef(\"%d, %d, %d\\n\", d0, d1, d2);\n }\n write(n - max(d0, max(d1, d2)));\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\nvoid main() {\n int d0 = 0, d1 = 0, d2 = 0;\n int n;\n readf(\"%d\", &n);\n foreach (i; 1 .. n) {\n int c;\n readf(\" %d\", &c);\n int n0 = max(d0, max(d1, d2));\n int n1 = d1;\n int n2 = d2;\n if (c & 1) {\n n1 = max(n1, max(d0, d2) + 1);\n }\n if (c & 2) {\n n2 = max(n2, max(d0, d1) + 1);\n }\n d0 = n0, d1 = n1, d2 = n2;\n }\n write(n - max(d0, max(d1, d2)));\n}"}], "src_uid": "08f1ba79ced688958695a7cfcfdda035"} {"source_code": "import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;\nint readint() { return readln.chomp.to!int; }\nint[] readints() { return readln.split.to!(int[]); }\n\nvoid main() {\n string s = readln.chomp;\n string t = readln.chomp;\n\n int cur = 0;\n foreach (c ; t) {\n if (c == s[cur]) cur++;\n }\n\n writeln(cur + 1);\n\n string _ = readln;\n}", "positive_code": [{"source_code": "module main;\n\nimport std.stdio : readln, writeln, write, writefln, writef;\nimport std.conv : to;\nimport std.array : split, replace;\nimport std.string : strip;\nimport std.algorithm : max, min, map, reduce, sort, reverse;\nimport std.functional : memoize;\n\nversion = A;\n\nversion (A)\n{\n void main()\n {\n auto sequence = read_one!string();\n auto instructions = read_one!string();\n size_t position = 0;\n foreach (instruction; instructions)\n {\n if (sequence[position] == instruction)\n {\n position += 1;\n }\n }\n writeln(position + 1);\n }\n}\nversion (B)\n{\n void main()\n {\n auto n = read_one!int();\n }\n}\nversion (C)\n{\n void main()\n {\n auto n = read_one!int();\n }\n}\nversion (D)\n{\n void main()\n {\n auto n = read_one!int();\n }\n}\nversion (E)\n{\n void main()\n {\n }\n}\n\nT read_one(T)()\n{\n return readln().strip().to!T();\n}\n \nT[] read_some(T)()\n{\n T[] ret;\n foreach (e; readln().strip().split())\n {\n ret ~= e.to!T();\n }\n return ret;\n}\n\nT[m] read_fixed(int m, T)()\n{\n T[m] ret;\n foreach (i, e; readln().strip().split())\n {\n ret[i] = e.to!T();\n }\n return ret;\n}\n"}, {"source_code": "import std.stdio;\n\nvoid main() {\n\tstring land = stdin.readln();\n\n\tsize_t position = 1;\n\n\tforeach (char command; stdin.readln()) {\n\t\tif (command == land[position - 1]) {\n\t\t\t++position;\n\t\t}\n\t}\n\n\tstdout.write(position);\n}"}], "negative_code": [], "src_uid": "f5a907d6d35390b1fb11c8ce247d0252"} {"source_code": "import std.stdio;\n\nvoid main() {\n\tlong n;\n\treadf!\"%s\\n\"(n);\n\n\tlong product=0;\n\tlong count=1;\n\tfor (int i=0; i 0; i--) {\n \tif(coordinate >= i) {\n \tsteps += coordinate/i;\n \tcoordinate = coordinate % i;\n \t}\n }\n\n writeln(steps);\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.uni;\nimport std.string;\nimport core.stdc.stdio;\nimport std.array;\nimport std.algorithm;\nimport std.string;\nimport std.math;\n\nint main(string[] argv)\n{\n\tint x;\n\tscanf(\"%d\", &x);\n\tint r = 0;\n\tint s = 5;\n\twhile (x > 0)\n\t{\n\t\tr += x / s;\n\t\tx = x % s;\n\t\ts--;\n\t}\n\tprintf(\"%d\", r);\n\treturn 0;\n}\n\n"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\n\nvoid main()\n{\n\t auto s1 = split(strip(readln));\n\t long n = to!long(s1[0], 10);\n\t if (n % 5 == 0)\n\t writeln(n / 5 );\n\t else\n\t writeln(n / 5 + 1);\n}"}, {"source_code": "import std.stdio;\n\nint main( ) {\n int n ;\n\treadf(\"%d\",n);\n\tint[] ar = [5, 4 ,3 ,2 ,1];\n\tint c = 0;\n\tfor (int i = 0 ; i < 5 ; i++ ) {\n\t\tint _c = n / ar[i];\n\t\tn -= ar[i] * _c;\n\t\tc += _c;\n\t\tif (n == 0)\n\t\t\tbreak;\n\t}\n\twrite(c , '\\n');\n\n\treturn 0;\n}\n"}, {"source_code": "import std.stdio, std.string, std.conv;\n\nvoid main() {\n int x = readln.chomp.to!int;\n writeln((x + 4)/ 5);\n}"}, {"source_code": "import std.stdio;\n\nint main()\n{\n\tint a=0;\n\treadf(\" %d\", &a);\n\tif (a%5==0)\n\t{\n\t\twriteln(a/5);\n\t}\n\telse\n\t{\n\t\twriteln((a/5)+1);\n\t}\n\treturn 0;\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\n\nvoid main()\n{\n\t auto s1 = split(strip(readln));\n\t long n = to!long(s1[0], 10);\n\t writeln(n / 5 + 1);\n}"}], "src_uid": "4b3d65b1b593829e92c852be213922b6"} {"source_code": "import std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\tauto a = new int [n];\n\t\tforeach (ref x; a)\n\t\t{\n\t\t\treadf (\" %s\", &x);\n\t\t}\n\n\t\tbool ok = false;\n\t\tforeach (s; 0..1 << n)\n\t\t{\n\t\t\tint cur = 0;\n\t\t\tforeach (i; 0..n)\n\t\t\t{\n\t\t\t\tif (s & (1 << i))\n\t\t\t\t{\n\t\t\t\t\tcur += a[i];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcur -= a[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cur % 360 == 0)\n\t\t\t{\n\t\t\t\tok = true;\n\t\t\t}\n\t\t}\n\t\twriteln (ok ? \"YES\" : \"NO\");\n\t}\n}\n", "positive_code": [{"source_code": "import std.stdio, std.string, std.conv;\nimport std.range, std.algorithm, std.array, std.typecons, std.container;\nimport std.math, std.numeric, core.bitop;\n\n\n\nvoid main() {\n int n;\n scan(n);\n auto a = iota(n).map!(i => readln.chomp.to!int).array;\n\n foreach (s ; 0 .. 1< 0)\n\t{\n\t\tauto a = new int [n];\n\t\tforeach (ref x; a)\n\t\t{\n\t\t\treadf (\" %s\", &x);\n\t\t}\n\n\t\tbool ok = false;\n\t\tforeach (s; 0..1 << n)\n\t\t{\n\t\t\tint cur = 0;\n\t\t\tforeach (i; 0..n)\n\t\t\t{\n\t\t\t\tif (s & (1 << i))\n\t\t\t\t{\n\t\t\t\t\tcur += a[i];\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcur -= a[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cur % 180 == 0)\n\t\t\t{\n\t\t\t\tok = true;\n\t\t\t}\n\t\t}\n\t\twriteln (ok ? \"YES\" : \"NO\");\n\t}\n}\n"}], "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10"} {"source_code": "module main;\nimport std.bigint,std.container,std.array,std.algorithm,std.conv,\n\tstd.functional,std.math,std.numeric,std.string,std.range,std.complex,\n\tstd.typecons,std.regex,std.random,std.uni,std.traits,std.variant;\nimport core.stdc.stdio : freopen;\nimport core.stdc.stdlib : system;\nimport std.stdio;\n//import core.stdc.stdio;\nalias RedBlackTree Rbt;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias BoyerMooreFinder strfind;\nalias mp=make_pair;\nalias bins=binary_search;\nalias orsq=orient_square;\nimmutable int mod=1000000007;\npure nothrow \n{\n\tT lcm (T)(auto ref T a,auto ref T b)\n\t{\n\t\treturn a/gcd(a,b)*b;\n\t}\n\tX binpow(X,Y)(X base,Y exp)\n\t\tif(is(typeof(exp&1)))\n\t{\n\t\tif(exp<0)return X(0);\n\t\tX res=X(1);\n\t\twhile(exp>0)\n\t\t{\n\t\t\tif(exp&1)res*=base;\n\t\t\tbase*=base;\n\t\t\texp>>=1;\n\t\t}\n\t\treturn res;\n\t}\n\tauto binpow(X,Y,Z)(X base,Y exp,in Z mm)\n\t\tif(is(typeof(exp&1)))\n\t{\n\t\tif(mm==0) return binpow(base,exp);\n\t\tif(exp<0)return X(0);\n\t\tauto res=X(1)%mm;\n\t\twhile(exp>0)\n\t\t{\n\t\t\tif(exp&1)res=(res*base)%mm;\n\t\t\tbase*=base;\n\t\t\tbase%=mm;\n\t\t\texp>>=1;\n\t\t}\n\t\treturn res;\n\t}\n\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\tsize_t lowb(T,X)(in T a,auto ref X g) \n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m]1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m] 0)\n{return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX first;\n\tY second;\n\talias first fi;\n\talias second se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t}\n\tthis(this){fi=fi;se=se;}\n\tthis(A,B)(auto ref pair!(A,B) p) if(is(A:X) && is(B:Y))\n\t{\n\t\tfi=p.fi;\n\t\tse=p.se;\n\t}\n\tpair!(X,Y) opAssign(A,B)(pair!(A,B) val)\n\t{\n\t\treturn this=pair!(X,Y)(val);\n\t}\n\tint opCmp(A,B)(in pair!(A,B) s_) const pure nothrow @safe \n\t\tif(is(typeof(s_.fis_.fi);\n\t\tif(cmp!=0)return cmp;\n\t\telse return (0-(ses_.se));\n\t}\n};\npair!(X,Y) make_pair(X,Y)(in X x_,in Y y_) pure nothrow @safe\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nnothrow void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\n@property auto arread(T)(){return readln.split.map!(to!(T)).array;}\nstruct Tree(T,alias arg=\"a+b\")\n{\n\tprivate alias fun=binaryFun!arg;\n\tprivate static const size_t n=size_t.max>>1;\n\tprivate T[size_t] t;\n\tthis(this){t=t.dup;}\n\tthis(R)(R range) if(isInputRange!R && is(ElementType!(R) : T))\n\t{\n\t\tforeach(pos,i;range) upd(pos,i);\n\t}\n\tthis(R,alias f)(Tree!(R,f) q) if(is(R:T))\n\t{\n\t\tforeach(i,j;q.t)\n\t\t{\n\t\t\tt[i]=j;\n\t\t}\n\t}\n\tTree!(T,arg) opAssign(R)(R val)\n\t{\n\t\treturn this=Tree!(T,arg)(val);\n\t}\n\tprivate void upd(in size_t v,in size_t vl,in size_t vr,in size_t i,in T x)\n\t{\n\t\tif (vr - vl == 1){t[v] = x;return;}\n\t\tsize_t vm = (vl + vr) >> 1;\n\t\tif(i < vm) upd(2*v, vl, vm, i, x);\n\t\telse upd(2*v+1, vm, vr, i, x);\n\t\tif(v*2+1 !in t)t[v]=t[v*2];\n\t\telse if (v*2 !in t)t[v]=t[v*2+1];\n\t\telse t[v]=fun(t[v*2],t[v*2+1]);\n\t}\n\tvoid upd(in size_t i,in T x)\n\t{\n\t\tupd(1,0,n,i,x);\n\t}\n\tprivate T cel(in size_t v,in size_t vl,in size_t vr,in size_t l,in size_t r)\n\t{\n\t\tif(vl==l && r==vr) return t[v];\n\t\tsize_t vm=(vl+vr) >> 1;\n\t\tif(r<=vm) return cel(2*v,vl,vm,l,r);\n\t\telse if(l>=vm) return cel(2*v+1,vm,vr,l,r);\n\t\telse return fun(cel(2*v,vl,vm,l,vm),cel(2*v+1,vm,vr,vm,r));\n\t}\n\tT cel(in size_t l,in size_t r){return cel(1,0,n,l,r);}\n};\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold schwartzSort multiSort partialSort heapify join filter countUntil\n//---------------------------------------------------------------program beginning-----------------------------------------------------------------\n\nvoid main()\n{\n\tint n;\n\tloop:while(input(&n))\n\t{\n\t\treadln;\n\t\tauto a=arread!int;\n\t\tif(a.sum!=0)\n\t\t{\n\t\t\twriteln(\"YES\");\n\t\t\twriteln(1);\n\t\t\twriteln(1,' ',n);\n\t\t\tcontinue loop;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tforeach(i;1..n)\n\t\t\t{\n\t\t\t\tif(sum(a[0..i])!=0 && sum(a[i..n])!=0)\n\t\t\t\t{\n\t\t\t\t\twriteln(\"YES\");\n\t\t\t\t\twriteln(2);\n\t\t\t\t\twriteln(1,' ',i);\n\t\t\t\t\twriteln(i+1,' ',n);\n\t\t\t\t\tcontinue loop;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\twriteln(\"NO\");\n\t}\n}", "positive_code": [{"source_code": "import std.bigint,std.container,std.array,std.algorithm,std.conv,\nstd.functional,std.math,std.numeric,std.string,std.range,std.complex,\nstd.typecons,std.regex,std.random,std.uni,std.traits,std.variant;\nimport core.stdc.stdio : freopen;\nimport core.stdc.stdlib : system;\nimport std.stdio;\n//import core.stdc.stdio;\nalias RedBlackTree Rbt;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias BoyerMooreFinder strfind;\nalias make_pair mp;\nalias binary_search bins;\nalias orient_square orsq;\nimmutable int mod=1000000007;\npure nothrow \n{\n\tT lcm (T)(auto ref T a,auto ref T b)\n\t{\n\t\treturn a/gcd(a,b)*b;\n\t}\n\tX binpow(X,Y)(X base,Y exp)\n\t\tif(is(typeof(exp&1)))\n\t\t{\n\t\t\tif(exp<0)return X(0);\n\t\t\tX res=X(1);\n\t\t\twhile(exp>0)\n\t\t\t{\n\t\t\t\tif(exp&1)res*=base;\n\t\t\t\tbase*=base;\n\t\t\t\texp>>=1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\tauto binpow(X,Y,Z)(X base,Y exp,in Z mm)\n\t\tif(is(typeof(exp&1)))\n\t\t{\n\t\t\tif(mm==0) return binpow(base,exp);\n\t\t\tif(exp<0)return X(0);\n\t\t\tauto res=X(1)%mm;\n\t\t\twhile(exp>0)\n\t\t\t{\n\t\t\t\tif(exp&1)res=(res*base)%mm;\n\t\t\t\tbase*=base;\n\t\t\t\tbase%=mm;\n\t\t\t\texp>>=1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\tsize_t lowb(T,X)(in T a,auto ref X g) \n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(!(a[m]1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(g1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(!(a[m] 0)\n{return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX first;\n\tY second;\n\talias first fi;\n\talias second se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t}\n\tthis(this){fi=fi;se=se;}\n\tthis(A,B)(auto ref pair!(A,B) p) if(is(A:X) && is(B:Y))\n\t{\n\t\tfi=p.fi;\n\t\tse=p.se;\n\t}\n\tpair!(X,Y) opAssign(A,B)(pair!(A,B) val)\n\t{\n\t\treturn this=pair!(X,Y)(val);\n\t}\n\tint opCmp(A,B)(in pair!(A,B) s_) const pure nothrow @safe \n\t\tif(is(typeof(s_.fis_.fi);\n\t\t\tif(cmp!=0)return cmp;\n\t\t\telse return (0-(ses_.se));\n\t\t}\n};\npair!(X,Y) make_pair(X,Y)(in X x_,in Y y_) pure nothrow @safe\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nnothrow void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\n@property auto arread(T)(){return readln.split.map!(to!(T)).array;}\nstruct Tree(T,alias arg=\"a+b\")\n{\n\tprivate alias fun=binaryFun!arg;\n\tprivate static const uint n=int.max;\n\tprivate T[uint] t;\n\tthis(this){t=t.dup;}\n\tthis(R)(R range) if(isInputRange!R && is(ElementType!(R) : T))\n\t{\n\t\tforeach(pos,i;range) upd(pos,i);\n\t}\n\tthis(R,alias f)(Tree!(R,f) q) if(is(R:T))\n\t{\n\t\tforeach(i,j;q.t)\n\t\t{\n\t\t\tt[i]=j;\n\t\t}\n\t}\n\tTree!(T,arg) opAssign(R)(R val)\n\t{\n\t\treturn this=Tree!(T,arg)(val);\n\t}\n\tprivate void upd(in uint v,in uint vl,in uint vr,in uint i,in T x)\n\t{\n\t\tif (vr - vl == 1){t[v] = x;return;}\n\t\tuint vm = (vl + vr) >> 1;\n\t\tif(i < vm) upd(2*v, vl, vm, i, x);\n\t\telse upd(2*v+1, vm, vr, i, x);\n\t\tif(v*2+1 !in t)t[v]=t[v*2];\n\t\telse if (v*2 !in t)t[v]=t[v*2+1];\n\t\telse t[v]=fun(t[v*2],t[v*2+1]);\n\t}\n\tvoid upd(in uint i,in T x)\n\t{\n\t\tupd(1,0,n,i,x);\n\t}\n\tprivate T cel(in uint v,in uint vl,in uint vr,in uint l,in uint r)\n\t{\n\t\tif(vl==l && r==vr) return t[v];\n\t\tuint vm=(vl+vr) >> 1;\n\t\tif(r<=vm) return cel(2*v,vl,vm,l,r);\n\t\telse if(l>=vm) return cel(2*v+1,vm,vr,l,r);\n\t\telse return fun(cel(2*v,vl,vm,l,vm),cel(2*v+1,vm,vr,vm,r));\n\t}\n\tT cel(in uint l,in uint r){return cel(1,0,n,l,r);}\n};\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold schwartzSort multiSort partialSort heapify join filter\n//---------------------------------------------------------------program beginning-----------------------------------------------------------------\n\nvoid main()\n{\n\tint n;\n\twhile(input(&n))\n\t{\n\t\treadln;\n\t\tauto a=arread!int;\n\t\tif(a.sum!=0)\n\t\t{\n\t\t\twriteln(\"YES\");\n\t\t\twriteln(1);\n\t\t\twriteln(1,' ',n);\n\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tforeach(i;1..n)\n\t\t\t{\n\t\t\t\tif(sum(a[0..i])!=0 && sum(a[i..n])!=0)\n\t\t\t\t{\n\t\t\t\t\twriteln(\"YES\");\n\t\t\t\t\twriteln(2);\n\t\t\t\t\twriteln(1,' ',i);\n\t\t\t\t\twriteln(i+1,' ',n);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\twriteln(\"NO\");\n\t}\n\tdebug system(\"pause\");\n}"}, {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.string;\n\nvoid main() {\n auto N = readln.chomp.to!int;\n auto A = readln.split.map!(to!int).array;\n\n if (A.map!(a => a == 0).all) {\n writeln(\"NO\");\n return;\n }\n\n writeln(\"YES\");\n\n if (A.sum == 0) {\n foreach (i; 0..N) if (A[i] != 0) {\n writeln(2);\n writeln(1, \" \", i+1);\n writeln(i+2, \" \", N);\n break;\n }\n } else {\n writeln(1);\n writeln(1, \" \", N);\n }\n}\n"}], "negative_code": [{"source_code": "import std.bigint,std.container,std.array,std.algorithm,std.conv,\nstd.functional,std.math,std.numeric,std.string,std.range,std.complex,\nstd.typecons,std.regex,std.random,std.uni,std.traits,std.variant;\nimport core.stdc.stdio : freopen;\nimport core.stdc.stdlib : system;\nimport std.stdio;\n//import core.stdc.stdio;\nalias RedBlackTree Rbt;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias BoyerMooreFinder strfind;\nalias make_pair mp;\nalias binary_search bins;\nalias orient_square orsq;\nimmutable int mod=1000000007;\npure nothrow \n{\n\tT lcm (T)(auto ref T a,auto ref T b)\n\t{\n\t\treturn a/gcd(a,b)*b;\n\t}\n\tX binpow(X,Y)(X base,Y exp)\n\t\tif(is(typeof(exp&1)))\n\t\t{\n\t\t\tif(exp<0)return X(0);\n\t\t\tX res=X(1);\n\t\t\twhile(exp>0)\n\t\t\t{\n\t\t\t\tif(exp&1)res*=base;\n\t\t\t\tbase*=base;\n\t\t\t\texp>>=1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\tauto binpow(X,Y,Z)(X base,Y exp,in Z mm)\n\t\tif(is(typeof(exp&1)))\n\t\t{\n\t\t\tif(mm==0) return binpow(base,exp);\n\t\t\tif(exp<0)return X(0);\n\t\t\tauto res=X(1)%mm;\n\t\t\twhile(exp>0)\n\t\t\t{\n\t\t\t\tif(exp&1)res=(res*base)%mm;\n\t\t\t\tbase*=base;\n\t\t\t\tbase%=mm;\n\t\t\t\texp>>=1;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\tsize_t lowb(T,X)(in T a,auto ref X g) \n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(!(a[m]1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(g1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(!(a[m] 0)\n{return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX first;\n\tY second;\n\talias first fi;\n\talias second se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t}\n\tthis(this){fi=fi;se=se;}\n\tthis(A,B)(auto ref pair!(A,B) p) if(is(A:X) && is(B:Y))\n\t{\n\t\tfi=p.fi;\n\t\tse=p.se;\n\t}\n\tpair!(X,Y) opAssign(A,B)(pair!(A,B) val)\n\t{\n\t\treturn this=pair!(X,Y)(val);\n\t}\n\tint opCmp(A,B)(in pair!(A,B) s_) const pure nothrow @safe \n\t\tif(is(typeof(s_.fis_.fi);\n\t\t\tif(cmp!=0)return cmp;\n\t\t\telse return (0-(ses_.se));\n\t\t}\n};\npair!(X,Y) make_pair(X,Y)(in X x_,in Y y_) pure nothrow @safe\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nnothrow void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\n@property auto arread(T)(){return readln.split.map!(to!(T)).array;}\nstruct Tree(T,alias arg=\"a+b\")\n{\n\tprivate alias fun=binaryFun!arg;\n\tprivate static const uint n=int.max;\n\tprivate T[uint] t;\n\tthis(this){t=t.dup;}\n\tthis(R)(R range) if(isInputRange!R && is(ElementType!(R) : T))\n\t{\n\t\tforeach(pos,i;range) upd(pos,i);\n\t}\n\tthis(R,alias f)(Tree!(R,f) q) if(is(R:T))\n\t{\n\t\tforeach(i,j;q.t)\n\t\t{\n\t\t\tt[i]=j;\n\t\t}\n\t}\n\tTree!(T,arg) opAssign(R)(R val)\n\t{\n\t\treturn this=Tree!(T,arg)(val);\n\t}\n\tprivate void upd(in uint v,in uint vl,in uint vr,in uint i,in T x)\n\t{\n\t\tif (vr - vl == 1){t[v] = x;return;}\n\t\tuint vm = (vl + vr) >> 1;\n\t\tif(i < vm) upd(2*v, vl, vm, i, x);\n\t\telse upd(2*v+1, vm, vr, i, x);\n\t\tif(v*2+1 !in t)t[v]=t[v*2];\n\t\telse if (v*2 !in t)t[v]=t[v*2+1];\n\t\telse t[v]=fun(t[v*2],t[v*2+1]);\n\t}\n\tvoid upd(in uint i,in T x)\n\t{\n\t\tupd(1,0,n,i,x);\n\t}\n\tprivate T cel(in uint v,in uint vl,in uint vr,in uint l,in uint r)\n\t{\n\t\tif(vl==l && r==vr) return t[v];\n\t\tuint vm=(vl+vr) >> 1;\n\t\tif(r<=vm) return cel(2*v,vl,vm,l,r);\n\t\telse if(l>=vm) return cel(2*v+1,vm,vr,l,r);\n\t\telse return fun(cel(2*v,vl,vm,l,vm),cel(2*v+1,vm,vr,vm,r));\n\t}\n\tT cel(in uint l,in uint r){return cel(1,0,n,l,r);}\n};\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold schwartzSort multiSort partialSort heapify join filter\n//---------------------------------------------------------------program beginning-----------------------------------------------------------------\n\nvoid main()\n{\n\tint n;\n\twhile(input(&n))\n\t{\n\t\treadln;\n\t\tauto a=arread!int;\n\t\tif(a.sum!=0)\n\t\t{\n\t\t\twriteln(\"YES\");\n\t\t\twriteln(1);\n\t\t\twriteln(1,' ',n);\n\t\t\treturn;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tforeach(i;1..n-1)\n\t\t\t{\n\t\t\t\tif(sum(a[0..i])!=0 && sum(a[i..n])!=0)\n\t\t\t\t{\n\t\t\t\t\twriteln(\"YES\");\n\t\t\t\t\twriteln(2);\n\t\t\t\t\twriteln(1,' ',i);\n\t\t\t\t\twriteln(i+1,' ',n);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\t\n\t\t}\n\t\twriteln(\"NO\");\n\t}\n\tdebug system(\"pause\");\n}"}], "src_uid": "3a9258070ff179daf33a4515def9897a"} {"source_code": "module cf_216A;\n\nimport std.stdio;\n\nvoid main() {\n int a, b, c;\n\n readf(\"%d %d %d\", &a, &b, &c);\n\n int count = c * (a + b - 1) + (a - 1) * (b - 1);\n writeln(count);\n}", "positive_code": [{"source_code": "import std.stdio;\n\nint main() {\n debug stdin = File(\"in.txt\", \"r\");\n\n int a, b, c;\n readf(\" %s %s %s\\n\", &a, &b, &c);\n int answer = 7;\n answer += (a - 2) * (2 + 2 - 1);\n answer += (b - 2) * (a + 2 - 1);\n answer += (c - 2) * (a + b - 1);\n writeln(answer);\n \n return 0;\n}"}], "negative_code": [{"source_code": "module cf_216A;\n\nimport std.stdio;\n\nvoid main() {\n int a, b, c;\n\n readf(\"%d %d %d\", &a, &b, &c);\n writeln(2 * (a + b + c));\n}"}], "src_uid": "8ab25ed4955d978fe20f6872cb94b0da"} {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.array;\nimport std.range;\nimport std.algorithm;\nimport std.container;\nimport std.math;\n\nvoid main() {\n string[] p = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n int n = readln.chomp.to!int;\n n--;\n while (n >= 5) {\n n -= 5;\n n /= 2;\n }\n writeln(p[n]);\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\nimport std.range;\n\n/// solve ==========================\nstring solve(int n){\n\n string[] persons = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n int times;\n int start;\n string res;\n int personNum;\n \n auto xs = recurrence!(\"(a[n-1] + (a[n-1] - a[n-2])*2)\")(1, 6);\n foreach(x; xs){\n if(x > n) break;\n start = x;\n times += 1;\n }\n personNum = (n - start) / (2^^(times-1));\n res = persons[personNum].to!string;\n return res;\n}\n\n/// main ====================\nvoid main(){\n auto n = readln.strip.to!int;\n solve(n).writeln;\n}\n"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\nimport std.range;\n\nstring solve(int n){\n\n string[] names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n int times;\n int start;\n string res;\n int modN;\n \n /// solve ==========================\n auto xs = recurrence!(\"(a[n-1] + (a[n-1] - a[n-2])*2)\")(1, 6);\n foreach(x; xs){\n if(x > n) break;\n start = x;\n times += 1;\n }\n modN = (n - start) / (2^^(times-1));\n res = names[modN].to!string;\n return res;\n}\n\n/// unittest -------------------\nunittest{\n assert( solve(1) == \"S\" );\n assert( solve(6) == \"S\" );\n assert( solve(1802) == \"P\" );\n writeln(\"---pass ---\");\n}\n\n/// main ====================\nvoid main(){\n auto n = readln.strip.to!int;\n solve(n).writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.conv : to;\n\nimmutable names = [\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"];\n\nvoid main()\n{\n ulong num;\n readf(\"%s\", &num);\n \n ulong groupSize = 5;\n \n while(true)\n {\n if (num <= groupSize)\n {\n names[cast(uint)((num-1)/(groupSize/5))].writeln;\n break;\n }\n \n num -= groupSize;\n groupSize *= 2;\n }\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\n\nvoid main()\n{\n auto n = stdin.readln.strip.to!int;\n int m=0, j=0;\n for(int i=1; i<=n; i+=5*(2^^j),j++) m=i;\n write([\"Sheldon\", \"Leonard\", \"Penny\", \"Rajesh\", \"Howard\"][(n-m)/(2^^(--j))]);\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport core.stdc.stdio;\nimport std.bigint;\nimport std.format;\nimport std.math;\n\nstring readline()\n{\n\tstring result = readln();\n\tif (result[result.length - 1] == '\\n') result.length--;\n\treturn result;\n}\n\nint main(string[] argv)\n{\n\tlong n;\n\tscanf(\"%d\", &n); n--;\n\tlong pm = 0;\n\tlong m = 1;\n\twhile ((pm + m * 5) <= n)\n\t{\n\t\tpm += m * 5;\n\t\tm = m * 2;\n\t}\n\n\tlong l = (n - pm) / m;\n\n\tstring[long] names;\n\tnames[0] = \"Sheldon\";\n\tnames[1] = \"Leonard\";\n\tnames[2] = \"Penny\";\n\tnames[3] = \"Rajesh\";\n\tnames[4] = \"Howard\";\n\twrite(names[l]);\n\treturn 0;\n}\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\nimport std.range;\n\nstring solve(int n){\n\n string names = \"SLPRH\";\n int times;\n int start;\n string res;\n int modN;\n \n /// solve ==========================\n auto xs = recurrence!(\"(a[n-1] + (a[n-1] - a[n-2])*2)\")(1, 6);\n foreach(x; xs){\n if(x > n) break;\n start = x;\n times += 1;\n }\n modN = (n - start) / (2^^(times-1));\n res = names[modN].to!string;\n return res;\n}\n\n/// unittest -------------------\nunittest{\n assert( solve(1) == \"S\" );\n assert( solve(6) == \"S\" );\n assert( solve(1802) == \"P\" );\n writeln(\"---pass ---\");\n}\n\n/// main ====================\nvoid main(){\n foreach(i; 1..25){\n writeln(i, \" \", solve(i));\n }\n}\n"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport core.stdc.stdio;\nimport std.bigint;\nimport std.format;\nimport std.math;\n\nstring readline()\n{\n\tstring result = readln();\n\tif (result[result.length - 1] == '\\n') result.length--;\n\treturn result;\n}\n\nint main(string[] argv)\n{\n\tlong n;\n\tscanf(\"%d\", &n); n--;\n\tlong pm = 0;\n\tlong m = 1;\n\twhile (pm + m * 5 <= n)\n\t{\n\t\tpm = pm + m * 5;\n\t\tm++;\n\t}\n\tdouble l = cast(double)(n - pm) / cast(double)(m);\n\n\tstring[long] names;\n\tnames[0] = \"Sheldon\";\n\tnames[1] = \"Leonard\";\n\tnames[2] = \"Penny\";\n\tnames[3] = \"Rajesh\";\n\tnames[4] = \"Howard\";\n\twrite(names[cast(long)round(l)]);\n\treturn 0;\n}\n"}], "src_uid": "023b169765e81d896cdc1184e5a82b22"} {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string readString() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int readInt() { \n return readString.to!int; \n }\n double readDouble() { \n return readString.to!double; \n }\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.readInt;\n while (t--) {\n int n = cin.readInt;\n int[] arr = new int[n];\n foreach (ref i; arr) i = cin.readInt;\n int count = 0;\n for (int i = 0; i < n; i++) {\n if (arr[i] == 1) count++;\n if (arr[i] == 0) if (i - 1 >= 0 && i + 1 < n && arr[i - 1] == 1 && arr[i + 1] == 1)\n count++;\n }\n writeln(count);\n } \n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.conv;\nimport std.array;\nimport std.algorithm;\nvoid main()\n{\n\tint num;\n\treadf(\"%d\\n\",&num);\n\tstring[]s=split(readln());\n\tint[]a;\n\tfor(int i=0;i 0)\n\t{\n\t\tauto z = [a, b, c];\n\t\tsort (z);\n\t\ta = z[0];\n\t\tb = z[1];\n\t\tc = z[2];\n\t\tlong res = 0;\n\t\tres += d - min (b - a, d);\n\t\tres += d - min (c - b, d);\n\t\twriteln (res);\n\t}\n}\n", "positive_code": [{"source_code": "module main;\n\nimport std.stdio;\nimport std.container.array;\nimport std.algorithm.sorting;\n\nvoid main(string[] args){\n int[] arr = [2:0];\n for (int i = 0; i < 3; i++) {\n scanf(\"%d\", &arr[i]);\n }\n arr.sort();\n int d;\n scanf(\"%d\", &d);\n int ans;\n int inc = d - (arr[1] - arr[0]);\n if (inc > 0) {\n ans += inc;\n }\n inc = d - (arr[2] - arr[1]);\n if (inc > 0) {\n ans += inc;\n }\n printf(\"%d\", ans);\n}\n"}, {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * y / gcd(x, y); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998244353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\n\tauto abc = new long[](3);\n\tforeach (i; 0..3)\n\t{\n\t\tabc[i] = RD;\n\t}\n\tauto d = RD;\n\n\tabc.sort();\n\tlong ans = max(0, d - (abc[1] - abc[0])) + max(0, d - (abc[2] - abc[1]));\n\n\twriteln(ans);\n\tstdout.flush();\n\tdebug readln();\n}"}], "negative_code": [], "src_uid": "47c07e46517dbc937e2e779ec0d74eb3"} {"source_code": "import std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\twriteln (((x2 - x1 + 1) * 1L * (y2 - y1 + 1) + 1) / 2);\n\t}\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\n\nvoid main()\n{\n\tlong x1, x2, y1, y2;\n\n\tscanf(\"%lld%lld%lld%lld\", &x1, &y1, &x2, &y2);\n\n\tlong dx = (x2 - x1) / 2;\n\tlong dy = (y2 - y1) / 2;\n\tprintf(\"%lld\\n\", (dx + 1) * (dy + 1) + dx * dy);\n}"}], "negative_code": [{"source_code": "import std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\twriteln (((x2 - x1 + 1) * 1L * (y2 - y1 + 1) +\n\t\t (x1 % 2 == y1 % 2)) / 2);\n\t}\n}\n"}, {"source_code": "import std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\twriteln (((x2 - x1 + 1) * 1L * (y2 - y1 + 1) +\n\t\t ((x1 ^ y1 ^ 1) & 1)) / 2);\n\t}\n}\n"}, {"source_code": "import std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\twriteln (((x2 - x1 + 1) * 1L * (y2 - y1 + 1) +\n\t\t (x1 & y1 & 1)) / 2);\n\t}\n}\n"}, {"source_code": "import std.exception;\nimport std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\tenforce (-1_000_000_000 <= x1 &&\n\t\t x1 <= x2 &&\n\t\t x2 <= +1_000_000_000);\n\t\tenforce (-1_000_000_000 <= x1 &&\n\t\t x1 <= x2 &&\n\t\t x2 <= +1_000_000_000);\n\t\tenforce ((x1 & 1) == (x2 & 1));\n\t\tauto res = (x2 - x1 + 1) * 1L * (y2 - y1 + 1) / 2;\n\t\tif ((x1 & 1) == (y1 & 1) && (y1 & 1) == (y2 & 1))\n\t\t{\n\t\t\tres++;\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}, {"source_code": "import std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\tauto res = (x2 - x1 + 1) * 1L * (y2 - y1 + 1) / 2;\n\t\tif ((x1 & 1) == (y1 & 1) && (y1 & 1) == (y2 & 1))\n\t\t{\n\t\t\tres++;\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}, {"source_code": "import std.stdio;\n\nvoid main ()\n{\n\tint x1, y1, x2, y2;\n\twhile (readf (\" %s %s %s %s\", &x1, &y1, &x2, &y2) > 0)\n\t{\n\t\tauto res = (x2 - x1 + 1) * 1L * (y2 - y1 + 1) / 2;\n\t\tif (x1 % 2 == y1 % 2 && y1 % 2 == y2 % 2)\n\t\t{\n\t\t\tres++;\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}], "src_uid": "00cffd273df24d1676acbbfd9a39630d"} {"source_code": "//DMD64 D Compiler 2.072.2\nimport std.stdio;\nvoid main(){\n int a,b,c,d;\n readf(\"%d %d\",&a,&b);\n if(a<1&&b>0){write(\"Impossible\");return;}\n c=a;\n if(b-a>0){c+=b-a;}\n d=a;\n if(b>0){d+=b-1;}\n write(c,' ',d);\n}", "positive_code": [{"source_code": "import std.stdio;void main(){int a,b;readf(\"%d %d\",&a,&b);if(a<1&&b>0){write(\"Impossible\");return;}write(a>b?a:b,' ',b!=0?a+b-1:a);}"}, {"source_code": "//rextester.com:dmd64 2.072.2--codeforces.com:dmd32 2.071.2\nimport std.stdio;\nvoid main(){\n int a,b;readf(\"%d %d\",&a,&b);\n if(a<1&&b>0){write(\"Impossible\");return;}\n write(a>b?a:b,' ',b!=0?a+b-1:a);\n}"}, {"source_code": "//DMD64 2.072.2 | RexTester.Com & DMD32 2.079.0 | CodeForces.Com\nimport std.stdio;\nvoid main() {\n int grown_ups, children;\n readf(\"%d %d\", &grown_ups, &children);\n\n if (grown_ups < 1 && children > 0) {\n write(\"Impossible\");\n return;\n }\n\n write(grown_ups > children ? grown_ups : children, ' ', children != 0 ? grown_ups + children - 1 : grown_ups);\n}"}], "negative_code": [], "src_uid": "1e865eda33afe09302bda9077d613763"} {"source_code": "import std.stdio, std.bigint, std.string;\n\nBigInt gcd(BigInt a, BigInt b) {\n\treturn b ? gcd(b, a % b) : a;\n}\n\nvoid main() {\n\n\tauto l = BigInt (readln(' ').strip);\n\tauto r = BigInt (readln.strip);\n\t\n\tforeach (i; l .. r + 1)\n\t\tforeach (j; i + 1 .. r + 1)\n\t\t\tforeach (k; j + 1 .. r + 1)\n\t\t\tif (gcd(i, j) == 1 && gcd(j, k) == 1 && gcd(i, k) != 1) {\n\t\t\t\twritefln(\"%d %d %d\", i, j, k);\n\t\t\t\treturn;\n\t\t\t}\n\t\n\twriteln(\"-1\");\n}", "positive_code": [{"source_code": "//ahmat\nimport core.stdc.stdio:scanf,printf,puts;\nimport core.bitop;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.functional;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.container;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\npragma(inline,true);\n\nvoid main(){\n ulong l,r;\n readf!\"%d %d\"(l,r);\n r++;\n readln;\n foreach(a;l..r)\n foreach(b;a+1..r)\n foreach(c;b+1..r)\n if(gcd(a,b)==1 && gcd(b,c)==1 && gcd(a,c)!=1){\n writefln!\"%d %d %d\"(a,b,c);\n return;\n }\n puts(\"-1\");\n}\n\n"}, {"source_code": "import std.stdio;\n\nlong GCD(long a, long b) {\n\treturn b ? GCD(b, a % b) : a;\n}\n\nvoid main() {\n\n\tlong l, r;\n\n\treadf(\" %s %s\", &l, &r);\n\n\tforeach (i; l .. r + 1)\n\t\tforeach (j; i + 1 .. r + 1)\n\t\t\tforeach (k; j + 1 .. r + 1)\n\t\t\tif (GCD(i, j) == 1 && GCD(j, k) == 1 && GCD(i, k) != 1) {\n\t\t\t\twritefln(\"%d %d %d\", i, j, k);\n\t\t\t\treturn;\n\t\t\t}\n\n\twriteln(\"-1\");\n}"}, {"source_code": "import std.stdio;\nimport std.numeric;\n\nvoid main() {\n\t\n\tlong l, r;\n\t\n\treadf(\" %s %s\", &l, &r);\n\t\n\tforeach (i; l .. r + 1)\n\t\tforeach (j; i + 1 .. r + 1)\n\t\t\tforeach (k; j + 1 .. r + 1)\n\t\t\tif (gcd(i, j) == 1 && gcd(j, k) == 1 && gcd(i, k) != 1) {\n\t\t\t\twritefln(\"%d %d %d\", i, j, k);\n\t\t\t\treturn;\n\t\t\t}\n\t\n\twriteln(\"-1\");\n}"}, {"source_code": "import std.stdio;\n\nvoid main() {\n\t\n\tlong l, r;\n\t\n\treadf(\" %s %s\", &l, &r);\n\t\n\tif (r - l < 2) {\n\t\twriteln(-1);\n\t\treturn;\n\t}\n\t\n\tif (!(l % 2)) {\n\t\twritefln(\"%s %s %s\", l, l + 1, l + 2);\n\t\treturn;\n\t}\n\t\n\tif (r - l > 2){\n\t\twritefln(\"%s %s %s\", l + 1, l + 2, l + 3);\n\t\treturn;\n\t}\n\t\n\twriteln(-1);\n}"}, {"source_code": "import std.stdio;\n\nlong GCD(long a, long b) {\n\treturn b ? GCD(b, a % b) : a;\n}\n\nvoid main() {\n\n\tlong l, r;\n\n\treadf(\" %s %s\", &l, &r);\n\n\tforeach (i; l .. r + 1) {\n\t\tforeach (j; i .. r + 1)\n\t\t\tforeach (k; j .. r + 1)\n\t\t\tif (GCD(i, j) == 1 && GCD(j, k) == 1 && GCD(i, k) != 1) {\n\t\t\t\t\twritefln(\"%d %d %d\", i, j, k);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t}\n\n\twriteln(\"-1\");\n}"}, {"source_code": "import std.stdio;\n\nvoid main() {\n\n\tlong l, r;\n\n\treadf(\" %s %s\", &l, &r);\n\n\tif (r - l + 1 < 3) {\n\t\twriteln(-1);\n\t\treturn;\n\t}\n\t\n\tif (l % 2 == 0) {\n\t\twritefln(\"%s %s %s\", l, l + 1, l + 2);\n\t\treturn;\n\t}\n\t\n\tif (r - l + 1 > 3){\n\t\twritefln(\"%s %s %s\", l + 1, l + 2, l + 3);\n\t\treturn;\n\t}\n\t\n\twriteln(-1);\n}"}], "negative_code": [{"source_code": "import std.stdio;\n\nlong GCD(long a, long b) {\n\treturn b ? GCD(b, a % b) : a;\n}\n\nvoid main() {\n\n\tlong l, r;\n\n\treadf(\" %s %s\", &l, &r);\n\n\tforeach (i; l .. r + 1) {\n\t\tforeach (j; i .. r + 1)\n\t\t\tforeach (k; j .. r + 1)\n\t\t\t\tif (j % i != 0 && k % j != 0 && GCD(i, k) != 1) {\n\t\t\t\t\twritefln(\"%d %d %d\", i, j, k);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t}\n\n\twriteln(\"-1\");\n}"}, {"source_code": "import std.stdio;\n\nvoid main() {\n\n\tlong l, r;\n\n\treadf(\" %s %s\", &l, &r);\n\n\tforeach (i; l .. r + 1) {\n\t\tforeach (j; i .. r + 1)\n\t\t\tforeach (k; j .. r + 1)\n\t\t\t\tif (j % i != 0 && k % j != 0) {\n\t\t\t\t\twritefln(\"%d %d %d\", i, j, k);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t}\n\n\twriteln(\"-1\");\n}"}], "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d"} {"source_code": "import std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\n\nvoid main()\n{\n int n;\n readf( \"%s\\n\", &n );\n auto a = readln.splitter.map!( to!int ).array;\n a.sort;\n auto ans = n*n;\n foreach ( int shift; 1..3 ) {\n int cur = 0;\n foreach ( int idx, int e; a ) {\n cur += abs( e - ( 2*idx + shift ) );\n }\n ans = min( ans, cur );\n }\n writeln( ans );\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.range;\nimport std.array;\nimport std.string;\nimport std.conv;\nimport std.typecons;\nimport std.algorithm;\nimport std.container;\nimport std.typecons;\nimport std.random;\nimport std.csv;\nimport std.regex;\nimport std.math;\nimport core.time;\nimport std.ascii;\nimport std.digest.sha;\nimport std.outbuffer;\nimport std.numeric;\nimport std.bigint;\n\nvoid main()\n{\n\tint n = readln.chomp.to!int;\n\tint[] p = readln.chomp.split.map!(to!int).array;\n\tstd.algorithm.sort(p);\n\tint ans = int.max;\n\tfor (int i = 1; i <= 2; ++i) {\n\t\tint sum = 0;\n\t\tforeach (int j, int t; p) {\n\t\t\tsum += abs(j * 2 + i - t);\n\t\t}\n\t\tans = min(ans, sum);\n\t}\n\tans.writeln;\n}\n\nvoid tie(R, Args...)(R arr, ref Args args)\n\t\tif (isRandomAccessRange!R || isArray!R)\nin\n{\n\tassert (arr.length == args.length);\n}\nbody\n{\n\tforeach (i, ref v; args) {\n\t\talias T = typeof(v);\n\t\tv = arr[i].to!T;\n\t}\n}\n\nvoid verbose(Args...)(in Args args)\n{\n\tstderr.write(\"[\");\n\tforeach (i, ref v; args) {\n\t\tif (i) stderr.write(\", \");\n\t\tstderr.write(v);\n\t}\n\tstderr.writeln(\"]\");\n}\n\n"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\n\nvoid main()\n{\n int n;\n readf( \"%s\\n\", &n );\n auto a = readln.splitter.map!( to!int ).array;\n a.sort;\n auto ans = n*n;\n foreach ( int shift; 1..3 ) {\n int cur = 0;\n foreach ( int idx, int e; a) {\n cur += abs( e - ( 2*idx + shift ) );\n }\n ans = min( ans, cur );\n }\n writeln(ans);\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.range;\nimport std.array;\nimport std.string;\nimport std.conv;\nimport std.typecons;\nimport std.algorithm;\nimport std.container;\nimport std.typecons;\nimport std.random;\nimport std.csv;\nimport std.regex;\nimport std.math;\nimport core.time;\nimport std.ascii;\nimport std.digest.sha;\nimport std.outbuffer;\nimport std.numeric;\nimport std.bigint;\n\nvoid main()\n{\n\tint n = readln.chomp.to!int;\n\tint[] p = readln.chomp.split.map!(to!int).array;\n\tint ans = int.max;\n\tfor (int i = 1; i <= 2; ++i) {\n\t\tint sum = 0;\n\t\tforeach (int j, int t; p) {\n\t\t\tsum += abs(j * 2 + i - t);\n\t\t}\n\t\tans = min(ans, sum);\n\t}\n\tans.writeln;\n}\n\nvoid tie(R, Args...)(R arr, ref Args args)\n\t\tif (isRandomAccessRange!R || isArray!R)\nin\n{\n\tassert (arr.length == args.length);\n}\nbody\n{\n\tforeach (i, ref v; args) {\n\t\talias T = typeof(v);\n\t\tv = arr[i].to!T;\n\t}\n}\n\nvoid verbose(Args...)(in Args args)\n{\n\tstderr.write(\"[\");\n\tforeach (i, ref v; args) {\n\t\tif (i) stderr.write(\", \");\n\t\tstderr.write(v);\n\t}\n\tstderr.writeln(\"]\");\n}\n\n"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\n\nvoid main()\n{\n int n;\n readf( \"%s\\n\", &n );\n auto a = readln.splitter.map!( to!int ).array;\n auto ans = n*n;\n foreach ( int shift; 1..3 ) {\n int cur = 0;\n foreach ( int idx, int e; a) {\n cur += abs( e - ( 2*idx + shift ) );\n }\n ans = min( ans, cur );\n }\n writeln(ans);\n}"}], "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a"} {"source_code": "#!/usr/bin/env dub\n/+ dub.sdl:\n name \"B\"\n+/\n\nimport std.array;\nimport std.algorithm;\nimport std.algorithm.iteration;\nimport std.conv;\nimport std.math;\nimport std.stdio;\nimport std.string;\n\nvoid main()\n{\n long[] beauty;\n foreach (i; 1..15) {\n beauty ~= (2^^i - 1) * (2 ^^ (i-1));\n }\n beauty.reverse();\n\n debug {\n writeln(beauty);\n }\n \n long N = to!long(readln().strip());\n \n foreach (b; beauty) {\n if (N % b == 0) {\n writeln(b);\n return;\n }\n }\n \n}", "positive_code": [{"source_code": "import std.stdio, std.string, std.conv, std.algorithm, std.numeric;\nimport std.range, std.array, std.math, std.typecons, std.container, core.bitop;\n\nimmutable inf = 10^^9 + 7;\n\nvoid main() {\n int n;\n scan(n);\n\n long ans = 1;\n\n foreach (k ; 1 .. 30) {\n long bn = 1L * (2L^^k - 1) * (2L^^(k - 1));\n if (k > bn) break;\n if (n % bn == 0) {\n ans = max(ans, bn);\n }\n }\n\n writeln(ans);\n}\n\n\nstruct UnionFind {\n private {\n int N;\n int[] p;\n int[] rank;\n }\n\n this (int n) {\n N = n;\n p = iota(N).array;\n rank = new int[](N);\n }\n\n int find_root(int x) {\n if (p[x] != x) {\n p[x] = find_root(p[x]);\n }\n\n return p[x];\n }\n\n bool same(int x, int y) {\n return find_root(x) == find_root(y);\n }\n\n void unite(int x, int y) {\n int u = find_root(x), v = find_root(y);\n\n if (u == v) return;\n\n if (rank[u] < rank[v]) {\n p[u] = v;\n }\n else {\n p[v] = u;\n\n if (rank[u] == rank[v]) {\n rank[u]++;\n }\n }\n }\n}\n\n\nvoid scan(T...)(ref T args) {\n string[] line = readln.split;\n foreach (ref arg; args) {\n arg = line.front.to!(typeof(arg));\n line.popFront();\n }\n assert(line.empty);\n}\n\n\nvoid fillAll(R, T)(ref R arr, T value) {\n static if (is(typeof(arr[] = value))) {\n arr[] = value;\n }\n else {\n foreach (ref e; arr) {\n fillAll(e, value);\n }\n }\n}\n\n\n\nstruct Queue(T) {\n private {\n int N, head, tail;\n T[] data;\n }\n\n this(int n) {\n N = n + 1;\n data = new T[](N);\n }\n\n bool empty() {\n return head == tail;\n }\n\n bool full() {\n return (tail + 1) % N == head;\n }\n\n T front() {\n return data[head];\n }\n\n void push(T x) {\n assert(!full);\n data[tail++] = x;\n tail %= N;\n }\n\n void pop() {\n assert(!empty);\n head = (head + 1) % N;\n }\n\n void clear() {\n head = tail = 0;\n }\n}"}], "negative_code": [], "src_uid": "339246a1be81aefe19290de0d1aead84"} {"source_code": "import std.stdio, std.string, std.algorithm;\nimport std.conv, std.array;\nimport std.container;\nimport std.typecons;\n\nalias sum = reduce!\"a + b\";\n\nvoid main() {\n int n, d; readf(\"%d %d\\n\", &n, &d);\n int[] a = stdin.readln.split.map!(to!int).array;\n int m; readf(\"%d\\n\", &m);\n int ans = a.sort[0 .. min(m, $)].sum - d * max(m - n, 0);\n ans.writeln;\n}\n", "positive_code": [{"source_code": "import std.stdio, std.algorithm, std.array, std.conv, std.string;\n\nvoid main() {\n auto input = new int[][2];\n foreach (ref elem; input) {\n elem = readln.chomp.split.map!(to!int).array;\n }\n int n = input[0][0];\n int d = input[0][1];\n int[] a = input[1].sort!(\"a < b\").array;\n int m = readln.chomp.to!int;\n\n int profit = 0;\n\n if (a.length >= m) {\n profit += reduce!(\"a + b\")(0, a[0 .. m]);\n } else {\n profit += reduce!(\"a + b\")(0, a);\n profit -= (m - a.length) * d;\n }\n\n profit.writeln;\n}\n"}], "negative_code": [], "src_uid": "5c21e2dd658825580522af525142397d"} {"source_code": "module main;\nimport std.bigint,std.container,std.array,std.algorithm,std.conv,std.parallelism,\n\tstd.functional,std.math,std.string,std.range,std.complex,std.bitmanip,\n\tstd.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,core.bitop,\n\tstd.meta,core.stdc.stdio : freopen;\nimport std.numeric: fft,Fft,gcd,inverseFft;alias big=BigInt;alias pair(X,Y)=Tuple!(X,\"fi\",Y,\"se\");\nalias lint=long;private const int mod=1_000_000_007;\nalias pii=pair!(int,int);alias pll=pair!(long,long);alias mp=make_pair;alias gcd=std.numeric.gcd;\nprivate\n{\n\tpure nothrow \n\t{\n\t\tT lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}\n\t\tpair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,\"fi\",Y,\"se\")(x_,y_);}\n\t\tbig gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}\n\t\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\t\tint sz(T)(T a) if(hasLength!T){return cast(int)a.length;}\n\t\tsize_t lowb(T,X)(T a,auto ref X g)\n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(!(a[m]1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(g 0)\n\t{\n\t\tsize_t s=0;\n\t\tforeach(ref e;ptrs)\n\t\t{\n\t\t\tif(isSomeChar!(Unqual!(typeof(e))))s+=readf(\" %c\",&e);\n\t\t\telse s+=readf(\" %s\",&e);\n\t\t}\n\t\treturn s==ptrs.length;\n\t}\n\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t{\n\t\tsize_t s=0;\n\t\tforeach(ref e;ptrs)\n\t\t{\n\t\t\tif(isSomeChar!(Unqual!(typeof(e))))s+=readf(\" %c\",&e);\n\t\t\telse s+=readf(\" %s\",&e);\n\t\t}\n\t\treadln;\n\t\treturn s==ptrs.length;\n\t}\n\tnothrow auto inf(in char* name) {return freopen(name,\"r\",core.stdc.stdio.stdin);}\n\tnothrow auto ouf(in char* name) {return freopen(name,\"w\",core.stdc.stdio.stdout);}\n\t@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nprivate\n{\n\t\n}\nvoid main()\n{\n\tversion(home)\n\t{\n\t\tassert(freopen(\"input.txt\",\"r\",core.stdc.stdio.stdin));\n\t\tassert(freopen(\"output.txt\",\"w\",core.stdc.stdio.stdout));\n\t}\n\tint n,x,y,w,h;\nloop:while(read(h,w,x,y,n))\n\t{\n\t\tauto a=arread!int;\n\t\tsort(a);\n\t\ta=a[max(0,sz(a)-34)..$];\n\t\treverse(a);\n\t\tauto dp=new int[10^^5+1],d=new int[10^^5+1];\n\t\tdp[x]=d[x]=y;\n\t\tforeach(i;0..a.length)\n\t\t{\n\t\t\tforeach(j;0..dp.length)\n\t\t\t{\n\t\t\t\tif((j>=w && dp[j]>=h) || (j>=h && dp[j]>=w))\n\t\t\t\t{\n\t\t\t\t\twriteln(i);\n\t\t\t\t\tcontinue loop;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//d[]=dp[];\n\t\t\tforeach(j;0..dp.length)\n\t\t\t{\n\t\t\t\tif(dp[j]!=0)\n\t\t\t\t{\n\t\t\t\t\tif(1L*j*a[i]<=10^^5)d[j*a[i]]=max(d[j*a[i]],dp[j]);\n\t\t\t\t\telse d[10^^5]=max(d[10^^5],dp[j]);\n\t\t\t\t\tif(1L*dp[j]*a[i]<=10^^5)d[j]=max(dp[j]*a[i],d[j]);\n\t\t\t\t\telse d[j]=10^^5;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp[]=d[];\n\t\t}\n\t\tforeach(j;0..dp.length)\n\t\t{\n\t\t\tif((j>=w && dp[j]>=h) || (j>=h && dp[j]>=w))\n\t\t\t{\n\t\t\t\twriteln(a.length);\n\t\t\t\tcontinue loop;\n\t\t\t}\n\t\t}\n\t\twriteln(-1);\n\t}\n}", "positive_code": [{"source_code": "import core.bitop;\nimport core.checkedint;\nimport core.simd;\nimport core.stdc.stdlib;\nimport core.stdc.string;\nimport std.algorithm;\nimport std.array;\nimport std.ascii;\nimport std.bigint;\nimport std.bitmanip;\nimport std.complex;\nimport std.container;\nimport std.conv;\nimport std.datetime;\nimport std.format;\nimport std.functional;\nimport std.math;\nimport std.meta;\nimport std.numeric;\nimport std.random;\nimport std.range;\nimport std.regex;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport std.variant;\n\n__gshared:\n\nalias BitSet(size_t n) = size_t[(n + size_t.sizeof * 8 - 1) / (size_t.sizeof * 8)];\n\nauto getAddrTuple() {\n return tuple();\n}\n\nauto getAddrTuple(T, U...)(ref T head, ref U tail) {\n return tuple(&head, getAddrTuple(tail).expand);\n}\n\nbool read(T...)(ref T vars) if (vars.length > 0) {\n return readf(' ' ~ replicate(\"%s \", vars.length), getAddrTuple(vars).expand) == vars.length;\n}\n\nT[ ] allocate(T)(size_t n) {\n return (cast(T*)malloc(n * T.sizeof))[0 .. n];\n}\n\nauto pairwise(R)(R range) if (isForwardRange!R) {\n return lockstep(range, dropOne(range));\n}\n\nint ih, iw, n;\nint[10^^5] _exts;\nint[ ] exts;\nuint[Tuple!(int, int, int)] dp;\n\nuint dyn(int pos, int curh, int curw) {\n if (curh >= ih && curw >= iw)\n return pos;\n if (pos == n)\n return uint.max;\n if (auto p = tuple(pos, curh, curw) in dp)\n return *p;\n uint result = uint.max;\n bool overflow;\n if (curh < ih) {\n int nexth = muls(curh, exts[pos], overflow);\n if (overflow) {\n nexth = int.max;\n overflow = false;\n }\n result = dyn(pos + 1, nexth, curw);\n }\n if (curw < iw) {\n int nextw = muls(curw, exts[pos], overflow);\n if (overflow)\n nextw = int.max;\n result = min(result, dyn(pos + 1, curh, nextw));\n }\n dp[tuple(pos, curh, curw)] = result;\n return result;\n}\n\nuint solve(int oh, int ow) {\n dp = null;\n return dyn(0, oh, ow);\n}\n\nvoid main() {\n int oh, ow;\n while (read(ih, iw, oh, ow, n)) {\n exts = _exts[0 .. n];\n foreach (ref x; exts)\n read(x);\n exts.sort!`a > b`;\n writeln(cast(int)min(solve(oh, ow), solve(ow, oh)));\n }\n}\n"}], "negative_code": [{"source_code": "module main;\nimport std.bigint,std.container,std.array,std.algorithm,std.conv,std.parallelism,\n\tstd.functional,std.math,std.string,std.range,std.complex,std.bitmanip,\n\tstd.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,core.bitop,\n\tstd.meta,core.stdc.stdio : freopen;\nimport std.numeric: fft,Fft,gcd,inverseFft;alias big=BigInt;alias pair(X,Y)=Tuple!(X,\"fi\",Y,\"se\");\nalias lint=long;private const int mod=1_000_000_007;\nalias pii=pair!(int,int);alias pll=pair!(long,long);alias mp=make_pair;alias gcd=std.numeric.gcd;\nprivate\n{\n\tpure nothrow \n\t{\n\t\tT lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}\n\t\tpair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,\"fi\",Y,\"se\")(x_,y_);}\n\t\tbig gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}\n\t\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\t\tint sz(T)(T a) if(hasLength!T){return cast(int)a.length;}\n\t\tsize_t lowb(T,X)(T a,auto ref X g)\n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(!(a[m]1)\n\t\t\t{\n\t\t\t\tauto m=(l+r)>>1;\n\t\t\t\tif(g 0)\n\t{\n\t\tsize_t s=0;\n\t\tforeach(ref e;ptrs)\n\t\t{\n\t\t\tif(isSomeChar!(Unqual!(typeof(e))))s+=readf(\" %c\",&e);\n\t\t\telse s+=readf(\" %s\",&e);\n\t\t}\n\t\treturn s==ptrs.length;\n\t}\n\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t{\n\t\tsize_t s=0;\n\t\tforeach(ref e;ptrs)\n\t\t{\n\t\t\tif(isSomeChar!(Unqual!(typeof(e))))s+=readf(\" %c\",&e);\n\t\t\telse s+=readf(\" %s\",&e);\n\t\t}\n\t\treadln;\n\t\treturn s==ptrs.length;\n\t}\n\tnothrow auto inf(in char* name) {return freopen(name,\"r\",core.stdc.stdio.stdin);}\n\tnothrow auto ouf(in char* name) {return freopen(name,\"w\",core.stdc.stdio.stdout);}\n\t@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nprivate\n{\n\t\n}\nvoid main()\n{\n\tversion(home)\n\t{\n\t\tassert(freopen(\"input.txt\",\"r\",core.stdc.stdio.stdin));\n\t\tassert(freopen(\"output.txt\",\"w\",core.stdc.stdio.stdout));\n\t}\n\tint n,x,y,w,h;\nloop:while(read(h,w,x,y,n))\n\t{\n\t\tauto a=arread!int;\n\t\tsort(a);\n\t\ta=a[max(0,sz(a)-34)..$];\n\t\treverse(a);\n\t\tauto dp=new lint[10^^5+1],d=new long[10^^5+1];\n\t\tdp[x]=d[x]=y;\n\t\tforeach(i;0..a.length)\n\t\t{\n\t\t\tforeach(j;0..dp.length)\n\t\t\t{\n\t\t\t\tif((j>=w && dp[j]>=h) || (j>=h && dp[j]>=w))\n\t\t\t\t{\n\t\t\t\t\twriteln(i);\n\t\t\t\t\tcontinue loop;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//d[]=dp[];\n\t\t\tforeach(j;0..dp.length)\n\t\t\t{\n\t\t\t\tif(dp[j]!=0)\n\t\t\t\t{\n\t\t\t\t\tif(1L*j*a[i]<=10^^5)d[j*a[i]]=max(d[j*a[i]],dp[j]);\n\t\t\t\t\tif(1L*dp[j]*a[i]<=10^^5)d[j]=max(dp[j]*a[i],d[j]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp[]=d[];\n\t\t}\n\t\tforeach(j;0..dp.length)\n\t\t{\n\t\t\tif((j>=w && dp[j]>=h) || (j>=h && dp[j]>=w))\n\t\t\t{\n\t\t\t\twriteln(a.length);\n\t\t\t\tcontinue loop;\n\t\t\t}\n\t\t}\n\t\twriteln(-1);\n\t}\n}"}], "src_uid": "18cb436618b2b85c3f5dc348c80882d5"} {"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.conv;\nimport std.range;\n\nvoid main() {\n int n = readln.chomp.to!int;\n int[][] diploma;\n for (int i = 0; i < 3; i++) {\n diploma ~= readln.chomp.split.map!(to!int).array;\n }\n\n int dip_1 = min(diploma[0][1], n - (diploma[1][0] + diploma[2][0]));\n n -= dip_1;\n int dip_2 = min(diploma[1][1], n - diploma[2][0]);\n int dip_3 = n - dip_2;\n writeln(dip_1, \" \", dip_2, \" \", dip_3);\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.c.stdio;\nimport std.math;\nimport std.algorithm;\nimport std.conv;\nimport std.string;\nimport std.array;\n\nvoid main() {\n int n = readln().strip.to!int;\n int x, y, z, u, v, w;\n scanf(\"%d%d%d%d%d%d\", &x, &u, &y, &v, &z, &w);\n n -= x + y + z;\n int d, e, f;\n d = min(n, u - x);\n n -= d;\n x += d;\n\n e = min(n, v - y);\n n -= e;\n y += e;\n \n f = min(n, w - z);\n n -= f;\n z += f;\n\n writeln(x, ' ', y, ' ', z);\n}\n"}], "negative_code": [], "src_uid": "3cd092b6507079518cf206deab21cf97"} {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string read_string() {\n while (tokens.empty) {\n tokens = readln.split;\n }\n auto token = tokens.front;\n tokens.popFront;\n return token;\n }\n \n int read_int() {\n return read_string.to!int;\n }\n \n string[] tokens;\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // int t = cin.read_int;\n while (t--) {\n int n = cin.read_int;\n int[] arr = new int[n];\n\n int ans = 0;\n for (int i = 0; i < n; i++) {\n arr[i] = cin.read_int;\n if (arr[0] > 15) {\n writeln(15);\n return;\n }\n if (i != 0) {\n if (arr[i] - arr[i - 1] > 15) {\n writeln(arr[i - 1] + 15);\n return;\n }\n }\n }\n if (arr[n - 1] + 15 >= 90) {\n writeln(90);\n } else writeln(arr[n - 1] + 15);\n } \n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\n\nconst int BORING = 15;\nconst int MATCH = 90;\n\nvoid main()\n{\n\tint n;\n\tint last = 0;\n\t\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tint x;\n\t\t\n\t\tscanf(\"%d\", &x);\n\t\t\n\t\tif ((x - 1) - last >= BORING) {\n\t\t\tprintf(\"%d\\n\", last + BORING);\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tlast = x;\n\t}\n\t\n\tprintf(\"%d\\n\", min(last + BORING, MATCH));\n}\n\n"}], "negative_code": [{"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string read_string() {\n while (tokens.empty) {\n tokens = readln.split;\n }\n auto token = tokens.front;\n tokens.popFront;\n return token;\n }\n \n int read_int() {\n return read_string.to!int;\n }\n \n string[] tokens;\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // int t = cin.read_int;\n while (t--) {\n int n = cin.read_int;\n int[] arr = new int[n];\n\n int ans = 0;\n for (int i = 0; i < n; i++) {\n arr[i] = cin.read_int;\n if (arr[0] > 15) {\n writeln(15);\n return;\n }\n if (i != 0) {\n if (arr[i] - arr[i - 1] > 15) {\n writeln(arr[i - 1] + 15);\n return;\n }\n }\n }\n writeln(90);\n } \n}"}], "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27"} {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\n\tforeach (from; 0 .. n)\n\t\tforeach (jump; 1 .. n) {\n\t\t\tbool ok;\n\t\t\tforeach (i; 0 .. 5) {\n\t\t\t\tint pos = from + i * jump;\n\t\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\t\tok = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ok)\n\t\t\t\treturn `yes`.write;\n\t\t}\n\n\t`no`.write;\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.range;\nimport std.array;\n\nT read(T)()\n{\n T t;\n readf(\" %s\", &t);\n return t;\n}\n\nint main(string[] args)\n{\n auto T = read!int;\n readln;\n auto arr = readln;\n arr = arr[0..T];\n arr ~= repeat('.', T).array;\n\n for (int i = 0; i < T; i++)\n {\n for (int j = 1; j < T; j++)\n {\n if (\n arr[i + j*0] == '*' &&\n arr[i + j*1] == '*' &&\n arr[i + j*2] == '*' &&\n arr[i + j*3] == '*' &&\n arr[i + j*4] == '*')\n {\n writeln(\"yes\");\n return 0;\n }\n }\n }\n\n writeln(\"no\");\n\n return 0;\n}\n"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\t\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\t\n\tforeach (from; 0 .. n) {\n\t\tif (s[from] != '.')\n\t\tforeach (jump; 1 .. n) {\n\t\t\tbool ok;\n\t\t\tforeach (i; 1 .. 5) {\n\t\t\t\tint pos = from + i * jump;\n\t\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\t\tok = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ok)\n\t\t\t\treturn write(\"yes\");\n\t\t}\n\t}\n\t\n\twrite(\"no\");\n}"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\t\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\t\n\tforeach (from; 0 .. n)\n\tforeach (jump; 1 .. n) {\n\t\tbool ok;\n\t\tforeach (i; 0 .. 5) {\n\t\t\tint pos = from + i * jump;\n\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\tok = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!ok)\n\t\t\treturn \"yes\".write;\n\t}\n\t\n\t\"no\".write;\n}"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\n\tint[] idx;\n\tforeach (i, e; s)\n\t\tif (e == '*')\n\t\t\tidx ~= i;\n\t\n\tforeach (from; idx) {\n\t\tforeach (jump; 1 .. n) {\n\t\t\tbool ok;\n\t\t\tforeach (i; 1 .. 5) {\n\t\t\t\tint pos = from + i * jump;\n\t\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\t\tok = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ok)\n\t\t\t\treturn write(\"yes\");\n\t\t}\n\t}\n\t\n\twrite(\"no\");\n}"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\t\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\t\n\tforeach (from; 0 .. n) {\n\t\tif (s[from] != '.')\n\t\tforeach (jump; 1 .. n) {\n\t\t\tbool ok;\n\t\t\tforeach (i; 0 .. 5) {\n\t\t\t\tint pos = from + i * jump;\n\t\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\t\tok = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ok)\n\t\t\t\treturn write(\"yes\");\n\t\t}\n\t}\n\t\n\twrite(\"no\");\n}"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\t\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\t\n\tforeach (from; 0 .. n)\n\tforeach (jump; 1 .. n) {\n\t\tbool ok;\n\t\tforeach (i; 0 .. 5) {\n\t\t\tint pos = from + i * jump;\n\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\tok = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!ok)\n\t\t\treturn write(\"yes\");\n\t}\n\t\n\twrite(\"no\");\n}"}, {"source_code": "import std.algorithm, std.conv, std.range, std.stdio, std.string;\nvoid main() {\n\tauto n = readln.strip.to!int, s = readln.strip;\n\twriteln (iota (1, n).any !(d => iota (d).any !(p =>\n\t\ts.drop (p).stride (d).canFind (\"*****\"))) ? \"yes\" : \"no\");\n}"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.exception;\nimport std.functional;\nimport std.math;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport core.bitop;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s \", &n) > 0)\n\t{\n\t\tauto s = readln ().strip ();\n\t\tbool ok = false;\n\t\tforeach (d; 1..n)\n\t\t{\n\t\t\tforeach (p; 0..n)\n\t\t\t{\n\t\t\t\tif (p + d * 4 < n)\n\t\t\t\t{\n\t\t\t\t\tif (s.drop (p)\n\t\t\t\t\t .stride (d)\n\t\t\t\t\t .takeExactly (5)\n\t\t\t\t\t .all !(q{a == '*'}))\n\t\t\t\t\t{\n\t\t\t\t\t\tok = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\twriteln (ok ? \"yes\" : \"no\");\n\t}\n}\n"}, {"source_code": "import std.algorithm, std.conv, std.range, std.stdio, std.string;\nvoid main() {\n\tauto n = readln.strip.to!int, s = readln.strip;\n\twriteln (iota (1, n).any !(d => iota (d).any !(p =>\n\t\ts.drop (p).stride (d).canFind (\"*****\"))) ? \"yes\" : \"no\");\n}\n"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\n\nvoid main() {\n\treadln;\n\tauto s = readln.strip;\n\n\tif(s.count('*') >= 5) {\n\t\twhile(true) {\n\t\t\tauto idx = cast(int)s.countUntil('*');\n\t\t\tif(idx < 0) break;\n\n\t\t\tforeach(k; 1..26) {\n\t\t\t\tubyte c;\n\n\t\t\t\tfor(uint i = idx; i < s.length && s[i] == '*'; c++, i += k) {}\n\n\t\t\t\tif(c >= 5) return `yes`.write;\n\t\t\t}\n\n\t\t\ts = s[idx + 1..$];\n\t\t}\n\t}\n\n\t`no`.write;\n}\n"}], "negative_code": [{"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\n\nvoid main() {\n\treadln;\n\tauto s = readln.strip;\n\n\tif(s.count('*') >= 5) {\n\t\twhile(true) {\n\t\t\tauto idx = cast(int)s.countUntil('*');\n\t\t\tif(idx < 0) break;\n\n\t\t\tforeach(k; 1..21) {\n\t\t\t\tubyte c;\n\n\t\t\t\tfor(uint i = idx; i < s.length && s[i] == '*'; c++, i += k) {}\n\n\t\t\t\tif(c >= 5) return `yes`.write;\n\t\t\t}\n\n\t\t\ts = s[idx + 1..$];\n\t\t}\n\t}\n\n\t`no`.write;\n}\n"}, {"source_code": "import std.stdio;\n\nvoid main() {\n\n\twriteln(__VERSION__);\n}"}, {"source_code": "import std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n\t\n\tint n = readln.strip.to!int;\n\tstring s = readln.strip;\n\t\n\tforeach (from; 0 .. n) {\n\t\tif (s[from] != '.')\n\t\tforeach (jump; 1 .. n) {\n\t\t\tbool ok;\n\t\t\tforeach (i; 0 .. 5) {\n\t\t\t\tint pos = from + i * jump;\n\t\t\t\tif (pos >= n || s[pos] != '*') {\n\t\t\t\t\twriteln(\"break\");\n\t\t\t\t\tok = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!ok)\n\t\t\t\treturn write(\"yes\");\n\t\t}\n\t}\n\t\n\twrite(\"no\");\n}"}], "src_uid": "12d451eb1b401a8f426287c4c6909e4b"} {"source_code": "import std.string, std.algorithm, std.stdio, std.range, std.array, std.typecons;\n\nvoid main()\n{\n auto s = readln.chomp;\n auto d = s.length.iota.retro.dropOne.map!(\n a => {\n string[] d = s.slide(a+1).map!\"a.text\".array;\n d.sort;\n return d.group.maxElement!\"a[1]\"; }()\n ).find!\"a[1]>b[1]\"(tuple(1,1));\n writeln(d.length>0?d[0][0].length:0);\n}", "positive_code": [{"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string read_string() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int read_int() { \n return read_string.to!int; \n }\n double read_double() { \n return read_string.to!double; \n }\n}\n\nint count_substr(char[] s, char[] sample) {\n int count = 0;\n for (int i = 0; i < s.length - sample.length + 1; i++) {\n if (s[i..i + sample.length] == sample) {\n count++; \n }\n }\n return count;\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.read_int;\n while (t--) {\n char[] s = cin.read_string.dup;\n\n int l = s.length;\n int maxx = -999;\n for (int i = l - 1; i >= 1; i--) {\n for (int j = 0; j < l - i + 1; j++) {\n int c = count_substr(s, s[j..j + i]); \n if (c >= 2) {\n writeln(s[j..j + i].length);\n return;\n }\n }\n }\n writeln(0);\n } \n}"}, {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string read_string() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int read_int() { \n return read_string.to!int; \n }\n double read_double() { \n return read_string.to!double; \n }\n}\n\nint count_substr(char[] s, char[] sample) {\n int count = 0;\n for (int i = 0; i < s.length - sample.length + 1; i++) {\n if (s[i..i + sample.length] == sample) {\n count++; \n }\n }\n return count;\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.read_int;\n while (t--) {\n char[] s = cin.read_string.dup;\n\n int l = s.length;\n int maxx = -999;\n for (int i = l - 1; i >= 1; i--) {\n for (int j = 0; j < l - i + 1; j++) {\n int c = count_substr(s, s[j..j + i]); \n if (c >= 2) {\n writeln(i);\n return;\n }\n }\n }\n writeln(0);\n } \n}"}], "negative_code": [], "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7"} {"source_code": "import std.stdio\n , std.typecons\n , std.traits\n , std.algorithm;\n\n\n\n\nT modulus(T)(auto ref T val) {\n import std.conv: to;\n return (val > 0.to!T\n ? val\n : -val);\n}\n\n\n\nvoid main() {\n \n long n;\n \n readf(\"%s\\n\", &n);\n //uint count;\n while(true) {\n //count.writeln;\n if(n >= 0) {\n writeln(n);\n return;\n }\n \n \n auto n2 = n.modulus % 100;\n \n if(n2 % 10 < n2 / 10) {\n const t = n.modulus / 100 * 10 + n2 % 10;\n writeln((t != 0 ? \"-\" : \"\"), t);\n }\n else\n {\n \n const t = n.modulus / 100 * 10 + n2 / 10;\n writeln((t != 0 ? \"-\" : \"\"), t);\n }\n \n //readf(\"%s\\n\", &n);\n //++count;\n break;\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "positive_code": [{"source_code": "import std.stdio: readln, writeln;\nimport std.string: strip;\nimport std.conv: to;\nimport std.algorithm: max;\n\n/**\n * User: Jior\n * Date: 03.06.13\n * Time: 13:13\n */\n\nvoid main(string[] args) {\n char[] buffer = strip(readln()).dup;\n int account = to!int(buffer);\n\n if (account < 0 && buffer.length > 2) {\n int var1 = to!int(buffer[0..$-1]);\n int var2 = to!int(buffer[0..$-2] ~ buffer[$-1..$]);\n\n if(var1 > account || var2 > account)\n writeln(max(var1, var2));\n } else {\n writeln(account);\n } \n}\n"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main() {\n //stdin.open(\"input.txt\", \"r\");\n //stdout.open(\"output.txt\", \"w\");\n string num = strip(readln());\n if (num[0] == '-') {\n int a = to!int(num[0..$-1]);\n int b = to!int(num[0..$-2] ~ num[$-1..$]);\n writeln(a > b ? a : b);\n } else {\n writeln(num);\n }\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\n\n// main================\nvoid main(){\n auto moneyStr = readln.chomp.dup;\n if(moneyStr.to!int >= 0){ writeln(moneyStr.to!int); }\n else{\n auto a = moneyStr[0..$-1].to!int;\n auto b = (moneyStr[0..$-2] ~ moneyStr[$-1]).to!int;\n max(a, b).writeln;\n }\n}\n"}, {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string readString() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int readInt() { \n return readString.to!int; \n }\n double readDouble() { \n return readString.to!double; \n }\n}\n\nint solve(string s) {\n if (s.to!int > 0) return s.to!int;\n else {\n if (s.to!int > -10) return s.to!int;\n else {\n char[] s1 = s.dup;\n int n = s1.length;\n if (s1[n - 1] < s[n - 2]) {\n s1 = s1.remove(n - 2);\n } else s1 = s1.remove(n - 1);\n return s1.to!int;\n }\n }\n}\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.readInt;\n while (t--) {\n string s = cin.readString;\n writeln(solve(s));\n } \n}"}, {"source_code": "import std.stdio\n , std.typecons\n , std.traits\n , std.algorithm;\n\n\n\n\nT mod(T)(auto ref T val) {\n import std.conv: to;\n return (val > 0.to!T\n ? val\n : -val);\n}\n\n\n\nvoid main() {\n \n long n;\n \n readf(\"%s\\n\", &n);\n \n while(true) {\n if(n >= 0) {\n writeln(n);\n return;\n }\n \n \n auto n2 = n.mod % 100;\n \n if(n2 % 10 < n2 / 10) {\n const t = n.mod / 100 * 10 + n2 % 10;\n writeln((t != 0 ? \"-\" : \"\"), t);\n }\n else\n {\n \n const t = n.mod / 100 * 10 + n2 / 10;\n writeln((t != 0 ? \"-\" : \"\"), t);\n }\n break;\n }\n \n \n}"}, {"source_code": "import std.stdio;\nimport core.stdc.stdio;\n\nint main(string[] argv)\n{\n\tlong n;\n\tscanf(\"%lld\", &n);\n\tlong a = n % 100;\n\tlong b = (n / 100) * 10;\n\tlong n1 = b + (a % 10);\n\tlong n2 = b + ((a / 10) % 10);\n\twrite(n > n1 ? n : n1 > n2 ? n1 : n2);\n\treturn 0;\n}"}, {"source_code": "import std.stdio, std.string, std.conv;\nimport std.algorithm, std.math;\n\nstring[] tokens;\nint tokenId = 0;\nstring readToken() { for (; tokenId == tokens.length; ) tokens = readln.split, tokenId = 0; return tokens[tokenId++]; }\nint readInt() { return to!int(readToken); }\nlong readLong() { return to!long(readToken); }\nreal readReal() { return to!real(readToken); }\n\nint del(int a) {\n\tint temp = abs(a);\n\tint first = temp / 10;\n\tint second = (temp / 100) * 10 + temp % 10;\n\tfirst *= -1;\n\tsecond *= -1;\n\tif(first < second) return second;\n\treturn first;\n}\n\nvoid main () {\n\tint a = readInt();\n\t\n\tif(a >= 0) writeln(a);\n\telse writeln(del(a));\n}"}, {"source_code": "//ahmat\nimport core.stdc.stdio:printf,scanf;\nimport std.stdio;\nimport std.string;\nimport std.container;\nimport std.array;\nimport std.range;\nimport std.algorithm;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.bitmanip;\nimport core.bitop;\nint sz(Range)(in Range r){return cast(int)r.length;}\nalias rbt=RedBlackTree!int;\n\nvoid main(){\n\tint n=readln.chomp.to!int;\n\tif(n<0){\n\t\twriteln(max(n/10,10*(n/100)+n%10));\n\t}else writeln(n);\n}"}, {"source_code": "import std.algorithm;\nimport std.conv;\nimport std.stdio;\n\nvoid main ()\n{\n foreach (s; stdin.byLine ())\n {\n writeln (max (to!int (s), to!int (s[0..$ - 1]),\n to!int (s[0..$ - 2] ~ s[$ - 1])));\n }\n}\n"}, {"source_code": "import std.algorithm, std.stdio;\n\nvoid main ()\n{\n\tint n;\n\treadf (\" %s\", &n);\n\twriteln (max (n, n / 10, n / 100 * 10 + n % 10));\n}\n"}, {"source_code": "import std.algorithm;\nimport std.stdio;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) != 0)\n\t{\n\t\twriteln (max (n, n / 10, n / 100 * 10 + n % 10));\n\t}\n}\n"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.exception;\nimport std.functional;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main ()\n{\n\tstring s;\n\twhile ((s = readln ().strip ()) != null)\n\t{\n\t\tif (s[0] == '-')\n\t\t{\n\t\t\twriteln (max (to!int (s[0..$ - 1]),\n\t\t\t to!int (s[0..$ - 2] ~ s[$ - 1])));\n\t\t}\n\t\telse\n\t\t{\n\t\t\twriteln (s);\n\t\t}\n\t}\n}\n"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\n\nvoid main() {\n string n = readln.chomp;\n if (n.to!long > 0) {\n writeln(n);\n } else {\n if (n[$-2].to!int < n[$-1].to!int) {\n writeln(n[0..$-1].to!long);\n } else {\n writeln((n[0..$-2] ~ n[$-1]).to!long);\n }\n }\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\n\n// main================\nvoid main(){\n auto moneyStr = readln.chomp.dup;\n auto a = moneyStr[0..$-1].to!int;\n auto b = (moneyStr[0..$-2] ~ moneyStr[$-1]).to!int;\n max(a, b).writeln;\n}\n"}, {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string readString() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int readInt() { \n return readString.to!int; \n }\n double readDouble() { \n return readString.to!double; \n }\n}\n\nint solve(string s) {\n if (s.to!int > 0) return s.to!int;\n else {\n if (s.to!int > -10) return s.to!int;\n else {\n char[] s1 = s.dup;\n s1 = s1.remove(s1.indexOf(max(s1[s1.length - 1], s1[s1.length - 2])));\n return s1.to!int;\n }\n }\n}\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.readInt;\n while (t--) {\n string s = cin.readString;\n writeln(solve(s));\n } \n}"}, {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string readString() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int readInt() { \n return readString.to!int; \n }\n double readDouble() { \n return readString.to!double; \n }\n}\n\nint solve(string s) {\n if (s.to!int > 0) return s.to!int;\n else {\n if (s.to!int > -10) return s.to!int;\n else {\n char[] s1 = s.dup;\n reverse(s1);\n s1 = s1.remove(s1.indexOf(max(s1[s1.length - 1], s1[s1.length - 2])));\n reverse(s1);\n return s1.to!int;\n }\n }\n}\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.readInt;\n while (t--) {\n string s = cin.readString;\n writeln(solve(s));\n } \n}"}, {"source_code": "import std.stdio\n , std.typecons\n , std.traits\n , std.algorithm;\n\n\n\n\nT modulus(T)(auto ref T val) {\n import std.conv: to;\n return (val > 0.to!T\n ? val\n : -val);\n}\n\n\n\nvoid main() {\n \n long n;\n \n readf(\"%s\\n\", &n);\n //uint count;\n while(true) {\n //count.writeln;\n if(n >= 0) {\n writeln(n);\n return;\n }\n \n \n auto n2 = n.modulus % 100;\n \n if(n2 % 10 < n2 / 10) {\n writeln(\"-\", n.modulus / 100 * 10 + n2 % 10);\n }\n else\n {\n \n const t = n.modulus / 100 * 10 + n2 / 10;\n writeln((t != 0 ? \"-\" : \"\"), n.modulus / 100 * 10 + n2 / 10);\n }\n \n //readf(\"%s\\n\", &n);\n //++count;\n break;\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import std.stdio\n , std.typecons\n , std.traits\n , std.algorithm;\n\n\n\n\nT modulus(T)(auto ref T val) {\n import std.conv: to;\n return (val > 0.to!T\n ? val\n : -val);\n}\n\n\n\nvoid main() {\n \n long n;\n \n readf(\"%s\\n\", &n);\n //uint count;\n while(true) {\n //count.writeln;\n if(n >= 0) {\n writeln(n);\n return;\n }\n \n \n auto n2 = n.modulus % 100;\n \n if(n2 % 10 < n2 / 10) {\n writeln(\"-\", n.modulus / 100 * 10 + n2 % 10);\n }\n else\n {\n writeln(\"-\", n.modulus / 100 * 10 + n2 / 10);\n }\n \n //readf(\"%s\\n\", &n);\n //++count;\n break;\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import std.stdio\n , std.typecons\n , std.traits\n , std.algorithm;\n\n\n\n\nT modulus(T)(auto ref T val) {\n import std.conv: to;\n return (val > 0.to!T\n ? val\n : -val);\n}\n\n\n\nvoid main() {\n \n long n;\n \n readf(\"%s\\n\", &n);\n //uint count;\n while(true) {\n //count.writeln;\n if(n >= 0) {\n writeln(n);\n return;\n }\n \n \n auto n2 = n.modulus % 100;\n \n if(n2 % 10 > n2 / 10) {\n writeln(\"-\", n.modulus / 100 * 10 + n2 % 10);\n }\n else\n {\n writeln(\"-\", n.modulus / 100 * 10 + n2 / 10);\n }\n \n //readf(\"%s\\n\", &n);\n //++count;\n break;\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\n\nvoid main() {\n string n = readln.chomp;\n if (n.to!long > 0) {\n writeln(n);\n } else {\n if (n[$-2].to!int < n[$-1].to!int) {\n writeln(n[0..$-1]);\n } else {\n writeln(n[0..$-2], n[$-1]);\n }\n }\n}"}, {"source_code": "import std.stdio: readln, writeln;\nimport std.string: strip;\nimport std.conv: to;\nimport std.algorithm: max;\n\n/**\n * User: Jior\n * Date: 03.06.13\n * Time: 13:13\n */\n\nvoid main(string[] args) {\n char[] buffer = strip(readln()).dup;\n int account = to!int(buffer);\n\n if (account < 0 && buffer.length > 2) {\n int var1 = to!int(buffer[0..$-1]);\n int var2 = to!int(buffer[0..$-2] ~ buffer[$-1..$]);\n\n if(var1 > account || var2 > account)\n writeln(max(var1, var2));\n } \n}\n"}], "src_uid": "4b0a8798a6d53351226d4f06e3356b1e"} {"source_code": "import std.stdio;\nimport std.array;\nimport std.algorithm.iteration;\n\nint solve(int n , int m) {\n if (m == n) return 0;\n if (m % n != 0) return -1;\n auto d = m/n;\n auto count = 0;\n if (d%2 != 0 && d%3!=0) return -1;\n while (d%6 == 0) {count+=2; d/=6;}\n while (d%3 == 0) {count++; d/=3;}\n while (d%2 == 0) {count++; d/=2;}\n if (d!=1) return -1;\n return count;\n}\n\nvoid main()\n{\n assert(solve(120,51840) == 7);\n assert(solve(42,42)==0);\n assert(solve(48,72)==-1);\n\n auto nm = readln.split.map!\"a.to!int\";\n auto n = nm[0], m =nm[1];\n writeln(solve(n,m));\n}\n", "positive_code": [{"source_code": "void main() {\n import std.stdio;\n import std.algorithm;\n import std.string;\n import std.conv;\n\n auto x = readln().split;\n const long start = x[0].to!long;\n long desti = x[1].to!long;\n\n if(desti == start) {\n \"0\".writeln;\n } else if(desti % start != 0) {\n \"-1\".writeln;\n } else if(desti % 2 != 0 && desti % 3 != 0) {\n \"-1\".writeln;\n } else {\n int cnt = 0;\n desti /= start;\n while(desti > 1) {\n if(desti % 3 == 0) {\n desti /= 3;\n } else if(desti % 2 == 0) {\n desti /= 2;\n } else {\n cnt = -1;\n break;\n }\n cnt++;\n }\n cnt.writeln;\n }\n}"}], "negative_code": [{"source_code": "void main() {\n import std.stdio;\n import std.algorithm;\n import std.string;\n import std.conv;\n\n auto x = readln().split;\n const long start = x[0].to!long;\n long desti = x[1].to!long;\n if(desti == start) {\n \"0\".writeln;\n } else if(desti % start != 0) {\n \"-1\".writeln;\n } else if(desti % 2 != 0 && desti % 3 != 0) {\n \"-1\".writeln;\n } else {\n int cnt = 0;\n while(desti > start) {\n if(desti % 3 != 0) {\n desti /= 2;\n } else {\n desti /= 3;\n }\n cnt++;\n }\n cnt.writeln;\n }\n}"}, {"source_code": "void main() {\n import std.stdio;\n import std.algorithm;\n import std.string;\n import std.conv;\n\n auto x = readln().split;\n const long start = x[0].to!long;\n long desti = x[1].to!long;\n\n if(desti == start) {\n \"0\".writeln;\n } else if(desti % start != 0) {\n \"-1\".writeln;\n } else if(desti % 2 != 0 && desti % 3 != 0) {\n \"-1\".writeln;\n } else {\n int cnt = 0;\n desti /= start;\n while(desti > 1) {\n if(desti % 3 != 0) {\n desti /= 2;\n } else {\n desti /= 3;\n }\n cnt++;\n }\n cnt.writeln;\n }\n}"}, {"source_code": "void main() {\n import std.stdio;\n import std.algorithm;\n import std.string;\n import std.conv;\n\n auto x = readln().split;\n const int start = x[0].to!int;\n int desti = x[1].to!int;\n if(desti == start) {\n \"0\".writeln;\n } else if(desti % start != 0) {\n \"-1\".writeln;\n } else if(desti % 2 != 0 && desti % 3 != 0) {\n \"-1\".writeln;\n } else {\n int cnt = 0;\n while(desti > start) {\n if(desti % 3 != 0) {\n desti /= 2;\n } else {\n desti /= 3;\n }\n cnt++;\n }\n cnt.writeln;\n }\n}"}, {"source_code": "void main() {\n import std.stdio;\n import std.algorithm;\n import std.string;\n import std.conv;\n\n auto x = readln().split;\n const long start = x[0].to!long;\n long desti = x[1].to!long;\n\n if(desti == start) {\n \"0\".writeln;\n } else if(desti % start != 0) {\n \"-1\".writeln;\n } else if(desti % 2 != 0 && desti % 3 != 0) {\n \"-1\".writeln;\n } else {\n int cnt = 0;\n desti /= start;\n while(desti > 1) {\n if(desti % 3 != 0) {\n desti /= 2;\n } else if(desti % 2 != 0) {\n desti /= 3;\n } else {\n cnt = -1;\n break;\n }\n cnt++;\n }\n cnt.writeln;\n }\n}"}, {"source_code": "void main() {\n import std.stdio;\n import std.algorithm;\n import std.string;\n import std.conv;\n\n auto x = readln().split;\n const int start = x[0].to!int;\n int desti = x[1].to!int;\n\n if(desti % start != 0) {\n \"-1\".writeln;\n } else if(desti % 2 != 0 && desti % 3 != 0) {\n \"-1\".writeln;\n } else {\n int cnt = 0;\n while(desti > start) {\n if(desti % 3 != 0) {\n desti /= 2;\n } else {\n desti /= 3;\n }\n cnt++;\n }\n cnt.writeln;\n }\n}"}], "src_uid": "3f9980ad292185f63a80bce10705e806"} {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.datetime.stopwatch;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n\nvoid main()\n{\n int n;\n readf(\"%s\", &n);\n readln;\n\n int ans = n-1;\n foreach (i; 2 .. n/2 + 1) {\n int a = i, b = n - i;\n if (gcd(a, b) != 1) { continue; }\n \n int steps = 1;\n while (a != 1 && b != 1) {\n if (a < b) { swap(a, b); }\n \n steps += a / b;\n a %= b;\n }\n if (a > 1 || b > 1) { steps += a-1 + b-1; }\n \n ans = min(ans, steps);\n }\n \n ans.writeln;\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.uni;\nimport std.conv;\nimport std.container;\nimport std.functional;\nimport std.algorithm;\nimport std.array;\nimport std.typecons;\nimport std.range;\nimport std.numeric;\n\nvoid main(string[] args)\n{\n inputFile = stdin;\n int stepsTo(int a, int b)\n {\n if (gcd(a, b) != 1) return int.max;\n if (a > b) swap(a, b);\n if (a == 1) return b - 1;\n return (b/a) + stepsTo(b % a, a);\n }\n auto n = next!int;\n if (n == 1) return writeln(\"0\");\n (1 + iota(0, n).map!(i => stepsTo(i, n - i)).fold!min).writeln;\n}\nulong bitCnt(long x)\n{\n ulong cnt = 0;\n while(x) {cnt += x & 1; x>>=1;}\n return cnt;\n}\nalias Arr(T) = Mat!(T, 1);\nstruct Mat(T, size_t dimension)\n{\n T[] _baseArray;\n T[] _slice;\n size_t[dimension] _sizes; size_t dim(size_t i) {return _sizes[i];}\n size_t[dimension] _indexer;\n this(T[] baseArray, size_t[dimension] sizes)\n {\n _baseArray = baseArray;\n _sizes = sizes;\n _indexer[dimension - 1] = 1;\n static foreach_reverse(i; 0 .. dimension - 1)\n _indexer[i] = _indexer[i + 1] * _sizes[i + 1];\n auto requiredSize = _indexer[0] * _sizes[0];\n debug assert(_baseArray.length >= requiredSize);\n _slice = _baseArray[0 .. requiredSize];\n }\n this(size_t[dimension] sizes)\n {\n size_t reqSize = 1;\n static foreach(i; 0 .. dimension)\n reqSize *= sizes[i];\n this(new T[](reqSize), sizes);\n }\n ref auto opIndex()\n {\n pragma(inline, true);\n return _slice[];\n }\n ref auto opIndex(I...)(I i)\n {\n pragma(inline, true);\n debug assert(i.length <= dimension);\n size_t index = mixin(iota(0, i.length).map!(j => text(\"i[\", j, \"]*_indexer[\", j, \"]\")).join(\"+\"));\n static if (i.length == dimension)\n {\n\treturn _slice[index];\n }\n else\n {\n\tenum sliceDimension = dimension - i.length;\n\tsize_t[sliceDimension] remSizes = _sizes[i.length .. $];\n\tauto basePortion = _slice[index .. index + _indexer[i.length - 1]];\n \treturn Mat!(T, sliceDimension)(basePortion, remSizes);\n }\n }\n static if (dimension == 2)\n {\n auto identity()\n {\n\tdebug assert(dim(0) == dim(1));\n\tauto n = dim(0);\n\tauto id = Mat!(T, 2)([n, n]);\n\tforeach(k; 0 .. n)\n\t id[k, k] = T(1);\n\treturn id;\n }\n bool canMultiply(Mat!(T, 2) b)\n {\n\treturn this.dim(1) == b.dim(0);\n }\n auto opBinary(string op)(Mat!(T, 2) b)\n\tif (op == \"*\")\n\t {\n\t debug assert(canMultiply(b));\n\t auto res = Mat!(T, 2)([this.dim(0), b.dim(1)]);\n\t foreach(i; 0 .. res.dim(0))\n\t foreach(k; 0 .. this.dim(1))\n\t\tforeach(j; 0 .. res.dim(1))\n\t\t res[i, j] = res[i, j] + this[i, k] * b[k, j];\n\t return res;\n\t }\n auto opBinary(string op)(ulong exp)\n\tif (op == \"^^\")\n\t {\n\t return this.pow(identity, exp);\n\t }\n mixin interiorBinPow;\n }\n}\n\nstruct Mod(T, ulong mod)\n{\n alias This = Mod!(T, mod);\n T _rep; T rep() {return _rep;}\n this(W)(W w)\n {\n _rep = ((cast(T) w)%mod + mod) % mod;\n }\n static auto plainConstruct(T t)\n {\n pragma(inline, true);\n debug assert(t >= 0 && t < mod);\n auto res = Mod!(T, mod).init;\n res._rep = t;\n return res;\n }\n string toString()\n {\n return to!string(rep);\n }\n debug invariant\n {\n assert(_rep >= 0 && _rep < mod);\n }\n auto opBinary(string op)(This b)\n {\n static if (op == \"+\")\n {\n\tT resrep = _rep + b._rep;\n\tif (resrep >= mod) resrep -= mod;\n\treturn This.plainConstruct(resrep);\n }\n else static if (op == \"-\")\n {\n\tT resrep = _rep - b._rep;\n\tif (resrep < 0) resrep += mod;\n\treturn This.plainConstruct(resrep);\n }\n else static if (op == \"*\")\n {\n\treturn This(_rep * b._rep);\n }\n }\n}\n\nmixin template interiorBinPow()\n{\n alias ThisType = typeof(this);\n auto pow(ThisType res, ulong exp)\n {\n if (exp < 0) debug assert(0);\n auto pow = this;\n while(exp)\n\t{\n\t if (exp & 1)\n\t res = res * pow;\n\t pow = pow * pow;\n\t exp >>= 1;\n\t}\n return res;\n }\n}\n\n// INPUT\nFile inputFile;\nDList!string _words;\nvoid _wordsFill()\n{\n while (_words.empty) _words.insertBack(inputFile.readln.split); \n}\nstring popWord()\n{\n _wordsFill;\n auto word = _words.front;\n _words.removeFront;\n return word;\n}\nstring peekWord()\n{\n _wordsFill;\n return _words.front;\n}\nT next(T)()\n{\n return to!T(popWord);\n}\nT peek(T)()\n{\n return to!T(peekWord);\n}\nauto next(T, S...)(S s)\n{\n static if (S.length == 0)\n {\n return to!T(popWord);\n }\n else\n {\n auto res = new typeof(next!T(s[1 .. $]))[](cast(size_t)s[0]);\n foreach(ref elem; res)\n elem = next!T(s[1 .. $]);\n return res;\n }\n}\n"}], "negative_code": [], "src_uid": "75739f77378b21c331b46b1427226fa1"} {"source_code": "import std.stdio;\nimport std.string;\n\nint main(string[] argv)\n{\n\tstring line = stdin.readln();\n\tif (line[line.length - 1] == '\\n')\n\t\tline.length--;\n\n\tif (indexOf(line, \"H\") != -1\n\t || indexOf(line, \"Q\") != -1\n\t || indexOf(line, \"9\") != -1)\n\t{\n\t\twrite(\"YES\");\n\t} else {\n\t\twrite(\"NO\");\n\t}\n\treturn 0;\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\n\nvoid main()\n{\n (readln.any!(a => canFind(['H','Q','9'],a))\n ? \"YES\" : \"NO\")\n .writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.string;\nimport std.regex;\n\nvoid main() {\n if (!match(readln, regex(`[HQ9]`)).empty) {\n \"YES\".writeln;\n } else {\n \"NO\".writeln;\n }\n}\n"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\n\n\nvoid main(){\n auto source = readln.chomp;\n auto hq = \"HQ9\";\n auto res = \"NO\";\n foreach(s; hq){\n if(source.find(s).length){\n res = \"YES\";\n break;\n }\n }\n res.writeln;\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\n\n\nvoid main(){\n auto source = readln.chomp;\n auto hq = \"HQ9+\";\n auto res = \"NO\";\n foreach(s; hq){\n if(source.find(s).length){\n res = \"YES\";\n break;\n }\n }\n res.writeln;\n}"}], "src_uid": "1baf894c1c7d5aeea01129c7900d3c12"} {"source_code": "import std.stdio;\nimport std.math;\nimport std.algorithm;\nimport std.array;\nimport std.string;\nimport std.conv;\n\nvoid main() {\n\t\n\tauto elemanSayisi = stdin.readln.strip.to!int();\n\tauto sayilar = stdin.readln.strip.split().map!(a => to!int(a)).array();\n\tauto sırayaDizilmişSayılar = sayilar.sort();\n\t\n\tint sonuç = 0; \n\tint birÖncekiEleman = sırayaDizilmişSayılar[0];\n\tint geçiciSonuç = 0;\n\t//1 , 2, 4 ,3 ,3 ,2 ,1\n\tfor ( int i = 0 ; i < sırayaDizilmişSayılar.length; i++ )\n\t{\n\t\tint şuandakiEleman = sırayaDizilmişSayılar[i];\n\t\tif ( şuandakiEleman == birÖncekiEleman)\n\t\t{\n\t\t\tgeçiciSonuç++;\n\t\t\tif ( geçiciSonuç > sonuç )\n\t\t\t\tsonuç = geçiciSonuç;\n\t\t}\n\t\telse \n\t\t{\n\n\t\t\tgeçiciSonuç = 1;\t\n\t\t\tbirÖncekiEleman = şuandakiEleman;\n\t\t}\n\t}\n\twriteln(sonuç);\n\t\n}", "positive_code": [{"source_code": "module acmd;\n\nimport std.stdio;\nimport std.conv;\nimport std.algorithm;\n\nint main () {\n version (offline_judje) {\n stdin.reopen (\"input.txt\", \"rt\");\n }\n int n;\n readf!\" %d\" (n);\n int[128] cnt;\n foreach (i; 0 .. n) {\n int num;\n readf!\" %d\" (num);\n cnt[num]++;\n }\n writeln (maxElement (cnt[]));\n\n return 0;\n}\n\n"}, {"source_code": "import core.bitop;\nimport std.algorithm;\nimport std.array;\nimport std.bitmanip;\nimport std.container;\nimport std.conv;\nimport std.functional;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport std.range.interfaces;\n\nvoid main()\n{\n readln;\n \n auto arr = readln.chomp.split.map!(to!int).array;\n \n int [int] cnt;\n arr.each!(x => ++cnt[x]);\n \n auto ans = cnt.values.maxElement;\n ans.writeln;\n}"}, {"source_code": "import std.stdio;\nint main()\n{\n\tint a=0;\n\treadf(\" %d\", &a);\n\tint[] m = new int[a];\n\tfor (int i=0; imax)\n\t\t{\n\t\t\tmax=n[i];\n\t\t}\n\t}\n\twriteln(max);\n\treturn 0;\n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.math;\nimport std.algorithm;\nimport std.array;\nimport std.string;\nimport std.conv;\n\nvoid main() {\n\t\n\tauto elemanSayisi = stdin.readln.strip.to!int();\n\tauto sayilar = stdin.readln.strip.split().map!(a => to!int(a)).array();\n\tauto sırayaDizilmişSayılar = sayilar.sort();\n\t\n\tint sonuç = 0; \n\tint birÖncekiEleman = sırayaDizilmişSayılar[0];\n\tint geçiciSonuç = 0;\n\t//1 , 2, 4 ,3 ,3 ,2 ,1\n\tfor ( int i = 0 ; i < sırayaDizilmişSayılar.length; i++ )\n\t{\n\t\tint şuandakiEleman = sırayaDizilmişSayılar[i];\n\t\tif ( şuandakiEleman == birÖncekiEleman)\n\t\t{\n\t\t\tgeçiciSonuç++;\n\t\t}\n\t\telse \n\t\t{\n\t\t\tif ( geçiciSonuç > sonuç )\n\t\t\t\tsonuç = geçiciSonuç;\n\t\t\tgeçiciSonuç = 0;\t\n\t\t\tbirÖncekiEleman = şuandakiEleman;\n\t\t}\n\t}\n\twriteln(sonuç);\n\t\n}"}, {"source_code": "import std.stdio;\nimport std.math;\nimport std.algorithm;\nimport std.array;\nimport std.string;\nimport std.conv;\n\nvoid main() {\n\t\n\tauto elemanSayisi = stdin.readln.strip.to!int();\n\tauto sayilar = stdin.readln.strip.split().map!(a => to!int(a)).array();\n\tauto sırayaDizilmişSayılar = sayilar.sort();\n\t\n\tint sonuç = 0; \n\tint birÖncekiEleman = sırayaDizilmişSayılar[0];\n\tint geçiciSonuç = 0;\n\t//1 , 2, 4 ,3 ,3 ,2 ,1\n\tfor ( int i = 0 ; i < sırayaDizilmişSayılar.length; i++ )\n\t{\n\t\tint şuandakiEleman = sırayaDizilmişSayılar[i];\n\t\tif ( şuandakiEleman == birÖncekiEleman)\n\t\t{\n\t\t\tgeçiciSonuç++;\n\t\t}\n\t\telse \n\t\t{\n\t\t\tif ( geçiciSonuç > sonuç )\n\t\t\t\tsonuç = geçiciSonuç;\n\t\t\tgeçiciSonuç = 1;\t\n\t\t\tbirÖncekiEleman = şuandakiEleman;\n\t\t}\n\t}\n\twriteln(sonuç);\n\t\n}"}], "src_uid": "f30329023e84b4c50b1b118dc98ae73c"} {"source_code": "module sigod.codeforces.p281A;\n\nimport std.stdio;\nimport std.string;\nimport std.conv;\n\nvoid main()\n{\n\n\tstdout.write(solve(stdin.readln().strip()));\n}\n\nstring solve(string str)\n{\n\treturn toUpper(str[0].to!string) ~ str[1 .. $];\n}\n\nunittest {\n\tassert(solve(\"ApPLe\") == \"ApPLe\");\n\tassert(solve(\"konjac\") == \"Konjac\");\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\nimport std.range;\nimport std.ascii;\n\nvoid main()\n{\n string word = readln;\n (cast(char)word[0].toUpper~word[1..$]).writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.typecons : Yes;\nimport std.algorithm.mutation : copy;\nimport std.conv : to;\n\nvoid main() {\n foreach(string s; stdin.byLineCopy(Yes.keepTerminator)) {\n (s[0].toUpper.to!string ~ s[1 .. $]).copy(stdout.lockingTextWriter);\n }\n}"}, {"source_code": "import std.stdio;\nimport std.uni;\nimport std.string;\nimport core.stdc.stdio;\nimport std.array;\nimport std.algorithm;\n\nint main(string[] argv)\n{\n\tstring line = readln();\n\tif (line[line.length - 1] == '\\n') line.length--;\n\twrite(capitalize(\"\" ~ line[0]) ~ line[1..line.length]);\n\treturn 0;\n}\n"}, {"source_code": "//ahmat\nimport core.stdc.stdio:scanf,printf,puts;\nimport core.bitop;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.functional;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.container;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\npragma(inline,true);\n\nvoid main(){\n dchar[] s=readln.strip.to!(dchar[]);\n writeln(toUpper(s[0]),s[1..$]);\n}\n\n"}, {"source_code": "//ahmat\nimport core.stdc.stdio:scanf,printf,puts;\nimport core.bitop;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.functional;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.container;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\npragma(inline,true);\n\nvoid main(){\n dchar[] s=readln.strip.to!(dchar[]);\n writeln(toUpper(s[0])~s[1..$]);\n}\n\n"}, {"source_code": "import std.stdio;\nimport std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.string;\nimport std.regex;\n\nvoid main() {\n string s = readln;\n\n if (!match(s[0].to!string, regex(`[a-z]`)).empty) {\n (s[0].to!string.toUpper ~ s[1..$]).write;\n } else {\n s.write;\n }\n}\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.typecons : Yes;\nimport std.algorithm.mutation : copy;\n\nvoid main() {\n foreach(string s; stdin.byLineCopy(Yes.keepTerminator)) {\n s.capitalize.copy(stdout.lockingTextWriter());\n }\n}"}], "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "// Code By H~$~C\n\nimport std.stdio, std.format;\nimport std.math, std.uni, std.bigint, std.numeric;\nimport std.array, std.string, std.container, std.range, std.typecons;\nimport std.algorithm, std.conv, std.functional, std.random;\n\nvoid _Main() {\n long k;\n readf!\" %s\"(k);\n if (k <= 1024) {\n int p = 1, c = 0;\n while (p < k) {\n p *= 2, c += 1;\n }\n foreach(i; \"codeforces\") {\n write(i);\n if (c) {\n write(i);\n c--;\n }\n }\n }\n else {\n long p = 2;\n while (true) {\n if (pow(p, 10) < k) {\n ++p;\n }\n else break;\n }\n --p;\n long r = pow(p, 10);\n int c = 0;\n while (r < k) {\n c += 1;\n r = r / p * (p + 1);\n }\n foreach(i; \"codeforces\") {\n foreach(j; 0 .. p) write(i);\n if (c) {\n write(i);\n c--;\n }\n }\n }\n}\n\nvoid main(string[] args) {\n int tests = 1;\n// readf!\" %d\"(tests);\n foreach (test; 0 .. tests) _Main();\n}\n\n", "positive_code": [{"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n// floor(a^(1/k))\nulong floorKthRoot(ulong a, ulong k) {\n import core.bitop : bsr;\n import std.algorithm : min;\n if (a == 0) {\n return 0;\n } else if (k <= 1) {\n return a;\n } else if (k == 2) {\n ulong b = a, x = 0, y = 0;\n for (int e = bsr(a) & ~1; e >= 0; e -= 2) {\n x <<= 1;\n y <<= 1;\n if (b >= (y | 1) << e) {\n b -= (y | 1) << e;\n x |= 1;\n y += 2;\n }\n }\n return x;\n } else if (k <= 40) {\n // min x s.t. x^k >= 2^64\n enum ulong[] HIS =\n [0, 0, 4294967296UL, 2642246, 65536, 7132, 1626, 566, 256, 139, 85, 57,\n 41, 31, 24, 20, 16, 14, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 5,\n 4, 4, 4, 4, 4, 4, 4, 4, 4];\n ulong lo = 1UL << (bsr(a) / k);\n ulong hi = min(1UL << (bsr(a) / k + 1), HIS[cast(size_t)(k)]);\n for (; lo + 1 < hi; ) {\n const ulong mid = (lo + hi) / 2;\n ulong b = mid * mid;\n foreach (i; 2 .. k) b *= mid;\n ((b <= a) ? lo : hi) = mid;\n }\n return lo;\n } else if (k <= 63) {\n return ((1UL << k) <= a) ? 2 : 1;\n } else {\n return 1;\n }\n}\n\n\nenum S = \"codeforces\";\nenum L = cast(int)(S.length);\n\nvoid main() {\n try {\n for (; ; ) {\n const K = readLong();\n \n const long a = floorKthRoot(K, L);\n foreach (m; 0 .. L + 1) {\n long prod = 1;\n foreach (i; 0 .. L) {\n prod *= ((i < m) ? (a + 1) : a);\n }\n if (prod >= K) {\n foreach (i; 0 .. L) {\n foreach (_; 0 .. ((i < m) ? (a + 1) : a)) {\n write(S[i]);\n }\n }\n writeln();\n break;\n }\n }\n }\n } catch (EOFException e) {\n }\n}\n"}, {"source_code": "import std.algorithm;\nimport std.conv;\nimport std.numeric;\nimport std.stdio;\nimport std.typecons;\n\nimmutable string answer = \"codeforces\";\nimmutable int len = 10;\n\nvoid main ()\n{\n\tlong k;\n\twhile (readf !(\" %s\") (k) > 0)\n\t{\n\t\tlong [len] s;\n\t\ts[] = 1;\n\t\tlong total = 1;\n\t\tfor (int i = 0; total < k; i = (i + 1) % len)\n\t\t{\n\t\t\ttotal /= s[i];\n\t\t\ts[i] += 1;\n\t\t\ttotal *= s[i];\n\t\t}\n\t\tforeach (i; 0..len)\n\t\t{\n\t\t\tforeach (j; 0..s[i])\n\t\t\t{\n\t\t\t\twrite (answer[i]);\n\t\t\t}\n\t\t}\n\t\twriteln;\n\t}\n}\n"}], "negative_code": [], "src_uid": "8001a7570766cadcc538217e941b3031"} {"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.algorithm;\nimport std.math;\nimport std.array;\n\nint main(string[] argv)\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint initial_sum = 0;\n\tint[] bits; bits.length = n;\n\tforeach (int i; 0..n)\n\t{\n\t\tint b;\n\t\tscanf(\"%d\", &b);\n\t\tinitial_sum += (b == 0 ? 0 : 1);\n\t\tbits[i] = b;\n\t}\n\tint[][] dp; dp.length = n;\n\tforeach (int i; 0..n)\n\t{\n\t\tdp[i].length = n;\n\t}\n\tint max = int.min;\n\tforeach (int i; 0..n)\n\t{\n\t\tforeach (int j; 0..(i+1))\n\t\t{\n\t\t\tint cm = (i > 0 && j < i ? dp[i-1][j] : initial_sum);\n\t\t\tdp[i][j] = cm - bits[i] + (1 - bits[i]);\n\t\t\tif (dp[i][j] > max)\n\t\t\t\tmax = dp[i][j];\n\t\t}\n\t}\n\tprintf(\"%d\", max);\n\treturn 0;\n}", "positive_code": [{"source_code": "import std.stdio;\n\nbool[] a;\nbyte n, max, ans;\n\nvoid maxone(int x, int y) {\n\tmax = 0;\n\tbool[] b = a[].dup;\n\tforeach (i; x .. y)\n\t\tb[i] ^= 1;\n\tforeach (i; 0 .. n)\n\t\tif (b[i])\n\t\t\tmax += 1;\n}\n\nvoid main() {\n\treadf(\" %s\", &n);\n\n\tbool c;\n\tforeach (i; 0 .. n) {\n\t\treadf(\" %b\", &c);\n\t\ta ~= c;\n\t}\n\n\tforeach (i; 0 .. n)\n\t\tforeach (j; i .. n) {\n\t\t\tmaxone(i, j + 1);\n\t\t\tif (max > ans)\n\t\t\t\tans = max;\n\t\t}\n\n\twriteln(ans);\n}"}, {"source_code": "import std.stdio;\nimport core.stdc.stdio;\n\nint main(string[] argv)\n{\n\tint n;\n\tscanf(\"%d\", &n);\n\tint initial_sum = 0;\n\tint[] bits; bits.length = n;\n\tforeach (int i; 0..n)\n\t{\n\t\tint b;\n\t\tscanf(\"%d\", &b);\n\t\tinitial_sum += (b == 0 ? 0 : 1);\n\t\tbits[i] = b;\n\t}\n\tint[] dp; dp.length = n;\n\tforeach (int i; 0..n)\n\t{\n\t\tdp[i] = initial_sum;\n\t}\n\tint max = int.min;\n\tforeach (int i; 0..n)\n\t{\n\t\tforeach (int j; 0..(i+1))\n\t\t{\n\t\t\tdp[j] = dp[j] - bits[i] + (1 - bits[i]);\n\t\t\tif (dp[j] > max)\n\t\t\t\tmax = dp[j];\n\t\t}\n\t}\n\tprintf(\"%d\", max);\n\treturn 0;\n}"}, {"source_code": "import std.stdio, std.string, std.algorithm;\nimport std.conv, std.array;\nimport std.container;\nimport std.typecons;\n\nvoid main() {\n int n; readf(\"%d\\n\", &n);\n int[] xs = readln.split.map!(to!int).array;\n int[][] cs = new int[][n + 1];\n for (int i = 0; i < n + 1; i++) {\n cs[i] = new int[n + 1];\n }\n for (int i = 0; i < n + 1; i++) { \n cs[i][i] = 0;\n for (int j = i; j < n; j++) {\n cs[i][j + 1] = cs[i][j] + xs[j];\n }\n }\n int ans = 0;\n for (int i = 0; i < n; i++) {\n for (int j = i + 1; j < n + 1; j++) {\n ans = max(\n ans,\n cs[0][i] + (j - i) - cs[i][j] + cs[j][n]\n );\n }\n }\n ans.writeln;\n}\n"}, {"source_code": "import std.algorithm;\nimport std.stdio;\nimport std.array;\nimport std.conv;\nimport std.string;\n\nvoid main() {\n int n = readln.chomp.to!int;\n int[] a = readln.split.map!(x => x.to!int).array;\n int maxima = 0;\n for(int i = 0; i < n; i++) {\n for(int j = 0; j <= i; j++) {\n int ones = 0;\n for(int idx = 0; idx < n; idx++) {\n if(idx >= j && idx <= i)\n ones += 1-a[idx];\n else\n ones += a[idx];\n }\n maxima = max(maxima,ones);\n }\n }\n maxima.writeln;\n}\n\n"}], "negative_code": [{"source_code": "import std.stdio;\n\nbool[] a;\nbyte ans, one;\n\nvoid main() {\n\tbyte n;\n\n\treadf(\" %s\", &n);\n\n\tbool c;\n\tforeach (i; 0 .. n) {\n\t\treadf(\" %b\", &c);\n\t\ta ~= c;\n\t\tif (c)\n\t\t\tone +=1;\n\t}\n\n\tforeach (i; 0 .. n - 1) {\n\t\tif (!a[i]) {\n\t\t\tans += 1;\n\t\t\tif (a[i + 1])\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tbyte temp = 0;\n\tforeach (i; 0 .. n - 1) {\n\t\tif (!a[i]) {\n\t\t\ttemp += 1;\n\t\t\tif (a[i + 1]) {\n\t\t\t\tif (temp > ans)\n\t\t\t\t\tans = temp;\n\t\t\t\ttemp = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\twriteln(ans + one);\n}"}, {"source_code": "import std.algorithm;\nimport std.stdio;\nimport std.array;\nimport std.conv;\nimport std.string;\n\nvoid main() {\n int n = readln.chomp.to!int;\n int[] a = readln.split.map!(x => x.to!int).array;\n int maxima = -1;\n for(int i = 0; i < n; i++) {\n for(int j = 0; j < i; j++) {\n int ones = 0;\n for(int idx = 0; idx < n; idx++) {\n if(idx >= j && idx <= i)\n ones += 1-a[idx];\n else\n ones += a[idx];\n }\n maxima = max(maxima,ones);\n }\n }\n maxima.writeln;\n}\n\n"}, {"source_code": "import std.algorithm;\nimport std.stdio;\nimport std.array;\nimport std.conv;\nimport std.string;\n\nvoid main() {\n int n = readln.chomp.to!int;\n int[] a = readln.split.map!(x => x.to!int).array;\n int maxima = 0;\n for(int i = 0; i < n; i++) {\n for(int j = 0; j < i; j++) {\n int ones = 0;\n for(int idx = 0; idx < n; idx++) {\n if(idx >= j && idx <= i)\n ones += 1-a[idx];\n else\n ones += a[idx];\n }\n maxima = max(maxima,ones);\n }\n }\n if(n == 1)\n if(a[0] == 0)\n maxima = 1;\n maxima.writeln;\n}\n\n"}, {"source_code": "import std.stdio, std.string, std.algorithm;\nimport std.conv, std.array;\nimport std.container;\nimport std.typecons;\n\nvoid main() {\n int n; readf(\"%d\\n\", &n);\n int[] xs = readln.split.map!(to!int).array;\n int[][] cs = new int[][n + 1];\n for (int i = 0; i < n + 1; i++) {\n cs[i] = new int[n + 1];\n }\n for (int i = 0; i < n + 1; i++) { \n cs[i][i] = 0;\n for (int j = i; j < n; j++) {\n cs[i][j + 1] = cs[i][j] + xs[j];\n }\n }\n int ans = max(cs[0][n], n - cs[0][n]);\n for (int i = 0; i < n; i++) {\n for (int j = i; j < n + 1; j++) {\n ans = max(\n ans,\n cs[0][i] + (j - i) - cs[i][j] + cs[j][n]\n );\n }\n }\n ans.writeln;\n}\n"}, {"source_code": "import std.stdio;\n\nbool[] a;\nbyte ans, one;\n\nvoid main() {\n\tbyte n;\n\n\treadf(\" %s\", &n);\n\n\tbool c;\n\tforeach (i; 0 .. n) {\n\t\treadf(\" %b\", &c);\n\t\ta ~= c;\n\t\tif (c)\n\t\t\tone +=1;\n\t}\n\n\tforeach (i; 0 .. n - 1) {\n\t\tif (!a[i]) {\n\t\t\tans += 1;\n\t\t\tif (a[i + 1])\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tbyte temp = 0;\n\tforeach (i; 0 .. n - 1) {\n\t\tif (!a[i]) {\n\t\t\ttemp += 1;\n\t\t\tif (a[i + 1]) {\n\t\t\t\tif (temp > ans)\n\t\t\t\t\tans = temp;\n\t\t\t\ttemp = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (n == 1 && a[0] == 1)\n\t\twriteln(0);\n\telse\n\t\twriteln(ans + one);\n}"}, {"source_code": "import std.stdio;\n\nbool[] a;\nbyte ans, one;\n\nvoid main() {\n\tbyte n;\n\n\treadf(\" %s\", &n);\n\n\tbool c;\n\tforeach (i; 0 .. n) {\n\t\treadf(\" %b\", &c);\n\t\ta ~= c;\n\t\tif (c)\n\t\t\tone +=1;\n\t}\n\n\tforeach (i; 0 .. n - 1) {\n\t\tif (!a[i]) {\n\t\t\tans += 1;\n\t\t\tif (a[i + 1])\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tbyte temp = 0;\n\tforeach (i; 0 .. n - 1) {\n\t\tif (!a[i]) {\n\t\t\ttemp += 1;\n\t\t\tif (a[i + 1]) {\n\t\t\t\tif (temp > ans)\n\t\t\t\t\tans = temp;\n\t\t\t\ttemp = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (n == 1 && a[0] == 1)\n\t\twriteln(0);\n\telse\n\t\tif (n == 1 && a[0] == 0)\n\t\t\twriteln(1);\n\t\telse\n\t\t\twriteln(ans + one);\n}"}], "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99"} {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.typecons;\nimport std.algorithm;\nimport std.array;\nimport std.range;\nimport std.math;\nimport std.regex;\n\nvoid main()\n{\n auto input = readln().split().map!(to!int)();\n int[][] times;\n foreach (s; stdin.byLine()) {\n \ttimes ~= s.split().map!(to!int)().array();\n }\n foreach (i, t; times) {\n \tint sum;\n \tforeach (tt; times[0 .. i]) {\n \t\tsum += tt[1];\n \t}\n \twhile (sum + t[1] > input[1]) {\n \t\tif (t[1] - 1 >= t[0]) {\n \t\t\tt[1]--;\n \t\t} else {\n \t\t\tauto minu = sum + t[1] - input[1];\n \t\t\tforeach_reverse (tt; times[0 .. i]) {\n \t\t\t\twhile (minu) {\n \t\t\t\t\tif (tt[0] == tt[1]) break;\n \t\t\t\t\telse {\n \t\t\t\t\t\ttt[1]--;\n \t\t\t\t\t\tminu--;\n \t\t\t\t\t\tsum--;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n\n \t\t\tif (minu) {\n \t\t\t\twriteln(\"NO\");\n \t\t\t\treturn;\n \t\t\t}\n \t\t}\n \t}\n }\n\n int sum;\n foreach (tt; times) {\n \tsum += tt[1];\n }\n if (sum != input[1]) {\n \twriteln(\"NO\");\n \treturn;\n }\n writeln(\"YES\");\n foreach (t; times[0 .. $-1]) {\n \twrite(t[1], \" \");\n }\n writeln(times[$-1][1]);\n \n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.typecons;\nimport std.algorithm;\nimport std.array;\nimport std.range;\nimport std.math;\nimport std.regex;\n\nvoid main()\n{\n auto input = readln().split().map!(to!int)();\n int[][] times;\n foreach (i; 0 .. input[0]) {\n times ~= readln().split().map!(to!int)().array();\n }\n foreach (i, t; times) {\n int sum;\n foreach (tt; times[0 .. i]) {\n sum += tt[1];\n }\n while (sum + t[1] > input[1]) {\n if (t[1] - 1 >= t[0]) {\n t[1]--;\n } else {\n auto minu = sum + t[1] - input[1];\n foreach_reverse (tt; times[0 .. i]) {\n while (minu) {\n if (tt[0] == tt[1]) break;\n else {\n tt[1]--;\n minu--;\n sum--;\n }\n }\n }\n\n if (minu) {\n writeln(\"NO\");\n return;\n }\n }\n }\n }\n\n int sum;\n foreach (tt; times) {\n sum += tt[1];\n }\n if (sum != input[1]) {\n writeln(\"NO\");\n return;\n }\n writeln(\"YES\");\n foreach (t; times[0 .. $-1]) {\n write(t[1], \" \");\n }\n writeln(times[$-1][1]);\n \n}"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.typecons;\nimport std.algorithm;\nimport std.array;\nimport std.range;\nimport std.math;\nimport std.regex;\n\nvoid main()\n{\n int[][] times;\n int sum, diff;\n\n auto input = readln().split().map!(to!int)();\n\n a:foreach (s; stdin.byLine()) {\n \tauto t = s.split().map!(to!int)().array();\n\n \twhile (sum + t[1] > input[1]) {\n \t\tif (t[1] - 1 >= t[0]) {\n \t\t\tt[1]--;\n \t\t} else {\n \t\t\tdiff = sum + t[1] - input[1];\n \t\t\tforeach_reverse (tt; times) {\n \t\t\t\twhile (tt[0] != tt[1] && diff) {\n \t\t\t\t\ttt[1]--;\n \t\t\t\t\tdiff--;\n \t\t\t\t\tsum--;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tif (diff) break a;\n \t}\n\n \ttimes ~= t;\n \tsum += t[1];\n }\n\n if (sum != input[1] || diff) {\n \twriteln(\"NO\");\n } else {\n \twriteln(\"YES\");\n \tforeach (t; times[0 .. $-1]) {\n \t\twrite(t[1], \" \");\n \t}\n \twriteln(times[$-1][1]);\n }\n \n}"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.typecons;\nimport std.algorithm;\nimport std.array;\nimport std.range;\nimport std.math;\nimport std.regex;\n\nvoid main()\n{\n int[][] times;\n int sum, diff;\n\n auto input = readln().split().map!(to!int)();\n\n a:foreach (s; stdin.byLine()) {\n auto t = s.split().map!(to!int)().array();\n\n while (sum + t[1] > input[1]) {\n if (t[1] - 1 >= t[0]) {\n t[1]--;\n } else {\n diff = sum + t[1] - input[1];\n foreach_reverse (tt; times) {\n while (tt[0] != tt[1]) {\n tt[1]--;\n diff--;\n sum--;\n }\n }\n }\n if (diff) break a;\n }\n\n times ~= t;\n sum += t[1];\n }\n\n if (sum != input[1] || diff) {\n writeln(\"NO\");\n } else {\n writeln(\"YES\");\n foreach (t; times[0 .. $-1]) {\n write(t[1], \" \");\n }\n writeln(times[$-1][1]);\n }\n \n}"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.typecons;\nimport std.algorithm;\nimport std.array;\nimport std.range;\nimport std.math;\nimport std.regex;\n\nvoid main()\n{\n int[][] times;\n int sum, diff;\n\n auto input = readln().split().map!(to!int)();\n\n a:foreach (s; stdin.byLine()) {\n \tauto t = s.split().map!(to!int)().array();\n\n \twhile (sum + t[1] > input[1]) {\n \t\tif (t[1] - 1 >= t[0]) {\n \t\t\tt[1]--;\n \t\t} else {\n \t\t\tdiff = sum + t[1] - input[1];\n \t\t\tforeach_reverse (tt; times) {\n \t\t\t\twhile (tt[0] != tt[1] && diff) {\n \t\t\t\t\ttt[1]--;\n \t\t\t\t\tdiff--;\n \t\t\t\t\tsum--;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tif (diff) {writeln(\"u\");break a;}\n \t}\n\n \ttimes ~= t;\n \tsum += t[1];\n }\n\n if (sum != input[1] || diff) {\n \twriteln(\"NO\");\n } else {\n \twriteln(\"YES\");\n \tforeach (t; times[0 .. $-1]) {\n \t\twrite(t[1], \" \");\n \t}\n \twriteln(times[$-1][1]);\n }\n \n}"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.typecons;\nimport std.algorithm;\nimport std.array;\nimport std.range;\nimport std.math;\nimport std.regex;\n\nvoid main()\n{\n auto input = readln().split().map!(to!int)();\n int[][] times;\n foreach (i; 0 .. input[0]) {\n times ~= readln().split().map!(to!int)().array();\n }\n foreach (i, t; times) {\n int sum;\n foreach (tt; times[0 .. i]) {\n sum += tt[1];\n }\n while (sum + t[1] > input[1]) {\n if (t[1] - 1 >= t[0]) {\n t[1]--;\n } else {\n auto minu = sum + t[1] - input[1];\n foreach_reverse (tt; times[0 .. i]) {\n while (minu) {\n if (tt[0] == tt[1]) break;\n else {\n tt[1]--;\n minu--;\n }\n }\n }\n\n if (minu) {\n writeln(\"NO\");\n return;\n }\n }\n }\n }\n\n int sum;\n foreach (tt; times) {\n sum += tt[1];\n }\n if (sum != input[1]) {\n writeln(\"NO\");\n return;\n }\n writeln(\"YES\");\n foreach (t; times[0 .. $-1]) {\n write(t[1], \" \");\n }\n writeln(times[$-1][1]);\n \n}"}], "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0"} {"source_code": "import std.math;\nimport std.stdio;\n\nvoid main() {\n\tuint n;\n\treadf(`%u`, &n);\n\tuint[] res;\n\n\twhile(n) {\n\t\tint k = cast(int)log10(n).floor.lrint, m = 10 ^^ k;\n\n\t\tloop: foreach(_; 0..n / m) {\n\t\t\tforeach(ref p; res)\n\t\t\t\tif(p / m % 10 == 0) {\n\t\t\t\t\tp += m;\n\t\t\t\t\tcontinue loop;\n\t\t\t\t}\n\n\t\t\tres ~= m;\n\t\t}\n\n\t\tn %= m;\n\t}\n\n\twritef(\"%u\\n%(%u %)\", res.length, res);\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.range;\nimport std.string;\nimport std.algorithm;\n\nvoid main() {\n string s = readln.chomp;\n int n = s.minPos!\"a > b\"[0] - 48;\n n.writeln;\n n.iota\n .map!(i => s.map!(c => c > i + 48 ? \"1\" : \"0\").join.find!\"a!=48\").join(\" \").writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.array;\nimport std.functional;\nimport std.algorithm;\nimport std.container;\nimport std.conv;\n\nchar[] n;\nlong[] result;\n\nvoid main() {\n\tn = cast(char[])(readln().strip);\n\tfor (;;) {\n\t\tstring t;\n\t\tfor (int i = 0; i < n.length; ++i)\n\t\t\tif (n[i] == '0')\n\t\t\t\tt ~= '0';\n\t\t\telse {\n\t\t\t\tt ~= '1';\n\t\t\t\t--n[i];\n\t\t\t}\n\t\tif (to!long(t))\n\t\t\tresult ~= to!long(t);\n\t\telse\n\t\t\tbreak;\n\t}\n\twriteln(result.length);\n\twritefln(\"%(%s %)\", result);\n}\n"}, {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;\n\nint N;\nint[] Q;\n\nvoid main() {\n N = readln.chomp.to!int;\n\n int q = 1;\n while (format(\"%b\", q).to!int <= 10^^6) {\n Q ~= format(\"%b\", q).to!int;\n q++;\n }\n\n\n auto dp = new int[](N+1);\n fill(dp, 1 << 30);\n dp[0] = 0;\n auto fukugen = new int[](N+1);\n\n foreach (i; 0..N+1) {\n foreach (j; 0..Q.length.to!int) {\n if (i + Q[j] <= N && dp[i]+1 < dp[i+Q[j]]) {\n dp[i+Q[j]] = dp[i]+1;\n fukugen[i+Q[j]] = Q[j];\n }\n }\n }\n\n dp[N].writeln;\n int[] ans;\n int a = N;\n while (a > 0) {\n ans = fukugen[a] ~ ans;\n a -= fukugen[a];\n }\n ans.map!(to!string).join(\" \").writeln;\n}\n"}, {"source_code": "import std.algorithm;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nimmutable int MAX_N = 1_000_003;\nimmutable int BASE = 10;\n\nvoid main ()\n{\n\tint [] d;\n\tforeach (i; 0..MAX_N)\n\t{\n\t\tbool ok = true;\n\t\tint v = i;\n\t\twhile (v > 0)\n\t\t{\n\t\t\tok &= (v % BASE) < 2;\n\t\t\tv /= BASE;\n\t\t}\n\t\tif (ok)\n\t\t{\n\t\t\td ~= i;\n\t\t}\n\t}\n\n\tauto f = new int [MAX_N];\n\tf[1..$] = int.max >> 1;\n\tauto p = new int [MAX_N];\n\tp[] = 0;\n\tforeach (i; 0..MAX_N)\n\t{\n\t\tforeach (c; d)\n\t\t{\n\t\t\tif (c > i)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (f[i] > f[i - c] + 1)\n\t\t\t{\n\t\t\t\tf[i] = f[i - c] + 1;\n\t\t\t\tp[i] = c;\n\t\t\t}\n\t\t}\n\t}\n\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\tint [] ans;\n\t\twhile (n)\n\t\t{\n\t\t\tans ~= p[n];\n\t\t\tn -= p[n];\n\t\t}\n\t\twriteln (ans.length);\n\t\twritefln (\"%(%s %)\", ans);\n\t}\n}\n"}], "negative_code": [{"source_code": "import std.math;\nimport std.stdio;\n\nvoid main() {\n\tuint n;\n\treadf(`%u`, &n);\n\tuint[] res;\n\n\twhile(n) {\n\t\tint t, k = cast(int)log10(n).floor.lrint;\n\n\t\twhile(true) {\n\t\t\tauto c = t + 10 ^^ k--;\n\t\t\tif(c > n) break;\n\t\t\telse t = c;\n\t\t\tif(k < 0) break;\n\t\t}\n\n\t\tn -= t;\n\t\tres ~= t;\n\t}\n\n\twritef(\"%u\\n%(%u %)\", res.length, res);\n}\n"}, {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;\n\nint N;\nint[] Q;\nTuple!(int, int)[int] mem;\n\nint dp(int n) {\n if (n < 10) return n;\n if (n in mem) return mem[n][0];\n\n mem[n] = tuple(1 << 30, -1);\n foreach (q; Q) {\n if (n >= q) {\n auto ret = dp(n-q) + 1;\n if (ret < mem[n][0]) {\n mem[n] = tuple(ret, q);\n }\n }\n }\n return mem[n][0];\n}\n\nvoid main() {\n N = readln.chomp.to!int;\n\n int q = 2;\n while (format(\"%b\", q).to!int <= 10^^6) {\n Q ~= format(\"%b\", q).to!int;\n q++;\n }\n\n reverse(Q);\n auto ans = dp(N);\n\n int[] ans2;\n while (N >= 10) {\n auto a = mem[N][1];\n ans2 ~= a;\n N -= a;\n }\n while (N--) {\n ans2 ~= 1;\n }\n ans2.map!(c => c.to!string).join(\" \").writeln;\n}\n"}, {"source_code": "import std.stdio;\nimport std.range;\nimport std.string;\nimport std.algorithm;\n\nvoid main() {\n auto s = readln.chomp;\n writeln(s);\n (s.minPos!\"a > b\"[0] - 48).iota\n .map!(i => s.map!(c => c > i + 48 ? \"1\" : \"0\").join.find!\"a!=48\").join(\" \").writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.range;\nimport std.string;\nimport std.algorithm;\n\nvoid main() {\n auto s = readln.chomp;;\n (s.minPos!\"a > b\"[0] - 48).iota\n .map!(i => s.map!(c => c > i + 48 ? \"1\" : \"0\").join.find!\"a!=48\")\n .join(\" \").writeln;\n}"}], "src_uid": "033068c5e16d25f09039e29c88474275"} {"source_code": "/+ dub.sdl:\n name \"A\"\n dependency \"dunkelheit\" version=\"1.0.1\"\n+/\n\nimport std.stdio, std.algorithm, std.range, std.conv;\n// import dkh.foundation, dkh.scanner;\n\nint main() {\n Scanner sc = new Scanner(stdin);\n scope(exit) assert(!sc.hasNext);\n\n int n;\n long[] a;\n sc.read(n, a);\n\n long sm = a.sum;\n int[] our = iota(n).filter!(i => i == 0 || 2 * a[i] <= a[0]).array;\n long my = our.map!(i => a[i]).sum;\n\n debug writeln(sm, \" \", my, \" \", our);\n\n if (sm >= my * 2) {\n writeln(\"0\");\n } else {\n writeln(our.length);\n writeln(our.map!\"a + 1\".map!(to!string).join(\" \"));\n }\n return 0;\n}\n/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/foundation.d */\n \n// module dkh.foundation;\n\n \nstatic if (__VERSION__ <= 2070) {\n /*\n Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d\n Copyright: Andrei Alexandrescu 2008-.\n License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).\n */\n template fold(fun...) if (fun.length >= 1) {\n auto fold(R, S...)(R r, S seed) {\n import std.algorithm : reduce;\n static if (S.length < 2) {\n return reduce!fun(seed, r);\n } else {\n import std.typecons : tuple;\n return reduce!fun(tuple(seed), r);\n }\n }\n }\n \n}\n/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/container/stackpayload.d */\n// module dkh.container.stackpayload;\n\n \nstruct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {\n import core.exception : RangeError;\n\n private T* _data;\n private uint len, cap;\n\n @property bool empty() const { return len == 0; }\n @property size_t length() const { return len; }\n alias opDollar = length;\n\n \n inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }\n \n ref inout(T) opIndex(size_t i) inout {\n version(assert) if (len <= i) throw new RangeError();\n return _data[i];\n } \n ref inout(T) front() inout { return this[0]; } \n ref inout(T) back() inout { return this[$-1]; } \n\n void reserve(size_t newCap) {\n import core.memory : GC;\n import core.stdc.string : memcpy;\n import std.conv : to;\n if (newCap <= cap) return;\n void* newData = GC.malloc(newCap * T.sizeof);\n cap = newCap.to!uint;\n if (len) memcpy(newData, _data, len * T.sizeof);\n _data = cast(T*)(newData);\n } \n void free() {\n import core.memory : GC;\n GC.free(_data);\n } \n \n void clear() {\n len = 0;\n }\n\n void insertBack(T item) {\n import std.algorithm : max;\n if (len == cap) reserve(max(cap * 2, MINCAP));\n _data[len++] = item;\n } \n alias opOpAssign(string op : \"~\") = insertBack; \n void removeBack() {\n assert(!empty, \"StackPayload.removeBack: Stack is empty\");\n len--;\n } \n}\n\n \n/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/scanner.d */\n// module dkh.scanner;\n\n// import dkh.container.stackpayload;\n\n \nclass Scanner {\n import std.stdio : File;\n import std.conv : to;\n import std.range : front, popFront, array, ElementType;\n import std.array : split;\n import std.traits : isSomeChar, isStaticArray, isArray; \n import std.algorithm : map;\n private File f;\n \n this(File f) {\n this.f = f;\n }\n private char[512] lineBuf;\n private char[] line;\n private bool succW() {\n import std.range.primitives : empty, front, popFront;\n import std.ascii : isWhite;\n while (!line.empty && line.front.isWhite) {\n line.popFront;\n }\n return !line.empty;\n }\n private bool succ() {\n import std.range.primitives : empty, front, popFront;\n import std.ascii : isWhite;\n while (true) {\n while (!line.empty && line.front.isWhite) {\n line.popFront;\n }\n if (!line.empty) break;\n line = lineBuf[];\n f.readln(line);\n if (!line.length) return false;\n }\n return true;\n }\n\n private bool readSingle(T)(ref T x) {\n import std.algorithm : findSplitBefore;\n import std.string : strip;\n import std.conv : parse;\n if (!succ()) return false;\n static if (isArray!T) {\n alias E = ElementType!T;\n static if (isSomeChar!E) {\n \n \n auto r = line.findSplitBefore(\" \");\n x = r[0].strip.dup;\n line = r[1];\n } else static if (isStaticArray!T) {\n foreach (i; 0..T.length) {\n assert(succW());\n x[i] = line.parse!E;\n }\n } else {\n StackPayload!E buf;\n while (succW()) {\n buf ~= line.parse!E;\n }\n x = buf.data;\n }\n } else {\n x = line.parse!T;\n }\n return true;\n }\n\n \n int unsafeRead(T, Args...)(ref T x, auto ref Args args) {\n if (!readSingle(x)) return 0;\n static if (args.length == 0) {\n return 1;\n } else {\n return 1 + read(args);\n }\n }\n \n void read(Args...)(auto ref Args args) {\n import std.exception : enforce;\n static if (args.length != 0) {\n enforce(readSingle(args[0]));\n read(args[1..$]);\n }\n }\n \n bool hasNext() {\n return succ();\n }\n}\n\n\n \n \n\n \n\n/*\nThis source code generated by dunkelheit and include dunkelheit's source code.\ndunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)\ndunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)\n*/\n", "positive_code": [{"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\nint N;\nint[] A;\n\nvoid main() {\n try {\n for (; ; ) {\n N = readInt();\n A = new int[N];\n foreach (i; 0 .. N) {\n A[i] = readInt();\n }\n \n int[] ans;\n ans ~= 0;\n foreach (i; 1 .. N) {\n if (A[0] >= 2 * A[i]) {\n ans ~= i;\n }\n }\n int sum;\n foreach (i; ans) {\n sum += A[i];\n }\n if (2 * sum > A.sum) {\n writeln(ans.length);\n foreach (index, i; ans) {\n if (index > 0) {\n write(\" \");\n }\n write(i + 1);\n }\n writeln();\n } else {\n writeln(0);\n }\n }\n } catch (EOFException e) {\n }\n}\n"}], "negative_code": [], "src_uid": "0a71fdaaf08c18396324ad762b7379d7"} {"source_code": "import core.bitop;\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nbool isPrime (int v)\n{\n\tif (v < 2)\n\t{\n\t\treturn false;\n\t}\n\tfor (int d = 2; d * d <= v; d++)\n\t{\n\t\tif (v % d == 0)\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\tfor (int m = 1; ; m++)\n\t\t{\n\t\t\tif (!isPrime (n * m + 1))\n\t\t\t{\n\t\t\t\twriteln (m);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\nimport std.range;\nimport std.string;\n\n\nbool prime(int n)\n{\n int i=2;\n for(;ix>0 && x>=a[k]).writeln;\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.conv;\nimport std.container;\n\nint main(string[] argv)\n{\n\tint n, k;\n\tscanf(\"%d %d\", &n, &k);\n\tint[] contestants = new int[n];\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d\", &contestants[i]);\n\t}\n\tint score = contestants[k-1];\n\tint result = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tresult += (contestants[i] > 0 && contestants[i] >= score) ? 1 : 0;\n\t}\n\twriteln(result);\n\treturn 0;\n}\n"}, {"source_code": "import std.stdio; \nvoid main() { \n\tint n, k;\n\treadf(\" %s\",&n);\n\treadf(\" %s\",&k);\n\tk--;\n\tint[] a = new int[n];\n\tfor (int i = 0; i < n; i++) {\n\t\treadf(\" %s\",&a[i]);\n\t}\n\ta = a.sort.reverse;\n\t//writeln(a);\n\tint answer = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tif (a[i] > 0 && a[i] >= a[k]) {\n\t\t\tanswer++;\n\t\t}\n\t}\n\twriteln(answer);\n}"}, {"source_code": "// https://codeforces.com/problemset/problem/158/A\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n int n, k;\n readf(\"%d %d\", &n, &k);\n readln;\n\n string input = readln;\n int[] a = input.split.map!(x => x.to!int).array;\n\n a.filter!(x => (x >= a[k-1]) && (x > 0)).count.writeln;\n}\n\n"}, {"source_code": "// https://codeforces.com/problemset/problem/158/A\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n int n, k;\n readf(\"%d %d\", &n, &k);\n readln;\n\n string input = readln;\n int[] a = input.split.map!(x => x.to!int).array;\n\n a.count!(x => (x >= a[k-1]) && (x > 0)).writeln;\n}\n\n"}, {"source_code": "import std.stdio;\nvoid main()\n{\n int [100000+10]arr;\n int n,k;\n readf(\"%d %d \",&n,&k);\n for(int i=1;i<=n;i++)readf(\"%d \",&arr[i]);\n int ans=0;\n for(int i=1;i<=n;i++)\n {\n if(arr[i]>=arr[k] && arr[i]>0)ans++;\n }\n writeln(ans);\n}\n"}, {"source_code": "module main;\n\nimport std.c.stdio;\n\nint main(string[] argv)\n{\n\tint n,k;\n\tscanf(\"%d %d\", &n, &k);\n\tint [] arr = new int[n];\n\tfor(int i = 0; i= arr[k-1] && arr[i] >0)\n\t\t\tq++;\n\tprintf(\"%d\", q);\n\treturn 0;\n}\n"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\nimport std.range;\n\nvoid main(){\n\tint n, k; readf(\"%d %d\\n\", &n, &k);\n\tauto buf = readln.split.map!(to!int).array;\n\t(buf[0] == 0) ? writeln(0) : buf.count!(a => a>=buf[k-1] && a>0 ).writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\nimport std.range;\n\nvoid main(){\n\tint n, k; readf(\"%d %d\\n\", &n, &k);\n\tauto buf = readln.split.map!(to!int).array;\n\tbuf.count!(a => (a >= buf[k-1]) && (a > 0) ).writeln;\n}"}, {"source_code": "import std.stdio;\n\nint main(string[] argv)\n{\n\tint n, pos;\n readf(\" %d %d\", &n, &pos);\n\tint[] a = new int[n];\n\tfor (int i = 0; i < n; ++i)\n\t\treadf(\" %d\", &a[i]);\n\tint j = pos - 1;\n\n\tif (a[j] == 0)\n\t\twhile (j >= 0 && a[j] == 0)\n\t\t\t--j;\n\telse\n\t\twhile (j+1 <= n-1 && a[j] == a[j+1])\n\t\t\t++j;\n\n\twriteln(j+1);\n\treadln;\n return 0;\n}\n"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.array;\n\nvoid main() {\n string[] l1 = readln().chomp().split();\n auto n = to!int(l1[0]);\n auto k = to!int(l1[1]);\n string[] l2 = readln().chomp().split();\n auto tot = 0;\n for (auto i=0; i 0) {\n tot += 1;\n }\n }\n auto kv = to!int(l2[k-1]);\n if (kv > 0) {\n while (tot < n && to!int(l2[tot]) == kv) {\n tot += 1;\n }\n }\n writeln(tot);\n}\n"}, {"source_code": "import std.stdio, std.string, std.conv;\n\nvoid main() {\n\n\tbyte n, k;\n\n\treadf(\"%s %s\\n\", &n, &k);\n\n\tshort max, ki;\n\tforeach (idx, score; readln.split) {\n\t\tif (idx == k - 1)\n\t\t\tki = score.to!byte;\n\t\tif (idx > k - 1 && score.to!byte < ki || score.to!byte == 0)\n\t\t\tbreak;\n\t\t++max;\n\t}\n\n\twriteln(max);\n}"}, {"source_code": "import std.stdio : readf, readln, writeln;\nimport std.math : ceil;\nimport std.conv : to;\nimport std.array : split;\n\nvoid main()\n{\n uint[] nums;\n uint n, k;\n uint counter;\n uint pass;\n \n readf(\"%s %s\\n\", &n, &k);\n \n foreach(uint i, string num; split(readln))\n {\n uint unum = to!uint(num);\n if ((i+1)==k) pass = unum;\n nums ~= unum;\n }\n foreach(num; nums)\n {\n if (num > 0 && num >= pass) ++counter;\n }\n\n writeln(counter);\n}"}, {"source_code": "import std.stdio;\n\nvoid main() {\n int n, k;\n readf(\"%d %d\\n\", &n, &k);\n\n int[] scores = new int[n];\n\n for (int i = 0; i < n-1; ++i) {\n readf(\"%d \", &scores[i]);\n }\n readf(\"%d\\n\", &scores[n-1]);\n\n int kScore = scores[k-1];\n int nextRound = 0;\n\n for (int i = 0; i < n; ++i) {\n if (scores[i] > 0 && scores[i] >= kScore) {\n nextRound++;\n }\n }\n\n writefln(\"%d\", nextRound);\n}"}, {"source_code": "import std.stdio;\nimport std.algorithm;\n\nvoid main() \n{\n int n, k;\n scanf(\"%d %d\", &n, &k);\n \n int[] a = new int[n];\n \n for (int i = 0; i < n; ++i) {\n scanf(\"%d\", &a[i]);\n }\n \n int f = a[k - 1];\n \n a.sort();\n \n \n int ans = 0;\n \n for (int i = 0; i < n; ++i) {\n \n \n if (a[i] > 0 && a[i] >= f)\n ans++;\n }\n \n \n \n printf(\"%d\\n\", ans);\n\n}\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\nimport std.range;\n\nvoid main(){\n\tint n, k; readf(\"%d %d\\n\", &n, &k);\n\tauto buf = readln.split.map!(to!int).array;\n\t(buf[0] == 0) ? writeln(0) : buf.count!(a => a>=buf[k-1]).writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\nimport std.array;\n\nvoid main() {\n string[] l1 = readln().chomp().split();\n auto n = to!int(l1[0]);\n auto k = to!int(l1[1]);\n string[] l2 = readln().chomp().split();\n auto tot = k;\n auto kv = to!int(l2[k-1]);\n if (kv > 0) {\n while (tot < n && to!int(l2[tot]) == kv) {\n tot += 1;\n }\n writeln(tot);\n } else {\n writeln(0);\n }\n}\n"}, {"source_code": "import std.stdio : readf, readln, writeln;\nimport std.math : ceil;\nimport std.conv : to;\nimport std.array : split;\n\nvoid main()\n{\n\tuint[] nums;\n\tuint n, k;\n\tuint counter;\n\tuint pass;\n\t\n\treadf(\"%s %s\\n\", &n, &k);\n\t\n\tforeach(uint i, string num; split(readln))\n\t{\n\t\tuint unum = to!uint(num);\n\t\tif (i==k) pass = unum;\n\t\tnums ~= unum;\n\t}\n\tforeach(num; nums)\n\t{\n\t\tif (num > 0 && num >= pass) ++counter;\n\t}\n\n\twriteln(counter);\n}"}, {"source_code": "import std.stdio;\nimport std.algorithm;\n\nvoid main() \n{\n int n, k;\n scanf(\"%d %d\", &n, &k);\n \n int[] a = new int[n];\n \n for (int i = 0; i < n; ++i) {\n scanf(\"%d\", &a[i]);\n }\n \n a.sort();\n \n int ans = 0;\n \n for (int i = 0; i < n; ++i) {\n if (a[i] > 0 && a[i] >= a[k - 1])\n ans++;\n }\n \n \n printf(\"%d\\n\", ans);\n\n}\n"}, {"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.conv;\nimport std.container;\n\nint main(string[] argv)\n{\n\tint n, k;\n\tscanf(\"%d %d\", &n, &k);\n\tint[] contestants = new int[n];\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d\", &contestants[i]);\n\t}\n\tint score = contestants[k];\n\tint result = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tresult += (contestants[i] > 0 && contestants[i] >= score) ? 1 : 0;\n\t}\n\twriteln(result);\n\treturn 0;\n}\n"}, {"source_code": "import std.stdio; \nvoid main() { \n\tint n, k;\n\treadf(\" %s\",&n);\n\treadf(\" %s\",&k);\n\tk--;\n\tint[] a = new int[n];\n\tfor (int i = 0; i < n; i++) {\n\t\treadf(\" %s\",&a[i]);\n\t}\n\ta = a.reverse;\n\tint answer = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tif (a[i] > 0 && a[i] >= a[k]) {\n\t\t\tanswer++;\n\t\t}\n\t}\n\twriteln(answer);\n}"}, {"source_code": "// https://codeforces.com/problemset/problem/158/A\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n int n, k;\n readf(\"%d %d\", &n, &k);\n readln;\n\n string input = readln;\n int[] a = input.split.map!(x => x.to!int).array;\n\n a.filter!(x => (x >= a[k-1]) && (x > 0));\n a.length.writeln;\n}\n\n"}], "src_uid": "193ec1226ffe07522caf63e84a7d007f"} {"source_code": "import std.stdio, std.string;\nimport std.algorithm;\n\ndouble saiki(int n, int t, double p, double[][] dp)\n{\n if (dp[n][t] != -1)\n {\n return dp[n][t];\n }\n if (n == 0)\n {\n dp[n][t] = 0.0;\n return 0.0;\n }\n if (t == 0)\n {\n dp[n][t] = cast(double)n;\n return cast(double)n;\n }\n auto ret0 = saiki(n - 1, t - 1, p, dp);\n auto ret1 = saiki(n, t - 1, p, dp);\n dp[n][t] = p * ret0 + (1.0 - p) * ret1;\n return dp[n][t];\n}\n\nvoid solve(int n, double p, int t)\n{\n auto dp = new double[][](n + 1, t + 1);\n foreach (i; 0 .. n + 1)\n {\n fill(dp[i], -1);\n }\n auto res = saiki(n, t, p, dp);\n writefln(\"%.10f\", cast(double)n - res);\n}\n\nint main(string[] args)\n{\n int n, t;\n double p;\n while (readf(\"%d %f %d\\n\", &n, &p, &t) == 3)\n {\n solve(n, p, t);\n }\n return 0;\n}", "positive_code": [{"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.exception;\nimport std.functional;\nimport std.math;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport core.bitop;\n\nvoid main ()\n{\n\tint n, t;\n\treal p;\n\twhile (readf (\" %s %s %s\", &n, &p, &t) > 0)\n\t{\n\t\treal q = 1.0 - p;\n\t\tauto f = new real [] [] (t + 1, n + 1);\n\t\tforeach (ref g; f)\n\t\t{\n\t\t\tg[] = 0.0;\n\t\t}\n\t\tf[0][0] = 1.0;\n\n\t\tforeach (i; 0..t)\n\t\t{\n\t\t\tforeach (j; 0..n)\n\t\t\t{\n\t\t\t\tf[i + 1][j + 1] += f[i][j] * p;\n\t\t\t\tf[i + 1][j + 0] += f[i][j] * q;\n\t\t\t}\n\t\t\tf[i + 1][n] += f[i][n];\n\t\t}\n\n\t\treal res = 0.0;\n\t\tforeach (j; 0..n + 1)\n\t\t{\n\t\t\tres += f[t][j] * j;\n\t\t}\n\t\twritefln (\"%.10f\", res);\n\t}\n}\n"}], "negative_code": [], "src_uid": "20873b1e802c7aa0e409d9f430516c1e"} {"source_code": "import std.stdio, std.bigint, std.string;\n\nvoid main() {\n auto a_ = readln.strip;\n auto n = a_.length;\n auto a = BigInt(a_);\n // auto b = BigInt(readln.strip);\n long b;\n scanf(\"%ld\", &b);\n auto ans = a % b;\n auto pow10n = 1; for (int i=0; i 100) {\n writeln(b);\n writeln(a);\n }\n auto ans = a % b;\n auto pow10n = 1; for (int i=0; i 100) {\n writeln(a);\n writeln(b);\n }\n auto ans = a % b;\n // auto pow10n = (BigInt(10) ^^ n);\n auto pow10n = 1;\n for (int i=0; i 1)\n\t\t\t{\n\t\t\t\tauto m = (l + r) >> 1;\n\t\t\t\tif (!(a[m] < g))\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\t\t\treturn (!(a[l] < g)) ? l : r;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tsize_t l = 0, r = a.length;\n\t\t\twhile (r - l > 1)\n\t\t\t{\n\t\t\t\tauto m = (l + r) >> 1;\n\t\t\t\tif (g < a[m])\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\t\t\treturn (g < a[l]) ? l : r;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn binf(a, g) != a.length;\n\t\t}\n\t}\n\t///write an array\n\tvoid putarr(X)(in X a, in char ch = ' ') if (isInputRange!X)\n\t{\n\t\twritefln(\"%(%s\" ~ ch ~ \"%)\", a);\n\t}\n\t///write a matrix\n\tvoid putarr(X)(in X a)\n\t\t\tif (isInputRange!X && isInputRange!(ElementType!X) && !isSomeString!(ElementType!X))\n\t{\n\t\twritefln(\"%(%(%s %)\\n%)\", a);\n\t}\n\t///get an array\n\tbool getarr(X)(X a, in size_t n)\n\t{\n\t\tbool b = 1;\n\t\tforeach (ref i; a[0 .. n])\n\t\t\tb = input(&i);\n\t\treturn b;\n\t}\n\t///read without format\n\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t{\n\t\tsize_t s = 0;\n\t\tforeach (ref e; ptrs)\n\t\t{\n\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\ts += readf(\" %c\", &e);\n\t\t\telse\n\t\t\t\ts += readf(\" %s\", &e);\n\t\t}\n\t\treturn s == ptrs.length;\n\t}\n\t///readln without format\n\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t{\n\t\tsize_t s = 0;\n\t\tforeach (ref e; ptrs)\n\t\t{\n\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\ts += readf(\" %c\", &e);\n\t\t\telse\n\t\t\t\ts += readf(\" %s\", &e);\n\t\t}\n\t\treadln;\n\t\treturn s == ptrs.length;\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\n\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tfreopen(\"input.txt\", \"r\", core.stdc.stdio.stdin);\n\t\t//freopen(\"output.txt\", \"w\", core.stdc.stdio.stdout);\n\t\t/*StopWatch sw;\n\t\tsw.start;\n\t\tscope (exit)\n\t\t{\n\t\t\tsw.stop;\n\t\t\tstderr.writefln(\"\\nTime: %d ms\", sw.peek.msecs);\n\t\t}*/\n\t}\n\tint k;\n\tloop: while (read(k))\n\t{\n\t\tforeach (ch; 'a' .. 'z' + 1)\n\t\t{\n\t\t\tint i;\n\t\t\twhile (i * (i + 1) / 2 <= k)\n\t\t\t\ti++;\n\t\t\tk -= i * (i - 1) / 2;\n\t\t\tforeach (_; 0 .. i)\n\t\t\t{\n\t\t\t\twrite(cast(char) ch);\n\t\t\t}\n\t\t}\n\t\twriteln;\n\t}\n}\n", "positive_code": [{"source_code": "/+ dub.sdl:\n name \"A\"\n dependency \"dcomp\" version=\">=0.6.0\"\n+/\n\nimport std.stdio, std.algorithm, std.range, std.conv;\n// import dcomp.foundation, dcomp.scanner;\n\nint main() {\n auto sc = new Scanner(stdin);\n int k;\n sc.read(k); k *= 2;\n if (k == 0) {\n writeln(\"miku\");\n return 0;\n }\n string s;\n char nw = 'a';\n while (k) {\n foreach (i; 1..1000) {\n if (k < (i+1)*(i)) {\n k -= i*(i-1);\n s ~= nw.repeat.take(i).array;\n nw++;\n break;\n }\n }\n }\n writeln(s);\n return 0;\n}\n/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/foundation.d */\n// module dcomp.foundation;\n \nstatic if (__VERSION__ <= 2070) {\n template fold(fun...) if (fun.length >= 1) {\n auto fold(R, S...)(R r, S seed) {\n import std.algorithm : reduce;\n static if (S.length < 2) {\n return reduce!fun(seed, r);\n } else {\n import std.typecons : tuple;\n return reduce!fun(tuple(seed), r);\n }\n }\n }\n \n}\nversion (X86) static if (__VERSION__ < 2071) {\n import core.bitop : bsf, bsr, popcnt;\n int bsf(ulong v) {\n foreach (i; 0..64) {\n if (v & (1UL << i)) return i;\n }\n return -1;\n }\n int bsr(ulong v) {\n foreach_reverse (i; 0..64) {\n if (v & (1UL << i)) return i;\n }\n return -1; \n }\n int popcnt(ulong v) {\n int c = 0;\n foreach (i; 0..64) {\n if (v & (1UL << i)) c++;\n }\n return c;\n }\n}\n/* IMPORT /home/yosupo/Program/dcomp/source/dcomp/scanner.d */\n// module dcomp.scanner;\n\n \nclass Scanner {\n import std.stdio : File;\n import std.conv : to;\n import std.range : front, popFront, array, ElementType;\n import std.array : split;\n import std.traits : isSomeChar, isStaticArray, isArray; \n import std.algorithm : map;\n File f;\n this(File f) {\n this.f = f;\n }\n char[512] lineBuf;\n char[] line;\n private bool succ() {\n import std.range.primitives : empty, front, popFront;\n import std.ascii : isWhite;\n while (true) {\n while (!line.empty && line.front.isWhite) {\n line.popFront;\n }\n if (!line.empty) break;\n if (f.eof) return false;\n line = lineBuf[];\n f.readln(line);\n }\n return true;\n }\n\n private bool readSingle(T)(ref T x) {\n import std.algorithm : findSplitBefore;\n import std.string : strip;\n import std.conv : parse;\n if (!succ()) return false;\n static if (isArray!T) {\n alias E = ElementType!T;\n static if (isSomeChar!E) {\n \n \n auto r = line.findSplitBefore(\" \");\n x = r[0].strip.dup;\n line = r[1];\n } else {\n auto buf = line.split.map!(to!E).array;\n static if (isStaticArray!T) {\n \n assert(buf.length == T.length);\n }\n x = buf;\n line.length = 0;\n }\n } else {\n x = line.parse!T;\n }\n return true;\n }\n int read(T, Args...)(ref T x, auto ref Args args) {\n if (!readSingle(x)) return 0;\n static if (args.length == 0) {\n return 1;\n } else {\n return 1 + read(args);\n }\n }\n}\n\n\n \n \n\n \n"}, {"source_code": "import core.bitop;\nimport std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.exception;\nimport std.functional;\nimport std.math;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nimmutable int limit = 1003;\n\nvoid main ()\n{\n\tauto f = new int [limit];\n\tf[0] = 0;\n\tf[1] = 0;\n\tforeach (j; 2..limit)\n\t{\n\t\tf[j] = int.max;\n\t\tforeach (k; 1..j)\n\t\t{\n\t\t\tf[j] = min (f[j], f[k] + f[j - k] + k * (j - k));\n\t\t}\n\t}\n\tdebug\n\t{\n\t\tforeach (j; 0..limit)\n\t\t{\n\t\t\twritefln (\"%6s: %6s\", j, f[j]);\n\t\t}\n\t}\n\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\tstring res;\n\t\tforeach (c; 'a'..'p')\n\t\t{\n\t\t\tint len = 0;\n\t\t\twhile (f[len + 1] <= n)\n\t\t\t{\n\t\t\t\tlen += 1;\n\t\t\t}\n\t\t\tn -= f[len];\n\t\t\tforeach (i; 0..len)\n\t\t\t{\n\t\t\t\tres ~= c;\n\t\t\t}\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}, {"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\nenum LIM = 10^^5 + 5;\n\nvoid main() {\n auto prev = new int[LIM];\n prev[] = -1;\n prev[0] = 0;\n foreach (i; 0 .. 3) {\n foreach_reverse (x; 0 .. LIM) {\n if (prev[x] != -1) {\n for (int a = 2; x + a * (a - 1) / 2 < LIM; ++a) {\n const xx = x + a * (a - 1) / 2;\n if (prev[xx] == -1) {\n prev[xx] = a;\n }\n }\n }\n }\n }\n foreach (x; 0 .. LIM) {\n assert(prev[x] != -1);\n }\n \n try {\n for (; ; ) {\n const K = readInt();\n \n int[] as;\n as ~= 1;\n for (int x = K; x > 0; ) {\n const a = prev[x];\n as ~= a;\n x -= a * (a - 1) / 2;\n }\n \n string ans;\n foreach (i, a; as) {\n ans ~= (cast(char)('a' + i)).repeat(a).array;\n }\n writeln(ans);\n }\n } catch (EOFException e) {\n }\n}\n"}, {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop;\n\n\nvoid main() {\n auto N = readln.chomp.to!int;\n\n if (N == 0) {\n \"a\".writeln;\n return;\n }\n\n string ans = \"\";\n char c = 'a';\n\n while (N > 0) {\n ans ~= c;\n int tmp = 1;\n while (N - tmp >= 0) {\n N -= tmp;\n ans ~= c;\n tmp += 1;\n }\n c += 1;\n }\n\n ans.writeln;\n}\n"}], "negative_code": [{"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop;\n\n\nvoid main() {\n auto N = readln.chomp.to!int;\n\n string ans = \"\";\n char c = 'a';\n\n while (N > 0) {\n ans ~= c;\n int tmp = 1;\n while (N - tmp >= 0) {\n N -= tmp;\n ans ~= c;\n tmp += 1;\n }\n c += 1;\n }\n\n ans.writeln;\n}\n"}, {"source_code": "module main;\n__gshared:\nimport core.bitop, std.algorithm, std.bigint, std.bitmanip, std.complex,\n\tstd.container, std.conv, std.datetime, std.functional, std.math, std.meta,\n\tstd.numeric, std.parallelism, std.random, std.range, std.regex, std.stdio,\n\tstd.string, std.traits, std.typecons, std.uni, std.variant;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\nalias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nenum mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///lcm\n\t\tT lcm(T)(auto ref T a, auto ref T b)\n\t\t{\n\t\t\treturn a / gcd(a, b) * b;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///BigInt greatest common divizor\n\t\tBigInt gcd(BigInt a, BigInt b)\n\t\t{\n\t\t\twhile (b)\n\t\t\t{\n\t\t\t\ta %= b;\n\t\t\t\tswap(a, b);\n\t\t\t}\n\t\t\treturn a;\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///integer size\n\t\tint sz(T)(T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tsize_t l = 0, r = a.length;\n\t\t\twhile (r - l > 1)\n\t\t\t{\n\t\t\t\tauto m = (l + r) >> 1;\n\t\t\t\tif (!(a[m] < g))\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\t\t\treturn (!(a[l] < g)) ? l : r;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tsize_t l = 0, r = a.length;\n\t\t\twhile (r - l > 1)\n\t\t\t{\n\t\t\t\tauto m = (l + r) >> 1;\n\t\t\t\tif (g < a[m])\n\t\t\t\t\tr = m;\n\t\t\t\telse\n\t\t\t\t\tl = m;\n\t\t\t}\n\t\t\treturn (g < a[l]) ? l : r;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn binf(a, g) != a.length;\n\t\t}\n\t}\n\t///write an array\n\tvoid putarr(X)(in X a, in char ch = ' ') if (isInputRange!X)\n\t{\n\t\twritefln(\"%(%s\" ~ ch ~ \"%)\", a);\n\t}\n\t///write a matrix\n\tvoid putarr(X)(in X a)\n\t\t\tif (isInputRange!X && isInputRange!(ElementType!X) && !isSomeString!(ElementType!X))\n\t{\n\t\twritefln(\"%(%(%s %)\\n%)\", a);\n\t}\n\t///get an array\n\tbool getarr(X)(X a, in size_t n)\n\t{\n\t\tbool b = 1;\n\t\tforeach (ref i; a[0 .. n])\n\t\t\tb = input(&i);\n\t\treturn b;\n\t}\n\t///read without format\n\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t{\n\t\tsize_t s = 0;\n\t\tforeach (ref e; ptrs)\n\t\t{\n\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\ts += readf(\" %c\", &e);\n\t\t\telse\n\t\t\t\ts += readf(\" %s\", &e);\n\t\t}\n\t\treturn s == ptrs.length;\n\t}\n\t///readln without format\n\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t{\n\t\tsize_t s = 0;\n\t\tforeach (ref e; ptrs)\n\t\t{\n\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\ts += readf(\" %c\", &e);\n\t\t\telse\n\t\t\t\ts += readf(\" %s\", &e);\n\t\t}\n\t\treadln;\n\t\treturn s == ptrs.length;\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\n\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tfreopen(\"input.txt\", \"r\", core.stdc.stdio.stdin);\n\t\t//freopen(\"output.txt\", \"w\", core.stdc.stdio.stdout);\n\t\t/*StopWatch sw;\n\t\tsw.start;\n\t\tscope (exit)\n\t\t{\n\t\t\tsw.stop;\n\t\t\tstderr.writefln(\"\\nTime: %d ms\", sw.peek.msecs);\n\t\t}*/\n\t}\n\tint k;\n\tloop: while (read(k))\n\t{\n\t\tforeach (ch; 'a' .. 'z' + 1)\n\t\t{\n\t\t\tint i = 1;\n\t\t\twhile (i * (i - 1) / 2 <= k)\n\t\t\t\ti++;\n\t\t\tk -= i * (i - 1) / 2;\n\t\t\tforeach (_; 0 .. i - 1)\n\t\t\t{\n\t\t\t\twrite(cast(char) ch);\n\t\t\t}\n\t\t}\n\t\twriteln;\n\t}\n}\n"}, {"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\nenum LIM = 10^^5 + 5;\n\nvoid main() {\n auto prev = new int[LIM];\n prev[] = -1;\n prev[0] = 0;\n foreach (i; 0 .. 3) {\n foreach_reverse (x; 0 .. LIM) {\n if (prev[x] != -1) {\n for (int a = 2; x + a * (a - 1) / 2 < LIM; ++a) {\n const xx = x + a * (a - 1) / 2;\n if (prev[xx] == -1) {\n prev[xx] = a;\n }\n }\n }\n }\n }\n foreach (x; 0 .. LIM) {\n assert(prev[x] != -1);\n }\n \n try {\n for (; ; ) {\n const K = readInt();\n \n int[] as;\n for (int x = K; x > 0; ) {\n const a = prev[x];\n as ~= a;\n x -= a * (a - 1) / 2;\n }\n \n string ans;\n foreach (i, a; as) {\n ans ~= (cast(char)('a' + i)).repeat(a).array;\n }\n writeln(ans);\n }\n } catch (EOFException e) {\n }\n}\n"}], "src_uid": "b991c064562704b6106a6ff2a297e64a"} {"source_code": "import std.stdio;\n\nint main() {\n debug stdin = File(\"in.txt\", \"r\");\n \n //writeln(\"%s\", \n int n;\n readf(\" %s\", &n);\n foreach (k; 1..5) {\n int[4] gs;\n readf(\" %s %s %s %s\", &gs[0], &gs[1], &gs[2], &gs[3]);\n foreach (i; 0..2) {\n foreach (j; 2..4) {\n if (gs[i] + gs[j] <= n) {\n writefln(\"%s %s %s\", k, gs[i], n - gs[i]);\n return 0;\n }\n }\n }\n }\n writeln(\"-1\");\n\n return 0;\n}\n", "positive_code": [{"source_code": "import std.stdio;\n\nvoid main() {\n debug stdin = File(\"input.txt\", \"r\");\n\n int n;\n readf(\" %s\", &n);\n foreach (i; 0 .. 4) {\n int[] a = new int[2];\n int[] b = new int[2];\n readf(\" %s %s %s %s\", &a[0], &a[1], &b[0], &b[1]);\n foreach (j; 0 .. 2) {\n foreach (k; 0 .. 2) {\n if (a[j] + b[k] <= n) {\n writeln(i + 1, \" \", n - b[k], \" \", b[k]);\n return;\n }\n }\n }\n }\n\n writeln(-1);\n}\n"}], "negative_code": [], "src_uid": "6e7ee0da980beb99ca49a5ddd04089a5"} {"source_code": "import std.stdio, std.algorithm, std.array, std.math, std.typecons, std.bigint, std.conv;\r\n \r\nvoid main()\r\n{\r\n int k;\r\n scanf(\"%d\", &k);\r\n long res1 = 2UL^^k - 2;\r\n BigInt n = 4;\r\n BigInt res2 = powmod(n, to!BigInt(res1), to!BigInt(10^^9 + 7));\r\n \r\n writeln((res2 * to!BigInt(6)) % (10^^9 + 7));\r\n}", "positive_code": [{"source_code": "// Cheese-Cracker: cheese-cracker.github.io\n\nconst ll MOD = to!long(1e9) + 7L;\nll modexp(ll base, ll exp){\n ll x = base % MOD;\n ll y = exp;\n ll res = 1;\n while(y > 0){\n if(y & 1){\n res *= x; res %= MOD;\n }\n x *= x; x %= MOD;\n y >>= 1;\n }\n return res;\n}\n\nvoid solve(){\n ll k = scan;\n ll ex = 1;\n for(int i = 0; i < k; ++i) ex *= 2;\n ll res = 6;\n res *= modexp(4, ex-2);\n res %= MOD;\n writeln(res);\n}\n\nvoid main(){\n solve;\n}\n\n/************** ***** That's All Folks! ***** **************/\nimport std.stdio, std.range, std.conv, std.typecons, std.algorithm, std.container, std.math;\nstring[] tk; T scan(T=long)(){while(!tk.length)tk = readln.split; string a=tk.front; tk.popFront; return a.to!T;}\nT[] scanArray(T=long)(){ auto r = readln.split.to!(T[]); return r; }\nvoid show(A...)(A a){ debug{ foreach(t; a){stderr.write(t, \"| \");} stderr.writeln; } }\nalias ll = long, tup = Tuple!(long, \"x\", long, \"y\");\n"}], "negative_code": [], "src_uid": "5144b9b281ea4087d8334d91c3c8bda4"} {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string read_string() {\n while (tokens.empty) {\n tokens = readln.split;\n }\n auto token = tokens.front;\n tokens.popFront;\n return token;\n }\n \n int read_int() {\n return read_string.to!int;\n }\n\n double read_double() {\n return read_string.to!double;\n }\n string[] tokens;\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // int t = cin.read_int;\n while (t--) {\n double d = cin.read_double;\n double L = cin.read_double;\n double v1 = cin.read_double;\n double v2 = cin.read_double;\n\n double rel_vel = v1 + v2;\n double dist = L - d;\n writefln(\"%.*f\", 18, (dist) / (rel_vel));\n } \n}", "positive_code": [{"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string read_string() {\n while (tokens.empty) {\n tokens = readln.split;\n }\n auto token = tokens.front;\n tokens.popFront;\n return token;\n }\n \n int read_int() {\n return read_string.to!int;\n }\n\n double read_double() {\n return read_string.to!double;\n }\n string[] tokens;\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // int t = cin.read_int;\n while (t--) {\n double d = cin.read_double;\n double L = cin.read_double;\n double v1 = cin.read_double;\n double v2 = cin.read_double;\n\n double rel_vel = v1 + v2 + 0.0;\n double dist = L - d - 0.0;\n writefln(\"%.*f\", 18, (dist) / (rel_vel));\n } \n}"}], "negative_code": [], "src_uid": "f34f3f974a21144b9f6e8615c41830f5"} {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional, std.meta;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.ascii, std.typecons;\n\nvoid main()\n{\n immutable int MD = 10 ^^ 9 + 7;\n int n, m;\n readf(\"%s %s\", &n, &m);\n readln;\n \n int[] dp;\n dp ~= 0;\n dp ~= 2;\n dp ~= 4;\n foreach (i; 3 .. max(n, m) + 1) {\n dp ~= (dp[i-1] + dp[i-2]) % MD;\n }\n \n debug { dp.writeln; }\n \n int ans = (((dp[n] + dp[m] - 2) % MD) + MD) % MD;\n \n ans.writeln;\n}\n", "positive_code": [{"source_code": "import std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nimmutable int mod = 10 ^^ 9 + 7;\nimmutable int limit = 100_005;\n\nvoid main ()\n{\n\tauto f = new int [limit];\n\tf[0] = 1;\n\tf[1] = 1;\n\tforeach (i; 2..limit)\n\t{\n\t\tf[i] = (f[i - 1] + f[i - 2]) % mod;\n\t}\n\n\tint m, n;\n\twhile (readf !(\" %s %s\") (&m, &n) > 0)\n\t{\n\t\tint res = 0;\n\t\tres = (res + f[m]) % mod;\n\t\tres = (res + f[n]) % mod;\n\t\tres = (res + mod - 1) % mod;\n\t\tres = (res * 2) % mod;\n\t\twriteln (res);\n\t}\n}\n"}], "negative_code": [], "src_uid": "0f1ab296cbe0952faa904f2bebe0567b"} {"source_code": "import core.bitop;\nimport std.algorithm;\nimport std.array;\nimport std.bitmanip;\nimport std.container;\nimport std.conv;\nimport std.functional;\nimport std.math;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport std.range.interfaces;\n\nvoid main()\n{\n int n, m;\n readf(\"%s %s\", &n, &m);\n readln;\n \n int [int] cnt;\n readln.chomp.split.map!(to!int).array.each!(x => ++cnt[x]);\n \n debug { cnt.writeln; }\n \n auto okDays = (int days) => cnt.values.map!(x => x / days).sum >= n;\n auto ans = okDays(1) ? (101).iota.dropOne.until!(days => !okDays(days)).array.back : 0;\n \n ans.writeln;\n}", "positive_code": [{"source_code": "import std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nvoid main ()\n{\n\tint n, m;\n\twhile (readf (\" %s %s\", &n, &m) > 0)\n\t{\n\t\treadln;\n\t\tauto a = readln.splitter.map !(to !(int)).array;\n\t\tauto b = new int [101];\n\t\tforeach (c; a)\n\t\t{\n\t\t\tb[c] += 1;\n\t\t}\n\t\tint res = 1;\n\t\twhile (b.map !(x => x / res).sum >= n)\n\t\t{\n\t\t\tres += 1;\n\t\t}\n\t\twriteln (res - 1);\n\t}\n}\n"}, {"source_code": "import std.algorithm,std.conv,std.range,std.stdio;void main(){int r=1,n=readln.split[0].to!int;int[101]b;foreach(c;readln.split)b[c.to!int]++;while(b[].map!(x=>x/r).sum>=n)r++;writeln(r-1);}\n"}, {"source_code": "import std.algorithm, std.conv, std.range, std.stdio;\nvoid main () {\n\tint r = 1, n = readln.split[0].to!int;\n\tint [101] b;\n\tforeach (c; readln.split) b[c.to!int]++;\n\twhile (b[].map !(x => x / r).sum >= n) r++;\n\twriteln (r - 1);\n}\n"}], "negative_code": [], "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe"} {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.datetime.stopwatch;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n\nvoid main()\n{\n int n;\n readf(\"%s\", &n);\n readln;\n\n struct rect { int x1, y1, x2, y2; }\n rect[] rs = new rect[] (n);\n foreach (i; 0 .. n) {\n readf(\"%s %s %s %s\", &rs[i].x1, &rs[i].y1, &rs[i].x2, &rs[i].y2);\n readln;\n }\n \n debug { rs.writeln; }\n \n immutable int INF = 10 ^^ 9;\n int sx1 = INF, sy1 = INF, sx2 = -INF, sy2 = -INF;\n int rectArea = rs.map!(r => (r.y2 - r.y1) * (r.x2 - r.x1)).sum;\n \n foreach (r; rs) {\n sx1 = min(sx1, r.x1);\n sy1 = min(sy1, r.y1);\n sx2 = max(sx2, r.x2);\n sy2 = max(sy2, r.y2);\n }\n\n if (sy2 - sy1 != sx2 - sx1) { \n writeln(\"NO\");\n return;\n }\n\n int area = (sy2 - sy1) * (sx2 - sx1);\n if (area != rectArea) { \n writeln(\"NO\");\n return; \n }\n\n writeln(\"YES\");\n}", "positive_code": [{"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.datetime.stopwatch;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n\nvoid main()\n{\n int n;\n readf(\"%s\", &n);\n readln;\n\n struct rect { int x1, y1, x2, y2; }\n rect[] rs = new rect[] (n);\n foreach (i; 0 .. n) {\n readf(\"%s %s %s %s\", &rs[i].x1, &rs[i].y1, &rs[i].x2, &rs[i].y2);\n readln;\n }\n \n debug { rs.writeln; }\n \n immutable int INF = 10 ^^ 9;\n int sx1 = INF, sy1 = INF, sx2 = -INF, sy2 = -INF;\n \n foreach (r; rs) {\n sx1 = min(sx1, r.x1);\n sy1 = min(sy1, r.y1);\n sx2 = max(sx2, r.x2);\n sy2 = max(sy2, r.y2);\n }\n\n if (sy2 - sy1 != sx2 - sx1) { \n writeln(\"NO\");\n return;\n }\n\n int rectArea = rs.map!(r => (r.y2 - r.y1) * (r.x2 - r.x1)).sum;\n int sqArea = (sy2 - sy1) * (sx2 - sx1);\n if (rectArea != sqArea) { \n writeln(\"NO\");\n return; \n }\n\n writeln(\"YES\");\n}"}, {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.datetime.stopwatch;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n\nvoid main()\n{\n int n;\n readf(\"%s\", &n);\n readln;\n\n struct rect { int x1, y1, x2, y2; }\n rect[] rs = new rect[] (n);\n foreach (i; 0 .. n) {\n readf(\"%s %s %s %s\", &rs[i].x1, &rs[i].y1, &rs[i].x2, &rs[i].y2);\n readln;\n }\n \n debug { rs.writeln; }\n \n immutable int INF = 10 ^^ 9;\n int sx1 = INF, sy1 = INF, sx2 = -INF, sy2 = -INF;\n int rectArea = rs.map!(r => (r.y2 - r.y1) * (r.x2 - r.x1)).sum;\n \n foreach (j; 0 .. n) {\n sx1 = min(sx1, rs[j].x1);\n sy1 = min(sy1, rs[j].y1);\n sx2 = max(sx2, rs[j].x2);\n sy2 = max(sy2, rs[j].y2);\n }\n\n if (sy2 - sy1 != sx2 - sx1) { \n writeln(\"NO\");\n return;\n }\n\n int area = (sy2 - sy1) * (sx2 - sx1);\n if (area != rectArea) { \n writeln(\"NO\");\n return; \n }\n\n writeln(\"YES\");\n}"}, {"source_code": "import std.stdio : write, writeln;\nimport std.array;\nimport std.range;\nimport std.typecons;\nimport std.bigint;\nimport std.algorithm;\n\nconst int INF = 1<<28;\n\nint n;\nint[4][] ps;\nint[2][] p;\nbool ans = false;\n\nvoid make( int depth, int end, int i ){\n\tif( depth == end ){\n\t\tsolve( depth );\n\t\treturn;\n\t}\n\tfor( int j = i; j < n; ++j ){\n\t\tauto tmp = p.clone;\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 3 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 3 ] ];\n\t\tmake( depth + 1, end, j + 1 );\n\t\tassert( tmp !is p );\n\t\tp = tmp.clone;\n\t}\n}\n\nvoid solve( int s ){\n\tbool[int[2]] data;\n\tfor( int i = 0; i < s*4; ++i ){\n\t\tbool f = false;\n\t\tfor( int j = 0; j < s*4; ++j ){\n\t\t\tif( i == j )continue;\n\t\n\t\t\tassert( p[ i ] !is p[ j ] );\n\t\t\tf |= p[ i ] == p[ j ];\n\t\t}\n\t\tif( !f ){\n\t\t\tdata[ p[ i ] ] = true;\n\t\t}\n\t}\n\t\n\tif( data.keys.length == 4 ){\n\t\tint min_x = INF, min_y = INF, max_x = 0, max_y = 0;\n\t\tforeach( v; data.keys ){\n\t\t\tmin_x = min( min_x, v.front );\n\t\t\tmin_y = min( min_y, v.back );\n\t\t\tmax_x = max( max_x, v.front );\n\t\t\tmax_y = max( max_y, v.back );\n\t\t}\n\t\tint[2] cntx, cnty;\n\t\tforeach( v; data.keys ){\n\t\t\tif( v.front == min_x )++cntx[0];\n\t\t\tif( v.front == max_x )++cntx[1];\n\t\t\tif( v.back == min_y )++cnty[0];\n\t\t\tif( v.back == max_y )++cnty[1];\n\t\t}\n\t\tans |= (cntx == [ 2, 2 ] && cnty == [ 2, 2 ] && (max_x - min_x) == (max_y - min_y) );\n\t}\n}\n\nvoid main(){\n\tn = next!int;\n\t\n\tforeach( i; n.iota ){\n\t\tint x1 = next!int;\n\t\tint y1 = next!int;\n\t\t\n\t\tint x2 = next!int;\n\t\tint y2 = next!int;\n\n\t\tps ~= [x1, y1, x2, y2];\n\t}\n\t\n/+\n\tfor( int s = 1; s <= n; ++s ){\n\t\tp = p.init;\n\t\tmake( 0, s, 0 );\n\t}\n+/\n\tp = p.init;\n\tmake( 0, n, 0 );\n\t\n\twriteln = ans ? \"YES\": \"NO\";\n}\n\n\nimport std.stdio : readln;\nimport std.conv : to;\nimport std.string : split, chomp;\nimport std.traits;\nstring[] input;\nstring delim = \" \";\nT next(T)()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.popFront;\n}\nbody\n{\n\treturn input.front.to!T;\n}\n\nT next( T : char )()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.front.popFront;\n}\nbody\n{\n\treturn input.front.front.to!T;\n}\n\n\n\nbool hasNext(){\n\tif(input.length > 0){\n\t\tif(input.front.length == 0){\n\t\t\tinput.popFront;\n\t\t\treturn hasNext;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tstring str = readln;\n\tif(str.length > 0){\n\t\tinput ~= str.chomp.split(delim);\n\t\treturn hasNext;\n\t}else{\n\t\treturn false;\n\t}\n}\n\n\nvoid dbg(T...)(T vs)\n{\n\timport std.stdio : stderr;\n\tforeach(v; vs)\n\t\tstderr.write(v.to!string ~ \" \");\n\tstderr.write(\"\\n\");\n}\n\nT clone(T)(T v){\n\tT v_;\n\tstatic if(isInputRange!(T)){\n\t\tforeach(ite; v){\n\t\t\tv_ ~= ite.clone;\n\t\t}\n\t}else{\n\t\tv_ = v;\n\t}\n\t\n\treturn v_;\n}\n\n"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.exception;\nimport std.functional;\nimport std.math;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\talias Tuple !(long, \"x\", long, \"y\") point;\n\t\talias Tuple !(point, \"a\", point, \"b\") rect;\n\t\tauto r = new rect [n];\n\t\tauto t = rect (point (int.max, int.max),\n\t\t point (int.min, int.min));\n\t\tlong s = 0;\n\t\tforeach (i; 0..n)\n\t\t{\n\t\t\treadf (\" %s %s %s %s\", &r[i].a.x, &r[i].a.y,\n\t\t\t &r[i].b.x, &r[i].b.y);\n\t\t\ts += (r[i].b.x - r[i].a.x) * (r[i].b.y - r[i].a.y);\n\t\t\tt.a.x = min (t.a.x, r[i].a.x);\n\t\t\tt.a.y = min (t.a.y, r[i].a.y);\n\t\t\tt.b.x = max (t.b.x, r[i].b.x);\n\t\t\tt.b.y = max (t.b.y, r[i].b.y);\n\t\t}\n\t\tif (t.b.x - t.a.x == t.b.y - t.a.y &&\n\t\t (t.b.x - t.a.x) * (t.b.y - t.a.y) == s)\n\t\t{\n\t\t\twriteln (\"YES\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\twriteln (\"NO\");\n\t\t}\n\t}\n}\n"}], "negative_code": [{"source_code": "import std.stdio : write, writeln;\nimport std.array;\nimport std.range;\nimport std.typecons;\nimport std.bigint;\nimport std.algorithm;\n\nconst int INF = 1<<28;\n\nvoid main(){\n\tint n = next!int;\n\t\n\tint[4][] ps;\n\tforeach( i; n.iota ){\n\t\tint x1 = next!int;\n\t\tint y1 = next!int;\n\t\t\n\t\tint x2 = next!int;\n\t\tint y2 = next!int;\n\n\t\tps ~= [x1, y1, x2, y2];\n\t}\n\t\n\tbool ans = false;\n\tfor( int s = 0; s <= n; ++s ){\n\t\tint[2][] p;\n\t\tfor( int r = 0; r < s; ++r ){\n\t\t\tp ~= [ ps[ r ][ 0 ], ps[ r ][ 1 ] ];\n\t\t\tp ~= [ ps[ r ][ 2 ], ps[ r ][ 1 ] ];\n\t\t\tp ~= [ ps[ r ][ 0 ], ps[ r ][ 3 ] ];\n\t\t\tp ~= [ ps[ r ][ 2 ], ps[ r ][ 3 ] ];\n\t\t}\n\t\tfor( int k = 0; k < s*4; ++k ){\n\t\t\tfor( int l = k+1; l < s*4; ++l ){\n\t\t\t\tbool[int[2]] data;\n\t\t\t\tfor( int i = 0; i <= k; ++i ){\n\t\t\t\t\tbool f = false;\n\t\t\t\t\tfor( int j = 0; j <= l; ++j ){\n\t\t\t\t\t\tif( i == j )continue;\n\t\t\t\t\n\t\t\t\t\t\tassert( p[ i ] !is p[ j ] );\n\t\t\t\t\t\tf |= p[ i ] == p[ j ];\n\t\t\t\t\t}\n\t\t\t\t\tif( !f ){\n\t\t\t\t\t\tdata[ p[ i ] ] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif( data.keys.length == 4 ){\n\t\t\t\t\tint min_x = INF, min_y = INF, max_x = 0, max_y = 0;\n\t\t\t\t\tforeach( v; data.keys ){\n\t\t\t\t\t\tmin_x = min( min_x, v.front );\n\t\t\t\t\t\tmin_y = min( min_x, v.back );\n\t\t\t\t\t\tmax_x = max( max_x, v.front );\n\t\t\t\t\t\tmax_y = max( max_y, v.back );\n\t\t\t\t\t}\n\t\t\t\t\tint[2] cntx, cnty;\n\t\t\t\t\tforeach( v; data.keys ){\n\t\t\t\t\t\tif( v.front == min_x )++cntx[0];\n\t\t\t\t\t\tif( v.front == max_x )++cntx[1];\n\t\t\t\t\t\tif( v.back == min_y )++cnty[0];\n\t\t\t\t\t\tif( v.back == max_y )++cnty[1];\n\t\t\t\t\t}\n\t\t\t\t\tans |= (cntx == [ 2, 2 ] && cnty == [ 2, 2 ]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\twriteln = ans ? \"YES\": \"NO\";\n}\n\n\nimport std.stdio : readln;\nimport std.conv : to;\nimport std.string : split, chomp;\nimport std.traits;\nstring[] input;\nstring delim = \" \";\nT next(T)()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.popFront;\n}\nbody\n{\n\treturn input.front.to!T;\n}\n\nT next( T : char )()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.front.popFront;\n}\nbody\n{\n\treturn input.front.front.to!T;\n}\n\n\n\nbool hasNext(){\n\tif(input.length > 0){\n\t\tif(input.front.length == 0){\n\t\t\tinput.popFront;\n\t\t\treturn hasNext;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tstring str = readln;\n\tif(str.length > 0){\n\t\tinput ~= str.chomp.split(delim);\n\t\treturn hasNext;\n\t}else{\n\t\treturn false;\n\t}\n}\n\n\nvoid dbg(T...)(T vs)\n{\n\timport std.stdio : stderr;\n\tforeach(v; vs)\n\t\tstderr.write(v.to!string ~ \" \");\n\tstderr.write(\"\\n\");\n}\n\nT clone(T)(T v){\n\tT v_;\n\tstatic if(isInputRange!(T)){\n\t\tforeach(ite; v){\n\t\t\tv_ ~= ite.clone;\n\t\t}\n\t}else{\n\t\tv_ = v;\n\t}\n\t\n\treturn v_;\n}\n\n"}, {"source_code": "import std.stdio : write, writeln;\nimport std.array;\nimport std.range;\nimport std.typecons;\nimport std.bigint;\nimport std.algorithm;\n\nconst int INF = 1<<28;\n\nint n;\nint[4][] ps;\nint[2][] p;\nbool ans = false;\n\nvoid make( int depth, int end, int i ){\n\tif( depth == end ){\n\t\tsolve( depth );\n\t}\n\tfor( int j = i; j < end; ++j ){\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 3 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 3 ] ];\n\t\tmake( depth + 1, end, j + 1 );\n\t}\n}\n\nvoid solve( int s ){\n\tbool[int[2]] data;\n\tfor( int i = 0; i < s*4; ++i ){\n\t\tbool f = false;\n\t\tfor( int j = 0; j < s*4; ++j ){\n\t\t\tif( i == j )continue;\n\t\n\t\t\tassert( p[ i ] !is p[ j ] );\n\t\t\tf |= p[ i ] == p[ j ];\n\t\t}\n\t\tif( !f ){\n\t\t\tdata[ p[ i ] ] = true;\n\t\t}\n\t}\n\tif( data.keys.length == 4 ){\n\t\tint min_ = INF, max_ = 0;\n\t\tforeach( vs; data.keys ){\n\t\t\tforeach( v; vs ){\n\t\t\t\tmin_ = min( min_, v );\n\t\t\t\tmax_ = max( max_, v );\n\t\t\t}\n\t\t}\n\t\tassert( min_ != max_ );\n\t\tint[2] cnt;\n\t\tforeach( vs; data.keys ){\n\t\t\tforeach( v; vs ){\n\t\t\t\tif( v == min_ )++cnt[ 0 ];\n\t\t\t\tif( v == max_ )++cnt[ 1 ];\n\t\t\t}\n\t\t}\n\t\tans |= cnt.front == 4 && cnt.back == 4;\n\t}\n}\n\nvoid main(){\n\tn = next!int;\n\t\n\tforeach( i; n.iota ){\n\t\tint x1 = next!int;\n\t\tint y1 = next!int;\n\t\t\n\t\tint x2 = next!int;\n\t\tint y2 = next!int;\n\n\t\tps ~= [x1, y1, x2, y2];\n\t}\n\t\n\tfor( int s = 1; s <= n; ++s ){\n\t\tp = p.init;\n\t\tmake( 0, s, 0 );\n\t}\n\t\n\twriteln = ans ? \"YES\": \"NO\";\n}\n\n\nimport std.stdio : readln;\nimport std.conv : to;\nimport std.string : split, chomp;\nimport std.traits;\nstring[] input;\nstring delim = \" \";\nT next(T)()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.popFront;\n}\nbody\n{\n\treturn input.front.to!T;\n}\n\nT next( T : char )()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.front.popFront;\n}\nbody\n{\n\treturn input.front.front.to!T;\n}\n\n\n\nbool hasNext(){\n\tif(input.length > 0){\n\t\tif(input.front.length == 0){\n\t\t\tinput.popFront;\n\t\t\treturn hasNext;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tstring str = readln;\n\tif(str.length > 0){\n\t\tinput ~= str.chomp.split(delim);\n\t\treturn hasNext;\n\t}else{\n\t\treturn false;\n\t}\n}\n\n\nvoid dbg(T...)(T vs)\n{\n\timport std.stdio : stderr;\n\tforeach(v; vs)\n\t\tstderr.write(v.to!string ~ \" \");\n\tstderr.write(\"\\n\");\n}\n\nT clone(T)(T v){\n\tT v_;\n\tstatic if(isInputRange!(T)){\n\t\tforeach(ite; v){\n\t\t\tv_ ~= ite.clone;\n\t\t}\n\t}else{\n\t\tv_ = v;\n\t}\n\t\n\treturn v_;\n}\n\n"}, {"source_code": "import std.stdio : write, writeln;\nimport std.array;\nimport std.range;\nimport std.typecons;\nimport std.bigint;\nimport std.algorithm;\n\nconst int INF = 1<<28;\n\nint n;\nint[4][] ps;\nint[2][] p;\nbool ans = false;\n\nvoid make( int depth, int end, int i ){\n\tif( depth == end ){\n\t\tsolve( depth );\n\t\treturn;\n\t}\n\tfor( int j = i; j < n; ++j ){\n\t\tauto tmp = p.clone;\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 3 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 3 ] ];\n\t\tmake( depth + 1, end, j + 1 );\n\t\tassert( tmp !is p );\n\t\tp = tmp.clone;\n\t}\n}\n\nvoid solve( int s ){\n\tbool[int[2]] data;\n\tfor( int i = 0; i < s*4; ++i ){\n\t\tbool f = false;\n\t\tfor( int j = 0; j < s*4; ++j ){\n\t\t\tif( i == j )continue;\n\t\n\t\t\tassert( p[ i ] !is p[ j ] );\n\t\t\tf |= p[ i ] == p[ j ];\n\t\t}\n\t\tif( !f ){\n\t\t\tdata[ p[ i ] ] = true;\n\t\t}\n\t}\n\tif( data.keys.length == 4 ){\n\t\tint min_x = INF, min_y = INF, max_x = 0, max_y = 0;\n\t\tforeach( v; data.keys ){\n\t\t\tmin_x = min( min_x, v.front );\n\t\t\tmin_y = min( min_x, v.back );\n\t\t\tmax_x = max( max_x, v.front );\n\t\t\tmax_y = max( max_y, v.back );\n\t\t}\n\t\tint[2] cntx, cnty;\n\t\tforeach( v; data.keys ){\n\t\t\tif( v.front == min_x )++cntx[0];\n\t\t\tif( v.front == max_x )++cntx[1];\n\t\t\tif( v.back == min_y )++cnty[0];\n\t\t\tif( v.back == max_y )++cnty[1];\n\t\t}\n\t\tans |= (cntx == [ 2, 2 ] && cnty == [ 2, 2 ] && (max_x - min_x) == (max_y - min_y) );\n\t}\n}\n\nvoid main(){\n\tn = next!int;\n\t\n\tforeach( i; n.iota ){\n\t\tint x1 = next!int;\n\t\tint y1 = next!int;\n\t\t\n\t\tint x2 = next!int;\n\t\tint y2 = next!int;\n\n\t\tps ~= [x1, y1, x2, y2];\n\t}\n\t\n\tfor( int s = 1; s <= n; ++s ){\n\t\tp = p.init;\n\t\tmake( 0, s, 0 );\n\t}\n\t\n\twriteln = ans ? \"YES\": \"NO\";\n}\n\n\nimport std.stdio : readln;\nimport std.conv : to;\nimport std.string : split, chomp;\nimport std.traits;\nstring[] input;\nstring delim = \" \";\nT next(T)()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.popFront;\n}\nbody\n{\n\treturn input.front.to!T;\n}\n\nT next( T : char )()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.front.popFront;\n}\nbody\n{\n\treturn input.front.front.to!T;\n}\n\n\n\nbool hasNext(){\n\tif(input.length > 0){\n\t\tif(input.front.length == 0){\n\t\t\tinput.popFront;\n\t\t\treturn hasNext;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tstring str = readln;\n\tif(str.length > 0){\n\t\tinput ~= str.chomp.split(delim);\n\t\treturn hasNext;\n\t}else{\n\t\treturn false;\n\t}\n}\n\n\nvoid dbg(T...)(T vs)\n{\n\timport std.stdio : stderr;\n\tforeach(v; vs)\n\t\tstderr.write(v.to!string ~ \" \");\n\tstderr.write(\"\\n\");\n}\n\nT clone(T)(T v){\n\tT v_;\n\tstatic if(isInputRange!(T)){\n\t\tforeach(ite; v){\n\t\t\tv_ ~= ite.clone;\n\t\t}\n\t}else{\n\t\tv_ = v;\n\t}\n\t\n\treturn v_;\n}\n\n"}, {"source_code": "import std.stdio : write, writeln;\nimport std.array;\nimport std.range;\nimport std.typecons;\nimport std.bigint;\nimport std.algorithm;\n\nconst int INF = 1<<28;\n\nint n;\nint[4][] ps;\nint[2][] p;\nbool ans = false;\n\nvoid make( int depth, int end, int i ){\n\tif( depth == end ){\n\t\tsolve( depth );\n\t}\n\tfor( int j = i; j < end; ++j ){\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 3 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 3 ] ];\n\t\tmake( depth + 1, end, j + 1 );\n\t}\n}\n\nvoid solve( int s ){\n\tfor( int k = 0; k < s*4; ++k ){\n\t\tfor( int l = k+1; l < s*4; ++l ){\n\t\t\tbool[int[2]] data;\n\t\t\tfor( int i = 0; i <= k; ++i ){\n\t\t\t\tbool f = false;\n\t\t\t\tfor( int j = 0; j <= l; ++j ){\n\t\t\t\t\tif( i == j )continue;\n\t\t\t\n\t\t\t\t\tassert( p[ i ] !is p[ j ] );\n\t\t\t\t\tf |= p[ i ] == p[ j ];\n\t\t\t\t}\n\t\t\t\tif( !f ){\n\t\t\t\t\tdata[ p[ i ] ] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif( data.keys.length == 4 ){\n\t\t\t\tint min_x = INF, min_y = INF, max_x = 0, max_y = 0;\n\t\t\t\tforeach( v; data.keys ){\n\t\t\t\t\tmin_x = min( min_x, v.front );\n\t\t\t\t\tmin_y = min( min_x, v.back );\n\t\t\t\t\tmax_x = max( max_x, v.front );\n\t\t\t\t\tmax_y = max( max_y, v.back );\n\t\t\t\t}\n\t\t\t\tint[2] cntx, cnty;\n\t\t\t\tforeach( v; data.keys ){\n\t\t\t\t\tif( v.front == min_x )++cntx[0];\n\t\t\t\t\tif( v.front == max_x )++cntx[1];\n\t\t\t\t\tif( v.back == min_y )++cnty[0];\n\t\t\t\t\tif( v.back == max_y )++cnty[1];\n\t\t\t\t}\n\t\t\t\tans |= (cntx == [ 2, 2 ] && cnty == [ 2, 2 ]);\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid main(){\n\tn = next!int;\n\t\n\tforeach( i; n.iota ){\n\t\tint x1 = next!int;\n\t\tint y1 = next!int;\n\t\t\n\t\tint x2 = next!int;\n\t\tint y2 = next!int;\n\n\t\tps ~= [x1, y1, x2, y2];\n\t}\n\t\n\tfor( int s = 1; s <= n; ++s ){\n\t\tp = p.init;\n\t\tmake( 0, s, 0 );\n\t}\n\t\n\twriteln = ans ? \"YES\": \"NO\";\n}\n\n\nimport std.stdio : readln;\nimport std.conv : to;\nimport std.string : split, chomp;\nimport std.traits;\nstring[] input;\nstring delim = \" \";\nT next(T)()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.popFront;\n}\nbody\n{\n\treturn input.front.to!T;\n}\n\nT next( T : char )()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.front.popFront;\n}\nbody\n{\n\treturn input.front.front.to!T;\n}\n\n\n\nbool hasNext(){\n\tif(input.length > 0){\n\t\tif(input.front.length == 0){\n\t\t\tinput.popFront;\n\t\t\treturn hasNext;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tstring str = readln;\n\tif(str.length > 0){\n\t\tinput ~= str.chomp.split(delim);\n\t\treturn hasNext;\n\t}else{\n\t\treturn false;\n\t}\n}\n\n\nvoid dbg(T...)(T vs)\n{\n\timport std.stdio : stderr;\n\tforeach(v; vs)\n\t\tstderr.write(v.to!string ~ \" \");\n\tstderr.write(\"\\n\");\n}\n\nT clone(T)(T v){\n\tT v_;\n\tstatic if(isInputRange!(T)){\n\t\tforeach(ite; v){\n\t\t\tv_ ~= ite.clone;\n\t\t}\n\t}else{\n\t\tv_ = v;\n\t}\n\t\n\treturn v_;\n}\n\n"}, {"source_code": "import std.stdio : write, writeln;\nimport std.array;\nimport std.range;\nimport std.typecons;\nimport std.bigint;\nimport std.algorithm;\n\nconst int INF = 1<<28;\n\nint n;\nint[4][] ps;\nint[2][] p;\nbool ans = false;\n\nvoid make( int depth, int end, int i ){\n\tif( depth == end ){\n\t\tsolve( depth );\n\t\treturn;\n\t}\n\tfor( int j = i; j < n; ++j ){\n\t\tauto tmp = p.clone;\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 1 ] ];\n\t\tp ~= [ ps[ j ][ 0 ], ps[ j ][ 3 ] ];\n\t\tp ~= [ ps[ j ][ 2 ], ps[ j ][ 3 ] ];\n\t\tmake( depth + 1, end, j + 1 );\n\t\tassert( tmp !is p );\n\t\tp = tmp.clone;\n\t}\n}\n\nvoid solve( int s ){\n\tbool[int[2]] data;\n\tfor( int i = 0; i < s*4; ++i ){\n\t\tbool f = false;\n\t\tfor( int j = 0; j < s*4; ++j ){\n\t\t\tif( i == j )continue;\n\t\n\t\t\tassert( p[ i ] !is p[ j ] );\n\t\t\tf |= p[ i ] == p[ j ];\n\t\t}\n\t\tif( !f ){\n\t\t\tdata[ p[ i ] ] = true;\n\t\t}\n\t}\n\t\n\tif( data.keys.length == 4 ){\n\t\tint min_x = INF, min_y = INF, max_x = 0, max_y = 0;\n\t\tforeach( v; data.keys ){\n\t\t\tmin_x = min( min_x, v.front );\n\t\t\tmin_y = min( min_y, v.back );\n\t\t\tmax_x = max( max_x, v.front );\n\t\t\tmax_y = max( max_y, v.back );\n\t\t}\n\t\tint[2] cntx, cnty;\n\t\tforeach( v; data.keys ){\n\t\t\tif( v.front == min_x )++cntx[0];\n\t\t\tif( v.front == max_x )++cntx[1];\n\t\t\tif( v.back == min_y )++cnty[0];\n\t\t\tif( v.back == max_y )++cnty[1];\n\t\t}\n\t\tans |= (cntx == [ 2, 2 ] && cnty == [ 2, 2 ] && (max_x - min_x) == (max_y - min_y) );\n\t}\n}\n\nvoid main(){\n\tn = next!int;\n\t\n\tforeach( i; n.iota ){\n\t\tint x1 = next!int;\n\t\tint y1 = next!int;\n\t\t\n\t\tint x2 = next!int;\n\t\tint y2 = next!int;\n\n\t\tps ~= [x1, y1, x2, y2];\n\t}\n\t\n\tfor( int s = 1; s <= n; ++s ){\n\t\tp = p.init;\n\t\tmake( 0, s, 0 );\n\t}\n\t\n\twriteln = ans ? \"YES\": \"NO\";\n}\n\n\nimport std.stdio : readln;\nimport std.conv : to;\nimport std.string : split, chomp;\nimport std.traits;\nstring[] input;\nstring delim = \" \";\nT next(T)()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.popFront;\n}\nbody\n{\n\treturn input.front.to!T;\n}\n\nT next( T : char )()\nin\n{\n\tassert(hasNext());\n}\nout\n{\n\tinput.front.popFront;\n}\nbody\n{\n\treturn input.front.front.to!T;\n}\n\n\n\nbool hasNext(){\n\tif(input.length > 0){\n\t\tif(input.front.length == 0){\n\t\t\tinput.popFront;\n\t\t\treturn hasNext;\n\t\t}\n\t\treturn true;\n\t}\n\t\n\tstring str = readln;\n\tif(str.length > 0){\n\t\tinput ~= str.chomp.split(delim);\n\t\treturn hasNext;\n\t}else{\n\t\treturn false;\n\t}\n}\n\n\nvoid dbg(T...)(T vs)\n{\n\timport std.stdio : stderr;\n\tforeach(v; vs)\n\t\tstderr.write(v.to!string ~ \" \");\n\tstderr.write(\"\\n\");\n}\n\nT clone(T)(T v){\n\tT v_;\n\tstatic if(isInputRange!(T)){\n\t\tforeach(ite; v){\n\t\t\tv_ ~= ite.clone;\n\t\t}\n\t}else{\n\t\tv_ = v;\n\t}\n\t\n\treturn v_;\n}\n\n"}, {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.datetime.stopwatch;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n\nvoid main()\n{\n int n;\n readf(\"%s\", &n);\n readln;\n\n struct rect { int x1, y1, x2, y2; }\n rect[] rs = new rect[] (n);\n foreach (i; 0 .. n) {\n readf(\"%s %s %s %s\", &rs[i].x1, &rs[i].y1, &rs[i].x2, &rs[i].y2);\n readln;\n }\n \n debug { rs.writeln; }\n \n immutable int INF = 10 ^^ 9;\n foreach (i; 1 .. (1 << n)) {\n int sx1 = INF, sy1 = INF, sx2 = -INF, sy2 = -INF;\n \n int rectArea = i.bitsSet.map!(x => (rs[x].y2 - rs[x].y1) * (rs[x].x2 - rs[x].x1)).sum;\n \n foreach (j; i.bitsSet) {\n sx1 = min(sx1, rs[j].x1);\n sy1 = min(sy1, rs[j].y1);\n sx2 = max(sx2, rs[j].x2);\n sy2 = max(sy2, rs[j].y2);\n }\n \n if (sy2 - sy1 != sx2 - sx1) { continue; }\n \n int area = (sy2 - sy1) * (sx2 - sx1);\n \n if (area != rectArea) { continue; }\n \n writeln(\"YES\");\n return;\n }\n \n writeln(\"NO\");\n}"}, {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.datetime.stopwatch;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n\nvoid main()\n{\n int n;\n readf(\"%s\", &n);\n readln;\n\n struct rect { int x1, y1, x2, y2; }\n rect[] rs = new rect[] (n);\n foreach (i; 0 .. n) {\n readf(\"%s %s %s %s\", &rs[i].x1, &rs[i].y1, &rs[i].x2, &rs[i].y2);\n readln;\n }\n \n debug { rs.writeln; }\n \n immutable int INF = 10 ^^ 9;\n int sx1 = INF, sy1 = INF, sx2 = -INF, sy2 = -INF;\n int rectArea = rs.map!(r => (r.y2 - r.y1) * (r.x2 - r.x1)).sum;\n \n foreach (j; 0 .. 5) {\n sx1 = min(sx1, rs[j].x1);\n sy1 = min(sy1, rs[j].y1);\n sx2 = max(sx2, rs[j].x2);\n sy2 = max(sy2, rs[j].y2);\n }\n\n if (sy2 - sy1 != sx2 - sx1) { \n writeln(\"NO\");\n return;\n }\n\n int area = (sy2 - sy1) * (sx2 - sx1);\n if (area != rectArea) { \n writeln(\"NO\");\n return; \n }\n\n writeln(\"YES\");\n}"}], "src_uid": "f63fc2d97fd88273241fce206cc217f2"} {"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.string;\n\nint main()\n{\n\treadln();\n\tint l = 'z' - 'a' + 1;\n\tstring line = readln();\n\tline = line.toLower;\n\tint[] letters; letters.length = l;\n\tint sum = 0;\n\tforeach (char x; line)\n\t{\n\t\tint idx = x - 'a';\n\t\tif (idx >= 0 && idx < l)\n\t\t{\n\t\t\tletters[idx] = 1;\n\t\t}\n\t}\n\n\tforeach (int i; 0..l) sum += letters[i];\n\twrite (sum == l ? \"YES\" : \"NO\");\n\treturn 0;\n}", "positive_code": [{"source_code": "import std.ascii;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\n\nbyte n, sum;\n\nvoid main() {\n\n\treadf(\" %s\\n\", &n);\n\n\tauto s = readln.strip;\n\n\tforeach (i; lowercase)\n\t\tif (find(s, i).length != 0 || find(s, std.string.toUpper(i)).length != 0)\n\t\t\t++sum;\n\n\tputs((sum == 26) ? \"YES\" : \"NO\");\n}"}, {"source_code": "import std.ascii;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\n\nbyte n, sum;\n\nvoid main() {\n\t\n\treadf(\" %s\\n\", &n);\n\n\tauto s = readln.strip;\n\n\tforeach (idx, el; lowercase)\n\t\tif (find(s, el).length != 0 || find(s, uppercase[idx]).length != 0)\n\t\t\t++sum;\n\t\n\tputs((sum == 26) ? \"YES\" : \"NO\");\n}"}, {"source_code": "import std.stdio, std.string, std.algorithm;\n\nbyte sum;\n\nvoid main() {\n\n\tint n;\n\treadf(\" %s\\n\", &n);\n\n\tstring a = readln.strip;\n\n\tforeach (immutable i; 'a' .. 'z' + 1)\n\t\tif (count(a, i) || count(a, toUpper(i)))\n\t\t\t++sum;\n\n\twriteln((sum is 26) ? \"YES\" : \"NO\");\n}"}, {"source_code": "import std.stdio;\nimport std.string;\n\nbool isPangram(string str) {\n str = str.toUpper();\n\n uint['Z'-'A'+1] seen;\n foreach (char i; str) {\n seen[i-'A']++;\n }\n\n bool result = true;\n for (int i = 0; i < seen.length && result; ++i) {\n if (seen[i] == 0) {\n result = false;\n }\n }\n\n return result;\n}\n\nunittest {\n assert(!isPangram(\"toosmallword\"));\n assert(isPangram(\"TheQuickBrownFoxJumpsOverTheLazyDog\"));\n}\n\nvoid main() {\n int len;\n string str;\n\n readf(\"%d\\n%s\\n\", &len, &str);\n\n if (isPangram(str)) {\n writeln(\"YES\");\n } else {\n writeln(\"NO\");\n }\n}"}, {"source_code": "import std.stdio: writeln, stdin;\nimport std.string: strip,tr;\nimport std.algorithm.iteration: uniq;\nimport std.algorithm.mutation: copy;\nimport std.algorithm.sorting: sort;\nimport std.array;\n\n\nvoid main()\n{\n stdin.readln;\n auto h = stdin.readln.strip.dup.tr(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwxyz\");\n auto g = cast(ubyte[])h;\n g.sort();\n writeln (g.uniq().array.length == 26 ? \"YES\" : \"NO\" );\n}"}, {"source_code": "//ahmat\nimport core.stdc.stdio:scanf,printf,puts;\nimport core.bitop;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.range;\nimport std.functional;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.container;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\npragma(inline,true);\n\nvoid main(){\n import std.bitmanip:BitArray;\n BitArray b;\n int n=readln.chomp.to!int;\n string s=readln.strip.toLower;\n b.length=26;\n foreach(c;s)\n b[c-'a']=true;\n writeln(b.count<26?\"NO\":\"YES\"); \n}\n\n"}, {"source_code": "import core.thread;\nimport std.conv, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;\n\n//\tInput\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }\nint readInt() { return to!int(readToken); }\nlong readLong() { return to!long(readToken); }\nreal readReal() { return to!real(readToken); }\n\n//\tchmin/chmax\nvoid chmin(T)(ref T t, in T f) { if (t > f) t = f; }\nvoid chmax(T)(ref T t, in T f) { if (t < f) t = f; }\n\n//\tPair\nstruct Pair(S, T) {\n\tS x; T y;\n\tint opCmp( const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tint opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tstring toString() const { return \"(\" ~ to!string(x) ~ \", \" ~ to!string(y) ~ \")\"; }\n}\nauto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); }\n\n//\tArray\nint binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }\nint lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a < val); }); }\nint upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); }\nT[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }\n\n\nint N;\nstring S;\n\nvoid main(string[] args) {\n\ttry {\n\tfor (; ; ) {\n\t\tN = readInt;\n\t\tS = readToken;\n\t\t\n\t\tauto app = new bool[26];\n\t\tforeach (s; S) {\n\t\t\tapp[s.toUpper - 'A'] = true;\n\t\t}\n\t\tconst ans = app.all;\n\t\twriteln(ans ? \"YES\" : \"NO\");\n\t\t\n\t}\n\t} catch (EOFException) {}\n}\n\n"}], "negative_code": [{"source_code": "import std.stdio: writeln, stdin;\nimport std.string: strip,tr;\nimport std.algorithm.searching: any;\nimport std.algorithm.iteration: filter;\nimport std.range;\nimport std.array;\n\n\nvoid main()\n{\n auto h = stdin.readln.strip.dup.tr(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwxyz\");\n auto g = cast(ubyte[])h;\n g = g.filter!\"a>=97 && a<=122\".array;\n ubyte[26] cs;\n auto a = cast(ubyte)'a';\n foreach(e;g ) cs[e-a]++;\n writeln(cs.dup.any!\"a==0\" ? \"NO\" : \"YES\");\n}"}, {"source_code": "import std.stdio: writeln, stdin;\nimport std.string: strip,tr;\nimport std.algorithm.searching: any;\nimport std.range;\nimport std.array;\n\n\nvoid main()\n{\n auto h = stdin.readln.strip.dup.tr(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwxyz\");\n ubyte[26] cs;\n auto a = cast(ubyte)'a';\n foreach(e;h ) cs[(cast(ubyte)e)-a]++;\n writeln(cs.dup.any!\"a==0\" ? \"NO\" : \"YES\");\n}"}, {"source_code": "import std.stdio: writeln, stdin;\nimport std.string: strip,tr;\nimport std.algorithm.searching: any;\nimport std.range;\nimport std.array;\n\n\nvoid main()\n{\n auto h = stdin.readln.strip.dup.tr(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwxyz\");\n auto g = cast(ubyte[])h;\n ubyte[26] cs;\n auto a = cast(ubyte)'a';\n foreach(e;h ) cs[e-a]++;\n writeln(cs.dup.any!\"a==0\" ? \"NO\" : \"YES\");\n}"}, {"source_code": "import std.stdio: writeln, stdin;\nimport std.string: strip,tr;\nimport std.algorithm.iteration: uniq;\nimport std.algorithm.mutation: copy;\nimport std.algorithm.sorting: sort;\nimport std.range;\nimport std.array;\n\n\nvoid main()\n{\n auto h = stdin.readln.strip.dup.tr(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\"abcdefghijklmnopqrstuvwxyz\");\n auto g = cast(ubyte[])h;\n g.sort();\n writeln (g.uniq().array.length == 26 ? \"YES\" : \"NO\" );\n}"}, {"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.string;\n\nint main()\n{\n\treadln();\n\tint l = 'z' - 'a';\n\tstring line = readln();\n\tline = line.toLower;\n\tint[] letters; letters.length = l;\n\tint sum = 0;\n\tforeach (char x; line)\n\t{\n\t\tint idx = x - 'a';\n\t\tif (idx >= 0 && idx < l)\n\t\t{\n\t\t\tletters[idx] = 1;\n\t\t}\n\t}\n\n\tforeach (int i; 0..l) sum += letters[i];\n\twrite (sum == l ? \"YES\" : \"NO\");\n\treturn 0;\n}"}], "src_uid": "f13eba0a0fb86e20495d218fc4ad532d"} {"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.math;\n\nvoid main() {\n auto a = readln.chomp.split.map!(to!double).reduce!(\"a + b\");\n auto b = readln.chomp.split.map!(to!double).reduce!(\"a + b\");\n auto n = readln.chomp.to!double;\n\n if ((a / 5).ceil + (b / 10).ceil <= n)\n writeln(\"YES\");\n else\n writeln(\"NO\");\n}", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\n\nvoid main(){\n int[3] as;\n int[3] bs;\n int n;\n for(int i = 0; i < 3; i++){\n int t;\n readf(\"%s \",&t);\n as[i] = t;\n }\n for(int i = 0; i < 3; i++){\n int t;\n readf(\"%s \",&t);\n bs[i] = t;\n }\n readf(\"%s \",&n);\n if (run(as,bs,n) == 0){\n writefln(\"NO\");\n return;\n }\n writefln(\"YES\");\n}\n\nint suma(int[] x){\n int sum = 0;\n foreach(v;x){\n sum += v;\n }\n return sum;\n}\n\nint run(int[] a, int[] b, int n){\n int sa = suma(a);\n int sb = suma(b);\n int pa = (sa / 5);\n int pb = (sb / 10);\n if (sa % 5 != 0){\n pa++;\n }\n if (sb % 10 != 0){\n pb++;\n }\n if (pa + pb > n){\n return 0;\n }\n return 1;\n}\n\n// TEST CASE AREA\nvoid test_case(){\n int[][] rs;\n\n rs ~= [run([1,1,1],[1,1,1],4),1];\n rs ~= [run([1,1,3],[2,3,4],2),1];\n rs ~= [run([1,0,0],[1,0,0],1),0];\n\n array_assert(rs);\n}\n\nvoid array_assert(int[][] rs){\n uint i = 1;\n bool failed = false;\n\n writefln(\"TEST\");\n\n foreach(int[] r;rs){\n if(r[0] != r[1]){\n failed = true;\n writefln(\"%s Failed %s is NOT %s\",i,r[0],r[1]);\n }\n i++;\n }\n\n if(!failed){\n writefln(\"OK\");\n }\n}\n\nuint[][] numerate(uint[] l){\n uint n = 0;\n uint[][] nl;\n\n foreach(uint x; l){\n nl ~= [x,n];\n n++;\n }\n\n return nl;\n}\n"}, {"source_code": "import std.stdio;\nimport std.c.stdio;\nimport std.algorithm;\nint main(string[] argv)\n{\n\tint a1,a2,a3,b1,b2,b3,n;\n\tscanf(\"%d\",&a1);\n\tscanf(\"%d\",&a2);\n\tscanf(\"%d\",&a3);\n\tscanf(\"%d\",&b1);\n\tscanf(\"%d\",&b2);\n\tscanf(\"%d\",&b3);\n\tscanf(\"%d\",&n);\n\twriteln(((a1+a2+a3+4)/5+(b1+b2+b3+9)/10)<=n? \"YES\":\"NO\");\n return 0;\n}\n"}, {"source_code": "import std.stdio;\nimport std.c.stdio;\nimport std.range;\nimport std.array;\nimport std.functional;\nimport std.algorithm;\nimport std.conv;\nimport std.container;\nimport std.math;\nimport std.numeric;\nimport std.string;\nimport std.c.string;\nimport std.regex;\nimport std.typecons;\n \nvoid main() {\n int a = readln.chomp.split(\" \").map!(to!int).array.reduce!\"a + b\";\n int b = readln.chomp.split(\" \").map!(to!int).array.reduce!\"a + b\";\n int n; scanf(\"%d\\n\", &n);\n\n int x = (a + 4) / 5 + (b + 9) / 10;\n writeln( x <= n ? \"YES\" : \"NO\" );\n}\n"}, {"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.algorithm;\nimport std.math;\nimport std.array;\n\nint main(string[] argv)\n{\n\tint[] a; a.length = 3;\n\tint[] b; b.length = 3;\n\tint n;\n\tscanf(\"%d %d %d\\n%d %d %d\\n%d\", &a[0], &a[1], &a[2], &b[0], &b[1], &b[2], &n);\n\tint as = a[0] + a[1] + a[2];\n\tint bs = b[0] + b[1] + b[2];\n\tint ts = as / 5 + (as % 5 == 0 ? 0 : 1) + bs / 10 + (bs % 10 == 0 ? 0 : 1);\n\twrite (ts <= n ? \"YES\" : \"NO\");\n\treturn 0;\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.bigint;\nimport std.array;\nimport std.ascii;\nimport std.math;\nimport std.numeric;\nimport std.algorithm;\nimport std.container;\nimport core.bitop;\nimport std.conv;\n\nalias Int = long;\n\nvoid main() {\n Int a = readln.split.map!(to!Int).reduce!((a, b) => a + b);\n Int b = readln.split.map!(to!Int).reduce!((a, b) => a + b);\n int n = readln.split.map!(to!int).array[0];\n debug writeln(a);\n debug writeln(b);\n debug writeln(n);\n\n auto rem = new Int[n];\n\n {\n rem[] = 5;\n while ( a > 0 && ! rem.empty ) {\n if ( rem.empty ) {\n writeln(\"NO\");\n return;\n }\n auto d = min(a, 5);\n a -= d;\n rem.front -= d;\n if ( rem.front <= 0 ) {\n rem.popFront();\n }\n }\n if ( ! rem.empty && rem.front < 5 ) {\n rem.popFront();\n }\n }\n\n debug writeln(rem);\n\n {\n rem[] = 10;\n while ( b > 0 && ! rem.empty ) {\n if ( rem.empty ) {\n writeln(\"NO\");\n return;\n }\n auto d = min(b, 10);\n b -= d;\n rem.front -= d;\n if ( rem.front <= 0 ) {\n rem.popFront();\n }\n }\n if ( ! rem.empty && rem.front < 10 ) {\n rem.popFront();\n }\n }\n\n if ( a > 0 || b > 0 ) {\n writeln(\"NO\");\n } else {\n writeln(\"YES\"); \n }\n}\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.bigint;\nimport std.array;\nimport std.ascii;\nimport std.math;\nimport std.numeric;\nimport std.algorithm;\nimport std.container;\nimport core.bitop;\nimport std.conv;\n\nalias Int = long;\n\nvoid main() {\n Int a = readln.split.map!(to!Int).reduce!((a, b) => a + b);\n Int b = readln.split.map!(to!Int).reduce!((a, b) => a + b);\n int n = readln.split.map!(to!int).array[0];\n debug writeln(a);\n debug writeln(b);\n debug writeln(n);\n\n auto rem = new Int[n];\n\n {\n rem[] = 5;\n while ( a > 0 ) {\n if ( rem.empty ) {\n writeln(\"NO\");\n return;\n }\n auto d = min(a, 5);\n a -= d;\n rem.front -= d;\n if ( rem.front <= 0 ) {\n rem.popFront();\n }\n }\n if ( rem.front < 5 ) {\n rem.popFront();\n }\n }\n\n debug writeln(rem);\n\n {\n rem[] = 10;\n while ( b > 0 ) {\n if ( rem.empty ) {\n writeln(\"NO\");\n return;\n }\n auto d = min(b, 10);\n b -= d;\n rem.front -= d;\n if ( rem.front <= 0 ) {\n rem.popFront();\n }\n }\n if ( rem.front < 10 ) {\n rem.popFront();\n }\n }\n\n writeln(\"YES\");\n}\n"}], "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e"} {"source_code": "import std.conv;\nimport std.string;\nimport std.functional;\nimport std.stdio;\nimport std.algorithm;\n\nint main() {\n\tulong fib(ulong n, ulong k, ulong max) {\n\t\talias memoize!fib mfib;\n\t\tif (n < k)\n\t\t\treturn 0;\n\t\telse if (n == k)\n\t\t\treturn 1;\n\t\telse {\n\t\t\tulong ans = 0;\n\t\t\tfor (ulong j = std.algorithm.max(k, n - k); (ans <= max) & (j <= n - 1); ++j) {\n\t\t\t\tans += mfib(j, k, max);\n\t\t\t\tif (ans > max) \n\t\t\t\t\treturn max + 1;\n\t\t\t}\n\t\t\treturn ans;\n\t\t}\n\t}\n\tauto tmp = split(strip(readln()), \" \");\n\tauto s = to!ulong(tmp[0]);\n\tauto k = to!ulong(tmp[1]);\n\t/*ulong ke = k;\n\twhile (fib(ke, k, s) <= s) {\n\t\twrite(fib(ke, k, s), \" \");\n\t\t++ke;\n\t}\n\twriteln();*/\n\tulong[] ans = [];\n\tauto s0 = s;\n\twhile (s > 0) {\n\t\tulong cnt = k;\n\t\twhile (fib(cnt, k, s0) <= s)\n\t\t\t++cnt;\n\t\t--cnt;\n\t\tans ~= fib(cnt, k, s0);\n\t\ts -= fib(cnt, k, s0);\n\t}\n\tif (ans.length == 1)\n\t\tans ~= 0;\n\twriteln(ans.length);\n\tforeach (ulong i; ans)\n\t\twrite(i, \" \");\n\treturn 0;\n}", "positive_code": [{"source_code": "import std.conv;\nimport std.string;\nimport std.functional;\nimport std.stdio;\nimport std.algorithm;\n\nint main() {\n\tuint fib(uint n, uint k) {\n\t\talias memoize!fib mfib;\n\t\tif (n < k)\n\t\t\treturn 0;\n\t\telse if (n == k)\n\t\t\treturn 1;\n\t\telse {\n\t\t\tuint ans = 0;\n\t\t\tfor (uint j = max(k, n - k); j <= n - 1; ++j)\n\t\t\t\tans += mfib(j, k);\n\t\t\treturn ans;\n\t\t}\n\t}\n\tauto tmp = split(strip(readln()), \" \");\n\tauto s = to!uint(tmp[0]);\n\tauto k = to!uint(tmp[1]);\n\tuint[] ans = [];\n\twhile (s > 0) {\n\t\tuint cnt = k;\n\t\twhile (fib(cnt, k) <= s)\n\t\t\t++cnt;\n\t\t--cnt;\n\t\tans ~= fib(cnt, k);\n\t\ts -= fib(cnt, k);\n\t}\n\tif (ans.length == 1)\n\t\tans ~= 0;\n\twriteln(ans.length);\n\tforeach (uint i; ans)\n\t\twrite(i, \" \");\n\treturn 0;\n}"}, {"source_code": "import std.conv;\nimport std.string;\nimport std.functional;\nimport std.stdio;\nimport std.algorithm;\n\nint main() {\n\tint fib(int n, int k) {\n\t\talias memoize!fib mfib;\n\t\tif (n < k)\n\t\t\treturn 0;\n\t\telse if (n == k)\n\t\t\treturn 1;\n\t\telse {\n\t\t\tint ans = 0;\n\t\t\tfor (int j = max(k, n - k); j <= n - 1; ++j)\n\t\t\t\tans += mfib(j, k);\n\t\t\treturn ans;\n\t\t}\n\t}\n\tauto tmp = split(strip(readln()), \" \");\n\tauto s = to!int(tmp[0]);\n\tauto k = to!int(tmp[1]);\n\tint[] ans = [];\n\twhile (s > 0) {\n\t\tint cnt = k;\n\t\twhile (fib(cnt, k) <= s)\n\t\t\t++cnt;\n\t\t--cnt;\n\t\tans ~= fib(cnt, k);\n\t\ts -= fib(cnt, k);\n\t}\n\tif (ans.length == 1)\n\t\tans ~= 0;\n\twriteln(ans.length);\n\tforeach (int i; ans)\n\t\twrite(i, \" \");\n\treturn 0;\n}"}, {"source_code": "import std.conv;\nimport std.string;\nimport std.functional;\nimport std.stdio;\nimport std.algorithm;\n\nint main() {\n\tulong fib(ulong n, ulong k) {\n\t\talias memoize!fib mfib;\n\t\tif (n < k)\n\t\t\treturn 0;\n\t\telse if (n == k)\n\t\t\treturn 1;\n\t\telse {\n\t\t\tulong ans = 0;\n\t\t\tfor (ulong j = max(k, n - k); j <= n - 1; ++j)\n\t\t\t\tans += mfib(j, k);\n\t\t\treturn ans;\n\t\t}\n\t}\n\tauto tmp = split(strip(readln()), \" \");\n\tauto s = to!ulong(tmp[0]);\n\tauto k = to!ulong(tmp[1]);\n\tulong[] ans = [];\n\twhile (s > 0) {\n\t\tulong cnt = k;\n\t\twhile (fib(cnt, k) <= s)\n\t\t\t++cnt;\n\t\t--cnt;\n\t\tans ~= fib(cnt, k);\n\t\ts -= fib(cnt, k);\n\t}\n\tif (ans.length == 1)\n\t\tans ~= 0;\n\twriteln(ans.length);\n\tforeach (ulong i; ans)\n\t\twrite(i, \" \");\n\treturn 0;\n}"}], "negative_code": [], "src_uid": "da793333b977ed179fdba900aa604b52"} {"source_code": "\nimport std.stdio;\n\nvoid main() {\n // writeln(\"hello world!\");\n // int[3] A;\n // foreach (i; 0 .. 3) {\n // readf(\" %s\", &A[i]);\n // }\n // writeln(A);\n // write(A, \"\\n\");\n // writefln(\"%(%s %)\", A);\n int t, s, x;\n readf(\" %s %s %s\\n\", &t, &s, &x);\n // writeln(n, x, y);\n if (t == x) {\n writeln(\"YES\");\n return;\n }\n foreach(k; 1 .. (x + s) / s) {\n if (t + k * s == x || t + k * s + 1 == x) {\n writeln(\"YES\");\n return;\n }\n }\n writeln(\"NO\");\n}\n", "positive_code": [{"source_code": "module main;\nimport std.bigint,std.container,std.array,std.algorithm,std.conv,\n\tstd.functional,std.math,std.numeric,std.string,std.range,std.complex,\n\tstd.typecons,std.regex,std.random,std.uni,std.traits,std.variant;\nimport core.stdc.stdio : freopen;\nimport core.stdc.stdlib : system;\nimport std.stdio;\n//import core.stdc.stdio;\nalias RedBlackTree Rbt;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias BoyerMooreFinder strfind;\nalias mp=make_pair;\nalias bins=binary_search;\nalias orsq=orient_square;\nimmutable int mod=1000000007;\npure nothrow \n{\n\tT lcm (T)(auto ref T a,auto ref T b)\n\t{\n\t\treturn a/gcd(a,b)*b;\n\t}\n\tX binpow(X,Y)(X base,Y exp)\n\t\tif(is(typeof(exp&1)))\n\t{\n\t\tif(exp<0)return X(0);\n\t\tX res=X(1);\n\t\twhile(exp>0)\n\t\t{\n\t\t\tif(exp&1)res*=base;\n\t\t\tbase*=base;\n\t\t\texp>>=1;\n\t\t}\n\t\treturn res;\n\t}\n\tauto binpow(X,Y,Z)(X base,Y exp,in Z mm)\n\t\tif(is(typeof(exp&1)))\n\t{\n\t\tif(mm==0) return binpow(base,exp);\n\t\tif(exp<0)return X(0);\n\t\tauto res=X(1)%mm;\n\t\twhile(exp>0)\n\t\t{\n\t\t\tif(exp&1)res=(res*base)%mm;\n\t\t\tbase*=base;\n\t\t\tbase%=mm;\n\t\t\texp>>=1;\n\t\t}\n\t\treturn res;\n\t}\n\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\tsize_t lowb(T,X)(in T a,auto ref X g) \n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m]1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m] 0)\n{return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX first;\n\tY second;\n\talias first fi;\n\talias second se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t}\n\tthis(this){fi=fi;se=se;}\n\tthis(A,B)(auto ref pair!(A,B) p) if(is(A:X) && is(B:Y))\n\t{\n\t\tfi=p.fi;\n\t\tse=p.se;\n\t}\n\tpair!(X,Y) opAssign(A,B)(pair!(A,B) val)\n\t{\n\t\treturn this=pair!(X,Y)(val);\n\t}\n\tint opCmp(A,B)(in pair!(A,B) s_) const pure nothrow @safe \n\t\tif(is(typeof(s_.fis_.fi);\n\t\tif(cmp!=0)return cmp;\n\t\telse return (0-(ses_.se));\n\t}\n};\npair!(X,Y) make_pair(X,Y)(in X x_,in Y y_) pure nothrow @safe\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nnothrow void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\n@property auto arread(T)(){return readln.split.map!(to!(T)).array;}\nstruct Tree(T,alias arg=\"a+b\")\n{\n\tprivate alias fun=binaryFun!arg;\n\tprivate static const size_t n=size_t.max>>1;\n\tprivate T[size_t] t;\n\tthis(this){t=t.dup;}\n\tthis(R)(R range) if(isInputRange!R && is(ElementType!(R) : T))\n\t{\n\t\tforeach(pos,i;range) upd(pos,i);\n\t}\n\tthis(R,alias f)(Tree!(R,f) q) if(is(R:T))\n\t{\n\t\tforeach(i,j;q.t)\n\t\t{\n\t\t\tt[i]=j;\n\t\t}\n\t}\n\tTree!(T,arg) opAssign(R)(R val)\n\t{\n\t\treturn this=Tree!(T,arg)(val);\n\t}\n\tprivate void upd(in size_t v,in size_t vl,in size_t vr,in size_t i,in T x)\n\t{\n\t\tif (vr - vl == 1){t[v] = x;return;}\n\t\tsize_t vm = (vl + vr) >> 1;\n\t\tif(i < vm) upd(2*v, vl, vm, i, x);\n\t\telse upd(2*v+1, vm, vr, i, x);\n\t\tif(v*2+1 !in t)t[v]=t[v*2];\n\t\telse if (v*2 !in t)t[v]=t[v*2+1];\n\t\telse t[v]=fun(t[v*2],t[v*2+1]);\n\t}\n\tvoid upd(in size_t i,in T x)\n\t{\n\t\tupd(1,0,n,i,x);\n\t}\n\tprivate T cel(in size_t v,in size_t vl,in size_t vr,in size_t l,in size_t r)\n\t{\n\t\tif(vl==l && r==vr) return t[v];\n\t\tsize_t vm=(vl+vr) >> 1;\n\t\tif(r<=vm) return cel(2*v,vl,vm,l,r);\n\t\telse if(l>=vm) return cel(2*v+1,vm,vr,l,r);\n\t\telse return fun(cel(2*v,vl,vm,l,vm),cel(2*v+1,vm,vr,vm,r));\n\t}\n\tT cel(in size_t l,in size_t r){return cel(1,0,n,l,r);}\n};\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold schwartzSort multiSort partialSort heapify join filter countUntil\n//---------------------------------------------------------------program beginning-----------------------------------------------------------------\n\nvoid main()\n{\n\tint t,x,s;\n\tloop:while(input(&t,&s,&x))\n\t{\n\t\tif(x==t ||(x>=t+s && (x-t)%s<=1))writeln(\"YES\");\n\t\telse writeln(\"NO\");\n\t}\n}"}], "negative_code": [{"source_code": "\nimport std.stdio;\n\nvoid main() {\n // writeln(\"hello world!\");\n // int[3] A;\n // foreach (i; 0 .. 3) {\n // readf(\" %s\", &A[i]);\n // }\n // writeln(A);\n // write(A, \"\\n\");\n // writefln(\"%(%s %)\", A);\n int t, s, x;\n readf(\" %s %s %s\\n\", &t, &x, &s);\n // writeln(n, x, y);\n if (t == x) {\n writeln(\"YES\");\n return;\n }\n foreach(k; 1 .. (x + s) / s) {\n if (t + k * s == x || t + k * s + 1 == x) {\n writeln(\"YES\");\n return;\n }\n }\n writeln(\"NO\");\n}\n"}], "src_uid": "3baf9d841ff7208c66f6de1b47b0f952"} {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nT[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * (y / gcd(x, y)); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998_244_353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\n\tauto n = RD!int;\n\tauto p = RD!int;\n\tint ans = -1;\n\tforeach (i; 1..33)\n\t{\n\t\tauto x = n - i * p;\n\t\tint cnt, cnt_max;\n\t\tforeach (j; 0..32)\n\t\t{\n\t\t\tauto bit = 1L << j;\n\t\t\tif (x & bit)\n\t\t\t{\n\t\t\t\t++cnt;\n\t\t\t\tcnt_max += 2^^j;\n\t\t\t}\n\t\t}\n\t\tdebug writeln(\"i:\", i, \" x:\", x, \" cnt:\", cnt);\n\t\tif (i >= cnt && i <= cnt_max)\n\t\t{\n\t\t\tans = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\twriteln(ans);\n\tstdout.flush();\n\tdebug readln();\n}", "positive_code": [{"source_code": "\n\n import core.bitop, std.bitmanip;\n import core.checkedint;\n import std.algorithm, std.functional;\n import std.array, std.container;\n import std.bigint;\n import std.conv;\n import std.math, std.numeric;\n import std.range, std.range.interfaces;\n import std.stdio, std.string;\n import std.typecons;\n \n void main()\n { \n int n, p;\n readf(\"%s %s\", &n, &p);\n readln;\n \n foreach (k; 1 .. 32) {\n long s = k.to!long * p;\n long nn = n.to!long - s;\n \n if (nn == 0) {\n continue;\n }\n \n int pcnt = nn > 0 ? nn.popcnt() : (-nn).popcnt();\n if (pcnt <= k && nn >= k) {\n writeln(k);\n return;\n }\n }\n \n writeln(-1);\n return;\n }"}, {"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\nenum LIM = 10^^5;\n\nvoid main() {\n try {\n for (; ; ) {\n const N = readLong();\n const P = readLong();\n \n int ans = LIM;\n foreach (k; 0 .. LIM) {\n const m = N - k * P;\n if (m >= 0) {\n if (popcnt(m) <= k && k <= m) {\n chmin(ans, k);\n }\n }\n }\n writeln((ans >= LIM) ? -1 : ans);\n }\n } catch (EOFException e) {\n }\n}\n"}], "negative_code": [{"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n \nvoid main()\n{ \n int n, p;\n readf(\"%s %s\", &n, &p);\n readln;\n\n foreach (k; 1 .. n/2 + 2) {\n long s = k.to!long * p;\n long nn = n.to!long - s;\n \n if (nn == 0) {\n continue;\n }\n \n int pcnt = nn > 0 ? nn.popcnt() : (-nn).popcnt();\n if (pcnt <= k && nn >= k) {\n writeln(k);\n return;\n }\n }\n \n writeln(-1);\n return;\n}"}, {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n \nvoid main()\n{ \n int n, p;\n readf(\"%s %s\", &n, &p);\n readln;\n\n foreach (k; 1 .. n/2 + 2) {\n int s = k * p;\n long nn = n - s;\n \n if (nn == 0) {\n continue;\n }\n \n int pcnt = nn > 0 ? nn.popcnt() : (-nn).popcnt();\n if (pcnt <= k && nn >= k) {\n writeln(k);\n return;\n }\n }\n \n writeln(-1);\n return;\n}"}, {"source_code": "import core.bitop, std.bitmanip;\nimport core.checkedint;\nimport std.algorithm, std.functional;\nimport std.array, std.container;\nimport std.bigint;\nimport std.conv;\nimport std.math, std.numeric;\nimport std.range, std.range.interfaces;\nimport std.stdio, std.string;\nimport std.typecons;\n \nvoid main()\n{ \n int n, p;\n readf(\"%s %s\", &n, &p);\n readln;\n\n foreach (k; 1 .. n/2 + 2) {\n int s = k * p;\n long nn = n - s;\n \n if (nn > 0 && (nn > 0 ? nn.popcnt() : (-nn).popcnt()) <= k) {\n writeln(k);\n return;\n }\n }\n \n writeln(-1);\n return;\n}"}], "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8"} {"source_code": "//ahmat\nimport core.stdc.stdio:scanf,printf,puts;\nimport core.bitop;\nimport std.stdio;\nimport std.string;\nimport std.ascii;\nimport std.algorithm;\nimport std.range;\nimport std.functional;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.container;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\npragma(inline,true);\n\nvoid main(){\n readln.split.to!(char[]).filter!isDigit.map!\"a-'0'\".array.sort.writefln!\"%(%d+%)\";\n}\n\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.conv;\nimport std.algorithm;\nimport std.array;\n\nvoid main(){\n auto s = readln.strip.split(\"+\").map!(e => e.strip).array;\n s.sort.join(\"+\").writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.range;\n\nvoid main()\n{\n readln\n .strip\n .splitter(\"+\")\n .array\n .sort\n .joiner(\"+\")\n .writeln;\n}"}, {"source_code": "import std.stdio;\nimport std.algorithm.comparison : equal;\nimport std.uni;\nimport std.array;\nimport std.algorithm;\n\nint main(string[] argv)\n{\n\tstring line = stdin.readln();\n\tif (line[line.length - 1] == '\\n')\n\t\tline.length--;\n\n\tstring[] nums = split(line, \"+\");\n\tnums.sort();\n\twritef(\"%s\", nums[0]);\n\tfor (int i = 1; i < nums.length; i++)\n\t{\n\t\twritef(\"+%s\", nums[i]);\n\t}\n\treturn 0;\n}\n"}, {"source_code": "import std.stdio;\nimport std.array;\nimport std.algorithm;\n\nint main() {\n auto s = stdin.byLine;\n foreach (line; s) {\n auto arr = line.split(\"+\");\n writeln(arr.sort().join(\"+\"));\n }\n return 0;\n}"}, {"source_code": "import std.stdio;\n\nvoid main(string[] args) {\n string data = std.stdio.readln();\n data = std.string.stripRight(data);\n\n auto words = std.string.split(data, \"+\");\n \n std.algorithm.sort(words);\n\n auto answer = std.string.join(words, \"+\");\n //foreach(word; words) {\n // std.stdio.writeln(word);\n //}\n\n std.stdio.writeln(answer);\n}\n"}, {"source_code": "// https://codeforces.com/problemset/problem/339/A\nimport std.algorithm;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n readln.strip.splitter(\"+\").array.sort.joiner(\"+\").writeln;\n}\n\n"}, {"source_code": "import std.stdio;\nimport std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.string;\nimport std.regex;\n\nvoid main() {\n readln.chomp.split(\"+\").sort.join(\"+\").writeln;\n}\n"}], "negative_code": [], "src_uid": "76c7312733ef9d8278521cf09d3ccbc8"} {"source_code": "import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;\n\nvoid main()\n{\n auto N = readln.chomp.to!int;\n\n long r;\n foreach (i; 2..N) {\n r += i * (i+1);\n }\n writeln(r);\n}", "positive_code": [{"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.string;\n\nvoid main() {\n auto N = readln.chomp.to!long;\n long ans = 0;\n\n foreach (i; 2..N) ans += i * (i + 1);\n\n ans.writeln;\n}\n"}, {"source_code": "//prewritten code: https://github.com/antma/algo\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.traits;\n\nvoid main() {\n int n;\n readf (\" %d\", &n);\n auto a = new long[][] (n+2, n+2);\n auto c = new int[n + 1];\n foreach (i; 0 .. n + 1) {\n c[i] = i;\n }\n debug stderr.writeln (c);\n long f (int i, int j) {\n if (i == j) return 0;\n assert (i < j);\n if (a[i][j] != 0) return a[i][j]; \n long r = long.max;\n foreach (k; i .. j) {\n //r = max (r, f (i, k) + f (k + 1, j) + c[i-1] * c[k] * c[j]);\n r = min (r, f (i, k) + f (k + 1, j) + (i - 1) * k * j);\n }\n debug stderr.writefln (\"f(%d, %d) = %d\", i, j, r);\n return a[i][j] = r;\n }\n writeln (f (2, n));\n}\n\n"}], "negative_code": [{"source_code": "//prewritten code: https://github.com/antma/algo\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.traits;\n\nvoid main() {\n int n;\n readf (\" %d\", &n);\n if (n == 3) {\n writeln (6);\n return;\n }\n auto a = new long[][] (n+2, n+2);\n auto c = new int[n + 2];\n foreach (i; 0 .. n + 1) {\n c[i] = i;\n }\n c[n+1] = 1;\n debug stderr.writeln (c);\n long f (int i, int j) {\n if (i >= j) {\n j += n;\n }\n if (a[i][j] != 0) return a[i][j]; \n long r;\n if (j == i + 2) {\n r = c[i] * c[i + 1] * c[i + 2];\n } else {\n foreach (k; i + 2 .. j) {\n debug stderr.writefln (\"i = %d, j = %d, k = %d\", i, j, k);\n r = max (r, f (i, k) + f (k, j));\n }\n }\n debug stderr.writefln (\"f(%d, %d) = %d\", i, j, r);\n return a[i][j] = r;\n }\n writeln (f (1, 1));\n}\n\n"}, {"source_code": "//prewritten code: https://github.com/antma/algo\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.traits;\n\nvoid main() {\n int n;\n readf (\" %d\", &n);\n if (n == 3) {\n writeln (6);\n return;\n }\n auto a = new long[][] (n+2, n+2);\n auto c = new int[n + 2];\n foreach (i; 0 .. n + 1) {\n c[i] = i;\n }\n c[n+1] = 1;\n debug stderr.writeln (c);\n long f (int i, int j) {\n if (i >= j) {\n j += n;\n }\n if (a[i][j] != 0) return a[i][j]; \n long r;\n if (j == i + 2) {\n r = c[i] * c[i + 1] * c[i + 2];\n } else {\n foreach (k; i + 2 .. j - 1) {\n debug stderr.writefln (\"i = %d, j = %d, k = %d\", i, j, k);\n r = max (r, f (i, k) + f (k, j));\n }\n }\n debug stderr.writefln (\"f(%d, %d) = %d\", i, j, r);\n return a[i][j] = r;\n }\n writeln (f (1, 1));\n}\n\n"}], "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a"} {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.string;\n\nimmutable long INF = 1L << 59;\n\nvoid main() {\n auto s = readln.split.map!(to!int);\n auto N = s[0];\n auto K = s[1];\n auto A = readln.split.map!(to!int).array;\n int x1 = A.count(1).to!int;\n int x2 = A.count(-1).to!int;\n\n int ans = 0;\n foreach (i; 0..N) {\n int cnt1 = 0, cnt2 = 0;\n foreach (j; 0..N) {\n if (abs(j - i) % K == 0) {\n if (A[j] == 1) cnt1 += 1;\n else cnt2 += 1;\n }\n }\n ans = max(ans, abs((x1 - cnt1) - (x2 - cnt2)));\n }\n\n ans.writeln;\n}\n", "positive_code": [{"source_code": "import std.algorithm;\nimport std.container;\nimport std.conv;\nimport std.format;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nvoid main() {\n int n,k;\n readf!\" %s %s\"(n, k);\n\n int[] a = new int[](n);\n foreach (i; 0 .. n) {\n readf!\" %s\"(a[i]);\n }\n\n int total = a.sum;\n\n int ans = 0;\n foreach (i; 0 .. k) {\n int temp = 0;\n for (int j = i; j < n; j += k) {\n temp += a[j];\n }\n ans = max(ans, (total - temp).abs);\n }\n\n writeln(ans);\n}\n"}], "negative_code": [], "src_uid": "6119258322e06fa6146e592c63313df3"} {"source_code": "import core.thread;\nimport std.conv, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;\n\n//\tInput\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }\nint readInt() { return to!int(readToken); }\nlong readLong() { return to!long(readToken); }\nreal readReal() { return to!real(readToken); }\n\n//\tchmin/chmax\nvoid chmin(T)(ref T t, in T f) { if (t > f) t = f; }\nvoid chmax(T)(ref T t, in T f) { if (t < f) t = f; }\n\n//\tPair\nstruct Pair(S, T) {\n\tS x; T y;\n\tint opCmp( const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tint opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tstring toString() const { return \"(\" ~ to!string(x) ~ \", \" ~ to!string(y) ~ \")\"; }\n}\nauto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); }\n\n//\tArray\nint binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }\nint lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a < val); }); }\nint upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); }\nT[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }\n\n\nimmutable V = 10^^6;\n\nint S, T;\n\nvoid main(string[] args) {\n\ttry {\n\tfor (; ; ) {\n\t\tS = readInt;\n\t\tT = readInt;\n\t\t\n\t\tint[] q;\n\t\tint[] d = new int[V];\n\t\td[] = -1;\n\t\td[S] = 0;\n\t\tq ~= S;\n\t\tfor (; !q.empty; ) {\n\t\t\tconst u = q.front;\n\t\t\tq.popFront;\n\t\t\tforeach (v; [ u * 2, u - 1 ]) if (0 < v && v < V) {\n\t\t\t\tif (d[v] == -1) {\n\t\t\t\t\td[v] = d[u] + 1;\n\t\t\t\t\tq ~= v;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\twriteln(d[T]);\n\t\t\n\t}\n\t} catch (EOFException) {}\n}\n\n", "positive_code": [{"source_code": "import std.stdio;\n\nint bfs(short n, short m) {\n\t\n\tif (n >= m)\n\t\treturn n - m;\n\n\tif (!(m & 1))\n\t\treturn bfs(n, m / 2) + 1;\n\t\n\tif (m & 1)\n\t\treturn bfs(n, (m + 1) / 2) + 2;\n\n\tassert(0);\n}\n\nvoid main() {\n\n\tshort n, m;\n\n\tscanf(\"%hd%hd\", &n, &m);\n\n\twriteln(bfs(n, m));\n}"}, {"source_code": "import std.stdio;\n\nvoid main() {\n\n\tshort n, m;\n\n\tscanf(\"%hd%hd\", &n, &m);\n\n\tint sum;\n\twhile (m > n) {\n\t\tif (!(m & 1))\n\t\t\tm /= 2;\n\t\telse\n\t\t\tm++;\n\t\tsum++;\n\t}\n\n\twriteln(sum + n - m);\n}"}, {"source_code": "import std.stdio;\n\nint bfs(short n, short m) {\n\t\n\tif (n >= m)\n\t\treturn n - m;\n\n\tif (m % 2 == 0)\n\t\treturn bfs(n, m / 2) + 1;\n\t\n\tif (m % 2 == 1)\n\t\treturn bfs(n, (m + 1) / 2) + 2;\n\n\tassert(0);\n}\n\nvoid main() {\n\n\tshort n, m;\n\n\tscanf(\"%hd%hd\", &n, &m);\n\n\twriteln(bfs(n, m));\n}"}, {"source_code": "import std.stdio;\nimport std.container;\nimport std.array;\nimport std.conv;\nimport std.string;\nimport std.algorithm;\n\n\nvoid main()\n{\n auto i = readln.chomp.split.map!\"a.to!int\";\n auto s = DList!int(i[0]);\n auto v = DList!int(0);\n bool [int] visited;\n\n int a,b;\n while (!s.empty && s.front!= i[1]) {\n a = s.front;\n b = v.front;\n s.removeFront();\n v.removeFront();\n if (! (a in visited)) {\n visited[a] = true;\n if (a1) {\n s.insertBack(a-1);\n v.insertBack(b+1);\n }\n\n }\n //writeln(array(s));\n }\n\n writeln(v.front);\n\n}\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.container;\nimport std.array;\nimport std.conv;\nimport std.string;\nimport std.algorithm;\n\n\nvoid main()\n{\n auto i = readln.chomp.split.map!\"a.to!int\";\n auto s = SList!int(i[0]);\n auto v = SList!int(0);\n bool [int] visited;\n\n int a,b;\n while (!s.empty && s.front!= i[1]) {\n a = s.front;\n b = v.front;\n s.removeFront();\n v.removeFront();\n if (! (a in visited)) {\n s.insertFront(a*2);\n v.insertFront(b+1);\n visited[a] = true;\n if (a>0) {\n writeln(\"here\");\n s.insertFront(a-1);\n v.insertFront(b+1);\n }\n }\n }\n\n writeln(v.front);\n\n}\n"}, {"source_code": "import std.stdio;\nimport std.container;\nimport std.array;\nimport std.conv;\nimport std.string;\nimport std.algorithm;\n\n\nvoid main()\n{\n auto i = readln.chomp.split.map!\"a.to!int\";\n auto s = SList!int(i[0]);\n auto v = SList!int(0);\n bool [int] visited;\n\n int a,b;\n while (!s.empty && s.front!= i[1]) {\n a = s.front;\n b = v.front;\n s.removeFront();\n v.removeFront();\n if (! (a in visited)) {\n s.insertFront(a*2);\n v.insertFront(b+1);\n visited[a] = true;\n if (a>0) {\n s.insertFront(a-1);\n v.insertFront(b+1);\n }\n }\n }\n\n writeln(v.front);\n\n}\n"}], "src_uid": "861f8edd2813d6d3a5ff7193a804486f"} {"source_code": "import std.stdio, std.algorithm, std.string;\n\nvoid main()\n{\n readln();\n auto s = readln().strip();\n\n bool ok = true;\n ok &= !canFind(s, \"000\");\n ok &= !canFind(s, \"11\");\n ok &= !s.startsWith(\"00\");\n ok &= !s.endsWith(\"00\");\n ok &= s != \"0\";\n\n writeln(ok ? \"Yes\" : \"No\");\n}", "positive_code": [{"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tforeach (i; 0 .. n - 1)\n\t{\n\t\tif (s[i] == '1' && s[i + 1] == '1')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t\tif (i == 0 && s[i] == '0' && s[i + 1] == '0')\n\t\t\treturn writeln(\"No\");\n\t\tif (i == n - 2 && s[i] == '0' && s[i + 1] == '0')\n\t\t\treturn writeln(\"No\");\n\t\tif (i > 0 && s[i] == '0' && s[i - 1] == '0' && s[i + 1] == '0')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t}\n\tif (n == 1 && s[0] == '0')\n\t\twriteln(\"No\");\n\telse\n\t\twriteln(\"Yes\");\n}\n"}, {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, std.bitmanip, std.regex;\n\nvoid main() {\n auto N = readln.chomp.to!int;\n auto A = readln.chomp;\n\n foreach (i; 0..N-1) {\n if (A[i] == '1' && A[i+1] == '1') {\n writeln(\"No\");\n return;\n }\n }\n\n foreach (i; 0..N) {\n if (A[i] == '1') continue;\n bool ok1 = (i == 0) || (i > 0 && A[i-1] == '0');\n bool ok2 = (i == N-1) || (i < N-1 && A[i+1] == '0');\n if (ok1 && ok2) {\n writeln(\"No\");\n return;\n }\n }\n\n writeln(\"Yes\");\n}\n"}], "negative_code": [{"source_code": "import std.stdio, std.algorithm, std.string;\n\nvoid main()\n{\n readln();\n auto s = readln();\n\n bool ok = true;\n ok &= !canFind(s, \"000\");\n ok &= !canFind(s, \"11\");\n ok &= !s.startsWith(\"00\");\n ok &= !s.endsWith(\"00\");\n\n writeln(ok ? \"Yes\" : \"No\");\n}"}, {"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tforeach (i; 0 .. n - 1)\n\t{\n\t\tif (s[i] == '1' && s[i + 1] == '1')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t\tif (i == 0 && s[i] == '0' && s[i + 1] == '0')\n\t\t\treturn writeln(\"No\");\n\t\tif (i == n - 2 && s[i] == '0' && s[i + 1] == '0')\n\t\t\treturn writeln(\"No\");\n\t\tif (i > 0 && s[i] == '0' && s[i - 1] == '0' && s[i + 1] == '0')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t}\n\twriteln(\"Yes\");\n\n}\n"}, {"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tif (count(s, '1') == (n + 1) / 2)\n\t\twriteln(\"Yes\");\n\telse\n\t\twriteln(\"No\");\n}\n"}, {"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tforeach (i; 0 .. n - 1)\n\t{\n\t\tif (s[i] == '1' && s[i + 1] == '1')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t\tif (i > 0 && s[i] == '0' && s[i - 1] == '0' && s[i + 1] == '0')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t}\n\twriteln(\"Yes\");\n\n}\n"}, {"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tif (n == 2)\n\t\tn++;\n\tif (count(s, '1') == (n + 1) / 2)\n\t\twriteln(\"Yes\");\n\telse\n\t\twriteln(\"No\");\n}\n"}, {"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tif (n == 2)\n\t{\n\t\tif (s[0] == '1' && s[1] == '1')\n\t\t\twriteln(\"Yes\");\n\t\telse\n\t\t\twriteln(\"No\");\n\t\treturn;\n\t}\n\tforeach (i; 0 .. s.length - 1)\n\t{\n\t\tif (s[i] == '1' && s[i + 1] == '1')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t}\n\tif (count(s, '1') == (n + 1) / 2)\n\t\twriteln(\"Yes\");\n\telse\n\t\twriteln(\"No\");\n}\n"}, {"source_code": "import core.bitop, std.algorithm, std.bigint, std.compiler, std.container,\n\tstd.complex, std.bitmanip, std.conv, std.math;\nimport std.numeric : Fft, fft, gcd, inverseFft;\nimport std.random, std.range, std.regex, std.stdio, std.string, std.traits,\n\tstd.typecons, std.uni;\n\nalias pair(X, Y) = Tuple!(X, \"fi\", Y, \"se\");\nalias mp = make_pair;\nalias pii = pair!(int, int);\nalias pll = pair!(long, long);\n// alias gcd = std.numeric.gcd;\nalias lint = long;\nalias rbt = RedBlackTree;\n///modulo\nconst int mod = 10 ^^ 9 + 7, mod2 = mod + 2;\npublic\n{\n\tpure nothrow\n\t{\n\t\t///int length\n\t\tint sz(T)(ref const T a) if (hasLength!T)\n\t\t{\n\t\t\treturn cast(int) a.length;\n\t\t}\n\t\t///make_pair\n\t\tpair!(X, Y) make_pair(X, Y)(in X x_, in Y y_)\n\t\t{\n\t\t\treturn tuple!(X, \"fi\", Y, \"se\")(x_, y_);\n\t\t}\n\t\t///square\n\t\t@property X sqr(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_;\n\t\t}\n\t\t///cube\n\t\t@property X cub(X)(in X a_)\n\t\t{\n\t\t\treturn a_ * a_ * a_;\n\t\t}\n\t\t///posicion lower bound\n\t\tsize_t lowb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).lowerBound(g).length;\n\t\t}\n\t\t///posicion upper bound\n\t\tsize_t upb(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn a.length - assumeSorted(a).upperBound(g).length;\n\t\t}\n\t\t///posicion binary search\n\t\tsize_t binf(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\tauto pos = lowb(a, g);\n\t\t\treturn (g == a[pos]) ? pos : a.length;\n\t\t}\n\t\t///binary search\n\t\tbool binary_search(T, X)(T a, auto ref X g)\n\t\t\t\tif (isRandomAccessRange!T && hasLength!T && is(typeof(g < a[0]) == bool))\n\t\t{\n\t\t\treturn assumeSorted(a).contains(g);\n\t\t}\n\t}\n\tstatic if (version_minor >= 74)\n\t{\n\t\t///read without format\n\t\tbool input(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\treturn readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tconst bool fl = readf!(replicate(\" %s\", ptrs.length))(ptrs) == ptrs.length;\n\t\t\treadln;\n\t\t\treturn fl;\n\t\t}\n\t}\n\telse\n\t{\n\t\t///read without format\n\t\tbool input(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t\t///readln without format\n\t\tbool read(T...)(ref T ptrs) if (ptrs.length > 0)\n\t\t{\n\t\t\tsize_t s;\n\t\t\tforeach (ref e; ptrs)\n\t\t\t{\n\t\t\t\tif (isSomeChar!(Unqual!(typeof(e))))\n\t\t\t\t\ts += readf(\" %c\", &e);\n\t\t\t\telse\n\t\t\t\t\ts += readf(\" %s\", &e);\n\t\t\t}\n\t\t\treadln;\n\t\t\treturn s == ptrs.length;\n\t\t}\n\t}\n\t///opening file\n\tnothrow auto inf(in char* name)\n\t{\n\t\treturn freopen(name, \"r\", core.stdc.stdio.stdin);\n\t}\n\t///closing file\n\tnothrow auto ouf(in char* name)\n\t{\n\t\treturn freopen(name, \"w\", core.stdc.stdio.stdout);\n\t}\n\t///parsing array from line\n\t@property auto arread(T)()\n\t{\n\t\treturn readln.splitter.map!(to!(T)).array;\n\t}\n\t///outbuffer\n\tvoid enter(T...)(T args)\n\t{\n\t\twriteln(args);\n\t\tstdout.flush;\n\t}\n}\n//foreach_reverse isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold return static heapify join filter foreach\n//------------------------------------------program beginning--------------------------\nvoid main()\n{\n\tversion (home)\n\t{\n\t\tassert(freopen(\"input.txt\", \"r\", core.stdc.stdio.stdin));\n\t}\n\tint n;\n\tread(n);\n\tstring s = readln.strip;\n\tforeach (i; 0 .. s.length - 1)\n\t{\n\t\tif (s[i] == '1' && s[i + 1] == '1')\n\t\t{\n\t\t\treturn writeln(\"No\");\n\t\t}\n\t}\n\tif (count(s, '1') == (n + 1) / 2)\n\t\twriteln(\"Yes\");\n\telse\n\t\twriteln(\"No\");\n}\n"}], "src_uid": "c14d255785b1f668d04b0bf6dcadf32d"} {"source_code": "import std.stdio,std.conv,std.array;\n\nvoid main()\n{\n\tint CountLarge = 0,CountSmall = 0;\n\tauto n = readln();\n\tforeach(string s;split(readln(),\" \"))\n\t{\n\t\tuint ui = parse!uint(s);\n\t\tif(ui == 200)CountLarge++; else CountSmall++;\n\t}\n\tif(CountLarge % 2 == 0) CountLarge = 0;\n\telse{\n\t\tif(CountSmall >= 2){\n\t\t\tCountLarge = 0;\n\t\t\tCountSmall -= 2;\n\t\t}else{\n\t\t\twriteln(\"NO\");\n\t\t\treturn;\n\t\t}\n\t}\n\tif(CountSmall % 2 == 0) writeln(\"YES\"); else writeln(\"NO\");\n}", "positive_code": [{"source_code": "import std.stdio,std.conv,std.array;\n\nvoid main()\n{\n\tint CountLarge = 0,CountSmall = 0;\n\tauto n = readln();\n\tforeach(string s;split(readln(),\" \"))\n\t{\n\t\tuint ui = parse!uint(s);\n\t\tif(ui == 200)CountLarge++; else CountSmall++;\n\t}\n\twriteln(((CountSmall % 2 == 1) || ((CountLarge % 2 == 1)&&(CountSmall <= 1)))?\"NO\":\"YES\");\n}"}], "negative_code": [{"source_code": "import std.stdio,std.conv,std.array;\n\nvoid main()\n{\n\tint CountLarge = 0,CountSmall = 0;\n\tauto n = readln();\n\tforeach(string s;split(readln(),\" \"))\n\t{\n\t\tuint ui = parse!uint(s);\n\t\tif(ui == 200)CountLarge++; else CountSmall++;\n\t}\n\t// if(CountLarge % 2 == 0) CountLarge = 0;\n\t// else{\n\t\t// if(CountSmall >= 2){\n\t\t\t// CountLarge = 0;\n\t\t\t// CountSmall -= 2;\n\t\t// }else{\n\t\t\t// writeln(\"NO\");\n\t\t\t// return;\n\t\t// }\n\t// }\n\t// if(CountSmall % 2 == 0) writeln(\"YES\"); else writeln(\"NO\");\n\twriteln(((CountSmall % 2 != 0) || (CountSmall < 2))?\"NO\":\"YES\");\n}"}], "src_uid": "9679acef82356004e47b1118f8fc836a"} {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.stdio;\n\nvoid main() {\n auto s = readln.split.map!(to!int);\n auto N = s[0];\n auto K = s[1];\n auto S = readln.chomp;\n auto F = new int[](26);\n auto L = new int[](26);\n fill(F, 1 << 29);\n\n foreach (i; 0..N) {\n F[S[i] - 'A'] = min(F[S[i] - 'A'], i);\n L[S[i] - 'A'] = max(L[S[i] - 'A'], i);\n }\n\n auto imos = new int[](10^^6 + 100);\n foreach (i; 0..26) if (F[i] != 1 << 29) imos[F[i]] += 1, imos[L[i] + 1] -= 1;\n foreach (i; 0..10^^6 + 50) imos[i + 1] += imos[i];\n\n writeln(imos.reduce!max > K ? \"YES\" : \"NO\");\n}\n", "positive_code": [{"source_code": "// tested by Hightail - https://github.com/dj3500/hightail\nimport std.stdio, std.string, std.conv, std.algorithm;\nimport std.range, std.array, std.math, std.typecons, std.container, core.bitop;\nimport std.datetime, std.bigint;\n\nint n, k;\nstring s;\n\nvoid main() {\n scan(n, k);\n s = readln.chomp;\n\n auto t = new int[](n + 10);\n\n foreach (char ch ; 'A' .. 'Z' + 1) {\n foreach (i ; 0 .. n) {\n if (s[i] == ch) {\n t[i]++;\n break;\n }\n }\n\n foreach_reverse (i ; 0 .. n) {\n if (s[i] == ch) {\n t[i + 1]--;\n break;\n }\n }\n }\n\n foreach (i ; 0 .. n + 1) {\n t[i + 1] += t[i];\n }\n\n debug {\n writeln(t);\n }\n\n if (t.reduce!max > k) {\n writeln(\"YES\");\n }\n else {\n writeln(\"NO\");\n }\n}\n\n\n\n\nvoid scan(T...)(ref T args) {\n string[] line = readln.split;\n foreach (ref arg; args) {\n arg = line.front.to!(typeof(arg));\n line.popFront();\n }\n assert(line.empty);\n}\n\n\nvoid fillAll(R, T)(ref R arr, T value) {\n static if (is(typeof(arr[] = value))) {\n arr[] = value;\n }\n else {\n foreach (ref e; arr) {\n fillAll(e, value);\n }\n }\n}"}], "negative_code": [], "src_uid": "216323563f5b2dd63edc30cb9b4849a5"} {"source_code": "import std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nlong gcd (long a, long b)\n{\n\tif (a == 0)\n\t{\n\t\treturn b;\n\t}\n\treturn gcd (b % a, a);\n}\n\nlong lcm (long a, long b)\n{\n\treturn a / gcd (a, b) * b;\n}\n\nlong solve (int [] p)\n{\n\tint n = cast (int) (p.length);\n\n\tauto q = new int [n];\n\tq[] = -1;\n\tforeach (i; 0..n)\n\t{\n\t\tq[p[i]] = i;\n\t}\n\tif (q.any !(x => x == -1))\n\t{\n\t\treturn -1;\n\t}\n\n\tlong res = 1;\n\tforeach (i; 0..n)\n\t{\n\t\tif (p[i] != -1)\n\t\t{\n\t\t\tint len = 0;\n\t\t\tint k = i;\n\t\t\twhile (p[k] != -1)\n\t\t\t{\n\t\t\t\tint r = k;\n\t\t\t\tk = p[k];\n\t\t\t\tp[r] = -1;\n\t\t\t\tlen += 1;\n\t\t\t}\n\t\t\tif (len % 2 == 0)\n\t\t\t{\n\t\t\t\tlen /= 2;\n\t\t\t}\n\t\t\tres = lcm (res, len);\n\t\t}\n\t}\n\n\treturn res;\n}\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\treadln;\n\t\tauto p = readln.split.map !(to !(int)).array;\n\t\tp[] -= 1;\n\t\twriteln (solve (p));\n\t}\n}\n", "positive_code": [{"source_code": "import std.bigint,std.container,std.array,std.algorithm,std.conv,std.bitmanip,std.functional,std.math,std.numeric,std.string,std.range,std.uni,std.complex,\nstd.typecons,std.regex,std.complex,std.random;\nimport core.stdc.stdio:freopen;\nimport std.stdio;\n//import core.stdc.stdio;\nalias RedBlackTree set;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias BoyerMooreFinder strfind;\nimmutable int mod=1000000007;\nT lcm (T)(T a,T b)\n{\n\treturn a/gcd(a,b)*b;\n}\npure nothrow X binpow(X,Y)(X base,Y exp)\nif(!is(Y==float) && !is(Y==real) && !is(Y==double))\n{\n\tif(exp<0)return X(0);\n\tX res=X(1);\n\twhile(exp>0)\n\t{\n\t\tif(exp&1)res*=base;\n\t\tbase*=base;\n\t\texp>>=1;\n\t}\n\treturn res;\n}\npure nothrow auto binpow(X,Y,Z)(X base,Y exp,in Z mm)\nif(!is(Y==float) && !is(Y==real) && !is(Y==double))\n{\n\tif(mm==0) return binpow(base,exp);\n\tif(exp<0)return X(0);\n\tauto res=X(1)%mm;\n\twhile(exp>0)\n\t{\n\t\tif(exp&1)res=(res*base)%mm;\n\t\tbase*=base;\n\t\tbase%=mm;\n\t\texp>>=1;\n\t}\n\treturn res;\n}\n@property void putarr(X)(X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}\nvoid putarr(X)(X a,in int n,in int m)\n{\n\tforeach(i;0..n)\n\t{\n\t\tforeach(j;0..m)write(a[i][j],' ');\n\t\twriteln;\n\t}\n}\nvoid getarr(X)(X a,in int n){foreach(ref i;a[0..n])input(&i);}\nbool input(T...)(T ptrs) if (ptrs.length > 0) {return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX first;\n\tY second;\n\talias first fi;\n\talias second se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t\t}\n\tthis(this){fi=fi;se=se;}\n\tint opCmp(ref const pair!(X,Y) s_) const pure nothrow\n\t{\n\t\tint cmp=0-(fis_.fi);\n\t\tif(cmp!=0)return cmp;\n\t\telse return (0-(ses_.se));\n\t}\n};\npair!(X,Y) mp(X,Y)(X x_,Y y_) pure nothrow\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nX sqr(X)(X a_) pure nothrow @property @nogc {return a_*a_;}\nX cub(X)(X a_) pure nothrow @property @nogc {return a_*a_*a_;}\nnothrow @nogc @system void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow @nogc @system void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\nauto arread(T)(){return readln.split.map!(to!(T)).array;}\nnothrow pure size_t lowb(T,X)(T a,X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t{\n\t\tauto m=(l+r)>>1;\n\t\tif(!(a[m]1)\n\t{\n\t\tauto m=(l+r)>>1;\n\t\tif(g1)\n\t{\n\t\tauto m=(l+r)>>1;\n\t\tif(!(a[m] q[q[x]] == x))\n\t\t{\n\t\t\treturn res;\n\t\t}\n\t}\n\treturn -1;\n}\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\treadln;\n\t\tauto p = readln.split.map !(to !(int)).array;\n\t\tp[] -= 1;\n\t\twriteln (solve (p));\n\t}\n}\n"}], "src_uid": "149221131a978298ac56b58438df46c9"} {"source_code": "import std.bigint,std.container,std.array,std.algorithm,std.conv,std.bitmanip,std.functional,std.math,std.numeric,std.string,std.range,std.uni,std.complex,\nstd.typecons,std.regex,std.complex,std.random;\nimport core.stdc.stdio:freopen;\nimport std.stdio;\n//import core.stdc.stdio;\nalias RedBlackTree set;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias BoyerMooreFinder strfind;\nimmutable int mod=1000000007;\npure nothrow X binpow(X,Y)(X base,Y exp)\nif(!is(Y==float) && !is(Y==real) && !is(Y==double))\n{\n\tif(exp<0)return X(0);\n\tX res=X(1);\n\twhile(exp>0)\n\t{\n\t\tif(exp&1)res*=base;\n\t\tbase*=base;\n\t\texp>>=1;\n\t}\n\treturn res;\n}\npure nothrow auto binpow(X,Y,Z)(X base,Y exp,in Z mm)\nif(!is(Y==float) && !is(Y==real) && !is(Y==double))\n{\n\tif(mm==0) return binpow(base,exp);\n\tif(exp<0)return X(0);\n\tauto res=X(1)%mm;\n\twhile(exp>0)\n\t{\n\t\tif(exp&1)res=(res*base)%mm;\n\t\tbase*=base;\n\t\tbase%=mm;\n\t\texp>>=1;\n\t}\n\treturn res;\n}\n@property void putarr(X)(X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}\nvoid putarr(X)(X a,in int n,in int m)\n{\n\tforeach(i;0..n)\n\t{\n\t\tforeach(j;0..m)write(a[i][j],' ');\n\t\twriteln;\n\t}\n}\nvoid getarr(X)(X a,in int n){foreach(ref i;a[0..n])input(&i);}\nbool input(T...)(T ptrs) if (ptrs.length > 0) {return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX fi;\n\tY se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t\t}\n\tthis(this){fi=fi;se=se;}\n\tint opCmp(ref const pair!(X,Y) s_) const pure nothrow\n\t{\n\t\tint cmp=0-(fis_.fi);\n\t\tif(cmp!=0)return cmp;\n\t\telse return (0-(ses_.se));\n\t}\n};\npair!(X,Y) mp(X,Y)(X x_,Y y_) pure nothrow\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nX sqr(X)(X a_) pure nothrow @property @nogc {return a_*a_;}\nX cub(X)(X a_) pure nothrow @property @nogc {return a_*a_*a_;}\nnothrow @nogc @system void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow @nogc @system void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\nauto arread(T)(){return readln.split.map!(to!(T)).array;}\nnothrow pure size_t lowb(T,X)(T a,X g) if(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t{\n\t\tauto m=(l+r)>>1;\n\t\tif(!(a[m]1)\n\t{\n\t\tauto m=(l+r)>>1;\n\t\tif(g1)\n\t{\n\t\tauto m=(l+r)>>1;\n\t\tif(!(a[m]0)\n\t{\n\t\tif(exp&1)res*=base;\n\t\tbase*=base;\n\t\texp>>=1;\n\t}\n\treturn res;\n}\npure nothrow @safe auto binpow(X,Y,Z)(X base,Y exp,in Z mm)\nif(!is(Y==float) && !is(Y==real) && !is(Y==double))\n{\n\tif(mm==0) return binpow(base,exp);\n\tif(exp<0)return X(0);\n\tauto res=X(1)%mm;\n\twhile(exp>0)\n\t{\n\t\tif(exp&1)res=(res*base)%mm;\n\t\tbase*=base;\n\t\tbase%=mm;\n\t\texp>>=1;\n\t}\n\treturn res;\n}\n@safe @property void putarr(X)(X a,in char ch=' '){foreach(const ref i;a)write(i,ch);}\n/*@safe @property void putarr(X)(X[][] a)\n{\n\tforeach(i;0..a.length)\n\t{\n\t\tforeach(j;0..a[i].length)write(a[i][j],' ');\n\t\twriteln;\n\t}\n}*/\nvoid getarr(X)(X a,in int n){foreach(ref i;a[0..n])input(&i);}\nbool input(T...)(T ptrs) if (ptrs.length > 0) {return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nstruct pair(X,Y)\n{\n\tX fi;\n\tY se;\n\tthis(X a_,Y b_){\n\t\tfi=a_;\n\t\tse=b_;\n\t\t}\n\tthis(this){fi=fi;se=se;}\n\tint opCmp(ref const pair!(X,Y) s_) const pure nothrow\n\t{\n\t\tint cmp=0-(fis_.fi);\n\t\tif(cmp!=0)return cmp;\n\t\telse return (0-(ses_.se));\n\t}\n};\npair!(X,Y) mp(X,Y)(X x_,Y y_) pure nothrow\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nX sqr(X)(X a_) pure nothrow @safe @property @nogc {return a_*a_;}\nX cub(X)(X a_) pure nothrow @safe @property @nogc {return a_*a_*a_;}\nnothrow @nogc @system void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow @nogc @system void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\nauto arread(T)(){return readln.split.map!(to!(T)).array;}\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin cumulativeFold schwartzSort multiSort partialSort heapify join\n//---------------------------------------------------------------program beginning-----------------------------------------------------------\n\nvoid main()\n{\n\tint n;\n\tinput(&n);\n\twriteln(binpow(1378,n,10));\n}"}], "negative_code": [], "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f"} {"source_code": "import std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nvoid main ()\n{\n\tauto tests = readln.strip.to !(int);\nmultitest_loop:\n\tforeach (test; 0..tests)\n\t{\n\t\tauto s = readln.strip;\n\t\tint res = 0;\n\t\tforeach (d; 1..10)\n\t\t{\n\t\t\tforeach (k; 1..5)\n\t\t\t{\n\t\t\t\tauto t = repeat (cast (char) (d + '0'), k);\n\t\t\t\tres += k;\n\t\t\t\tif (equal (s, t))\n\t\t\t\t{\n\t\t\t\t\twriteln (res);\n\t\t\t\t\tcontinue multitest_loop;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tassert (false);\n\t}\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.conv;\nimport std.string;\n\nint[string] precalc;\n\nvoid main()\n{\n {\n int strokes = 0;\n for (int i = 1; i <= 9; ++i) {\n string key = \"\";\n for (int j = 1; j <= 4; ++j) {\n key ~= i.to!string;\n strokes += j;\n precalc[key] = strokes;\n }\n }\n }\n\n auto t = readln.strip.to!int;\n while (t-- > 0) {\n writeln(precalc[readln.strip]);\n }\n}\n"}, {"source_code": "// Cheese-Cracker: cheese-cracker.github.io\n\nvoid play(){\n int n;\n n = rd!int;\n int dig = n % 10;\n int tim = 0;\n while(n > 0){\n n /= 10;\n ++tim;\n }\n int res = 10*(dig - 1) + (tim*(tim+1))/2;\n writeln(res);\n}\n\nint main(){\n long t = 1;\n t = rd; // Toggle!\n while(t--) play(); // Let's play!\n stdout.flush;\n return 0;\n}\n\n/**********It's A Me Mario!**********/\nimport std.stdio, std.conv, std.functional, std.string, std.algorithm;\nimport std.container, std.range, std.typecons, std.numeric, std.math, std.random;\nstatic string[] inp;\nT rd(T = long)(){while(!inp.length) inp = readln.chomp.split; string a = inp[0]; inp.popFront; return a.to!T;}\nT[] rdarr(T = long)(){ auto r = readln.chomp.split.to!(T[]); return r; }\nvoid show(A...)(A a) { debug{ a.each!(w => write(w, \"| \")); writeln; } }\nalias ll = long;\nalias rbt = redBlackTree;\nalias tup = Tuple!(long, long);\nT max(T = long)(T a, T b){ return (a > b) ? a : b; }\nT min(T = long)(T a, T b){ return (a < b) ? a : b; }\n"}, {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.bigint, std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic File _f;\nvoid file_io(string fn) { _f = File(fn, \"r\"); }\nstatic string[] s_rd;\nT _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nT _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nT[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }\nT[] RDA(T = long)(T fix = 0) { if (_f.isOpen) return _RDA!T(_f, fix); else return _RDA!T(fix); }\n\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nvoid chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nT lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998_244_353;\n//long mod = 1_000_003;\nvoid moda(T)(ref T x, T y) { x = (x + y) % mod; }\nvoid mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(T)(ref T x, T y) { x = (x * y) % mod; }\nvoid modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }\nvoid modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }\n\nvoid main()\n{\n\tauto t = RD!int;\n\tauto ans = new long[](t);\n\tforeach (ti; 0..t)\n\t{\n\t\tauto x = RD!string;\n\n\t\tauto len = x.length;\n\t\tans[ti] = (cast(long)(x[0]-'0')-1)*10 + (len*(len+1)/2);\n\t}\n\n\tforeach (e; ans)\n\t\twriteln(e);\n\tstdout.flush;\n\tdebug readln;\n}\n"}], "negative_code": [], "src_uid": "289a55128be89bb86a002d218d31b57f"} {"source_code": "import std.algorithm;\r\nimport std.conv;\r\nimport std.range;\r\nimport std.stdio;\r\nimport std.string;\r\nimport std.typecons;\r\n\r\nimmutable int mod = 998_244_353;\r\nimmutable int limit = 504;\r\n\r\nvoid main ()\r\n{\r\n\tauto c = new int [] [] (limit, limit);\r\n\tforeach (i; 0..limit)\r\n\t{\r\n\t\tc[i][0] = 1 % mod;\r\n\t\tforeach (j; 1..i + 1)\r\n\t\t{\r\n\t\t\tc[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;\r\n\t\t}\r\n\t}\r\n\r\n\tauto p = new int [] [] (limit, limit);\r\n\tforeach (i; 1..limit)\r\n\t{\r\n\t\tp[i][0] = 1;\r\n\t\tforeach (j; 1..limit)\r\n\t\t{\r\n\t\t\tp[i][j] = (p[i][j - 1] * 1L * i) % mod;\r\n\t\t}\r\n\t}\r\n\r\n\tauto f = new int [] [] (limit, limit);\r\n\tforeach (x; 0..limit)\r\n\t{\r\n\t\tf[0][x] = 1;\r\n\t}\r\n\tforeach (n; 2..limit)\r\n\t{\r\n\t\tforeach (x; 1..limit)\r\n\t\t{\r\n\t\t\tint delta = min (n - 1, x);\r\n\t\t\tint y = x - delta;\r\n\t\t\tforeach (k; 0..n + 1)\r\n\t\t\t{\r\n\t\t\t\tf[n][x] = (f[n][x] + f[k][y] * 1L *\r\n\t\t\t\t (c[n][k] * 1L * p[delta][n - k] %\r\n\t\t\t\t mod)) % mod;\r\n\t\t\t}\r\n\t\t\tdebug {writefln !(\"f[%s][%s] = %s\") (n, x, f[n][x]);}\r\n\t\t}\r\n\t}\r\n\r\n\tint n, x;\r\n\twhile (readf !(\" %s %s\") (n, x) > 0)\r\n\t{\r\n\t\twriteln (f[n][x]);\r\n\t}\r\n}\r\n", "positive_code": [{"source_code": "immutable multi = false;\n\nint n, x;\nimmutable long p = 998244353;\nalias Zp = Z!p;\nZp[][] ways, prePow;\n\nZp getWays(int size, int range)\n{\n\tpragma(inline, true);\n\tassert(size >= 0);\n\tif (range >= 0) return ways[size][range];\n\telse return Zp(size == 0);\n}\n\nZp[][] C = new Zp[][](501, 501);\nstatic this()\n{\n\tC[0][0] = Zp(1);\n\tforeach(size; 1 .. 501)\n\t{\n\t\tC[size][0] = Zp(1);\n\t\tforeach(subsize; 1 .. size + 1)\n\t\t{\n\t\t\tC[size][subsize] = C[size-1][subsize-1] + C[size-1][subsize];\n\t\t}\n\t}\n}\n\nZp calcWays(int size, int range)\n{\n\tpragma(inline, true);\n\tif (size == 0) return Zp(1);\n\tif (size == 1) return Zp(0);\n\tif (range == 0) return Zp(0);\n\tZp ans = Zp(0);\n\tforeach(noDies; 0 .. size + 1)\n\t{\n\t\tZp noWaysDies = prePow[min(range, size - 1)][noDies];\n\t\tnoWaysDies = noWaysDies * C[size][noDies];\n\t\tnoWaysDies = noWaysDies * getWays(size - noDies, range - (size - 1));\n\t\tans = ans + noWaysDies;\n\t}\n\treturn ans;\n}\n\nvoid solve(int tc)\n{\n\tn = readInt!int;\n\tx = readInt!int;\n\tZp.makeFactorials(2 * n);\n\tways = new Zp[][](n+1, x+1);\n\tprePow = new Zp[][](501, 501);\n\tforeach(b; 0 .. 501) prePow[b][0] = Zp(1);\n\tforeach(b; 0 .. 501)\n\t{\n\t\tforeach(ex; 1 .. 501)\n\t\t\tprePow[b][ex] = prePow[b][ex-1] * Zp(b);\n\t}\n\tforeach(size; 0 .. n + 1)\n\t\tforeach(range; 0 .. x + 1)\n\t\t\tways[size][range] = calcWays(size, range);\n\tdebug\n\t{\n\t\tforeach(size; 0 .. n + 1)\n\t\t\tways[size].writeln;\n\t}\n\tways[n][x].rep.writeln;\n}\n\n// modular {{{\nstruct Z(immutable long m)\n{\n\tlong rep;\n\tstatic immutable bool primeModulus = isPrime(m);\n\tstatic Z!m[] fact;\n\tstatic if (primeModulus) { static Z!m[] invFact; }\n\tstatic makeFactorials(int n)\n\t{\n\t\tfact = new Z!m[](n + 1);\n\t\tfact[0] = Z!m(1);\n\t\tforeach(i; 1 .. n + 1) fact[i] = Z!m(i) * fact[i - 1];\n\t\tstatic if (primeModulus)\n\t\t{\n\t\t\tinvFact = new Z!m[](n + 1);\n\t\t\tinvFact[n] = fact[n].inv;\n\t\t\tforeach_reverse(i; 0 .. n) invFact[i] = Z!m(i + 1) * invFact[i + 1];\n\t\t}\n\t}\n\n\tthis(long num)\n\t{\n\t\trep = num;\n\t}\n\n\tZ!m opBinary(string operator)(Z!m rhs)\n\t{\n\t\tstatic if (operator == \"+\")\n\t\t{\n\t\t\tlong result = rhs.rep + this.rep;\n\t\t\tif (result >= m)\n\t\t\t\tresult -= m;\n\t\t\treturn Z!m(result);\n\t\t}\n\t\telse static if (operator == \"-\")\n\t\t{\n\t\t\tlong result = this.rep - rhs.rep;\n\t\t\tif (result < 0)\n\t\t\t\tresult += m;\n\t\t\treturn Z!m(result);\n\t\t}\n\t\telse static if (operator == \"*\")\n\t\t{\n\t\t\tlong result = this.rep * rhs.rep;\n\t\t\tif (result >= m)\n\t\t\t\tresult %= m;\n\t\t\treturn Z!m(result);\n\t\t}\n\t\telse static if (operator == \"/\" && primeModulus)\n\t\t{\n\t\t\tassert(rhs != Z!m(0));\n\t\t\treturn this * rhs.inv;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tstatic assert(text(\"Operator \", operator, \" not supported\"));\n\t\t}\n\t}\n\n\tZ!m opBinary(string operator)(long exponent) if (operator == \"^^\")\n\t{\n\t\tassert(exponent >= 0);\n\t\tZ!m base = this;\n\t\tZ!m result = 1;\n\t\twhile (exponent)\n\t\t{\n\t\t\tif (exponent & 1)\n\t\t\t\tresult = result * base;\n\t\t\tbase = base * base;\n\t\t\texponent >>= 1;\n\t\t}\n\t\treturn result;\n\t}\n\n\tstatic if (primeModulus)\n\t{\n\t\tZ!m inv()\n\t\t{\n\t\t\treturn this^^(m - 2);\n\t\t}\n\t\tstatic Z!m C(int n, int k)\n\t\t{\n\t\t\tif (k < 0 || k > n) return Z!m(0);\n\t\t\treturn fact[n] * invFact[k] * invFact[n - k];\n\t\t}\n\t}\n\n\tinvariant\n\t{\n\t\tassert(rep >= 0 && rep < m);\n\t}\n}\nbool isPrime(long n)\n{\n\tfor(long d = 2; d * d <= n; d++)\n\t\tif (n % d == 0) return false;\n\treturn true; \n}\nunittest\n{\n\talias Zp = Z!23;\n\tstatic assert(Zp.primeModulus);\n\tforeach(i; 1 .. 23) assert(Zp(i) * Zp(i).inv == Zp(1));\n\tZp.makeFactorials(22);\n\tforeach(i; 0 .. 23) assert(Zp.fact[i] * Zp.invFact[i] == Zp(1));\n\tassert(Zp.C(3, 2) == Zp(3));\n\tassert(Zp.C(4, 2) == Zp(6));\n}\n// }}}\n\n\n//{{{\nvoid main()\n{\n\tauto t = multi? readInt!int : 1;\n\tforeach(tc; 0 .. t) solve(tc);\n}\n//}}}\n// input {{{\nint currChar;\nstatic this()\n{\n\tcurrChar = ' ';\n}\n\nchar topChar()\n{\n\treturn cast(char) currChar;\n}\n\nvoid popChar()\n{\n\timport core.stdc.stdio;\n\tcurrChar = getchar();\n}\n\nauto readInt(T)()\n{\n\tT num = 0;\n\tint sgn = 0;\n\twhile (topChar.isWhite)\n\t{\n\t\tpopChar;\n\t}\n\twhile (topChar == '-' || topChar == '+')\n\t{\n\t\tsgn ^= (topChar == '-');\n\t\tpopChar;\n\t}\n\twhile (topChar.isDigit)\n\t{\n\t\tnum *= 10;\n\t\tnum += (topChar - '0');\n\t\tpopChar;\n\t}\n\tif (sgn)\n\t\treturn -num;\n\treturn num;\n}\n\nstring readString()\n{\n\tstring res = \"\";\n\twhile (topChar.isWhite)\n\t\tpopChar;\n\twhile (!topChar.isWhite)\n\t{\n\t\tres ~= topChar;\n\t\tpopChar;\n\t}\n\treturn res;\n}\nvoid writes(T...)(T t)\n{\n\tstatic foreach(i, ti; t)\n\t{\n\t\tstatic if (isIterable!(T[i]))\n\t\t{\n\t\t\tforeach(e; ti)\n\t\t\t{\n\t\t\t\twrite(e, \" \");\n\t\t\t}\n\t\t}\n\t}\n}\nauto ra(V)()\n{\n\tint n = readInt!int;\n\treturn ma(n, readInt!V);\n}\nauto rt(V)()\n{\n\tint n = readInt!int;\n\tint m = readInt!int;\n\treturn ma(n, ma(m, readInt!V));\n}\nauto rbg()\n{\n\tint n = readInt!int;\n\tint m = readInt!int;\n\tauto adj = new int[][](n);\n\tforeach(i; 0 .. m)\n\t{\n\t\tauto u = readInt!int - 1;\n\t\tauto v = readInt!int - 1;\n\t\tadj[u] ~= v;\n\t\tadj[v] ~= u;\n\t}\n\treturn adj;\n}\nauto ma(V)(size_t n, lazy V v)\n{\n\tauto arr = new V[](n);\n\tforeach(ref ai; arr) ai = v;\n\treturn arr;\n}\n// }}}\n// imports {{{\nimport std.stdio;\nimport std.algorithm;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\nimport std.container;\nimport std.range;\nimport std.array;\nimport std.ascii;\n// }}}\n"}], "negative_code": [{"source_code": "immutable multi = true;\n\nvoid solve(int tc)\n{\n\tauto n = readInt!int;\n\tauto m = readInt!int;\n\tauto a = ma(n, ma(m, readInt!int));\n\tauto minmaxL = new Tuple!(int, int)[][](n);\n\tauto minmaxR = new Tuple!(int, int)[][](n);\n\tforeach(i, ref ai; a)\n\t{\n\t\tminmaxL[i] = ai.cumulativeFold!(min, max).array;\n\t\tminmaxR[i] = ai.retro.cumulativeFold!(min, max).array.retro.array;\n\t}\n\tchar[] getConfiguration(int k)\n\t{\n\t\tdebug writeln(\"for k = \", k);\n\t\tstruct Row\n\t\t{\n\t\t\tTuple!(int, int) left, right;\n\t\t}\n\t\tRow[] rows = new Row[](n);\n\t\tforeach(i, ref rowi; rows)\n\t\t{\n\t\t\trowi = Row(minmaxL[i][k], minmaxR[i][k+1]);\n\t\t}\n\t\tdebug writeln(\"rows = \", rows);\n\t\tauto events = new Tuple!(int, int, int)[](2 * n);\n\t\tint evlen = 0;\n\t\tforeach(i, row; rows)\n\t\t{\n\t\t\tevents[evlen++] = tuple(row.left[0], +1, cast(int)i);\n\t\t\tevents[evlen++] = tuple(row.left[1] + 1, -1, cast(int)i);\n\t\t}\n\t\tint pfMinPrev = int.max;\n\t\tint sfMaxPrev = int.min;\n\t\tauto pfMin = new int[](2 * n);\n\t\tauto sfMax = new int[](2 * n);\n\t\tsort(events);\n\t\tdebug writeln(\"events = \", events);\n\t\tdebug writeln(\"evlen = \", evlen);\n\t\tforeach(i, evi; events)\n\t\t{\n\t\t\tif (evi[1] == +1)\n\t\t\t{\n\t\t\t\tpfMinPrev = min(pfMinPrev, rows[evi[2]].right[0]);\n\t\t\t}\n\t\t\tpfMin[i] = pfMinPrev;\n\t\t}\n\t\t\n\t\tforeach_reverse(i, evi; events)\n\t\t{\n\t\t\tif (evi[1] == +1)\n\t\t\t{\n\t\t\t\tsfMaxPrev = max(sfMaxPrev, rows[evi[2]].right[1]);\n\t\t\t}\n\t\t\tsfMax[i] = sfMaxPrev;\n\t\t}\n\t\tdebug writeln(\"pfMin = \", pfMin);\n\t\tdebug writeln(\"sfMax = \", sfMax);\n\t\tint open = 0;\n\t\tint cut = -1;\n\t\tauto color = new char[](n);\n\t\tcolor[] = 'R';\n\t\tforeach(i, evi; events)\n\t\t{\n\t\t\topen += evi[1];\n\t\t\tif (i+1 < events.length && open == 0)\n\t\t\t{\n\t\t\t\tdebug writeln(\"found a cut at i = \", i);\n\t\t\t\tif (pfMin[i] > sfMax[i])\n\t\t\t\t{\n\t\t\t\t\tdebug writeln(\"it's a good cut!\");\n\t\t\t\t\tforeach(j; 0 .. i)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (events[j][1] > 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolor[events[j][2]] = 'B';\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn color;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\tforeach(k; 0 .. m - 1)\n\t{\n\t\tauto config = getConfiguration(k);\n\t\tif (config !is null)\n\t\t{\n\t\t\twriteln(\"YES\");\n\t\t\tconfig.write(\" \");\n\t\t\treturn writeln(k+1);\n\t\t}\n\t}\n\treturn writeln(\"NO\");\n}\n\n//{{{\nvoid main()\n{\n\tauto t = multi? readInt!int : 1;\n\tforeach(tc; 0 .. t) solve(tc);\n}\n//}}}\n// input {{{\nint currChar;\nstatic this()\n{\n\tcurrChar = ' ';\n}\n\nchar topChar()\n{\n\treturn cast(char) currChar;\n}\n\nvoid popChar()\n{\n\timport core.stdc.stdio;\n\tcurrChar = getchar();\n}\n\nauto readInt(T)()\n{\n\tT num = 0;\n\tint sgn = 0;\n\twhile (topChar.isWhite)\n\t{\n\t\tpopChar;\n\t}\n\twhile (topChar == '-' || topChar == '+')\n\t{\n\t\tsgn ^= (topChar == '-');\n\t\tpopChar;\n\t}\n\twhile (topChar.isDigit)\n\t{\n\t\tnum *= 10;\n\t\tnum += (topChar - '0');\n\t\tpopChar;\n\t}\n\tif (sgn)\n\t\treturn -num;\n\treturn num;\n}\n\nstring readString()\n{\n\tstring res = \"\";\n\twhile (topChar.isWhite)\n\t\tpopChar;\n\twhile (!topChar.isWhite)\n\t{\n\t\tres ~= topChar;\n\t\tpopChar;\n\t}\n\treturn res;\n}\nvoid writes(T...)(T t)\n{\n\tstatic foreach(i, ti; t)\n\t{\n\t\tstatic if (isIterable!(T[i]))\n\t\t{\n\t\t\tforeach(e; ti)\n\t\t\t{\n\t\t\t\twrite(e, \" \");\n\t\t\t}\n\t\t}\n\t}\n}\nauto ra(V)()\n{\n\tint n = readInt!int;\n\treturn ma(n, readInt!V);\n}\nauto rt(V)()\n{\n\tint n = readInt!int;\n\tint m = readInt!int;\n\treturn ma(n, ma(m, readInt!V));\n}\nauto rbg()\n{\n\tint n = readInt!int;\n\tint m = readInt!int;\n\tauto adj = new int[][](n);\n\tforeach(i; 0 .. m)\n\t{\n\t\tauto u = readInt!int - 1;\n\t\tauto v = readInt!int - 1;\n\t\tadj[u] ~= v;\n\t\tadj[v] ~= u;\n\t}\n\treturn adj;\n}\nauto ma(V)(size_t n, lazy V v)\n{\n\tauto arr = new V[](n);\n\tforeach(ref ai; arr) ai = v;\n\treturn arr;\n}\n// }}}\n// imports {{{\nimport std.stdio;\nimport std.algorithm;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\nimport std.container;\nimport std.range;\nimport std.array;\nimport std.ascii;\n// }}}\n"}, {"source_code": "import std.algorithm;\r\nimport std.conv;\r\nimport std.range;\r\nimport std.stdio;\r\nimport std.string;\r\nimport std.typecons;\r\n\r\nimmutable int mod = 998_244_353;\r\nimmutable int limit = 504;\r\n\r\nvoid main ()\r\n{\r\n\tauto c = new int [] [] (limit, limit);\r\n\tforeach (i; 0..limit)\r\n\t{\r\n\t\tc[i][0] = 1 % mod;\r\n\t\tforeach (j; 1..i + 1)\r\n\t\t{\r\n\t\t\tc[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;\r\n\t\t}\r\n\t}\r\n\r\n\tauto p = new int [] [] (limit, limit);\r\n\tforeach (i; 1..limit)\r\n\t{\r\n\t\tp[i][0] = 1;\r\n\t\tforeach (j; 1..limit)\r\n\t\t{\r\n\t\t\tp[i][j] = (p[i][j - 1] * 1L * i) % mod;\r\n\t\t}\r\n\t}\r\n\r\n\tauto f = new int [] [] (limit, limit);\r\n\tforeach (x; 0..limit)\r\n\t{\r\n\t\tf[0][x] = 1;\r\n\t}\r\n\tforeach (n; 2..limit)\r\n\t{\r\n\t\tforeach (x; 1..limit)\r\n\t\t{\r\n\t\t\tint delta = min (n - 1, x);\r\n\t\t\tint y = x - delta;\r\n\t\t\tforeach (k; 0..n + 1)\r\n\t\t\t{\r\n\t\t\t\tf[n][x] = (f[n][x] + f[k][y] * 1L *\r\n\t\t\t\t (c[n][k] * 1L * p[delta][n - k]) %\r\n\t\t\t\t mod) % mod;\r\n\t\t\t}\r\n\t\t\tdebug {writefln !(\"f[%s][%s] = %s\") (n, x, f[n][x]);}\r\n\t\t}\r\n\t}\r\n\r\n\tint n, x;\r\n\twhile (readf !(\" %s %s\") (n, x) > 0)\r\n\t{\r\n\t\twriteln (f[n][x]);\r\n\t}\r\n}\r\n"}], "src_uid": "1908d1c8c6b122a4c6633a7af094f17f"} {"source_code": "import std.algorithm, std.array, std.conv, std.stdio, std.string;\n\nvoid main ()\n{\n\tstring s;\n\twhile ((s = readln.strip) != \"\")\n\t{\n\t\tauto a = s.splitter.map !(to !(long)).array;\n\t\tauto n = a.length;\n\t\tlong res = 0;\n\t\tforeach (i; 0..n)\n\t\t{\n\t\t\tauto q = a[i] / n;\n\t\t\tauto r = a[i] % n;\n\t\t\tauto b = a.dup;\n\t\t\tb[i] = 0;\n\t\t\tforeach (j; 0..n)\n\t\t\t{\n\t\t\t\tb[(i + j + 1) % n] += q + (j < r);\n\t\t\t}\n\t\t\tauto cur = b.filter !(x => x % 2 == 0).sum;\n\t\t\tres = max (res, cur);\n\t\t}\n\t\twriteln (res);\n\t}\n}\n", "positive_code": [{"source_code": "import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;\n\nauto rdsp(){return readln.splitter;}\nvoid pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}\nvoid readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}\n\nvoid main()\n{\n long[] a; readA(14, a);\n\n auto ans = 0L;\n foreach (i; 0..14) {\n auto b = a.dup;\n b[i] = 0;\n foreach (j; 0..14)\n b[(i+j+1)%14] += a[i]/14 + (j < a[i]%14);\n\n auto r = 0L;\n foreach (j; 0..14)\n if (b[j]%2 == 0) r += b[j];\n ans = max(ans, r);\n }\n\n writeln(ans);\n}\n"}, {"source_code": "import std.stdio;\nimport std.range;\nimport std.array;\nimport std.string;\nimport std.conv;\nimport std.typecons;\nimport std.algorithm;\nimport std.container;\nimport std.typecons;\nimport std.random;\nimport std.csv;\nimport std.regex;\nimport std.math;\nimport core.time;\nimport std.ascii;\nimport std.digest.sha;\nimport std.outbuffer;\n\nvoid main()\n{\n\tenum N = 14;\n\tlong[] a = readln.chomp.split.map!(to!long).array;\n\tlong ans = 0;\n\tforeach (i, v; a) {\n\t\t// simulate\n\t\tlong[] b = a.dup;\n\t\tb[i] = 0;\n\t\tforeach (j; 0..N) {\n\t\t\tb[cast(uint)((i + j + 1) % N)] += v / N;\n\t\t}\n\t\tforeach (j; 0 .. v % N) {\n\t\t\t++b[cast(uint)((i + j + 1) % N)];\n\t\t}\n\t\tlong sub = 0;\n\t\tforeach (w; b) {\n\t\t\tif (w % 2 == 0) {\n\t\t\t\tsub += w;\n\t\t\t}\n\t\t}\n\t\tans = max(ans, sub);\n\t}\n\tans.writeln;\n}\n\nvoid tie(R, Args...)(R arr, ref Args args)\n\t\tif (isRandomAccessRange!R || isArray!R)\nin\n{\n\tassert (arr.length == args.length);\n}\nbody\n{\n\tforeach (i, ref v; args) {\n\t\talias T = typeof(v);\n\t\tv = arr[i].to!T;\n\t}\n}\n\nvoid verbose(Args...)(in ref Args args)\n{\n\tstderr.write(\"[\");\n\tforeach (i, ref v; args) {\n\t\tif (i) stderr.write(\", \");\n\t\tstderr.write(v);\n\t}\n\tstderr.writeln(\"]\");\n}\n\n"}, {"source_code": "void main(){\n import std.stdio, std.string, std.conv, std.algorithm;\n\n int n=14;\n auto a=readln.split.to!(long[]);\n long ret=0;\n foreach(i; 0..n)if(a[i]>0){\n auto b=a.dup;\n long k=b[i];\n b[i]=0;\n foreach(j; 0..n) b[j]+=k/n;\n for(int j=1; j<=(k%n).to!(int); j++) b[(i+j)%n]+=1;\n long score=0;\n foreach(e; b)if(e%2==0) score+=e;\n ret=max(ret, score);\n }\n writeln(ret);\n}\n\nvoid rd(T...)(ref T x){\n import std.stdio, std.string, std.conv;\n auto l=readln.split;\n assert(l.length==x.length);\n foreach(i, ref e; x) e=l[i].to!(typeof(e));\n}"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main()\n{\n auto a = readln.splitter.map!(to!int).array;\n a ~= a;\n long ans = 0;\n foreach (i; 0..14) {\n auto now = a[i+1..i+1+14].dup;\n \n debug { writeln(now); }\n \n now[$-1] = 0;\n \n auto curVal = (int j, long e) => e + a[i] / 14 + (a[i] % 14 >= j);\n auto vals = now.enumerate(1).map!(x => curVal(x.index, x.value));\n \n debug { writeln(vals); }\n \n ans = max (ans, vals.filter!(x => x % 2 == 0).sum);\n }\n \n writeln (ans);\n}"}], "negative_code": [{"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main()\n{\n auto a = readln.splitter.map!(to!int).array;\n a ~= a;\n long ans = 0;\n foreach (i; 0..14) {\n auto now = a[i+1..i+1+14].dup;\n \n debug { writeln(now); }\n \n now[$-1] = 0;\n \n auto curVal = (int j, int e) => e + a[i] / 14 + (a[i] % 14 >= j);\n auto vals = now.enumerate(1).map!(x => curVal(x.index, x.value));\n \n debug { writeln(vals); }\n \n ans = max (ans, vals.filter!(x => x % 2 == 0).sum);\n }\n \n writeln (ans);\n}"}, {"source_code": "import std.algorithm;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\n\nvoid main()\n{\n auto a = readln.splitter.map!(to!int).array;\n a ~= a;\n int ans = 0;\n foreach (i; 0..14) {\n auto now = a[i+1..i+1+14].dup;\n \n debug { writeln(now); }\n \n now[$-1] = 0;\n \n auto curVal = (int j, int e) => e + a[i] / 14 + (a[i] % 14 >= j);\n auto vals = now.enumerate(1).map!(x => curVal(x.index, x.value));\n \n debug { writeln(vals); }\n \n ans = max (ans, vals.filter!(x => x % 2 == 0).sum);\n }\n \n writeln (ans);\n}"}, {"source_code": "void main(){\n import std.stdio, std.string, std.conv, std.algorithm;\n\n int n=14;\n auto a=readln.split.to!(long[]);\n long ret=0;\n foreach(i; 0..n)if(a[i]>0){\n auto b=a.dup;\n long k=b[i];\n b[i]=0;\n foreach(j; 0..n) b[j]+=k/n;\n for(int j=1; j<=(k%n).to!(int); j++) b[j%n]+=1;\n long score=reduce!((r, e)=>(r+(e%2==0 ? e : 0L)))(0L, b);\n ret=max(ret, score);\n }\n writeln(ret);\n}\n\nvoid rd(T...)(ref T x){\n import std.stdio, std.string, std.conv;\n auto l=readln.split;\n assert(l.length==x.length);\n foreach(i, ref e; x) e=l[i].to!(typeof(e));\n}"}], "src_uid": "1ac11153e35509e755ea15f1d57d156b"} {"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.conv;\nimport std.array;\nimport std.range;\n\nvoid main()\n{\n auto nm = readln.split.map!(to!int);\n auto ts = readln.split.map!(to!int);\n auto count = 0;\n auto d = nm[1]-ts[0];\n foreach(t; ts.dropOne) {\n if (d<0) {\n writeln(-1);\n return;\n } else {\n d-=10;\n count+=2;\n }\n //writef(\"d=%d c=%d \",d,count);\n d-=t;\n }\n if (d<0) {\n writeln(-1);\n return;\n }\n while (d>=10) {\n d-=10;\n count+=2;\n }\n if (d>=5) { count++;}\n writeln(count);\n}\n", "positive_code": [{"source_code": "import core.thread;\nimport std.conv, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;\n\n//\tInput\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }\nint readInt() { return to!int(readToken); }\nlong readLong() { return to!long(readToken); }\nreal readReal() { return to!real(readToken); }\n\n//\tchmin/chmax\nvoid chmin(T)(ref T t, in T f) { if (t > f) t = f; }\nvoid chmax(T)(ref T t, in T f) { if (t < f) t = f; }\n\n//\tPair\nstruct Pair(S, T) {\n\tS x; T y;\n\tint opCmp( const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tint opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tstring toString() const { return \"(\" ~ to!string(x) ~ \", \" ~ to!string(y) ~ \")\"; }\n}\nauto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); }\n\n//\tArray\nint binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }\nint lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a < val); }); }\nint upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); }\nT[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }\n\n\nint N, D;\nint[] A;\n\nvoid main(string[] args) {\n\ttry {\n\tfor (; ; ) {\n\t\tN = readInt;\n\t\tD = readInt;\n\t\tA = new int[N];\n\t\tforeach (i; 0 .. N) {\n\t\t\tA[i] = readInt;\n\t\t}\n\t\t\n\t\tconst x = D - reduce!\"a + b\"(0, A) - 10 * (N - 1);\n\t\tif (x < 0) {\n\t\t\twriteln(-1);\n\t\t} else {\n\t\t\twriteln(x / 5 + 2 * (N - 1));\n\t\t}\n\t}\n\t} catch (EOFException) {}\n}\n\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.conv;\n\nvoid main()\n{\n auto nm = readln.split.map!(to!int);\n auto ts = readln.split.map!(to!int);\n auto count = 0;\n auto d = nm[1];\n foreach(t; ts) {\n d-=t;\n if (d<0) {\n writeln(-1);\n return;\n } else {\n d-=10;\n count+=2;\n }\n }\n if (d>5) { count++;}\n writeln(count);\n}\n"}], "src_uid": "b16f5f5c4eeed2a3700506003e8ea8ea"} {"source_code": "import std.stdio;\nvoid main()\n{\n\tauto q=[\"monday\" : 1,\"tuesday\" : 2,\"wednesday\" : 3,\"thursday\" : 4,\"friday\" : 5,\"saturday\" : 6 ,\"sunday\" : 7];\n\tstring a,b;\n\treadf(\"%s\\n%s\\n\",&a,&b);\n\t//writeln(a);\n\tint x=q[a],y=q[b];\n\tint p;\n\tif(x>y) p=7+y-x;\n\telse p=y-x;\n\tif(p <4 && p!=1)writeln(\"YES\");\n\telse writeln(\"NO\");\n}\n", "positive_code": [{"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\nenum DOWS = [\n\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\"\n];\n\nvoid main() {\n try {\n for (; ; ) {\n const S = readToken();\n const T = readToken();\n \n const s = DOWS.countUntil(S);\n const t = DOWS.countUntil(T);\n bool ans;\n foreach (n; [28, 30, 31]) {\n if ((s + n - t) % 7 == 0) {\n debug {\n writeln(\"ok \", n);\n }\n ans = true;\n }\n }\n writeln(ans ? \"YES\" : \"NO\");\n }\n } catch (EOFException e) {\n }\n}\n"}, {"source_code": "import std.stdio;\nimport std.math;\nimport std.algorithm;\nimport std.range;\nimport std.random;\nimport std.regex;\nimport std.string;\nimport std.numeric;\nimport std.functional;\nimport std.bigint;\nimport std.bitmanip;\nimport std.conv;\nimport std.container;\nalias redBlackTree rbt;\nalias BigInt big;\n//writeln readf readln string wstring dstring delegate function static length\n//double float real foreach immutable assert unittest continue break\n\nvoid main()\n{\n\tint[string] q=[\"monday\" : 1,\"tuesday\" : 2,\"wednesday\" : 3,\"thursday\" : 4,\"friday\" : 5,\"saturday\" : 6 ,\"sunday\" : 7];\n\tstring a=readln,b=readln;\n a=a[0..$-1];\n b=b[0..$-1];\n int x=q[a],y=q[b];\n\tint p;\n\tif(x>y) p=7+y-x;\n\telse p=y-x;\n\tif(p <4 && p!=1)writeln(\"YES\");\n\telse writeln(\"NO\");\n}\n"}, {"source_code": "import std.stdio;\nimport std.math;\nimport std.algorithm;\nimport std.range;\nimport std.random;\nimport std.regex;\nimport std.string;\nimport std.numeric;\nimport std.functional;\nimport std.bigint;\nimport std.bitmanip;\nimport std.conv;\nimport std.container;\nalias redBlackTree rbt;\nalias BigInt big;\n//writeln readf readln string wstring dstring delegate function static length\n//double float real foreach immutable assert unittest continue break\n\nvoid main()\n{\n\tauto q=[\"monday\" : 1,\"tuesday\" : 2,\"wednesday\" : 3,\"thursday\" : 4,\"friday\" : 5,\"saturday\" : 6 ,\"sunday\" : 7];\n\tstring a,b;\n\treadf(\"%s\\n%s\\n\",&a,&b);\n\t//writeln(a);\n\tint x=q[a],y=q[b];\n\tint p;\n\tif(x>y) p=7+y-x;\n\telse p=y-x;\n\tif(p <4 && p!=1)writeln(\"YES\");\n\telse writeln(\"NO\");\n}\n"}], "negative_code": [], "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"} {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic File _f;\nvoid file_io(string fn) { _f = File(fn, \"r\"); }\nstatic string[] s_rd;\nT _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nT _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nT[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }\nT[] RDA(T = long)(T fix = 0) { if (_f.isOpen) return _RDA!T(_f, fix); else return _RDA!T(fix); }\n\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * (y / gcd(x, y)); }\n\n//long mod = 10^^9 + 7;\nlong mod = 998244353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\n\tauto n = RD;\n\tlong[] p;\n\tfor (long i = 2; i*i <= n; ++i)\n\t{\n\t\tif (n % i == 0)\n\t\t{\n\t\t\tp ~= i;\n\t\t\tp ~= n/i;\n\t\t}\n\t}\n\tlong ans = n;\n\tforeach (e; p)\n\t{\n\t\tans = gcd(ans, e);\n\t}\n\n\twriteln(ans);\n\tstdout.flush();\n\tdebug readln();\n}", "positive_code": [{"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\nint root(int[] uf, int u) {\n return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u]));\n}\nbool connect(int[] uf, int u, int v) {\n u = uf.root(u);\n v = uf.root(v);\n if (u == v) return false;\n if (uf[u] > uf[v]) swap(u, v);\n uf[u] += uf[v];\n uf[v] = u;\n return true;\n}\n\n\n\nvoid main() {\n try {\n for (; ; ) {\n const N = readLong();\n \n long[] ds;\n for (long d = 1; d * d <= N; ++d) {\n if (N % d == 0) {\n ds ~= d;\n if (d != N / d) {\n ds ~= N / d;\n }\n }\n }\n ds.sort();\n const dsLen = cast(int)(ds.length);\n debug {\n writeln(\"ds = \", ds);\n }\n if (dsLen <= 2) {\n writeln(N);\n } else {\n const V = cast(int)(ds[1]);\n auto uf = new int[V];\n uf[] = -1;\n foreach (j; 2 .. dsLen) {\n for (int u = 0, v = cast(int)(ds[j] % V); u < V; ++u, ++v %= V) {\n uf.connect(u, v);\n }\n }\n int ans;\n foreach (u; 0 .. V) {\n if (uf[u] < 0) {\n ++ans;\n }\n }\n writeln(ans);\n }\n }\n } catch (EOFException e) {\n }\n}\n"}, {"source_code": "import std.algorithm;\nimport std.conv;\nimport std.numeric;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nvoid main ()\n{\n\tlong n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\tlong res = n;\n\t\tfor (long d = 2; d * d <= n; d++)\n\t\t{\n\t\t\tif (n % d == 0)\n\t\t\t{\n\t\t\t\tres = gcd (res, d);\n\t\t\t\tres = gcd (res, n / d);\n\t\t\t}\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}, {"source_code": "import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;\nimport std.math, std.random, std.bigint, std.datetime, std.format;\nvoid main(string[] args){ if(args.length > 1) if(args[1] == \"-debug\") DEBUG = 1; solve(); }\nvoid log()(){ writeln(\"\"); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, \" \"), log(a); } bool DEBUG = 0; \nstring rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }\nT rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;\nT[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;\nT[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;\n\n// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //\n\nvoid solve(){\n\tlong n = rlong;\n\t\n\tlong[] ds = [n];\n\tfor(long i = 2 ; i * i <= n; i ++){\n\t\tif(n % i == 0) ds ~= i, ds ~= n / i;\n\t}\n\tds.sort();\n\t\n\tforeach(d; ds[1 .. $]){\n\t\tif(d % ds[0] != 0){\n\t\t\t1.writeln;\n\t\t\treturn;\n\t\t}\n\t}\n\tds[0].writeln;\n\treturn;\n}\n"}], "negative_code": [{"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\nint root(int[] uf, int u) {\n return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u]));\n}\nbool connect(int[] uf, int u, int v) {\n u = uf.root(u);\n v = uf.root(v);\n if (u == v) return false;\n if (uf[u] > uf[v]) swap(u, v);\n uf[u] += uf[v];\n uf[v] = u;\n return true;\n}\n\n\n\nvoid main() {\n try {\n for (; ; ) {\n const N = readLong();\n \n long[] ds;\n for (long d = 1; d * d <= N; ++d) {\n if (N % d == 0) {\n ds ~= d;\n if (d != N / d) {\n ds ~= d;\n }\n }\n }\n ds.sort();\n const dsLen = cast(int)(ds.length);\n if (dsLen <= 2) {\n writeln(N);\n } else {\n const V = cast(int)(ds[1]);\n auto uf = new int[V];\n uf[] = -1;\n foreach (j; 2 .. dsLen) {\n for (int u = 0, v = cast(int)(ds[j] % V); u < V; ++u, ++v %= V) {\n uf.connect(u, v);\n }\n }\n int ans;\n foreach (u; 0 .. V) {\n if (uf[u] < 0) {\n ++ans;\n }\n }\n writeln(ans);\n }\n }\n } catch (EOFException e) {\n }\n}\n"}], "src_uid": "f553e89e267c223fd5acf0dd2bc1706b"} {"source_code": "import std.algorithm, std.conv, std.range, std.stdio, std.string;\nvoid main () {\n\tauto n = readln.strip.to!int, a = readln.split.map !(to!int).array;\n\tforeach (d; 0..101) foreach (b; 0..101) if (a.all !(x => [b - d, b, b + d].canFind (x))) {d.write; return;}\n\twrite (-1);\n}\n", "positive_code": [{"source_code": "import std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.stdio;\n\nimmutable int limit = 101;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\treadln;\n\t\tauto a = readln.splitter.map !(to !(int)).array;\n\t\tint res = limit;\n\t\tforeach (base; 0..limit)\n\t\t{\n\t\t\tforeach (diff; 0..limit)\n\t\t\t{\n\t\t\t\tif (a.all !(x => x == base ||\n\t\t\t\t x == base - diff || x == base + diff))\n\t\t\t\t{\n\t\t\t\t\tres = min (res, diff);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (res == limit)\n\t\t{\n\t\t\tres = -1;\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}, {"source_code": "import std.stdio, std.conv, std.string;\nimport std.array, std.range, std.algorithm, std.container;\nimport std.math, std.random, std.bigint, std.datetime, std.format;\nstring read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }\n\nint DEBUG_LEVEL = 0;\nvoid print()(){ writeln(\"\"); }\nvoid print(T, A ...)(T t, lazy A a){ write(t), print(a); }\nvoid print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }\n\nconst long mod = 1_000_000_007;\n\nvoid main(string[] args){\n\tif(args.length > 1 && args[1] == \"-debug\"){\n\t\tif(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;\n\t\telse DEBUG_LEVEL = 1;\n\t}\n\t\n\tint n = read.to!int;\n\tint[] as = readln.chomp.split.map!(to!int).array;\n\t\n\tbool[int] aset;\n\tforeach(a; as) aset[a] = 1;\n\t\n\tint ans;\n\t\n\tint[] ks = aset.keys;\n\tks.sort();\n\tif(ks.length == 1) ans = 0;\n\telse if(ks.length == 2){\n\t\tans = ks[1] - ks[0];\n\t\tif(ans % 2 == 0) ans /= 2;\n\t}\n\telse if(ks.length == 3){\n\t\tif(ks[1] - ks[0] == ks[2] - ks[1]) ans = ks[1] - ks[0];\n\t\telse ans = -1;\n\t}\n\telse ans = -1;\n\t\n\tans.writeln;\n\n}\n/*\n\nHow many different a do they have?\nIf more than 4, impossible.\nIf 3, possible if and only if it is like 1-4-7.\nIf 2 or 1, always possible.\n\n*/\n"}, {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nbool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }\nbool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }\n\nlong mod = 10^^9 + 7;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\t\n\tauto N = RD;\n\tauto a = RDR.ARR;\n\ta = a.sort().uniq.array;\n\n\tif (a.length == 1)\n\t{\n\t\twriteln(0);\n\t}\n\telse if (a.length == 2)\n\t{\n\t\tauto x = a[1] - a[0];\n\t\twriteln(x % 2 == 0 ? x / 2 : x);\n\t}\n\telse if (a.length == 3)\n\t{\n\t\tlong l = a[0];\n\t\tlong m = a[1];\n\t\tlong r = a[2];\n\t\twriteln(m - l == r - m ? m - l : -1);\n\t}\n\telse \n\t{\n\t\twriteln(-1);\n\t}\n\t\n\tstdout.flush();\n\tdebug readln();\n}"}], "negative_code": [{"source_code": "import std.stdio, std.conv, std.string;\nimport std.array, std.range, std.algorithm, std.container;\nimport std.math, std.random, std.bigint, std.datetime, std.format;\nstring read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }\n\nint DEBUG_LEVEL = 0;\nvoid print()(){ writeln(\"\"); }\nvoid print(T, A ...)(T t, lazy A a){ write(t), print(a); }\nvoid print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }\n\nconst long mod = 1_000_000_007;\n\nvoid main(string[] args){\n\tif(args.length > 1 && args[1] == \"-debug\"){\n\t\tif(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;\n\t\telse DEBUG_LEVEL = 1;\n\t}\n\t\n\tint n = read.to!int;\n\tint[] as = readln.chomp.split.map!(to!int).array;\n\t\n\tbool[int] aset;\n\tforeach(a; as) aset[a] = 1;\n\t\n\tint ans;\n\t\n\tint[] ks = aset.keys;\n\tks.sort();\n\tif(ks.length == 1) ans = 0;\n\telse if(ks.length == 2) ans = ks[1] - ks[0];\n\telse if(ks.length == 3){\n\t\tif(ks[1] - ks[0] == ks[2] - ks[1]) ans = ks[1] - ks[0];\n\t\telse ans = -1;\n\t}\n\telse ans = -1;\n\t\n\tans.writeln;\n\n}\n/*\n\nHow many different a do they have?\nIf more than 4, impossible.\nIf 3, possible if and only if it is like 1-4-7.\nIf 2 or 1, always possible.\n\n*/\n"}, {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nbool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }\nbool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }\n\nlong mod = 10^^9 + 7;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\t\n\tauto N = RD;\n\tauto a = RDR.ARR;\n\ta = a.sort().uniq.array;\n\n\tif (a.length == 1)\n\t{\n\t\twriteln(0);\n\t}\n\telse if (a.length == 2)\n\t{\n\t\tauto x = a[1] - a[0];\n\t\twriteln(x % 2 == 0 ? x / 2 : -1);\n\t}\n\telse if (a.length == 3)\n\t{\n\t\tlong l = a[0];\n\t\tlong m = a[1];\n\t\tlong r = a[2];\n\t\twriteln(m - l == r - m ? m - l : -1);\n\t}\n\telse \n\t{\n\t\twriteln(-1);\n\t}\n\t\n\tstdout.flush();\n\tdebug readln();\n}"}], "src_uid": "d486a88939c132848a7efdf257b9b066"} {"source_code": "import std.stdio : writeln;\n\nstruct IO {\n string readToken() {\n import std.stdio : stdin;\n import std.array : split;\n import std.range : empty, front, popFront;\n\n while (tokens.empty) {\n tokens = stdin.readln.split;\n }\n string token = tokens.front;\n tokens.popFront;\n return token;\n }\n\n int readInt() {\n import std.conv : to;\n\n return readToken.to!(int);\n }\n\n string[] tokens;\n}\n\nvoid main() {\n import std.algorithm : min, sort;\n\n IO io;\n int n = io.readInt;\n int[] p = new int[n + 2];\n int target = n >> 1;\n for (int i = 1; i <= n; ++i) {\n p[i] = io.readInt - 1;\n if (~p[i]) {\n if (p[i] &= 1) {\n target--;\n }\n }\n }\n int result = n;\n for (int mask = 0; mask < 1 << 2; ++mask) {\n p[0] = mask & 1, p[n + 1] = mask >> 1;\n int cost = 0, low = 0, high = 0, j = 0, pc = 0, nc = 0;\n int[] positives = new int[n + 1], negatives = new int[n + 1];\n for (int i = 1; i <= n + 1; ++i) {\n if (~p[i]) {\n int length = i - j - 1;\n if (p[i] != p[j]) {\n cost++, high += length;\n }\n else if (p[i]) {\n low += length, high += length, negatives[nc++] = length;\n }\n else {\n positives[pc++] = length;\n }\n j = i;\n }\n }\n positives.sort!(\"a > b\");\n negatives.sort!(\"a > b\");\n for (int i = 0; i < pc && high < target; ++i) {\n cost += 2, high += positives[i];\n }\n for (int i = 0; i < nc && low > target; ++i) {\n cost += 2, low -= negatives[i];\n }\n result = min(result, cost);\n }\n writeln(result);\n}\n", "positive_code": [{"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.bigint, std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic File _f;\nvoid file_io(string fn) { _f = File(fn, \"r\"); }\nstatic string[] s_rd;\nT _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nT _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nT[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }\nT[] RDA(T = long)(T fix = 0) { if (_f.isOpen) return _RDA!T(_f, fix); else return _RDA!T(fix); }\n\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nvoid chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * (y / gcd(x, y)); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998244353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\nvoid modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }\n\nvoid main()\n{\n\tauto n = RD!int;\n\tauto p = RDA!int;\n\t\n\tauto cnt = new int[](2);\n\tcnt[0] = n/2;\n\tcnt[1] = (n+1)/2;\n\tforeach (i; 0..n)\n\t{\n\t\tif (p[i] == 0) continue;\n\t\tauto j = p[i] % 2;\n\t\t--cnt[j];\n\t}\n\n\tauto dp = new int[][][](n+1, n+1, 2);\n\tforeach (i; 0..n+1)\n\t{\n\t\tforeach (j; 0..n+1)\n\t\t\tdp[i][j][] = -1;\n\t}\n\tdp[cnt[0]][cnt[1]][0] = 0;\n\tdp[cnt[0]][cnt[1]][1] = 0;\n\tforeach (i; 0..n)\n\t{\n\t\tauto ndp = new int[][][](n+1, n+1, 2);\n\t\tforeach (j; 0..n+1)\n\t\t{\n\t\t\tforeach (k; 0..n+1)\n\t\t\t\tndp[j][k][] = -1;\n\t\t}\n\t\tforeach (j; 0..n+1)\n\t\t{\n\t\t\tforeach (k; 0..n+1)\n\t\t\t{\n\t\t\t\tforeach (l; 0..2)\n\t\t\t\t{\n\t\t\t\t\tif (dp[j][k][l] == -1) continue;\n\t\t\t\t\tif (p[i] != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tauto eo = p[i] % 2;\n\t\t\t\t\t\tauto num = dp[j][k][l] + (eo != l ? 1 : 0);\n\t\t\t\t\t\tif (ndp[j][k][eo] == -1)\n\t\t\t\t\t\t\tndp[j][k][eo] = num;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tndp[j][k][eo].chmin(num);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (j != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tauto num = dp[j][k][l] + (l != 0 ? 1 : 0);\n\t\t\t\t\t\tif (ndp[j-1][k][0] == -1)\n\t\t\t\t\t\t\tndp[j-1][k][0] = num;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tndp[j-1][k][0].chmin(num);\n\t\t\t\t\t}\n\t\t\t\t\tif (k != 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tauto num = dp[j][k][l] + (l != 1 ? 1 : 0);\n\t\t\t\t\t\tif (ndp[j][k-1][1] == -1)\n\t\t\t\t\t\t\tndp[j][k-1][1] = num;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tndp[j][k-1][1].chmin(num);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdp = ndp;\n\t}\n\tdebug writeln(dp);\n\n\tint ans = int.max;\n\tforeach (i; 0..2)\n\t{\n\t\tif (dp[0][0][i] != -1)\n\t\t\tans.chmin(dp[0][0][i]);\n\t}\n\n\twriteln(ans);\n\tstdout.flush;\n\tdebug readln;\n}\n"}, {"source_code": "import std.conv, std.functional, std.range, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;\nimport core.bitop;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }\nint readInt() { return readToken.to!int; }\nlong readLong() { return readToken.to!long; }\nreal readReal() { return readToken.to!real; }\n\nbool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }\nbool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }\n\nint binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }\nint lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }\nint upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }\n\n\nenum INF = 10^^9;\n\nvoid main() {\n try {\n for (; ; ) {\n const N = readInt();\n auto P = new int[N];\n foreach (i; 0 .. N) {\n P[i] = readInt();\n }\n \n auto dp = new int[][][](N + 1, N + 1, 2);\n foreach (i; 0 .. N + 1) {\n foreach (j; 0 .. N + 1) {\n dp[i][j][] = INF;\n }\n }\n dp[0][0][] = 0;\n foreach (i; 0 .. N) {\n foreach (j; 0 .. i + 1) foreach (s; 0 .. 2) {\n foreach (t; 0 .. 2) {\n if (P[i] == 0 || P[i] % 2 == t) {\n chmin(dp[i + 1][j + t][t], dp[i][j][s] + abs(s - t));\n }\n }\n }\n }\n int ans = INF;\n foreach (s; 0 .. 2) {\n chmin(ans, dp[N][N - N / 2][s]);\n }\n writeln(ans);\n }\n } catch (EOFException e) {\n }\n}\n"}, {"source_code": "import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;\nimport std.math, std.random, std.bigint, std.datetime, std.format;\nvoid main(string[] args){ if(args.length > 1) if(args[1] == \"-debug\") DEBUG = 1; solve(); }\nvoid log()(){ writeln(\"\"); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, \" \"), log(a); } bool DEBUG = 0; \nstring rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }\nT rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;\nT[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;\nT[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;\nT chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }\n\n// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //\n\nconst long infty = 100999;\n\nvoid solve(){\n\tint n = rint;\n\tlong[] as = rlong(n);\n\n\tint p = (n + 1) / 2, q = n / 2, z; // how many odds, evens, zeros\n\tforeach(a; as){\n\t\tif(a == 0) z += 1;\n\t\telse if(a % 2) p -= 1;\n\t\telse q -= 1;\n\t}\n\tlog(\"p:\", p, \"q:\", q, \"z:\", z);\n\n\tlong[][][] xs = new long[][][](n, p + 1, q + 1);\n\t\t\t// xs[i][j][k]: use j odd and k even bulbs and the rightmost is odd and the min score\n\tlong[][][] ys = new long[][][](n, p + 1, q + 1);\n\t\t\t// ys[i][j][k]: use j odd and k even bulbs and the rightmost is even and the min score\n\n\tforeach(i, a; as){\n\t\tif(a > 0){ // forced\n\t\t\tif(a % 2){ // forced odd\n\t\t\t\tforeach(j; 0 .. p + 1) foreach(k; 0 .. q + 1){\n\t\t\t\t\tif(i > 0) xs[i][j][k] = min(xs[i - 1][j][k], ys[i - 1][j][k] + 1);\n\t\t\t\t\telse xs[i][j][k] = 0;\n\t\t\t\t\tys[i][j][k] = infty;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{ // forced even\n\t\t\t\tforeach(j; 0 .. p + 1) foreach(k; 0 .. q + 1){\n\t\t\t\t\txs[i][j][k] = infty;\n\t\t\t\t\tif(i > 0) ys[i][j][k] = min(xs[i - 1][j][k] + 1, ys[i - 1][j][k]);\n\t\t\t\t\telse ys[i][j][k] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse{ // free\n\t\t\tforeach(j; 0 .. p + 1) foreach(k; 0 .. q + 1){\n\t\t\t\tif(i > 0){\n\t\t\t\t\tif(j > 0) xs[i][j][k] = min(xs[i - 1][j - 1][k], ys[i - 1][j - 1][k] + 1);\n\t\t\t\t\telse xs[i][j][k] = infty;\n\t\t\t\t\tif(k > 0) ys[i][j][k] = min(xs[i - 1][j][k - 1] + 1, ys[i - 1][j][k - 1]);\n\t\t\t\t\telse ys[i][j][k] = infty;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tif(j == 1 && k == 0) xs[i][j][k] = 0;\n\t\t\t\t\telse xs[i][j][k] = infty;\n\t\t\t\t\tif(j == 0 && k == 1) ys[i][j][k] = 0;\n\t\t\t\t\telse ys[i][j][k] = infty;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlog(\"xs:\", xs[i], \"ys:\", ys[i]);\n\t}\n\tlong ans = min(xs[n - 1][p][q], ys[n - 1][p][q]);\n\tans.writeln;\n}"}, {"source_code": "//prewritten code: https://github.com/antma/algo\nimport std.algorithm;\nimport std.array;\nimport std.conv;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.traits;\n\nfinal class InputReader {\n private:\n ubyte[] p, buffer;\n bool eof;\n bool rawRead () {\n if (eof) {\n return false;\n }\n p = stdin.rawRead (buffer);\n if (p.empty) {\n eof = true;\n return false;\n }\n return true;\n }\n ubyte nextByte(bool check) () {\n static if (check) {\n if (p.empty) {\n if (!rawRead ()) {\n return 0;\n }\n }\n }\n auto r = p.front;\n p.popFront ();\n return r;\n }\n public:\n this () {\n buffer = uninitializedArray!(ubyte[])(16<<20);\n }\n bool seekByte (in ubyte lo) {\n while (true) {\n p = p.find! (c => c >= lo);\n if (!p.empty) {\n return false;\n }\n if (!rawRead ()) {\n return true;\n }\n }\n }\n template next(T) if (isSigned!T) {\n T next () {\n if (seekByte (45)) {\n return 0;\n }\n T res;\n ubyte b = nextByte!false ();\n if (b == 45) {\n while (true) {\n b = nextByte!true ();\n if (b < 48 || b >= 58) {\n return res;\n }\n res = res * 10 - (b - 48);\n }\n } else {\n res = b - 48;\n while (true) {\n b = nextByte!true ();\n if (b < 48 || b >= 58) {\n return res;\n }\n res = res * 10 + (b - 48);\n }\n }\n }\n }\n template next(T) if (isUnsigned!T) {\n T next () {\n if (seekByte (48)) {\n return 0;\n }\n T res = nextByte!false () - 48;\n while (true) {\n ubyte b = nextByte!true ();\n if (b < 48 || b >= 58) {\n break;\n }\n res = res * 10 + (b - 48);\n }\n return res;\n }\n }\n T[] nextA(T) (in int n) {\n auto a = uninitializedArray!(T[]) (n);\n foreach (i; 0 .. n) {\n a[i] = next!T;\n }\n return a;\n }\n}\n\nvoid main() {\n auto r = new InputReader ();\n immutable n = r.next!uint ();\n auto a = r.nextA!uint (n);\n auto b = new bool[n + 1];\n foreach (i; a) {\n b[i] = true;\n }\n int odds, evens;\n for (int i = 1; i <= n; ++i) {\n if (!b[i]) {\n if (i & 1) odds++; else evens++;\n }\n }\n int[] pos;\n foreach (i; 0 .. n) {\n if (a[i] == 0) pos ~= i;\n }\n immutable int m = pos.length.to!int;\n auto dp = new int[][][] (m + 1, odds + 1, 3);\n foreach (i; 0 .. m + 1) foreach (j; 0 .. odds + 1) dp[i][j][] = -1;\n auto vo = new int[m];\n auto ve = new int[m];\n b = new bool[m];\n foreach (i; 0 .. m) {\n immutable int k = pos[i];\n if (k > 0) {\n if (a[k-1] != 0) {\n if (a[k-1] & 1) {\n ve[i]++;\n } else {\n vo[i]++;\n }\n } else b[i] = true;\n }\n if (k+1 < n) {\n if (a[k+1] != 0) {\n if (a[k+1] & 1) {\n ve[i]++;\n } else {\n vo[i]++;\n }\n }\n }\n }\n debug stderr.writeln (vo);\n debug stderr.writeln (ve);\n debug stderr.writeln (b);\n debug stderr.writeln (odds);\n debug stderr.writeln (evens);\n\n int f (const int k, const int o, const int last) {\n if (dp[k][o][last] >= 0) return dp[k][o][last];\n immutable int r = m - k;\n if (!r) return dp[k][o][last] = 0; \n immutable int co = odds - o,\n ce = k - co,\n e = evens - ce;\n assert (e >= 0);\n int res = int.max;\n if (o > 0) {\n int w = f (k + 1, o - 1, 1) + vo[k];\n if (b[k] && last == 0) ++w;\n res = min (res, w);\n }\n if (e > 0) {\n int w = f (k + 1, o, 0) + ve[k];\n if (b[k] && last == 1) ++w;\n res = min (res, w);\n }\n return dp[k][o][last] = res;\n }\n int res = f (0, odds, 2);\n foreach (i; 1 .. n) {\n if (a[i-1] != 0 && a[i] != 0 && 0 != ((a[i-1] ^ a[i]) & 1)) {\n ++res;\n }\n }\n writeln (res);\n}\n\n"}], "negative_code": [], "src_uid": "90db6b6548512acfc3da162144169dba"} {"source_code": "module acmd;\n\nimport std.stdio;\nimport std.conv;\nimport std.algorithm;\nimport std.string;\nimport std.container;\n\nint main () {\n version (offline_judje) {\n stdin.reopen (\"input.txt\", \"rt\");\n }\n\n int n, k;\n readf!\" %d %d\" (n, k);\n int[] nums;\n foreach (i; 0 .. n) {\n int num; readf!\" %d\" (num);\n nums ~= num;\n }\n auto curnums = nums[];\n int ans = 0;\n while (curnums.length > 0) {\n if (curnums[0] <= k) {\n ans++;\n curnums = curnums[1 .. $];\n }\n else if (curnums[$ - 1] <= k) {\n ans++;\n curnums = curnums[0 .. $ - 1];\n }\n else break;\n }\n write (ans);\n\n return 0;\n}\n\n", "positive_code": [{"source_code": "import std.algorithm;\nimport std.array;\nimport std.bitmanip;\nimport std.container;\nimport std.conv;\nimport std.functional;\nimport std.math;\nimport std.range;\nimport std.stdio;\nimport std.string;\nimport std.typecons;\nimport std.range.interfaces;\n\nvoid main()\n{\n int n, k;\n readf(\"%s %s\", &n, &k);\n readln;\n \n auto a = readln.chomp.split.map!(to!int).array;\n \n int check(int[] a, int k) {\n return cast(int) a.until!(x => x > k).array.length;\n }\n \n auto ans = min(check(a, k) + check(a.retro.array, k), n);\n \n ans.writeln;\n}"}], "negative_code": [], "src_uid": "ecf0ead308d8a581dd233160a7e38173"} {"source_code": "import std.stdio, std.array, std.string, std.conv, std.algorithm;\nimport std.typecons, std.range, std.random, std.math, std.container;\nimport std.numeric, std.bigint, core.bitop, core.stdc.string;\n\nvoid main() {\n auto N = readln.chomp.to!int;\n auto A = readln.split.map!(to!int).array;\n A.sort();\n iota(0, N, 2).map!(i => A[i+1] - A[i]).sum.writeln;\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.algorithm;\nint main()\n{\n\tint t=0;\n\treadf(\" %d\", &t);\n\tint[] m = new int[t];\n\tfor (int i=0; i=0)\n\t\twriteln(\"YES\");\n\telse writeln(\"NO\");\n}\n"}], "src_uid": "b6456a39d38fabcd25267793ed94d90c"} {"source_code": "module main;\nimport std.bigint,std.container,std.array,std.algorithm,std.conv,\n\tstd.functional,std.math,std.numeric,std.string,std.range,std.complex,\n\tstd.typecons,std.regex,std.random,std.uni,std.traits,std.variant,\n\tstd.stdio,std.bitmanip;\nimport core.stdc.stdio : freopen;\nalias RedBlackTree Rbt;\nalias redBlackTree rbt;\nalias BigInt big;\nalias pair!(int,int) pii;\nalias pair!(long,long) pll;\nalias boyerMooreFinder strfind;\nalias make_pair mp;\nalias binary_search bins;\nalias pair(X,Y)=Tuple!(X,q{fi},Y,q{se});\npair!(X,Y) make_pair(X,Y)(in X x_,in Y y_)\n{\n\tpair!(X,Y) pp;\n\tpp.fi=x_;\n\tpp.se=y_;\n\treturn pp;\n}\nimmutable int mod=10^^9+7;\npure nothrow \n{\n\tT lcm (T)(auto ref T a,auto ref T b)\n\t{\n\t\treturn a/gcd(a,b)*b;\n\t}\n\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\tsize_t lowb(T,X)(in T a,auto ref X g) \n\t\tif(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m]1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m] 0)\n{return readf(replicate(\" %s\", ptrs.length), ptrs)==ptrs.length;}\nbool read(T...)(T ptrs) if (ptrs.length > 0)\n{return readf(replicate(\" %s\", ptrs.length)~'\\n', ptrs)==ptrs.length;}\nnothrow void inf(in char* name) {freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow void ouf(in char* name) {freopen(name,\"w\",core.stdc.stdio.stdout);}\n@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold schwartzSort multiSort partialSort heapify join filter countUntil\n//---------------------------------------------------------------program beginning-----------------------------------------------------------------\n\nvoid main()\n{\n\t/*int n;\n\tloop:while(read(&n))\n\t{\n\n\t}*/\n\tauto s=readln.strip;\n\tif(s.count!isUpper>s.count!isLower)\n\t{\n\t\tforeach(c;s)write(toUpper(c));\n\t}\n\telse foreach(c;s)write(toLower(c));\n}", "positive_code": [{"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.algorithm;\nimport std.string;\nimport std.math;\n\nint main(string[] argv)\n{\n\tstring line = readln();\n\tif (line[$-1] == '\\n') line.length--;\n\tstring upper = toUpper(line);\n\tstring lower = toLower(line);\n\tint diffu, diffl;\n\tforeach (int i; 0..line.length)\n\t{\n\t\tdiffu += abs(line[i] - upper[i]);\n\t\tdiffl += abs(line[i] - lower[i]);\n\t}\n\twrite (diffu >= diffl ? lower : upper);\n\treturn 0;\n}\n"}, {"source_code": "//ahmat\nimport core.stdc.stdio:scanf,printf,puts;\nimport core.bitop;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.functional;\nimport std.array;\nimport std.container;\nimport std.conv;\nimport std.container;\nimport std.typecons;\nimport std.math;\nimport std.numeric;\npragma(inline,true);\n\nvoid main(){\n char[] s=readln.strip.to!(char[]);\n int n=0;\n foreach(ref x;s){\n if(x.to!int<97) n++;\n }\n if(2*n>s.length)\n s.toUpper.writeln;\n else \n s.toLower.writeln;\n}\n\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport core.stdc.stdio;\nimport std.algorithm;\nimport std.string;\nimport std.math;\n\nint main(string[] argv)\n{\n\tstring line = readln();\n\tif (line[$-1] == '\\n') line.length--;\n\tstring upper = toUpper(line);\n\tstring lower = toLower(line);\n\tint diffu, diffl;\n\tforeach (int i; 0..line.length)\n\t{\n\t\tdiffu += abs(line[i] - upper[i]);\n\t\tdiffl += abs(line[i] - lower[i]);\n\t}\n\twrite (diffu > diffl ? lower : upper);\n\treturn 0;\n}\n"}], "src_uid": "b432dfa66bae2b542342f0b42c0a2598"} {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nT[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * (y / gcd(x, y)); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998_244_353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\n\tauto n = RD;\n\tauto p = RD;\n\tauto w = RD!int;\n\tauto d = RD!int;\n\n\tauto r = p % w;\n\tauto used = new bool[](10^^5);\n\tint a;\n\tint cnt = -1;\n\tforeach (i; 0..10^^5)\n\t{\n\t\tif (a == r)\n\t\t{\n\t\t\tcnt = i;\n\t\t\tbreak;\n\t\t}\n\t\telse if (used[a] == true)\n\t\t\tbreak;\n\t\tused[a] = true;\n\n\t\ta += d;\n\t\ta %= w;\n\t}\n\n\tif (cnt == -1)\n\t\twriteln(-1);\n\telse\n\t{\n\t\tauto y = cast(long)cnt;\n\t\tauto x = (p - y*d) / w;\n\t\tauto z = n - x - y;\n\t\tif (x < 0 || z < 0)\n\t\t\twriteln(-1);\n\t\telse\n\t\t\twriteln(x, \" \", y, \" \", z);\n\t}\n\n\tstdout.flush();\n\tdebug readln();\n}", "positive_code": [{"source_code": "import std.algorithm;\nimport std.range;\nimport std.stdio;\nimport std.typecons;\nimport std.traits;\nimport std.array;\nvoid read(T...)(ref T args)\n{\n import std.traits;\n static foreach(i; 0 .. T.length)\n static if(isArray!(T[i]) && !is(T[i] == string))\n foreach(ref e; args[i])\n \tread(e);\n else static if(isTuple!(T[i]))\n {\n\tstatic foreach(n; 0 .. T[i].Types.length)\n\t {\n\t read(args[i][n]);\n\t }\n }\n else\n readf!\" %s \"(args[i]);\n}\nauto brange(alias low, alias high, alias pred, bool value)()\n{\n return iota(low, high + 1).map!((a) => cast(int) pred(a)).assumeSorted.equalRange(value);\n}\nauto ftrue(alias low, alias high, alias pred)()\n{\n return brange!(low, high, pred, false).length + low;\n}\nauto itup(alias k, alias F)()\n{\n alias T = Parameters!F;\n foreach(i; 0 .. k)\n {\n T t;\n get(t);\n F(t);\n }\n}\nalias get = read;\nalias wr = writeln;\n\nT egcd(T)(T a, T b, out T x, out T y)\n{\n if (a == 0) {\n x = 0;\n y = 1;\n return b;\n }\n T x1, y1;\n auto d = egcd(b % a, a, x1, y1);\n x = y1 - (b / a) * x1;\n y = x1;\n return d;\n}\n\nvoid solve(ln a, ln b, ln m, out ln x, out ln p, out bool hassol)\n{\n b %= m;\n ln y = 0;\n ln g = egcd(a, m, x, y);\n if (b % g != 0)\n {\n hassol = false;\n return;\n }\n hassol = true;\n x *= b / g;\n p = m / g;\n x %= p;\n x += p;\n x %= p;\n return;\n}\n\nalias ln = long;\n\nint main()\n{\n ln n, p, w, d; get(n, p, w, d);\n auto h = w - d;\n ln np;\n ln period;\n bool hassol;\n solve(w, p, h, np, period, hassol);\n if (hassol)\n {\n ln top = min(n, p / d);\n ln delta = top - np;\n np += (delta / period) * period;\n ln z = n - np;\n ln y = (w * np - p) / h;\n ln x = np - y;\n if (y >= 0 && x >= 0 && z >= 0)\n\t{\n\t wr(x, \" \", y, \" \", z);\n\t}\n else\n\t{\n\t wr(-1);\n\t}\n }\n else\n {\n wr(-1);\n }\n return 0;\n}\n"}, {"source_code": "import std.algorithm;\nimport std.range;\nimport std.stdio;\nimport std.typecons;\nimport std.traits;\nimport std.array;\nvoid read(T...)(ref T args)\n{\n import std.traits;\n static foreach(i; 0 .. T.length)\n static if(isArray!(T[i]) && !is(T[i] == string))\n foreach(ref e; args[i])\n \tread(e);\n else static if(isTuple!(T[i]))\n {\n\tstatic foreach(n; 0 .. T[i].Types.length)\n\t {\n\t read(args[i][n]);\n\t }\n }\n else\n readf!\" %s \"(args[i]);\n}\nauto brange(alias low, alias high, alias pred, bool value)()\n{\n return iota(low, high + 1).map!((a) => cast(int) pred(a)).assumeSorted.equalRange(value);\n}\nauto ftrue(alias low, alias high, alias pred)()\n{\n return brange!(low, high, pred, false).length + low;\n}\nauto itup(alias k, alias F)()\n{\n alias T = Parameters!F;\n foreach(i; 0 .. k)\n {\n T t;\n get(t);\n F(t);\n }\n}\nalias get = read;\nvoid wone(T)(T t, char end)\n{\n static if(isArray!T && !is(T == string))\n {\n foreach(i; 0 .. t.length - 1)\n\t write(t[i], ' ');\n write(t[$ - 1], end);\n }\n else\n write(t, end);\n}\nvoid wr(T...)(T t)\n{\n static foreach(i; 0 .. T.length)\n static if(i + 1 < T.length)\n wone(t[i], ' ');\n else\n wone(t[i], '\\n');\n}\nvoid ans(T...)(T t)\n{\n import core.stdc.stdlib;\n wr(t);\n exit(0);\n}\nstruct ModNum(T)\n{\n T representative, modulus;\n this(T representative, T modulus)\n {\n this.representative = representative;\n this.modulus = modulus;\n }\n T minimalPositiveRepresentative()\n {\n return ((representative % modulus) + modulus) % modulus;\n }\n T minimalNegativeRepresentative()\n {\n return ((representative % modulus) - modulus) % modulus;\n }\n T maxRepresentative(T upperBound)\n {\n return upperBound - pmod(upperBound - representative, modulus);\n }\n}\n// minimum possible representative of x modulo m.\nT pmod(T)(T x, T m)\n{\n return (x % m + m) % m;\n}\n// solves ax + by = gcd(a, b) and returns gcd(a, b)\nT extendedEuclideanAlgorithm(T)(T a, T b, out T x, out T y)\n{\n if (a == 0)\n {\n x = 0, y = 1;\n return b;\n }\n T x1, y1;\n auto d = egcd(b % a, a, x1, y1);\n x = y1 - (b / a) * x1, y = x1;\n return d;\n}\nalias egcd = extendedEuclideanAlgorithm;\n// solves ax = b (mod m) giving a solution as a modulus class.\nbool solveLinearCongruence(T)(T a, T b, T m, out ModNum!T res)\n{\n T x, p;\n b = pmod(b, m);\n T y;\n T g = egcd(a, m, x, y);\n if (b % g != 0)\n return false;\n p = m / g;\n x = pmod(x * b / g, p);\n res.representative = x;\n res.modulus = p;\n return true;\n}\nvoid main()\n{\n alias solve = solveLinearCongruence;\n alias ln = long;\n ln n, p, w, d; get(n, p, w, d);\n auto h = w - d;\n ModNum!ln np;\n if (solve(w, p, h, np))\n {\n ln maxNp = np.maxRepresentative(/*upper bound*/ min(n, p / d));\n ln z = n - maxNp;\n ln y = (w * maxNp - p) / h;\n ln x = maxNp - y;\n if (y >= 0 && x >= 0 && z >= 0)\n\t ans(x, y, z);\n }\n ans(-1);\n}\n"}], "negative_code": [{"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nT[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * (y / gcd(x, y)); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998_244_353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\n\tauto n = RD;\n\tauto p = RD;\n\tauto w = RD!int;\n\tauto d = RD!int;\n\n\tauto r = p % w;\n\tauto used = new bool[](10^^5);\n\tint a;\n\tint cnt = -1;\n\tforeach (i; 0..10^^5)\n\t{\n\t\tif (a == r)\n\t\t{\n\t\t\tcnt = i;\n\t\t\tbreak;\n\t\t}\n\t\telse if (used[a] == true)\n\t\t\tbreak;\n\t\tused[a] = true;\n\n\t\ta += d;\n\t\ta %= w;\n\t}\n\n\tif (cnt == -1)\n\t\twriteln(-1);\n\telse\n\t{\n\t\tauto y = cast(long)cnt;\n\t\tauto x = (p - y*d) / w;\n\t\tauto z = n - x - y;\n\t\tif (z < 0)\n\t\t\twriteln(-1);\n\t\telse\n\t\t\twriteln(x, \" \", y, \" \", z);\n\t}\n\n\tstdout.flush();\n\tdebug readln();\n}"}, {"source_code": "import std.stdio, std.conv, std.functional, std.string;\nimport std.algorithm, std.array, std.container, std.range, std.typecons;\nimport std.numeric, std.math, std.random;\nimport core.bitop;\n\nstring FMT_F = \"%.10f\";\n\nstatic string[] s_rd;\nT RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }\nstring RDR()() { return readln.chomp; }\nT[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }\nT[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }\nT[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }\nsize_t[] MAKE_IDX(alias less = \"a < b\", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}\nsize_t MIN_POS(alias less = \"a < b\", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }\n\nbool inside(T)(T x, T b, T e) { return x >= b && x < e; }\nlong lcm(long x, long y) { return x * (y / gcd(x, y)); }\n\nlong mod = 10^^9 + 7;\n//long mod = 998_244_353;\n//long mod = 1_000_003;\nvoid moda(ref long x, long y) { x = (x + y) % mod; }\nvoid mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }\nvoid modm(ref long x, long y) { x = (x * y) % mod; }\n\nvoid main()\n{\n\tauto n = RD;\n\tauto p = RD;\n\tauto w = RD!int;\n\tauto d = RD!int;\n\n\tauto r = p % w;\n\tauto used = new bool[](10^^5);\n\tint a;\n\tint cnt = -1;\n\tforeach (i; 0..10^^5)\n\t{\n\t\tif (a == r)\n\t\t{\n\t\t\tcnt = i;\n\t\t\tbreak;\n\t\t}\n\t\telse if (used[a] == true)\n\t\t\tbreak;\n\t\tused[a] = true;\n\n\t\ta += d;\n\t\ta %= w;\n\t}\n\n\tif (cnt == -1)\n\t\twriteln(-1);\n\telse\n\t{\n\t\tauto y = cnt;\n\t\tauto x = (p - y*d) / w;\n\t\tauto z = n - x - y;\n\t\tif (z < 0)\n\t\t\twriteln(-1);\n\t\telse\n\t\t\twriteln(x, \" \", y, \" \", z);\n\t}\n\n\tstdout.flush();\n\tdebug readln();\n}"}], "src_uid": "503116e144d19eb953954d99c5526a7d"} {"source_code": "import std.stdio,\n\tstd.algorithm;\n\nvoid main() {\n\tint a, b;\n\treadf!` %s %s`(a, b);\n\twriteln(min(a, b), ' ', (max(a, b) - min(a, b)) / 2);\n}\n", "positive_code": [{"source_code": "import std.stdio;\n\nint main(string[] argv)\n{\n\tint a, b;\n\treadf(\"%d %d\", &a, &b);\n\tif (a < b) { int t = a; a = b; b = t; }\n\tint t = a - b;\n\twrite(b, \" \", t / 2);\n\treturn 0;\n}"}, {"source_code": "import std.stdio;\nint min(int a, int b)\n{\n\tif (ab)\n\t{\n\t\treturn a;\n\t}\n\telse\n\t{\n\t\treturn b;\n\t}\n}\nint main()\n{\n\tint a=0;\n\tint b=0;\n\treadf(\" %d\", &a);\n\treadf(\" %d\", &b);\n\twriteln(min(a,b));\n\tint c=a-min(a,b);\n\tint d=b-min(a,b);\n\tint e=max(c,d);\n\twriteln(e/2);\n\treturn 0;\n}"}], "negative_code": [], "src_uid": "775766790e91e539c1cfaa5030e5b955"} {"source_code": "import std.conv, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;\nimport core.bitop, core.thread;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }\nint readInt() { return readToken().to!int; }\nlong readLong() { return readToken().to!long; }\nreal readReal() { return readToken().to!real; }\n\nvoid chmin(T)(ref T t, in T f) { if (t > f) t = f; }\nvoid chmax(T)(ref T t, in T f) { if (t < f) t = f; }\n\nint binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }\nint lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }\nint upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }\n\n\nimmutable MO = 10L^^9 + 7;\nimmutable LIM = 10^^5 + 10;\n\nlong[] inv;\nvoid prepare() {\n inv = new long[LIM];\n inv[1] = 1;\n foreach (i; 2 .. LIM) {\n inv[i] = MO - (MO / i) * inv[cast(size_t)(MO % i)] % MO;\n }\n}\n\nlong N;\nint K;\n\nvoid main() {\n prepare();\n \n try {\n for (; ; ) {\n N = readLong();\n K = readInt();\n Tuple!(long, int)[] ps;\n long n = N;\n for (long d = 2; d * d <= n; ++d) {\n if (n % d == 0) {\n int e;\n do {\n ++e;\n n /= d;\n } while (n % d == 0);\n ps ~= tuple(d, e);\n }\n }\n if (n > 1) {\n ps ~= tuple(n, 1);\n }\n debug {\n writeln(\"ps = \", ps);\n }\n long ans = 1;\n foreach (entry; ps) {\n const p = entry[0];\n const e = entry[1];\n auto dp = new long[][](K + 1, e + 1);\n dp[0][0] = 1;\n foreach (i; 1 .. e + 1) {\n dp[0][i] = (dp[0][i - 1] * p) % MO;\n }\n foreach (k; 1 .. K + 1) {\n long sum;\n foreach (i; 0 .. e + 1) {\n (sum += dp[k - 1][i]) %= MO;\n dp[k][i] = (sum * inv[i + 1]) % MO;\n }\n }\n (ans *= dp[K][e]) %= MO;\n }\n writeln(ans);\n }\n } catch (EOFException e) {\n }\n}\n", "positive_code": [{"source_code": "import std.algorithm;\nimport std.conv;\nimport std.range;\nimport std.stdio;\nimport std.string;\n\nimmutable int mod = 10 ^^ 9 + 7;\nimmutable int small = 100;\n\nint powMod (int a, int b)\n{\n\tint res = 1;\n\twhile (b > 0)\n\t{\n\t\tif (b & 1)\n\t\t{\n\t\t\tres = (res * 1L * a) % mod;\n\t\t}\n\t\ta = (a * 1L * a) % mod;\n\t\tb >>= 1;\n\t}\n\treturn res;\n}\n\nint invMod (int a)\n{\n\treturn powMod (a, mod - 2);\n}\n\nvoid main ()\n{\n\tlong n;\n\tint k;\n\twhile (readf (\" %s %s\", &n, &k) > 0)\n\t{\n\t\tint [] primes;\n\t\tint [] powers;\n\t\tint [] [] prob;\n\t\tint total = 0;\n\t\tfor (int d = 2; d * 1L * d <= n; d++)\n\t\t{\n\t\t\tif (n % d == 0)\n\t\t\t{\n\t\t\t\tint num = 0;\n\t\t\t\tdo\n\t\t\t\t{\n\t\t\t\t\tn /= d;\n\t\t\t\t\tnum += 1;\n\t\t\t\t}\n\t\t\t\twhile (n % d == 0);\n\t\t\t\tprimes ~= d;\n\t\t\t\tpowers ~= num;\n\t\t\t\ttotal += 1;\n\t\t\t}\n\t\t}\n\t\tif (n > 1)\n\t\t{\n\t\t\tprimes ~= n % mod;\n\t\t\tpowers ~= 1;\n\t\t\ttotal += 1;\n\t\t}\n\n\t\tauto inv = new int [small];\n\t\tforeach (i; 1..small)\n\t\t{\n\t\t\tinv[i] = invMod (i);\n\t\t}\n\n\t\tforeach (i; 0..total)\n\t\t{\n\t\t\tint limit = powers[i];\n\t\t\tauto f = new int [] [] (2, limit + 1);\n\t\t\tint b = 0;\n\t\t\tf[b][] = 0;\n\t\t\tf[b][limit] = 1;\n\t\t\tforeach (j; 0..k)\n\t\t\t{\n\t\t\t\tb ^= 1;\n\t\t\t\tf[b][] = 0;\n\t\t\t\tforeach (u; 0..limit + 1)\n\t\t\t\t{\n\t\t\t\t\tforeach (v; 0..u + 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tf[b][v] = (f[b][v] +\n\t\t\t\t\t\t f[!b][u] * 1L *\n\t\t\t\t\t\t inv[u + 1]) % mod;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tdebug {writeln (primes[i], \": \", f[b]);}\n\t\t\tprob ~= f[b];\n\t\t}\n\n\t\tint res = 0;\n\n\t\tvoid recur (int i, int cur)\n\t\t{\n\t\t\tdebug {writeln (\"recur \", i, \" \", cur);}\n\t\t\tif (i == total)\n\t\t\t{\n\t\t\t\tres = (res + cur) % mod;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint temp = cur;\n\t\t\tforeach (u; 0..powers[i] + 1)\n\t\t\t{\n\t\t\t\trecur (i + 1, (temp * 1L * prob[i][u]) % mod);\n\t\t\t\ttemp = (temp * 1L * primes[i]) % mod;\n\t\t\t}\n\t\t}\n\n\t\trecur (0, 1);\n\t\twriteln (res);\n\t}\n}\n"}], "negative_code": [{"source_code": "import std.conv, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons;\nimport core.bitop, core.thread;\n\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; }\nint readInt() { return readToken().to!int; }\nlong readLong() { return readToken().to!long; }\nreal readReal() { return readToken().to!real; }\n\nvoid chmin(T)(ref T t, in T f) { if (t > f) t = f; }\nvoid chmax(T)(ref T t, in T f) { if (t < f) t = f; }\n\nint binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }\nint lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); }\nint upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); }\n\n\nimmutable MO = 10L^^9 + 7;\nimmutable LIM = 10^^5 + 10;\n\nlong[] inv;\nvoid prepare() {\n inv = new long[LIM];\n inv[1] = 1;\n foreach (i; 2 .. LIM) {\n inv[i] = MO - (MO / i) * inv[cast(size_t)(MO % i)] % MO;\n }\n}\n\nlong N;\nint K;\n\nvoid main() {\n prepare();\n \n try {\n for (; ; ) {\n N = readLong();\n K = readInt();\n Tuple!(long, int)[] ps;\n long n = N;\n for (long d = 2; d * d <= n; ++d) {\n int e;\n do {\n ++e;\n n /= d;\n } while (n % d == 0);\n ps ~= tuple(d, e);\n }\n if (n > 1) {\n ps ~= tuple(n, 1);\n }\n debug {\n writeln(\"ps = \", ps);\n }\n long ans = 1;\n foreach (entry; ps) {\n const p = entry[0];\n const e = entry[1];\n auto dp = new long[][](K + 1, e + 1);\n dp[0][0] = 1;\n foreach (i; 1 .. e + 1) {\n dp[0][i] = (dp[0][i - 1] * p) % MO;\n }\n foreach (k; 1 .. K + 1) {\n long sum;\n foreach (i; 0 .. e + 1) {\n (sum += dp[k - 1][i]) %= MO;\n dp[k][i] = (sum * inv[i + 1]) % MO;\n }\n }\n (ans *= dp[K][e]) %= MO;\n }\n writeln(ans);\n }\n } catch (EOFException e) {\n }\n}\n"}], "src_uid": "dc466d9c24b7dcb37c0e99337b4124d2"} {"source_code": "import std.stdio;\n\nvoid main()\n{\n\tint n;\n\tint res = 0;\n\tchar[200 + 1] s;\n\t\n\tscanf(\"%d%s\", &n, &s[0]);\n\tfor (int i = 0; i < n; i++) {\n\t\tint vertical = 0;\n\t\tint horizontal = 0;\n\t\tfor (int j = i; j < n; j++) {\n\t\t\tif (s[j] == 'U')\n\t\t\t\tvertical--;\n\t\t\tif (s[j] == 'D')\n\t\t\t\tvertical++;\n\t\t\tif (s[j] == 'L')\n\t\t\t\thorizontal--;\n\t\t\tif (s[j] == 'R')\n\t\t\t\thorizontal++;\n\t\t\t\n\t\t\tif (vertical == 0 && horizontal == 0)\n\t\t\t\tres++;\n\t\t}\n\t}\n\t\n\tprintf(\"%d\\n\", res);\n}\n", "positive_code": [{"source_code": "import std.stdio;\nimport std.string;\n\nimmutable int[] dx = [-1, 0, 1, 0];\nimmutable int[] dy = [0, -1, 0, 1];\nimmutable string dir = \"LURD\";\n\nvoid main() {\n int n;\n readf(\" %s\", &n);\n readln;\n auto s = readln.strip;\n int ans = 0;\n foreach (i; 0..n) {\n foreach (j; i..n) {\n int x = 0;\n int y = 0;\n foreach (k; i..j + 1) {\n x += dx[dir.indexOf(s[k])];\n y += dy[dir.indexOf(s[k])];\n }\n if (x == 0 && y == 0) {\n ans++;\n }\n }\n }\n writeln(ans);\n}\n\n"}, {"source_code": "import std.algorithm, std.stdio, std.range, std.string;\n\nauto f (string t)\n{\n\treturn t.count ('U') == t.count ('D') &&\n\t\tt.count ('L') == t.count ('R');\n}\n\nvoid main ()\n{\n\treadln;\n\tauto s = readln.strip;\n\ts.length.iota.map !(x =>\n\t\tx.iota.map !(y =>\n\t\t\tf (s[y..x + 1])\n\t\t).sum\n\t).sum.writeln;\n}\n"}, {"source_code": "import std.algorithm;\nimport std.stdio;\nimport std.string;\n\nvoid main ()\n{\n\tint n;\n\twhile (readf (\" %s\", &n) > 0)\n\t{\n\t\treadln;\n\t\tauto s = readln.strip;\n\t\tint res = 0;\n\t\tforeach (i; 0..n)\n\t\t{\n\t\t\tforeach (j; i..n)\n\t\t\t{\n\t\t\t\tauto t = s[i..j + 1];\n\t\t\t\tif (t.count ('U') == t.count ('D') &&\n\t\t\t\t t.count ('L') == t.count ('R'))\n\t\t\t\t{\n\t\t\t\t\tres++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\twriteln (res);\n\t}\n}\n"}], "negative_code": [], "src_uid": "7bd5521531950e2de9a7b0904353184d"} {"source_code": "import std.stdio;\nint sum(int a)\n{\n\tint s=0;\n\twhile(a!=0)\n\t{\n\t\ts=s+a%10;\n\t\ta=a/10;\n\t}\n\treturn s;\n}\nint main()\n{\n\tint a=0;\n\treadf(\" %d\", &a);\n\tint i=a;\n\twhile (true)\n\t{\n\t\tif (sum(i)%4==0)\n\t\t{\n\t\t\twriteln(i);\n\t\t\treturn 0;\n\t\t}\n\t\ti=i+1;\n\t}\n\treturn 0;\n}", "positive_code": [{"source_code": "void main() {\n import std.stdio, std.string, std.conv, std.algorithm;\n\n int a;\n rd(a);\n\n int digit_sum(int x) {\n int ret = 0;\n while (x) {\n ret += x % 10;\n x /= 10;\n }\n return ret;\n }\n\n for (int n = a;; n++) {\n if (digit_sum(n) % 4 == 0) {\n writeln(n);\n break;\n }\n }\n\n}\n\nvoid rd(T...)(ref T x) {\n import std.stdio : readln;\n import std.string : split;\n import std.conv : to;\n\n auto l = readln.split;\n assert(l.length == x.length);\n foreach (i, ref e; x)\n e = l[i].to!(typeof(e));\n}\n"}], "negative_code": [], "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7"} {"source_code": "module _template;\nimport std.stdio;\nimport std.string;\nimport std.algorithm;\nimport std.container;\nimport std.range;\nimport std.math;\nimport std.numeric;\nimport std.conv;\nimport std.typecons;\nimport std.format;\n\nstruct IO {\n string[] tk;\n string readString() {\n while (tk.empty) \n tk = readln.split;\n auto tkt = tk.front;\n tk.popFront;\n return tkt;\n }\n int readInt() { \n return readString.to!int; \n }\n double readDouble() { \n return readString.to!double; \n }\n}\n\nvoid main() {\n IO cin;\n int t = 1;\n // t = cin.readInt;\n while (t--) {\n int n = cin.readInt;\n int m = cin.readInt;\n writeln(min(n, m) % 2 ? \"Akshat\" : \"Malvika\");\n } \n}", "positive_code": [{"source_code": "import core.thread;\nimport std.conv, std.stdio, std.string;\nimport std.algorithm, std.array, std.bigint, std.math, std.range;\n\n//\tInput\nclass EOFException : Throwable { this() { super(\"EOF\"); } }\nstring[] tokens;\nstring readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }\nint readInt() { return to!int(readToken); }\nlong readLong() { return to!long(readToken); }\nreal readReal() { return to!real(readToken); }\n\n//\tchmin/chmax\nvoid chmin(T)(ref T t, const T f) { if (t > f) t = f; }\nvoid chmax(T)(ref T t, const T f) { if (t < f) t = f; }\n\n//\tPair\nstruct Pair(S, T) {\n\tS x; T y;\n\tint opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }\n\tstring toString() const { return \"(\" ~ to!string(x) ~ \", \" ~ to!string(y) ~ \")\"; }\n}\nauto pair(S, T)(S x, T y) { return Pair!(S, T)(x, y); }\n\n//\tArray\nint binarySearch(T)(T[] as, bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }\nint lowerBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a < val); }); }\nint upperBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <= val); }); }\nT[] unique(T)(T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }\n\n\nint M, N;\n\nvoid main(string[] args) {\n\ttry {\n\tfor (; ; ) {\n\t\tM = readInt;\n\t\tN = readInt;\n\t\tbool ans = (min(M, N) % 2 != 0);\n\t\twriteln(ans ? \"Akshat\" : \"Malvika\");\n\t}\n\t} catch (EOFException) {}\n}\n\n"}, {"source_code": "import std.stdio;\nimport std.uni;\nimport std.string;\nimport core.stdc.stdio;\nimport std.array;\nimport std.algorithm;\nimport std.string;\nimport std.math;\n\nint main(string[] argv)\n{\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tint ww = 1;\n\twhile (n > 0 && m > 0)\n\t{\n\t\tn--; m--;\n\t\tww++;\n\t\tww %= 2;\n\t}\n\tprintf((ww == 0 ? \"Akshat\" : \"Malvika\"));\n\treturn 0;\n}\n\n"}, {"source_code": "import std.stdio;\nimport std.string;\nimport std.bigint;\nimport std.array;\nimport std.ascii;\nimport std.math;\nimport std.numeric;\nimport std.algorithm;\nimport std.container;\nimport core.bitop;\n\nalias Int = long;\n\nvoid main() {\n Int n, m;\n readf(\" %s\", &n);\n readf(\" %s\", &m);\n if ( min(n, m) % 2 == 0 ) {\n writeln(\"Malvika\");\n } else {\n writeln(\"Akshat\");\n }\n}\n"}], "negative_code": [{"source_code": "import std.stdio;\nimport std.uni;\nimport std.string;\nimport core.stdc.stdio;\nimport std.array;\nimport std.algorithm;\nimport std.string;\nimport std.math;\n\nint main(string[] argv)\n{\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tint s = n + m;\n\tint ww = 1;\n\twhile (s > 1)\n\t{\n\t\ts -= 2;\n\t\tww++;\n\t\tww %= 2;\n\t}\n\tprintf((ww == 0 ? \"Akshat\" : \"Malvika\"));\n\treturn 0;\n}\n\n"}], "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4"} {"source_code": "import std.stdio, std.string, std.algorithm;\nimport std.conv, std.array;\nimport std.numeric;\n\nvoid main() {\n int x, y, a, b;\n readf(\"%d %d %d %d\\n\", &x, &y, &a, &b);\n int z = x * y / gcd(x, y);\n int f = (a + z - 1) / z;\n int t = b / z;\n //writeln(f, \" \", t);\n writef(\"%d\\n\", t - f + 1);\n}\n", "positive_code": [{"source_code": "module main;\n\nimport std.stdio,std.numeric;\n\nint main(string[] args)\n{\n ulong x,y,a,b;\n readf(\" %s %s %s %s\",&x,&y,&a,&b);\n auto l=lcm(x,y);\n writefln(\"%s\",(b/l-a/l)+(a%l?0:1));\n return 0;\n}\n\nT lcm(T)(T a, T b)\n{\n return (a/gcd(a,b))*b;\n}\n"}], "negative_code": [{"source_code": "import std.stdio, std.string, std.algorithm;\nimport std.conv, std.array;\nimport std.numeric;\n\nvoid main() {\n int x, y, a, b;\n readf(\"%d %d %d %d\\n\", &x, &y, &a, &b);\n int z = x * y / gcd(x, y);\n int f = (a + z - 1) / z;\n int t = (b + z - 1) / z;\n writef(\"%d\\n\", t - f + 1);\n}\n"}], "src_uid": "c7aa8a95d5f8832015853cffa1374c48"} {"source_code": "import std.bigint,std.container,std.array,std.algorithm,std.conv,\n\tstd.functional,std.math,std.numeric,std.string,std.range,std.complex,\n\tstd.typecons,std.regex,std.random,std.uni,std.traits,std.stdio,std.variant,\n\tcore.stdc.stdio : freopen;\nimport core.stdc.stdlib : system;\n//import core.stdc.stdio;\nalias RedBlackTree Rbt;alias redBlackTree rbt;alias BigInt big;\nalias pair(X,Y)=Tuple!(X,\"fi\",Y,\"se\");\nalias pair!(int,int) pii;alias pair!(long,long) pll;alias BoyerMooreFinder strfind;\nalias long lint;\nalias make_pair mp;alias binary_search bins;alias gcd=std.numeric.gcd;\nimmutable int mod=1000000007;\npure nothrow \n{\n\tT lcm (T)(auto ref T a,auto ref T b){return a/gcd(a,b)*b;}\n\tpair!(X,Y) make_pair(X,Y)(in X x_,in Y y_){return tuple!(X,\"fi\",Y,\"se\")(x_,y_);}\n\tbig gcd(big a,big b){while(b){a%=b;swap(a,b);}return a;}\n\t@property X sqr(X)(in X a_) {return a_*a_;}\n\t@property X cub(X)(in X a_) {return a_*a_*a_;}\n\tsize_t lowb(T,X)(in T a,auto ref X g)\n\t if(isRandomAccessRange!T && hasLength!T && is(typeof(g1)\n\t\t{\n\t\t\tauto m=(l+r)>>1;\n\t\t\tif(!(a[m] 0)\n{\n\tsize_t s=0;\n\tforeach(ref e;ptrs)\n\t{\n\t\ts+=readf(\" %s\",&e);\n\t}\n\treturn s==ptrs.length;\n}\nbool read(T...)(auto ref T ptrs) if (ptrs.length > 0)\n{\n\tsize_t s=0;\n\tforeach(ref e;ptrs)\n\t{\n\t\ts+=readf(\" %s\",&e);\n\t}\n\treadln;\n\treturn s==ptrs.length;\n}\nnothrow auto inf(in char* name) {return freopen(name,\"r\",core.stdc.stdio.stdin);}\nnothrow auto ouf(in char* name) {return freopen(name,\"w\",core.stdc.stdio.stdout);}\n@property auto arread(T)(){return readln.splitter.map!(to!(T)).array;}\n//split strip isAlpha isNumber isWhite isLower isUpper toLower toUpper mixin\n//cumulativeFold schwartzSort multiSort partialSort heapify join filter\n//------------------------------------------program beginning--------------------------------------------\n\nvoid main()\n{\n\tversion(ONLINE_JUDGE){}\n\telse\n\t{\n\t\tassert(freopen(\"input.txt\",\"r\",core.stdc.stdio.stdin));\n\t\tassert(freopen(\"output.txt\",\"w\",core.stdc.stdio.stdout));\n\t}\n\tint n,k;\n\t//writeln(\"hello\");\nloop:while(read(n,k))\n\t{\n\t\tint[int] q;\n\t\tfor(int i=2;i*i<=n;i++)\n\t\t{\n\t\t\twhile(n%i==0)\n\t\t\t{\n\t\t\t\tq[i]++;\n\t\t\t\tn/=i;\n\t\t\t}\n\t\t}\n\t\tif(n>1)q[n]++;\n\t\tauto s=q.byValue.sum;\n\t\tif(s=k)\n\t\t\t{\n\t\t\t\tg*=del.front;\n\t\t\t\tdel.popFront;\n\t\t\t}\n\t\t\twrite(g,' ');\n\t\t\tforeach(x;del)write(x,' ');\n\t\t\twriteln;\n\t\t}\n\t}\n\t//debug system(\"pause\");\n}\n", "positive_code": [{"source_code": "import std.stdio, std.string, std.conv, std.algorithm;\nimport std.range, std.array, std.math, std.typecons;\n\nint n, k;\n\nvoid main() {\n scan(n, k);\n\n if (k == 1) {\n writeln(n);\n return;\n }\n\n int[] ans;\n int cnt;\n\n for (int p = 2; p <= n/p; ++p) {\n while (n % p == 0) {\n ans ~= p;\n cnt++;\n n /= p;\n\n if (cnt == k - 1 && n > 1) {\n ans ~= n;\n cnt++;\n n = 1;\n break;\n }\n }\n\n if (cnt == k) break;\n }\n\n if (n > 1) {\n ans ~= n;\n cnt++;\n }\n\n if (cnt == k) {\n writefln(\"%(%s %)\", ans);\n }\n else {\n writeln(-1);\n }\n}\n\n\nvoid scan(T...)(ref T args) {\n auto line = readln.split;\n foreach (ref arg ; args) {\n arg = line.front.to!(typeof(arg));\n line.popFront();\n }\n assert(line.empty);\n}"}, {"source_code": "import std.stdio, std.string, std.conv, std.algorithm;\nimport std.range, std.array, std.math, std.typecons;\n\nimmutable int inf = 10^^9 + 7;\n\nint n, k;\n\nvoid main() {\n scan(n, k);\n\n if (k == 1) {\n writeln(n);\n return;\n }\n\n auto primes = new int[](0);\n int cnt;\n\n for (int p = 2; p*p <= n; ++p) {\n while (n % p == 0) {\n n /= p;\n primes ~= p;\n cnt++;\n\n if (cnt == k - 1 && n > 1) {\n cnt++;\n primes ~= n;\n n = 1;\n break;\n }\n }\n\n if (cnt == k) break;\n }\n\n if (n > 1) {\n cnt++;\n primes ~= n;\n }\n\n if (cnt == k) {\n writefln(\"%(%s %)\", primes);\n }\n else {\n writeln(-1);\n }\n}\n\n\nvoid scan(T...)(ref T args) {\n auto line = readln.split;\n foreach (ref arg ; args) {\n arg = line.front.to!(typeof(arg));\n line.popFront();\n }\n assert(line.empty);\n}"}], "negative_code": [], "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79"}